Re: Managing accidental read/writes to address zero
"bobgrice2003" <[email protected]>
| Newsgroups | gmane.comp.hardware.motorola.microcontrollers |
|---|---|
| Message-ID | <[email protected]> |
--- In [email protected], "shanz9903" <duncan.perrett@e...> wrote: > If a program has a bug and tries to use a null pointer, how can you > setup the PowerPC (555) to ensure that the program will crash. The > exception vector table shows 0x0 to 0x0FF as RESERVED (for future > use). > > PS: I know the software should use 'asserts' to test for null > pointers. > > Any advice appreciated. Thanks. If you are using a mix of supervisor/user code, then protecting in user mode is fairly straightforward. Assuming you are booting at 0x100, then use the instruction memory protection unit to mark this area as 'supervisor only' and the rest of your flash as either access. The code snippet is : /* Setup the instruction memory protection unit * We setup two overlapping regions, region 0 having priority. * Region 0 covers the boot code and is no user access, this traps * any null pointers that the user tries to execute down. * Region 1 covers the rest of internal flash and allows user * fetch/read * * The global region is set with no access */ SetSPR(SPR_MI_RBA0, 0x0); /* Region 0 Base = 0x0 */ SetSPR(SPR_MI_RA0, 0x0000f400); /* Size = 64k */ /* PP = Super Fetch */ /* no guard or inhibit */ SetSPR(SPR_MI_RBA1, 0x0); /* Region 1 Base = 0x0 */ SetSPR(SPR_MI_RA1, 0x000ff800); /* Size = 1M */ /* PP = super/user fetch*/ /* no guard or inhibit */ ----------------------------------------------------------- To learn more about Freescale Microcontrollers, please visit http://www.freescale.com/mcu Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/MPC500/ <*> To unsubscribe from this group, send an email to: [email protected] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/