]>
Commit | Line | Data |
---|---|---|
9e2a82e4 JP |
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 = 0; | |
15 | unsigned char vgasave = 0; | |
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 | char statstr[512]; | |
38 | outb(0x80, 0x0B); | |
39 | pcisave = inl(0xCF8); | |
40 | vgasave = inb(0x3D4); | |
41 | outb(0x80, 0x1B); | |
42 | /* | |
43 | pci_unbother_all(); | |
44 | */ | |
45 | counter++; | |
46 | outb(0x80, 0x2B); | |
47 | sprintf(statstr, "15-412! %08x %08x", smi_status(), counter); | |
48 | outb(0x80, 0x3B); | |
49 | strblit(statstr, 0, 0); | |
50 | outb(0x80, 0x4B); | |
51 | ||
52 | /* | |
53 | eth_poll(); | |
54 | */ | |
55 | ||
56 | if (inl(0x840) & 0x1000) | |
57 | { | |
58 | /* | |
59 | pci_dump(); | |
60 | */ | |
61 | outl(0x840, 0x1100); | |
62 | outl(0x840, 0x0100); | |
63 | } | |
64 | ||
65 | /* | |
66 | smi_poll(); | |
67 | ||
68 | pci_bother_all(); | |
69 | */ | |
70 | outl(0xCF8, pcisave); | |
71 | outb(0x3D4, vgasave); | |
72 | } | |
73 | ||
74 | void timer_handler(smi_event_t ev) | |
75 | { | |
76 | static unsigned int ticks = 0; | |
77 | ||
78 | smi_disable_event(SMI_EVENT_FAST_TIMER); | |
79 | smi_enable_event(SMI_EVENT_FAST_TIMER); | |
80 | ||
81 | outb(0x80, (ticks++) & 0xFF); | |
82 | ||
83 | outlog(); | |
84 | } | |
85 | ||
86 | ||
87 | void __firstrun_start() { | |
88 | smi_disable(); | |
89 | outb(0x80, 0x41); | |
90 | ||
91 | smi_register_handler(SMI_EVENT_FAST_TIMER, timer_handler); | |
92 | smi_enable_event(SMI_EVENT_FAST_TIMER); | |
93 | ||
94 | smi_enable(); | |
95 | } | |
96 |