home *** CD-ROM | disk | FTP | other *** search
- /*
- exception_handler.c
- exception handlers for PowerOS
- copyright 1996-1997 by Ben Martz
- all rights reserved world wide
-
- ANY AND ALL MODIFICATIONS TO THIS SOURCE MUST CREDIT THE ORIGINAL
- AUTHOR, BEN MARTZ (benmartz@ic.net), AND MUST BE GIVEN TO THE AUTHOR
- FOR INTEGRATION INTO THE MAIN PowerOS SOURCE TREE. THANK YOU FOR YOUR
- COOPERATION!
- */
-
- #include "poweros_types.h"
- #include "debug_console.h"
-
- /*********************************************************************/
-
- void SystemReset(void) {
- unsigned long x,y;
-
- x = cgetx(); y = cgety(); cgotoxy(1,20);
- dprintf("SystemReset");
- /* do stuff here */
- cgotoxy(x,y);
- __asm__ volatile("b _SystemReset_exit");
- }
-
- /*********************************************************************/
-
- void MachineCheck(void) {
- unsigned long x,y;
-
- x = cgetx(); y = cgety(); cgotoxy(1,20);
- dprintf("MachineCheck");
- /* do stuff here */
- cgotoxy(x,y);
- __asm__ volatile("b _MachineCheck_exit");
- }
-
- /*********************************************************************/
-
- typedef struct {
- unsigned long reserved_on_601 : 1;
- unsigned long not_in_hash : 1;
- unsigned long cleared : 2;
- unsigned long protected : 1;
- unsigned long io_err : 1;
- unsigned long store_or_load : 1;
- unsigned long cleared_2 : 2;
- unsigned long ea_matches : 1;
- unsigned long cleared_3 : 1;
- unsigned long eciwx_or_ecowx : 1;
- unsigned long cleared_4 : 20;
- } DSISR_BITS;
-
- void DataStorage(void) {
- unsigned long x,y;
- unsigned long dar;
- DSISR_BITS dsisr;
-
- x = cgetx(); y = cgety(); cgotoxy(1,20);
- dprintf("DataStorage");
-
- /* get the DAR and DSISR */
- __asm__ volatile("mfspr %0,19" : "=r" (dar));
- __asm__ volatile("mfspr %0,18" : "=r" (dsisr));
-
- /* the DAR contains the address of the first byte
- of the attempted access */
- dprintf(" at 0x%x : ",dar);
-
- /* the DSISR contains some bits that tell us what happened */
- if(dsisr.not_in_hash) dprintf("not_in_hash ");
- if(dsisr.protected) dprintf("protected ");
- if(dsisr.io_err) dprintf("io_err ");
- if(dsisr.store_or_load) dprintf("(store) ");
- else dprintf("(load) ");
- if(dsisr.ea_matches) dprintf("ea_matches ");
- if(dsisr.eciwx_or_ecowx) dprintf("eciwx_or_ecowx");
-
- cgotoxy(x,y);
- __asm__ volatile("b _DataStorage_exit");
- }
-
- /*********************************************************************/
-
- void InstructionStorage(void) {
- unsigned long x,y;
- unsigned long addr;
-
- x = cgetx(); y = cgety(); cgotoxy(1,20);
- dprintf("InstructionStorage");
-
- /* SRR0 contains the address of the next instruction
- to the executed */
- __asm__ volatile("mfsrr0 %0" : "=r" (addr));
-
- dprintf(" at 0x%x",addr);
-
- cgotoxy(x,y);
- __asm__ volatile("b _InstructionStorage_exit");
- }
-
- /*********************************************************************/
-
- void External(void) {
- unsigned long x,y;
-
- x = cgetx(); y = cgety(); cgotoxy(1,20);
- dprintf("External");
- /* do stuff here */
- cgotoxy(x,y);
- __asm__ volatile("b _External_exit");
- }
-
- /*********************************************************************/
-
- void Alignment(void) {
- unsigned long x,y;
-
- x = cgetx(); y = cgety(); cgotoxy(1,20);
- dprintf("Alignment");
- /* do stuff here */
- cgotoxy(x,y);
- __asm__ volatile("b _Alignment_exit");
- }
-
- /*********************************************************************/
-
- void Program(void) {
- unsigned long x,y;
-
- x = cgetx(); y = cgety(); cgotoxy(1,20);
- dprintf("Program");
- /* do stuff here */
- cgotoxy(x,y);
- __asm__ volatile("b _Program_exit");
- }
-
- /*********************************************************************/
-
- void FPUnavailable(void) {
- unsigned long x,y;
-
- x = cgetx(); y = cgety(); cgotoxy(1,20);
- dprintf("FPUnavailable");
- /* do stuff here */
- cgotoxy(x,y);
- __asm__ volatile("b _FPUnavailable_exit");
- }
-
- /*********************************************************************/
-
- void Decrementer(void) {
- unsigned long x,y;
-
- x = cgetx(); y = cgety(); cgotoxy(1,20);
- dprintf("Decrementer");
- /* do stuff here */
- cgotoxy(x,y);
- __asm__ volatile("b _Decrementer_exit");
- }
-
- /*********************************************************************/
-
- void IOException(void) {
- unsigned long x,y;
-
- x = cgetx(); y = cgety(); cgotoxy(1,20);
- dprintf("IOException");
- /* do stuff here */
- cgotoxy(x,y);
- __asm__ volatile("b _IOException_exit");
- }
-
- /*********************************************************************/
-
- void SystemCall(unsigned long call) {
- unsigned long x,y;
-
- x = cgetx(); y = cgety(); cgotoxy(1,20);
- dprintf("SystemCall(%x)",call);
- switch(call) {
- case 0x1234:
- dprintf(" HI!");
- break;
- default:
- dprintf(" unknown system call!");
- }
- cgotoxy(x,y);
- __asm__ volatile("b _SystemCall_exit");
- }
-
- /*********************************************************************/
-
- void Trace(void) {
- unsigned long x,y;
-
- x = cgetx(); y = cgety(); cgotoxy(1,20);
- dprintf("Trace");
- /* do stuff here */
- cgotoxy(x,y);
- __asm__ volatile("b _Trace_exit");
- }
-
- /*********************************************************************/
-
- void FPAssist(void) {
- unsigned long x,y;
-
- x = cgetx(); y = cgety(); cgotoxy(1,20);
- dprintf("FPAssist");
- /* do stuff here */
- cgotoxy(x,y);
- __asm__ volatile("b _FPAssist_exit");
- }
-
- /*********************************************************************/
-
- void UnknownException(void) {
- unsigned long x,y;
-
- x = cgetx(); y = cgety(); cgotoxy(1,20);
- dprintf("UnknownException");
- cgotoxy(x,y);
- __asm__ volatile("b _UnknownException_exit");
- }
-