#include <revolution/os.h> #define OS_PROTECT_CHAN0 0 #define OS_PROTECT_CHAN1 1 #define OS_PROTECT_CHAN2 2 #define OS_PROTECT_CHAN3 3 // Capability bits #define OS_PROTECT_CONTROL_NONE 0x00 #define OS_PROTECT_CONTROL_READ 0x01 // OK to read [addr, addr + nBytes) #define OS_PROTECT_CONTROL_WRITE 0x02 // OK to write [addr, addr + nBytes) #define OS_PROTECT_CONTROL_RDWR (OS_PROTECT_CONTROL_READ | OS_PROTECT_CONTROL_WRITE) // Error type for OSErrorHandler(). #define OS_ERROR_PROTECTION 15 // dsisr bits for memory protection error handler, which tells // from which region the error was reported #define OS_PROTECT0_BIT 0x00000001 // by OS_PROTECT_CHAN0 range #define OS_PROTECT1_BIT 0x00000002 // by OS_PROTECT_CHAN1 range #define OS_PROTECT2_BIT 0x00000004 // by OS_PROTECT_CHAN2 range #define OS_PROTECT3_BIT 0x00000008 // by OS_PROTECT_CHAN3 range #define OS_PROTECT_ADDRERR_BIT 0x00000010 // by [24M or 48M, 64M) void OSProtectRange( u32 chan, void* addr, u32 nBytes, u32 control );
| chan | One of OS_PROTECT_CHANn. It is possible to specify up to four regions. |
|---|---|
| addr | Start address. |
| nBytes | Size of the region to be stored. |
| control | One of OS_PROTECT_CONTROL_*. |
None.
In the specified region, sets access protection of the internal main memory (MEM1 region). The addr argument will be rounded DOWN to the closest 1024-byte boundary, while the end address (that is, addr + nBytes) will be rounded UP to the closest 1024-byte boundary.
Once a range is specified, any main memory access (for example, from Broadway, Graphics Processor, VI, and DI) that violates the specified memory control setting (OS_PROTECT_CONTROL_*) will raise an external interrupt from Hollywood to Broadway. Upon such a memory protection violation interrupt, the OS_ERROR_PROTECTION error will be raised; this error can be captured by the user-specified function registered through OSSetErrorHandler.
Note that OSProtectRange first flushes and invalidates the corresponding Broadway cache blocks. Thus Broadway's load and store instructions to the specified region after the call to OSProtectRange will cause a cache-line read first off. This cache-line read will trigger an OS_ERROR_PROTECTION error near the execution of the code if OS_PROTECT_CONTROL_WRITE or OS_PROTECT_CONTROL_NONE capability is specified.
Note: This feature is valid only for the internal main memory (MEM1 region). This feature cannot be used for external main memory (MEM2 region).
2008/01/18 Revised See Also to reflect category changes.
2006/03/01 Initial version.
CONFIDENTIAL