[502609c8] | 1 | #ifndef _mmu_405_h |
---|
| 2 | #define _mmu_405_h |
---|
| 3 | |
---|
| 4 | /* |
---|
| 5 | Simple interface to the PowerPC 405 MMU |
---|
| 6 | |
---|
| 7 | The intention here is just to allow the MMU to be used to define cacheability and |
---|
| 8 | read/write/execute permissions in a simple enough way to fit entirely into the |
---|
| 9 | 64-entry TLB cache. |
---|
| 10 | |
---|
| 11 | This code does not do address relocation and does not generate any MMU-related interrupts. |
---|
| 12 | |
---|
| 13 | The process ID support is there for a possible future extension where RTEMS supports |
---|
| 14 | setting the process ID on task switches, which allows per-process stack protection |
---|
| 15 | |
---|
| 16 | This code will call fatal_error() if your add_space() calls overrun the 64 entries |
---|
| 17 | |
---|
| 18 | Michael Hamel ADInstruments 2008 |
---|
| 19 | |
---|
| 20 | */ |
---|
| 21 | |
---|
| 22 | |
---|
| 23 | #ifdef __cplusplus |
---|
| 24 | extern "C" { |
---|
| 25 | #endif |
---|
| 26 | |
---|
| 27 | #include "stdint.h" |
---|
| 28 | |
---|
| 29 | enum { |
---|
| 30 | kAllProcessIDs = 0 |
---|
| 31 | }; |
---|
| 32 | |
---|
| 33 | typedef enum MMUAccessType { |
---|
| 34 | executable, |
---|
| 35 | readOnlyData, |
---|
| 36 | readOnlyNoCache, |
---|
| 37 | readWriteData, |
---|
| 38 | readWriteNoCache, |
---|
| 39 | readWriteExecutable |
---|
| 40 | } MMUAccessType; |
---|
| 41 | |
---|
| 42 | /* Initialise and clear the MMU */ |
---|
| 43 | void mmu_initialise(); |
---|
| 44 | |
---|
| 45 | /* Turn on/off data access translation */ |
---|
| 46 | bool mmu_enable_data(bool enable); |
---|
| 47 | |
---|
| 48 | /* Turn on instruction translation */ |
---|
| 49 | bool mmu_enable_code(bool enable); |
---|
| 50 | |
---|
| 51 | /* Define properties for an area of memory (must be 1K-aligned) */ |
---|
| 52 | void mmu_add_space(uint32_t startAddr, uint32_t endAddr, MMUAccessType permissions, uint8_t processID); |
---|
| 53 | |
---|
| 54 | /* Delete a memory property definition */ |
---|
| 55 | void mmu_remove_space(uint32_t startAddr, uint32_t endAddr); |
---|
| 56 | |
---|
| 57 | /* Return number of TLB entries out of total in use */ |
---|
| 58 | int mmu_get_tlb_count(); |
---|
| 59 | |
---|
| 60 | /* Allocate a new process ID and return it */ |
---|
| 61 | uint8_t mmu_new_processID(); |
---|
| 62 | |
---|
| 63 | /* Free a process ID that has been in use */ |
---|
| 64 | void mmu_free_processID(uint8_t freeThis); |
---|
| 65 | |
---|
| 66 | /* Return the current process ID */ |
---|
| 67 | uint8_t mmu_current_processID(); |
---|
| 68 | |
---|
| 69 | /* Change the process ID to ID and return the old value */ |
---|
| 70 | uint8_t mmu_set_processID(uint8_t toID); |
---|
| 71 | |
---|
| 72 | |
---|
| 73 | #ifdef __cplusplus |
---|
| 74 | } |
---|
| 75 | #endif |
---|
| 76 | |
---|
| 77 | #endif //_mmu_405.h |
---|