]>
Commit | Line | Data |
---|---|---|
1 | #include <io.h> | |
2 | #include <smram.h> | |
3 | #include <video_defines.h> | |
4 | #include <minilib.h> | |
5 | ||
6 | static char logents[4][41] = {{0}}; | |
7 | ||
8 | #define VRAM_BASE 0xA0000UL | |
9 | #define TEXT_CONSOLE_OFFSET 0x18000UL | |
10 | ||
11 | #define TEXT_CONSOLE_BASE (VRAM_BASE + TEXT_CONSOLE_OFFSET) | |
12 | ||
13 | #define COLOR 0x1F | |
14 | ||
15 | static unsigned char vga_read(unsigned char idx) | |
16 | { | |
17 | outb(CRTC_IDX_REG, idx); | |
18 | return inb(CRTC_DATA_REG); | |
19 | } | |
20 | ||
21 | static char * vga_base() | |
22 | { | |
23 | return (char *) ( | |
24 | TEXT_CONSOLE_BASE | |
25 | | (((unsigned int) vga_read(CRTC_START_ADDR_LSB_IDX)) << 9) | |
26 | | (((unsigned int) vga_read(CRTC_START_ADDR_MSB_IDX)) << 1) | |
27 | ); | |
28 | } | |
29 | ||
30 | void strblit(char *src, int row, int col) | |
31 | { | |
32 | char *destp = vga_base() + row * 80 * 2 + col * 2; | |
33 | smram_state_t old_state = smram_save_state(); | |
34 | ||
35 | smram_aseg_set_state(SMRAM_ASEG_SMMCODE); | |
36 | ||
37 | while (*src) | |
38 | { | |
39 | *(destp++) = *(src++); | |
40 | *(destp++) = COLOR; | |
41 | } | |
42 | ||
43 | smram_restore_state(old_state); | |
44 | } | |
45 | ||
46 | void outlog() | |
47 | { | |
48 | int y, x; | |
49 | char *basep = vga_base(); | |
50 | ||
51 | smram_state_t old_state = smram_save_state(); | |
52 | ||
53 | smram_aseg_set_state(SMRAM_ASEG_SMMCODE); | |
54 | ||
55 | for (y = 0; y < 4; y++) | |
56 | for (x = 40; x < 80; x++) | |
57 | { | |
58 | basep[y*80*2+x*2] = ' '; | |
59 | basep[y*80*2+x*2+1] = 0x1F; | |
60 | } | |
61 | ||
62 | smram_restore_state(old_state); | |
63 | ||
64 | for (y = 0; y < 4; y++) | |
65 | strblit(logents[y], y, 40); | |
66 | } | |
67 | ||
68 | void dolog(char *s) | |
69 | { | |
70 | memmove(logents[0], logents[1], sizeof(logents[0])*3); | |
71 | strcpy(logents[3], s); | |
72 | } |