]> Joshua Wise's Git repositories - netwatch.git/blame - aseg-paging/smi.c
Working serial output in pagingland. Continues to run, too.
[netwatch.git] / aseg-paging / smi.c
CommitLineData
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>
113df320 7#include <serial.h>
9e2a82e4
JP
8#include "../net/net.h"
9#include "vga-overlay.h"
10
11#include "pagetable.h"
12
13unsigned int counter = 0;
14unsigned int lastctr = 0;
15unsigned long pcisave = 0;
16unsigned char vgasave = 0;
17
18void set_cr0(unsigned int);
19
20#define get_cr0() \
21 ({ \
22 register unsigned int _temp__; \
23 asm volatile("mov %%cr0, %0" : "=r" (_temp__)); \
24 _temp__; \
25 })
26
27
28#define set_cr3(value) \
29 { \
30 register unsigned int _temp__ = (value); \
31 asm volatile("mov %0, %%cr3" : : "r" (_temp__)); \
32 }
33#define CR0_PG 0x80000000
34
35
36void smi_entry(void)
37{
38 char statstr[512];
39 outb(0x80, 0x0B);
40 pcisave = inl(0xCF8);
41 vgasave = inb(0x3D4);
42 outb(0x80, 0x1B);
43/*
44 pci_unbother_all();
45 */
46 counter++;
47 outb(0x80, 0x2B);
48 sprintf(statstr, "15-412! %08x %08x", smi_status(), counter);
49 outb(0x80, 0x3B);
50 strblit(statstr, 0, 0);
51 outb(0x80, 0x4B);
52
113df320
JW
53 serial_init();
54 dolog("wee!");
55
9e2a82e4
JP
56 /*
57 eth_poll();
58 */
59
60 if (inl(0x840) & 0x1000)
61 {
62 /*
63 pci_dump();
64 */
65 outl(0x840, 0x1100);
66 outl(0x840, 0x0100);
67 }
68
113df320 69
9e2a82e4 70 smi_poll();
113df320 71/*
9e2a82e4
JP
72 pci_bother_all();
73 */
74 outl(0xCF8, pcisave);
75 outb(0x3D4, vgasave);
76}
77
78void timer_handler(smi_event_t ev)
79{
80 static unsigned int ticks = 0;
81
82 smi_disable_event(SMI_EVENT_FAST_TIMER);
83 smi_enable_event(SMI_EVENT_FAST_TIMER);
84
85 outb(0x80, (ticks++) & 0xFF);
86
87 outlog();
88}
89
90
91void __firstrun_start() {
113df320
JW
92 smram_state_t smram;
93
94 smram = smram_save_state();
95 smram_tseg_set_state(SMRAM_TSEG_OPEN);
9e2a82e4
JP
96 smi_disable();
97 outb(0x80, 0x41);
98
99 smi_register_handler(SMI_EVENT_FAST_TIMER, timer_handler);
100 smi_enable_event(SMI_EVENT_FAST_TIMER);
101
102 smi_enable();
103}
104
This page took 0.036095 seconds and 4 git commands to generate.