/* printk2 (for system call) ------------------------------------------------*/ void printk2(char** sp) { char* s = *sp; va_list ap; va_start2(ap, sp); smp_lock((unsigned long)&video_lk); while (*s != '\0') { if (*s == '%') { switch (*(++ s)) { case 's': video_puts(va_arg(ap, char*)); break; case 'x': video_putn(va_arg(ap, long), 16); break; case 'd': video_putn(va_arg(ap, long), 10); break; case 'c': video_putc((char)va_arg(ap, long)); break; default: video_putc('%'); video_putc(*(s - 1)); } } else { video_putc(*s); } s ++; }
void video_puts(char *string) { while (*string) { video_putc(*string); string++; } }
int fbterm (int op, struct DevEntry *dev, unsigned long param, int data) { unsigned char code; switch (op) { case OP_OPEN: return 0; case OP_INIT: case OP_XBAUD: case OP_BAUD: return 0; case OP_TXRDY: return 1; case OP_TX: //*(unsigned char*)0xbfd003f8 = data&0xff; if(vga_available) video_putc(data&0xff); //fb_putchar(data&0xff); break; case OP_RXRDY: if ( #if NMOD_USB_KBD != 0 (usb_kbd_available && usb_kbd_code) || #endif (kbd_available && kbd_code) ) { return 1; }else { return 0; } case OP_RX: #if NMOD_USB_KBD != 0 if(usb_kbd_available && usb_kbd_code){ code = usb_kbd_code; usb_kbd_code = 0; return code; } #endif if(kbd_available && kbd_code){ code = kbd_code; kbd_code = 0; return code; }else{ return 0; } case OP_RXSTOP: break; } return 0; }
void video_bios_print_string(char *s, int x, int y, int attr, int count) { int cattr = current_attr; if (attr != -1) current_attr = attr; video_set_cursor(x,y); while (count) { char c = *s++; if (attr == -1) current_attr = *s++; video_putc(c); count--; } }
// output a character to the console static void cons_putc(int c) { serial_putc(c); video_putc(c); }
void video_putc(int c) { // if no attribute given, then use black on white if (!(c & ~0xFF)) c |= 0x0700; switch (c & 0xff) { case '\b': if (terminal.crt_pos > 0) { terminal.crt_pos--; terminal.crt_buf[terminal.crt_pos] = (c & ~0xff) | ' '; } break; case '\n': terminal.crt_pos += CRT_COLS; /* fallthru */ case '\r': terminal.crt_pos -= (terminal.crt_pos % CRT_COLS); break; case '\t': video_putc(' '); video_putc(' '); video_putc(' '); video_putc(' '); video_putc(' '); break; default: terminal.crt_buf[terminal.crt_pos++] = c; /* write the character */ break; } if (terminal.crt_pos >= CRT_SIZE) { int i; memmove(terminal.crt_buf, terminal.crt_buf + CRT_COLS, (CRT_SIZE - CRT_COLS) * sizeof(uint16_t)); for (i = CRT_SIZE - CRT_COLS; i < CRT_SIZE; i++) terminal.crt_buf[i] = 0x0700 | ' '; terminal.crt_pos -= CRT_COLS; } /* move that little blinky thing */ outb(addr_6845, 14); outb(addr_6845 + 1, terminal.crt_pos >> 8); outb(addr_6845, 15); outb(addr_6845 + 1, terminal.crt_pos); //tmphack //static int tmpcount = 0; /*static int tmpcount = 0 ; int i; if(tmpcount <11946) { for (i = 0; !(inb(COM1 + COM_LSR) & COM_LSR_TXRDY) && i < 12800;//is_transimit_empty i++) { inb(0x84); inb(0x84); inb(0x84); inb(0x84); } outb(COM1+COM_TX, c); tmpcount++; } */ }
void cons_putc(char c) { serial_putc(c); video_putc(c); }
/* Writes C to the vga display and serial port. The caller has already acquired the console lock if appropriate. */ static void putchar_have_lock (uint8_t c) { ASSERT (console_locked_by_current_thread ()); write_cnt++; serial_putc (c); video_putc (c); }
void video_putc(int c) { int i,temp,temp2; // if no attribute given, then use black on white if (!(c & ~0xFF)) c |= 0x0700; switch (c & 0xff) { case '\b': if (blk_pos > line_pos){ crt_buf[blk_pos-1] = (c & ~0xff) | ' '; for (i=blk_pos-1;i<crt_pos;++i){ crt_buf[i] = crt_buf[i+1]; } blk_pos--; crt_pos--; } break; case '\n': crt_pos += CRT_COLS; blk_pos = crt_pos; line_pos = crt_pos + 2; /* fallthru */ case '\r': // blk_right(); crt_pos -= (crt_pos % CRT_COLS); blk_pos = crt_pos; line_pos = crt_pos + 2; break; case '\t': video_putc(' '); video_putc(' '); video_putc(' '); video_putc(' '); video_putc(' '); blk_pos = crt_pos; break; default: // basically just shifts all the characters in the buffer that are to the right of the blinker position to the right temp = crt_buf[blk_pos]; crt_buf[blk_pos] = c; for (i=blk_pos+1;i<crt_pos+1;i++){ temp2 = crt_buf[i]; crt_buf[i] = temp; temp = temp2; } crt_pos++; blk_pos++; break; } // the following just resizes the window if (crt_pos >= CRT_SIZE) { int i; memmove(crt_buf, crt_buf + CRT_COLS, (CRT_SIZE - CRT_COLS) * sizeof(uint16_t)); for (i = CRT_SIZE - CRT_COLS; i < CRT_SIZE; i++) crt_buf[i] = 0x0700 | ' '; crt_pos -= CRT_COLS; blk_pos = crt_pos; line_pos = crt_pos + 2; } /* move that little blinky thing */ set_blk(blk_pos); }
void becnputchar(void *dev, register int c) { video_putc(c); }