3 #include <video_defines.h>
11 static char logents[LOGLEN][41] = {{0}};
12 static int prodptr = 0;
13 static int flush_imm = 0;
15 #define VRAM_BASE 0xA0000UL
16 #define TEXT_CONSOLE_OFFSET 0x18000UL
18 #define TEXT_CONSOLE_BASE (VRAM_BASE + TEXT_CONSOLE_OFFSET)
22 void vga_flush_imm(int imm)
27 static unsigned char vga_read(unsigned char idx)
29 outb(CRTC_IDX_REG, idx);
30 return inb(CRTC_DATA_REG);
33 static char * vga_base()
37 + (((unsigned int) vga_read(CRTC_START_ADDR_MSB_IDX)) << 9)
38 + (((unsigned int) vga_read(CRTC_START_ADDR_LSB_IDX)) << 1)
42 void strblit(char *src, int row, int col)
44 char *destp = vga_base() + row * 80 * 2 + col * 2;
45 smram_state_t old_state = smram_save_state();
47 smram_aseg_set_state(SMRAM_ASEG_SMMCODE);
51 *(destp++) = *(src++);
55 smram_restore_state(old_state);
61 char *basep = vga_base();
63 smram_state_t old_state = smram_save_state();
65 smram_aseg_set_state(SMRAM_ASEG_SMMCODE);
67 for (y = 0; y < LOG_ONSCREEN; y++)
68 for (x = 40; x < 80; x++)
70 basep[y*80*2+x*2] = ' ';
71 basep[y*80*2+x*2+1] = 0x1F;
74 smram_restore_state(old_state);
76 for (y = -LOG_ONSCREEN; y < 0; y++)
77 strblit(logents[(y + prodptr) % LOGLEN], y + LOG_ONSCREEN, 40);
80 void dolog(const char *s)
82 strcpy(logents[prodptr], s);
83 prodptr = (prodptr + 1) % LOGLEN;
87 void (*output)(const char *s) = dolog;
89 void dologf(const char *fmt, ...)
94 vsnprintf(logents[prodptr], 40, fmt, va);
96 prodptr = (prodptr + 1) % LOGLEN;
100 void (*outputf)(const char *s, ...) = dologf;
102 void dump_log (char * target) {
103 memcpy(target, logents, sizeof(logents));