]>
Commit | Line | Data |
---|---|---|
1 | #include <io.h> | |
2 | #include <smram.h> | |
3 | #include <video_defines.h> | |
4 | #include <minilib.h> | |
5 | #include <smi.h> | |
6 | #include <pci-bother.h> | |
7 | #include "../net/net.h" | |
8 | #include "vga-overlay.h" | |
9 | ||
10 | #include "pagetable.h" | |
11 | ||
12 | unsigned int counter = 0; | |
13 | unsigned int lastctr = 0; | |
14 | unsigned long pcisave; | |
15 | unsigned char vgasave; | |
16 | ||
17 | void set_cr0(unsigned int); | |
18 | ||
19 | #define get_cr0() \ | |
20 | ({ \ | |
21 | register unsigned int _temp__; \ | |
22 | asm volatile("mov %%cr0, %0" : "=r" (_temp__)); \ | |
23 | _temp__; \ | |
24 | }) | |
25 | ||
26 | ||
27 | #define set_cr3(value) \ | |
28 | { \ | |
29 | register unsigned int _temp__ = (value); \ | |
30 | asm volatile("mov %0, %%cr3" : : "r" (_temp__)); \ | |
31 | } | |
32 | #define CR0_PG 0x80000000 | |
33 | ||
34 | ||
35 | void smi_entry(void) | |
36 | { | |
37 | /* | |
38 | char statstr[512]; | |
39 | */ | |
40 | ||
41 | outb(0x80, 0xBB); | |
42 | return; | |
43 | ||
44 | char * pagedir = pt_setup(0xA0000); | |
45 | outb(0x80, 0x43); | |
46 | set_cr3((int)pagedir); | |
47 | outb(0x80, 0xA5); | |
48 | ||
49 | /* Turn paging on */ | |
50 | set_cr0(get_cr0() | CR0_PG); | |
51 | outb(0x80, 0xAA); | |
52 | ||
53 | pcisave = inl(0xCF8); | |
54 | vgasave = inb(0x3D4); | |
55 | /* | |
56 | pci_unbother_all(); | |
57 | */ | |
58 | ||
59 | counter++; | |
60 | /* | |
61 | sprintf(statstr, "15-412! %08x %08x", smi_status(), counter); | |
62 | strblit(statstr, 0, 0); | |
63 | */ | |
64 | ||
65 | /* | |
66 | eth_poll(); | |
67 | */ | |
68 | ||
69 | if (inl(0x840) & 0x1000) | |
70 | { | |
71 | /* | |
72 | pci_dump(); | |
73 | */ | |
74 | outl(0x840, 0x1100); | |
75 | outl(0x840, 0x0100); | |
76 | } | |
77 | ||
78 | /* | |
79 | smi_poll(); | |
80 | ||
81 | pci_bother_all(); | |
82 | */ | |
83 | outl(0xCF8, pcisave); | |
84 | outb(0x3D4, vgasave); | |
85 | } | |
86 | ||
87 | void timer_handler(smi_event_t ev) | |
88 | { | |
89 | static unsigned int ticks = 0; | |
90 | ||
91 | smi_disable_event(SMI_EVENT_FAST_TIMER); | |
92 | smi_enable_event(SMI_EVENT_FAST_TIMER); | |
93 | ||
94 | outb(0x80, (ticks++) & 0xFF); | |
95 | ||
96 | outlog(); | |
97 | } | |
98 | ||
99 | ||
100 | void __firstrun_start() { | |
101 | smi_disable(); | |
102 | outb(0x80, 0x41); | |
103 | ||
104 | smi_register_handler(SMI_EVENT_FAST_TIMER, timer_handler); | |
105 | smi_enable_event(SMI_EVENT_FAST_TIMER); | |
106 | ||
107 | smi_enable(); | |
108 | } | |
109 |