00001 // EPOS-- PC Mediator Initialization 00002 00003 // This work is licensed under the Creative Commons 00004 // Attribution-NonCommercial-NoDerivs License. To view a copy of this license, 00005 // visit http://creativecommons.org/licenses/by-nc-nd/2.0/ or send a letter to 00006 // Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA. 00007 00008 #include <mach/pc/pc.h> 00009 00010 __BEGIN_SYS 00011 00012 // void default_handler(void) 00013 // { 00014 // Display display; 00015 // display.position(0, 70); 00016 // display.puts("PANIC"); 00017 // IA32::halt(); 00018 // } 00019 00020 int PC::init(System_Info * si) 00021 { 00022 db<PC>(TRC) << "PC::init()\n"; 00023 00024 // for(int i = 0; i < IA32::IDT_ENTRIES; i++) 00025 // int_handler(i, &handler_wrapper<default_handler>); 00026 00027 return 0; 00028 } 00029 00030 // //======================================================================== 00031 // // page_fault 00032 // // 00033 // // Desc: Page fault exception handler (what a handling! :-)). 00034 // // 00035 // // Parm: exception stack and error code pushed by the CPU 00036 // //------------------------------------------------------------------------ 00037 // void page_fault(Reg32 eip, Reg32 cs, Reg32 eflags, Reg32 esp3, Reg32 ss, 00038 // Reg32 error) 00039 // { 00040 // IA32 cpu; 00041 00042 // db<Setup>(ERR) << "this thread generated an invalid address and will be terminated!\n"; 00043 // db<Setup>(ERR) << "address=" << (void *)cpu.cr2() << "\n"; 00044 // db<Setup>(ERR) << "context={cs=" << cs 00045 // << ",ip=" << (void *)eip 00046 // << ",flg=" << (void *)eflags 00047 // << ",ss=" << (void *)ss 00048 // << ",sp=" << (void *)esp3 00049 // << ",err=" << (void *)error << "}\n"; 00050 00051 // panic(); 00052 // } 00053 00054 // //======================================================================== 00055 // // gpf 00056 // // 00057 // // Desc: GPF exception handler (what a handling! :-)). 00058 // // 00059 // // Parm: exception stack and error code pushed by the CPU 00060 // //------------------------------------------------------------------------ 00061 // void gpf(Reg32 eip, Reg32 cs, Reg32 eflags, Reg32 esp3, Reg32 ss, Reg32 error) 00062 // { 00063 // short ds; 00064 // ASM("movw %%ds, %0" : "=o" (ds) : ); 00065 00066 // db<Setup>(ERR) << "this thread caused a GPF and will be terminated!\n"; 00067 // db<Setup>(ERR) << "context={cs=" << cs 00068 // << ",ds=" << ds 00069 // << ",ip=" << (void *)eip 00070 // << ",flg=" << (void *)eflags 00071 // << ",ss=" << (void *)ss 00072 // << ",sp=" << (void *)esp3 00073 // << ",err=" << (void *)error << "}\n", 00074 00075 // panic(); 00076 // } 00077 00078 // //======================================================================== 00079 // // fpu 00080 // // 00081 // // Desc: FPU exception handler. 00082 // //------------------------------------------------------------------------ 00083 // void fpu() 00084 // { 00085 // db<Setup>(ERR) << "FPU generated an interrupt!\n"; 00086 00087 // // ASM("clts"); 00088 00089 // panic(); 00090 // } 00091 00092 // //======================================================================== 00093 // // syscall 00094 // // 00095 // // Desc: FPU exception handler. 00096 // //------------------------------------------------------------------------ 00097 // void syscall() 00098 // { 00099 // db<Setup>(ERR) << "System call invoked but no OS kernel loaded (yet)!\n"; 00100 00101 // panic(); 00102 // } 00103 00104 // //======================================================================== 00105 // // panic 00106 // // 00107 // // Desc: This function is called if something goes wrong during setup, 00108 // // including uncaught interrupts. 00109 // //------------------------------------------------------------------------ 00110 // void panic() 00111 // { 00112 // unsigned short *video; 00113 00114 // // Set a pointer to GCA text frame buffer so we can say something 00115 // video = reinterpret_cast<unsigned short *>( 00116 // Traits<PC_Display>::FRAME_BUFFER_ADDRESS); 00117 00118 // video [0] = 'P' | 0x1f00; 00119 // video [1] = 'A' | 0x1f00; 00120 // video [2] = 'N' | 0x1f00; 00121 // video [3] = 'I' | 0x1f00; 00122 // video [4] = 'C' | 0x1f00; 00123 // video [5] = '!' | 0x1f00; 00124 00125 // ASM("hlt"); 00126 // } 00127 00128 00129 __END_SYS