1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 2<HTML> 3<HEAD> 4<META http-equiv="Content-Type" content="text/html; charset=windows-1252"> 5<META http-equiv="Content-Style-Type" content="text/css"> 6<META name="GENERATOR" content="Microsoft FrontPage 5.0"> 7<LINK rel="stylesheet" href="../../CSS/revolution.css" type="text/css"> 8<TITLE>OSProtectRange</TITLE> 9</HEAD> 10<BODY> 11<H1>OSProtectRange</H1> 12<H2>C Specification</H2> 13<DL> 14 <DD> 15<PRE><CODE>#include <revolution/os.h></CODE></PRE> 16 <DD> 17<PRE>#define OS_PROTECT_CHAN0 0 18#define OS_PROTECT_CHAN1 1 19#define OS_PROTECT_CHAN2 2 20#define OS_PROTECT_CHAN3 3 21 22// Capability bits 23#define OS_PROTECT_CONTROL_NONE 0x00 24#define OS_PROTECT_CONTROL_READ 0x01 // OK to read [addr, addr + nBytes) 25#define OS_PROTECT_CONTROL_WRITE 0x02 // OK to write [addr, addr + nBytes) 26#define OS_PROTECT_CONTROL_RDWR (OS_PROTECT_CONTROL_READ | OS_PROTECT_CONTROL_WRITE) 27 28// Error type for OSErrorHandler(). 29#define OS_ERROR_PROTECTION 15 30 31// dsisr bits for memory protection error handler, which tells 32// from which region the error was reported 33#define OS_PROTECT0_BIT 0x00000001 // by OS_PROTECT_CHAN0 range 34#define OS_PROTECT1_BIT 0x00000002 // by OS_PROTECT_CHAN1 range 35#define OS_PROTECT2_BIT 0x00000004 // by OS_PROTECT_CHAN2 range 36#define OS_PROTECT3_BIT 0x00000008 // by OS_PROTECT_CHAN3 range 37#define OS_PROTECT_ADDRERR_BIT 0x00000010 // by [24M or 48M, 64M) 38 39void OSProtectRange( u32 chan, void* addr, u32 nBytes, u32 control );</code></PRE> 40</DL> 41<H2>Arguments</H2> 42<TABLE border="1" cellpadding="3" cellspacing="0.1"> 43 <TBODY> 44 <TR> 45<TD width="120" bgcolor="#ffffe8"><EM><STRONG><CODE><code><EM><STRONG>chan</STRONG></EM></code></CODE></STRONG></EM></TD> 46<TD width="520">One of the <CODE>OS_PROTECT_CHAN</CODE><EM>n</EM> values. Can specify up to four regions.</TD> 47 </TR> 48 <TR> 49<TD width="120" bgcolor="#ffffe8"><EM><STRONG><CODE><STRONG><EM><CODE>addr</CODE></EM></STRONG></CODE></STRONG></EM></TD> 50<TD width="520">Start address.</TD> 51 </TR> 52 <TR> 53<TD width="120" bgcolor="#ffffe8"><STRONG><EM><CODE><STRONG><EM><CODE>nBytes</CODE></EM></STRONG></CODE></EM></STRONG></TD> 54<TD width="520">Size of region to protect.</TD> 55 </TR> 56 <TR> 57<TD width="120" bgcolor="#ffffe8"><EM><STRONG><CODE><STRONG><EM><CODE>control</CODE></EM></STRONG></CODE></STRONG></EM></TD> 58<TD width="520">One of the <CODE>OS_PROTECT_CONTROL_*</CODE> values. </TD> 59 </TR> 60 </TBODY> 61</TABLE> 62<H2>Return Values</H2> 63<P>None.</P> 64<H2>Description</H2> 65<P>Sets the access protection of the <B>internal main memory (MEM1 region)</B> in the specified region. The <code><strong><em>addr</em></strong></code> argument will be rounded down to the closest 1024 byte boundary, while the end address (i.e., <code><strong><em>addr</em></strong></code>+ <strong><em><code>nBytes</code></em></strong>) will be rounded up to the closest 1024 byte boundary.</P> 66<P>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 (<code>OS_PROTECT_CONTROL_*</code>) will generate an external interrupt from Hollywood to Broadway. When a memory protection violation interrupt occurs, the generated <code>OS_ERROR_PROTECTION</code> error can be captured with the user defined function that is registered using the <a href="OSSetErrorHandler.html"><code>OSSetErrorHandler</code></a> function.</P> 67<P><code>OSProtectRange</code> 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 <code>OSProtectRange</code> function. This cache block read will cause an <code>OS_ERROR_PROTECTION</code> error during the code execution if the <code>OS_PROTECT_CONTROL_WRITE</code> or <code>OS_PROTECT_CONTROL_NONE</code> function is specified.</P> 68<P><B>Note: This feature is valid only for the internal main memory (MEM1 region). This feature cannot be used for external main memory (MEM2 region).</B></P> 69 70<H2>See Also</H2> 71<P><a target="contents" href="../list.html#Error">Error Functions</a>, <a href="OSSetErrorHandler.html"><code>OSSetErrorHandler</code></a></P> 72<H2>Revision History</H2> 73<P>03/01/2006 Initial version.</P> 74</BODY> 75</HTML>