Changeset 1f12fab in mainline for kernel/arch/sparc32/src/mm/page.c


Ignore:
Timestamp:
2013-10-07T20:00:34Z (11 years ago)
Author:
Jakub Klama <jakub.klama@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a73ebf0
Parents:
80d9d83
Message:

First attempt to implement preemptive trap handlers
and switch to userspace. Preemptive traps are needed
for at least page faults, as page fault handling code
can trigger window underflow/overflow exceptions.

This commit also introduces userspace window buffer
for saving userspace register windows (just as in
sparc64).

These changes are unfinished and far from working
correctly.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/sparc32/src/mm/page.c

    r80d9d83 r1f12fab  
    3434
    3535#include <arch/mm/page.h>
     36#include <arch/mm/page_fault.h>
     37#include <arch/mm/tlb.h>
    3638#include <genarch/mm/page_pt.h>
    3739#include <arch/mm/frame.h>
     
    7577
    7678        /* Switch MMU to new context table */
    77         asi_u32_write(ASI_MMUREGS, 0x100, KA2PA(as_context_table) >> 4);
     79        asi_u32_write(ASI_MMUREGS, MMU_CONTEXT_TABLE, KA2PA(as_context_table) >> 4);
    7880
    7981        //boot_page_table_free();
     
    8284void page_fault(unsigned int n __attribute__((unused)), istate_t *istate)
    8385{
     86        uint32_t fault_status = asi_u32_read(ASI_MMUREGS, MMU_FAULT_STATUS);
     87        uintptr_t fault_address = asi_u32_read(ASI_MMUREGS, MMU_FAULT_ADDRESS);
     88        mmu_fault_status_t *fault = (mmu_fault_status_t *)&fault_status;
     89        mmu_fault_type_t type = (mmu_fault_type_t)fault->ft;
     90
     91        printf("page fault on address 0x%08x, status 0x%08x\n", fault_address, fault_status);
     92
     93        if (type == FAULT_TYPE_LOAD_USER_DATA) 
     94                as_page_fault(fault_address, PF_ACCESS_READ, istate);
     95
     96        if (type == FAULT_TYPE_EXECUTE_USER)
     97                as_page_fault(fault_address, PF_ACCESS_EXEC, istate);
     98
     99        if (type == FAULT_TYPE_STORE_USER_DATA || type == FAULT_TYPE_STORE_USER_INSTRUCTION)
     100                as_page_fault(fault_address, PF_ACCESS_WRITE, istate);
    84101}
    85102
Note: See TracChangeset for help on using the changeset viewer.