Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/arm32/src/mm/page_fault.c

    recd1a0a r9d58539  
    4242#include <print.h>
    4343
    44 /** Returns value stored in comnbined/data fault status register.
     44/** Returns value stored in fault status register.
    4545 *
    4646 *  @return Value stored in CP15 fault status register (FSR).
    47  *
    48  *  "VMSAv6 added a fifth fault status bit (bit[10]) to both the IFSR and DFSR.
    49  *  It is IMPLEMENTATION DEFINED how this bit is encoded in earlier versions of
    50  *  the architecture. A write flag (bit[11] of the DFSR) has also been
    51  *  introduced."
    52  *  ARM Architecture Reference Manual version i ch. B4.6 (PDF p. 719)
    53  *
    54  *  See ch. B4.9.6 for location of data/instruction FSR.
    55  *
    56  */
    57 static inline fault_status_t read_data_fault_status_register(void)
    58 {
    59         fault_status_t fsu;
    60        
    61         /* Combined/Data fault status is stored in CP15 register 5, c0. */
     47 */
     48static inline fault_status_t read_fault_status_register(void)
     49{
     50        fault_status_union_t fsu;
     51       
     52        /* fault status is stored in CP15 register 5 */
    6253        asm volatile (
    6354                "mrc p15, 0, %[dummy], c5, c0, 0"
    64                 : [dummy] "=r" (fsu.raw)
     55                : [dummy] "=r" (fsu.dummy)
    6556        );
    6657       
    67         return fsu;
    68 }
    69 
    70 /** Returns DFAR (fault address register) content.
    71  *
    72  * This register is equivalent to FAR on pre armv6 machines.
    73  *
    74  * @return DFAR (fault address register) content (address that caused a page
     58        return fsu.fs;
     59}
     60
     61/** Returns FAR (fault address register) content.
     62 *
     63 * @return FAR (fault address register) content (address that caused a page
    7564 *         fault)
    7665 */
    77 static inline uintptr_t read_data_fault_address_register(void)
     66static inline uintptr_t read_fault_address_register(void)
    7867{
    7968        uintptr_t ret;
     
    133122}
    134123
    135 #if defined(PROCESSOR_armv4) | defined(PROCESSOR_armv5)
    136124/** Decides whether read or write into memory is requested.
    137125 *
     
    154142                panic("page_fault - instruction does not access memory "
    155143                    "(instr_code: %#0" PRIx32 ", badvaddr:%p).",
    156                     *(uint32_t*)instr_union.instr, (void *) badvaddr);
     144                    instr_union.pc, (void *) badvaddr);
    157145                return PF_ACCESS_EXEC;
    158146        }
     
    174162        panic("page_fault - instruction doesn't access memory "
    175163            "(instr_code: %#0" PRIx32 ", badvaddr:%p).",
    176             *(uint32_t*)instr_union.instr, (void *) badvaddr);
     164            instr_union.pc, (void *) badvaddr);
    177165
    178166        return PF_ACCESS_EXEC;
    179167}
    180 #endif
    181168
    182169/** Handles "data abort" exception (load or store at invalid address).
     
    188175void data_abort(unsigned int exc_no, istate_t *istate)
    189176{
    190         uintptr_t badvaddr = read_data_fault_address_register();
    191 
    192 #if defined(PROCESSOR_armv6) | defined(PROCESSOR_armv7_a)
    193         fault_status_t fsr = read_data_fault_status_register();
    194         const pf_access_t access =
    195             fsr.data.wr ? PF_ACCESS_WRITE : PF_ACCESS_READ;
    196 #elif defined(PROCESSOR_armv4) | defined(PROCESSOR_armv5)
    197         const pf_access_t access = get_memory_access_type(istate->pc, badvaddr);
    198 #else
    199 #error "Unsupported architecture"
    200 #endif
     177        fault_status_t fsr __attribute__ ((unused)) =
     178            read_fault_status_register();
     179        uintptr_t badvaddr = read_fault_address_register();
     180
     181        pf_access_t access = get_memory_access_type(istate->pc, badvaddr);
     182
    201183        int ret = as_page_fault(badvaddr, access, istate);
    202184
     
    215197void prefetch_abort(unsigned int exc_no, istate_t *istate)
    216198{
    217         /* NOTE: We should use IFAR and IFSR here. */
    218199        int ret = as_page_fault(istate->pc, PF_ACCESS_EXEC, istate);
    219200
Note: See TracChangeset for help on using the changeset viewer.