2 * VGA text overlay code
3 * NetWatch system management mode administration console
5 * Copyright (c) 2008 Jacob Potter and Joshua Wise. All rights reserved.
6 * This program is free software; you can redistribute and/or modify it under
7 * the terms found in the file LICENSE in the root of this source tree.
13 #include <video_defines.h>
20 #define LOG_ONSCREEN 4
22 static char logents[LOGLEN][41] = {{0}};
23 static int prodptr = 0;
24 static int flush_imm = 0;
26 #define VRAM_BASE 0xA0000UL
27 #define TEXT_CONSOLE_OFFSET 0x18000UL
29 #define TEXT_CONSOLE_BASE (VRAM_BASE + TEXT_CONSOLE_OFFSET)
33 void vga_flush_imm(int imm)
38 static unsigned char vga_read(unsigned char idx)
40 outb(CRTC_IDX_REG, idx);
41 return inb(CRTC_DATA_REG);
44 static char * vga_base()
48 + (((unsigned int) vga_read(CRTC_START_ADDR_MSB_IDX)) << 9)
49 + (((unsigned int) vga_read(CRTC_START_ADDR_LSB_IDX)) << 1)
53 void strblit(char *src, int row, int col, int fill)
55 char *destp = vga_base() + row * 80 * 2 + col * 2;
57 smram_state_t old_state = smram_save_state();
60 smram_aseg_set_state(SMRAM_ASEG_SMMCODE);
65 *(destp++) = *(src++);
78 smram_restore_state(old_state);
87 for (y = -LOG_ONSCREEN; y < 0; y++)
88 strblit(logents[(y + prodptr + LOGLEN) % LOGLEN], y + LOG_ONSCREEN, 40, 1);
92 void dolog(const char *s)
94 strcpy(logents[prodptr], s);
95 prodptr = (prodptr + 1) % LOGLEN;
103 void (*output)(const char *s) = dolog;
105 void dologf(const char *fmt, ...)
111 vsnprintf(logents[prodptr], 40, fmt, va);
112 s = logents[prodptr];
118 prodptr = (prodptr + 1) % LOGLEN;
122 void (*outputf)(const char *s, ...) = dologf;
124 void dump_log (char * target) {
125 memcpy(target, logents, sizeof(logents));