OSProtectRange

C Specification

#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 );

Arguments

chan one of the OS_PROTECT_CHANn values. Can specify up to four regions.
addr Start address.
nBytes Size of region to protect.
control one of the OS_PROTECT_CONTROL_* values.

Return Values

None.

Description

Sets the access protection of the internal main memory (MEM1 region) in the specified region. The addr argument will be rounded down to the closest 1024 byte boundary, while the end address (i.e., addr+ nBytes) will be rounded up to the closest 1024 byte boundary.

Once a region is specified, any main memory access (e.g, from Broadway, Graphics Processor, VI, DI, and such) that violates the specified memory control setting (OS_PROTECT_CONTROL_*) will generate an external interrupt from Hollywood to Broadway. When a memory protection violation interrupt occurs, the generated OS_ERROR_PROTECTION error can be captured with the user defined function that is registered using the OSSetErrorHandler function.

OSProtectRange first flushes and invalidates the corresponding Broadway cache blocks. Therefore, Broadway's load and store instructions to the specified region will first perform a cache block read after the call to the OSProtectRange function. This cache block read will cause an OS_ERROR_PROTECTION error during the code execution if the OS_PROTECT_CONTROL_WRITE or OS_PROTECT_CONTROL_NONE function 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).

See Also

Error Functions, OSSetErrorHandler

Revision History

2006/03/01 Initial version.


CONFIDENTIAL