00001
00002
00003
00004
00005
00006
00007
00008 #ifndef __pc_h
00009 #define __pc_h
00010
00011 #include <machine.h>
00012 #include <arch/ia32/cpu.h>
00013 #include <arch/ia32/mmu.h>
00014 #include <arch/ia32/tsc.h>
00015 #include "memory_map.h"
00016 #include "pci.h"
00017 #include "ic.h"
00018 #include "timer.h"
00019 #include "rtc.h"
00020 #include "display.h"
00021 #include "uart.h"
00022
00023 __BEGIN_SYS
00024
00025 class PC: public Machine_Common
00026 {
00027 private:
00028 typedef Traits<PC> Traits;
00029 static const Type_Id TYPE = Type<PC>::TYPE;
00030
00031 static const int SYSCALL_INT = Traits::SYSCALL_INT;
00032
00033 public:
00034
00035 enum {
00036 INT_BASE = Traits::INT_BASE,
00037 INT_TIMER = INT_BASE + 0,
00038 INT_KEYBOARD = INT_BASE + 1
00039 };
00040
00041 public:
00042 PC() {}
00043 ~PC() {}
00044
00045 static Handler int_handler(int i) {
00046 IA32::IDT_Entry * idt = (IA32::IDT_Entry *)Memory_Map<PC>::INT_VEC;
00047 if(i < IA32::IDT_ENTRIES)
00048 return (Handler)idt[i].offset();
00049 }
00050 static void int_handler(int i, Handler h) {
00051 IA32::IDT_Entry * idt = (IA32::IDT_Entry *)Memory_Map<PC>::INT_VEC;
00052 if(i < IA32::IDT_ENTRIES)
00053 idt[i] = IA32::IDT_Entry(IA32::GDT_SYS_CODE,
00054 (IA32::Reg32)h,
00055 IA32::SEG_IDT_ENTRY);
00056 }
00057 template <Handler h> static void handler_wrapper(){
00058 ASM(" cli \n"
00059 " pushl %eax \n"
00060 " pushl %ecx \n"
00061 " pushl %edx \n"
00062 " pushl %ebx \n"
00063 " pushl %esi \n"
00064 " pushl %edi \n"
00065 " movb $0x20, %al \n"
00066 " outb %al, $0x20 \n");
00067
00068 ASM(" call *%0 \n"
00069 " popl %%edi \n"
00070 " popl %%esi \n"
00071 " popl %%ebx \n"
00072 " popl %%edx \n"
00073 " popl %%ecx \n"
00074 " popl %%eax \n"
00075 " leave # this may change with GCC \n"
00076 " sti \n"
00077 " iret \n" : : "r"(h));
00078 }
00079
00080 static int init(System_Info * si);
00081
00082 public:
00083 IA32 cpu;
00084 IA32_MMU mmu;
00085 IA32_TSC tsc;
00086 PC_IC ic;
00087 PC_PCI pci;
00088 PC_Display display;
00089 };
00090
00091 typedef PC Machine;
00092
00093 __END_SYS
00094
00095 #endif