void drawcursor(uint x, uint y) { u8 row, bit; uartputc('W'); for(row=0; row<15; row++) for(bit=0; bit<8; bit++) drawpixel(x+bit, y+row); uartputc('X'); }
// Print to the console. only understands %d, %x, %p, %s. void cprintf(char *fmt, ...) { int i, c; int locking; uint *argp; char *s; locking = cons.locking; if(locking) acquire(&cons.lock); if (fmt == 0) panic("null fmt"); argp = (uint *)(void*)(&fmt + 1); for(i = 0; (c = fmt[i] & 0xff) != 0; i++){ if(c != '%'){ // gpuputc(c); uartputc(c); continue; } c = fmt[++i] & 0xff; if(c == 0) break; switch(c){ case 'd': printint(*argp++, 10, 1); break; case 'x': case 'p': printint(*argp++, 16, 0); break; case 's': if((s = (char*)*argp++) == 0) s = "(null)"; for(; *s; s++){ // gpuputc(*s); uartputc(*s); } break; case '%': // gpuputc('%'); uartputc('%'); break; default: // Print unknown % sequence to draw attention. // gpuputc('%'); uartputc('%'); // gpuputc(c); uartputc(c); break; } } if(locking) release(&cons.lock); }
void consputc(int c) { if(c == BACKSPACE){ uartputc('\b'); uartputc(' '); uartputc('\b'); } else uartputc(c); cgaputc(c); }
//static void void gpuputc(uint c) { if(c=='\n'){ cursor_x = 0; cursor_y += fontheight; if(cursor_y >= frameheight) { memmove((u8 *)fbinfo.fbp, (u8 *)fbinfo.fbp+framewidth*fontheight*2, (frameheight - fontheight)*framewidth*2); cursor_y = frameheight - fontheight; setgpucolour(0); while(cursor_x < framewidth) { drawcursor(cursor_x, cursor_y); cursor_x = cursor_x + fontwidth; } setgpucolour(0xffff); cursor_x = 0; } } else if(c == BACKSPACE) { if (cursor_x > 0) { cursor_x -= fontwidth; setgpucolour(0); drawcursor(cursor_x, cursor_y); setgpucolour(0xffff); } } else { uartputc('1'); setgpucolour(0); uartputc('2'); drawcursor(cursor_x, cursor_y); uartputc('3'); setgpucolour(0xffff); uartputc('4'); if(c!=' ') drawcharacter(c, cursor_x, cursor_y); cursor_x = cursor_x + fontwidth; uartputc('5'); if(cursor_x >= framewidth) { cursor_x = 0; cursor_y += fontheight; uartputc('6'); if(cursor_y >= frameheight) { memmove((u8 *)fbinfo.fbp, (u8 *)fbinfo.fbp+framewidth*fontheight*2, (frameheight - fontheight)*framewidth*2); cursor_y = frameheight - fontheight; setgpucolour(0); uartputc('7'); while(cursor_x < framewidth) { drawcursor(cursor_x, cursor_y); cursor_x = cursor_x + fontwidth; } uartputc('8'); setgpucolour(0xffff); cursor_x = 0; } } uartputc('9'); } }
void uartputs(char *data, int len) { int x; clockpoll(); x = splfhi(); while (len--){ if(*data == '\n') uartputc('\r'); uartputc(*data++); } splx(x); }
void drawpixel(uint x, uint y) { u16 *addr; if(x >= framewidth || y >= frameheight) return; uartputc('M'); addr = (u16 *) fbinfo.fbp; uartputc('V'); // addr = (u16 *) ((FBI *)FrameBufferInfo)->fbp; addr += y*1024 + x; uartputc('C'); *addr = gpucolour; uartputc('E'); return; }
void consputc(int c) { if(panicked){ cli(); for(;;) ; } if(c == BACKSPACE){ uartputc('\b'); uartputc(' '); uartputc('\b'); } else uartputc(c); cgaputc(c); }
void consputc(int c) { if(panicked){ disableinterrupt(); for(;;) ; } if(c == BACKSPACE){ uartputc('\b'); uartputc(' '); uartputc('\b'); } else uartputc(c); //cgaputc(c); }
void putc(int c) { cgaputc(c); if(uart != -1) uartputc(uart, c); }
void uartinit(void) { char *p; // Turn off the FIFO outb(COM1+2, 0); // 9600 baud, 8 data bits, 1 stop bit, parity off. outb(COM1+3, 0x80); // Unlock divisor outb(COM1+0, 115200/9600); outb(COM1+1, 0); outb(COM1+3, 0x03); // Lock divisor, 8 data bits. outb(COM1+4, 0); outb(COM1+1, 0x01); // Enable receive interrupts. // If status is 0xFF, no serial port. if(inb(COM1+5) == 0xFF) return; uart = 1; // Acknowledge pre-existing interrupt conditions; // enable interrupts. inb(COM1+2); inb(COM1+0); picenable(IRQ_COM1); ioapicenable(IRQ_COM1, 0); // Announce that we're here. for(p="xv6...\n"; *p; p++) uartputc(*p); }
static void printint(int xx, int base, int sign) { static u8 digits[] = "0123456789abcdef"; u8 buf[16]; int i; uint x, y, b; if(sign && (sign = xx < 0)) x = -xx; else x = xx; b = base; i = 0; do{ y = div(x, b); buf[i++] = digits[x - y * b]; }while((x = y) != 0); if(sign) buf[i++] = '-'; while(--i >= 0){ // gpuputc(buf[i]); uartputc(buf[i]); } }
void consputc(int c) { if (panicked) { cli(); for (;;) ; } if (c == BACKSPACE) { uartputc('\b'); uartputc(' '); uartputc('\b'); } else if (c != KEY_LEFT && c != KEY_RIGHT) uartputc(c); cgaputc(c); }
void consputc(int c) { if(panicked){ cli(); for(;;) ; } // commented out because uart will no longer mirror console if(c == BACKSPACE){ uartputc('\b'); uartputc(' '); uartputc('\b'); } else uartputc(c); // cgaputc(c); }
void consoleinit(void) { uint fbinfoaddr; fbinfoaddr = initframebuf(framewidth, frameheight, framecolors); ///if(fbinfoaddr != 0) NotOkLoop(); if(fbinfoaddr != 0) { uartputc('N'); while(1); } else uartputc('Y'); initlock(&cons.lock, "console"); memset(&input, 0, sizeof(input)); initlock(&input.lock, "input"); memset(devsw, 0, sizeof(struct devsw)*NDEV); devsw[CONSOLE].write = consolewrite; devsw[CONSOLE].read = consoleread; cons.locking = 1; panicked = 0; // must initialize in code since the compiler does not cursor_x=cursor_y=0; }
int consolewrite(struct inode *ip, char *buf, int n) { int i; // cprintf("consolewrite is called: ip=%x buf=%x, n=%x", ip, buf, n); iunlock(ip); acquire(&cons.lock); for(i = 0; i < n; i++){ // gpuputc(buf[i] & 0xff); uartputc(buf[i] & 0xff); } release(&cons.lock); ilock(ip); return n; }
void consputc(int c) { if(panicked){ cli(); for(;;) ; } if(c == BACKSPACE){ // gpuputc('\b'); gpuputc(' '); gpuputc('\b'); uartputc('\b'); uartputc(' '); uartputc('\b'); } else if(c == C('D')) { // gpuputc('^'); gpuputc('D'); uartputc('^'); uartputc('D'); } else { // gpuputc(c); uartputc(c); } }
void uartsetcolor(char c) { switch (c) { case 'A': uartputc(27); uartputc('['); uartputc('3'); uartputc('1'); uartputc(';'); uartputc('1'); uartputc('m'); break; case 'B': uartputc(27); uartputc('['); uartputc('3'); uartputc('2'); uartputc('m'); break; case 'C': uartputc(27); uartputc('['); uartputc('3'); uartputc('2'); uartputc('m'); break; case 'D': uartputc(27); uartputc('['); uartputc('3'); uartputc('5'); uartputc('m'); break; case 'E': uartputc(27); uartputc('['); uartputc('4'); uartputc('3'); uartputc('m'); break; default: uartputc(27); uartputc('['); uartputc('0'); uartputc('m'); break; } }
/* for debugging */ void prs(char *s) { for(; *s; s++) uartputc(*s); }