3 #include <video_defines.h>
11 static char logents[LOGLEN][41] = {{0}};
12 static int prodptr = 0;
14 #define VRAM_BASE 0xA0000UL
15 #define TEXT_CONSOLE_OFFSET 0x18000UL
17 #define TEXT_CONSOLE_BASE (VRAM_BASE + TEXT_CONSOLE_OFFSET)
21 static unsigned char vga_read(unsigned char idx)
23 outb(CRTC_IDX_REG, idx);
24 return inb(CRTC_DATA_REG);
27 static char * vga_base()
31 + (((unsigned int) vga_read(CRTC_START_ADDR_MSB_IDX)) << 9)
32 + (((unsigned int) vga_read(CRTC_START_ADDR_LSB_IDX)) << 1)
36 void strblit(char *src, int row, int col)
38 char *destp = vga_base() + row * 80 * 2 + col * 2;
39 smram_state_t old_state = smram_save_state();
41 smram_aseg_set_state(SMRAM_ASEG_SMMCODE);
45 *(destp++) = *(src++);
49 smram_restore_state(old_state);
55 char *basep = vga_base();
57 smram_state_t old_state = smram_save_state();
59 smram_aseg_set_state(SMRAM_ASEG_SMMCODE);
61 for (y = 0; y < LOG_ONSCREEN; y++)
62 for (x = 40; x < 80; x++)
64 basep[y*80*2+x*2] = ' ';
65 basep[y*80*2+x*2+1] = 0x1F;
68 smram_restore_state(old_state);
70 for (y = -LOG_ONSCREEN; y < 0; y++)
71 strblit(logents[(y + prodptr) % LOGLEN], y + LOG_ONSCREEN, 40);
74 void dolog(const char *s)
76 strcpy(logents[prodptr], s);
77 prodptr = (prodptr + 1) % LOGLEN;
79 void (*output)(const char *s) = dolog;
81 void dologf(const char *fmt, ...)
86 vsnprintf(logents[prodptr], 40, fmt, va);
88 prodptr = (prodptr + 1) % LOGLEN;
90 void (*outputf)(const char *s, ...) = dologf;
92 void dump_log (char * target) {
93 memcpy(target, logents, sizeof(logents));