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
13<H2>Syntax</H2>
14<dl><dd><pre class="construction">
15#include &lt;revolution/os.h&gt;
16
17#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 );
40</pre></dd></dl>
41
42<H2>Arguments</H2>
43<TABLE class="arguments" border="1" >
44  <TBODY>
45    <TR>
46<TH>chan</TH>
47<TD>One of <CODE>OS_PROTECT_CHAN</CODE><EM>n</EM>. It is possible to specify up to four regions.</TD>
48    </TR>
49    <TR>
50<TH>addr</TH>
51<TD>Start address.</TD>
52    </TR>
53    <TR>
54<TH>nBytes</TH>
55<TD>Size of the region to be stored.</TD>
56    </TR>
57    <TR>
58<TH>control</TH>
59<TD>One of <CODE>OS_PROTECT_CONTROL_*</CODE>.</TD>
60    </TR>
61  </TBODY>
62</TABLE>
63
64<H2>Return Values</H2>
65<P>None.</P>
66
67<H2>Description</H2>
68<P>In the specified region, sets access protection of the <B>internal main memory (MEM1 region)</B>. The <SPAN class="argument">addr</SPAN> argument will be rounded DOWN to the closest 1024-byte boundary, while the end address (that is, <SPAN class="argument">addr</SPAN> + <SPAN class="argument">nBytes</SPAN>) will be rounded UP to the closest 1024-byte boundary.</P>
69<P>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 (<code>OS_PROTECT_CONTROL_*</code>) will raise an external interrupt from Hollywood to Broadway. Upon such a memory protection violation interrupt, the <CODE>OS_ERROR_PROTECTION</CODE> error will be raised; this error can be captured by the user-specified function registered through <A href="../Error/OSSetErrorHandler.html"><CODE>OSSetErrorHandler</CODE></A>.</P>
70<P>Note that <code>OSProtectRange</code> first flushes and invalidates the corresponding Broadway cache blocks. Thus Broadway's load and store instructions to the specified region after the call to <code>OSProtectRange</code> will cause a cache-line read first off. This cache-line read will trigger an <code>OS_ERROR_PROTECTION</code> error near the execution of the code if <code>OS_PROTECT_CONTROL_WRITE</code> or <code>OS_PROTECT_CONTROL_NONE</code> capability is specified.</P>
71<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>
72
73<H2>See Also</H2>
74<P class="reference">
75<A href="../Error/OSSetErrorHandler.html">OSSetErrorHandler</A>
76</P>
77
78<H2>Revision History</H2>
79<P>
802008/01/18 Revised <B>See Also</B> to reflect category changes. <BR>2006/03/01 Initial version.<BR>
81</P>
82
83<hr><p>CONFIDENTIAL</p></body>
84</HTML>