X-Git-Url: http://git.joshuawise.com/netwatch.git/blobdiff_plain/d24901e6cc51d80d30e074eba9fdb3b64d938dc2..9c86d6da946b19a513ab554ee12473360d38d93d:/aseg/vga-overlay.c?ds=inline diff --git a/aseg/vga-overlay.c b/aseg/vga-overlay.c index d205656..7d107d7 100644 --- a/aseg/vga-overlay.c +++ b/aseg/vga-overlay.c @@ -3,8 +3,14 @@ #include #include #include +#include -static char logents[4][41] = {{0}}; +#define LOGLEN 96 +#define LOG_ONSCREEN 4 + +static char logents[LOGLEN][41] = {{0}}; +static int prodptr = 0; +static int flush_imm = 0; #define VRAM_BASE 0xA0000UL #define TEXT_CONSOLE_OFFSET 0x18000UL @@ -13,6 +19,11 @@ static char logents[4][41] = {{0}}; #define COLOR 0x1F +void vga_flush_imm(int imm) +{ + flush_imm = imm; +} + static unsigned char vga_read(unsigned char idx) { outb(CRTC_IDX_REG, idx); @@ -34,7 +45,7 @@ void strblit(char *src, int row, int col) smram_state_t old_state = smram_save_state(); smram_aseg_set_state(SMRAM_ASEG_SMMCODE); - + while (*src) { *(destp++) = *(src++); @@ -53,7 +64,7 @@ void outlog() smram_aseg_set_state(SMRAM_ASEG_SMMCODE); - for (y = 0; y < 4; y++) + for (y = 0; y < LOG_ONSCREEN; y++) for (x = 40; x < 80; x++) { basep[y*80*2+x*2] = ' '; @@ -62,22 +73,32 @@ void outlog() smram_restore_state(old_state); - for (y = 0; y < 4; y++) - strblit(logents[y], y, 40); + for (y = -LOG_ONSCREEN; y < 0; y++) + strblit(logents[(y + prodptr) % LOGLEN], y + LOG_ONSCREEN, 40); } -void dolog(char *s) +void dolog(const char *s) { - memmove(logents[0], logents[1], sizeof(logents[0])*3); - strcpy(logents[3], s); + strcpy(logents[prodptr], s); + prodptr = (prodptr + 1) % LOGLEN; + if (flush_imm) + outlog(); } +void (*output)(const char *s) = dolog; -void dologf(char *fmt, ...) +void dologf(const char *fmt, ...) { va_list va; - memmove(logents[0], logents[1], sizeof(logents[0])*3); va_start(va, fmt); - vsnprintf(logents[3], 40, fmt, va); + vsnprintf(logents[prodptr], 40, fmt, va); va_end(va); + prodptr = (prodptr + 1) % LOGLEN; + if (flush_imm) + outlog(); +} +void (*outputf)(const char *s, ...) = dologf; + +void dump_log (char * target) { + memcpy(target, logents, sizeof(logents)); }