|
|
1.1 ! root 1: /* ! 2: * Copyright (C) 2003, 2004 Stefan Reinauer ! 3: * ! 4: * See the file "COPYING" for further information about ! 5: * the copyright and warranty status of this work. ! 6: */ ! 7: ! 8: #include "config.h" ! 9: #include "kernel/kernel.h" ! 10: #include "drivers/drivers.h" ! 11: #include "openbios.h" ! 12: #include "libopenbios/console.h" ! 13: #include "libopenbios/ofmem.h" ! 14: ! 15: void cls(void); ! 16: ! 17: #ifdef CONFIG_DEBUG_CONSOLE ! 18: ! 19: /* ****************************************************************** ! 20: * simple polling video/keyboard console functions ! 21: * ****************************************************************** */ ! 22: ! 23: #ifdef CONFIG_DEBUG_CONSOLE_VIDEO ! 24: ! 25: #define VMEM_BASE 0x00800000ULL ! 26: #define VMEM_SIZE (1024*768*1) ! 27: #define DAC_BASE 0x00200000ULL ! 28: #define DAC_SIZE 16 ! 29: ! 30: unsigned char *vmem; ! 31: volatile uint32_t *dac; ! 32: ! 33: static void video_putchar(int c) ! 34: { ! 35: char buf; ! 36: ! 37: buf = c & 0xff; ! 38: ! 39: console_draw_fstr(&buf, 1); ! 40: } ! 41: ! 42: static void video_cls(void) ! 43: { ! 44: memset((void *)vmem, 0, VMEM_SIZE); ! 45: } ! 46: ! 47: void tcx_init(uint64_t base) ! 48: { ! 49: vmem = (unsigned char *)ofmem_map_io(base + VMEM_BASE, VMEM_SIZE); ! 50: dac = (uint32_t *)ofmem_map_io(base + DAC_BASE, DAC_SIZE); ! 51: ! 52: console_init(); ! 53: } ! 54: ! 55: #endif ! 56: ! 57: /* ****************************************************************** ! 58: * common functions, implementing simple concurrent console ! 59: * ****************************************************************** */ ! 60: ! 61: int putchar(int c) ! 62: { ! 63: #ifdef CONFIG_DEBUG_CONSOLE_SERIAL ! 64: serial_putchar(c); ! 65: #endif ! 66: #ifdef CONFIG_DEBUG_CONSOLE_VIDEO ! 67: video_putchar(c); ! 68: #endif ! 69: return c; ! 70: } ! 71: ! 72: int availchar(void) ! 73: { ! 74: #ifdef CONFIG_DEBUG_CONSOLE_SERIAL ! 75: if (uart_charav(CONFIG_SERIAL_PORT)) ! 76: return 1; ! 77: #endif ! 78: #ifdef CONFIG_DEBUG_CONSOLE_VIDEO ! 79: if (keyboard_dataready()) ! 80: return 1; ! 81: #endif ! 82: return 0; ! 83: } ! 84: ! 85: int getchar(void) ! 86: { ! 87: #ifdef CONFIG_DEBUG_CONSOLE_SERIAL ! 88: if (uart_charav(CONFIG_SERIAL_PORT)) ! 89: return (uart_getchar(CONFIG_SERIAL_PORT)); ! 90: #endif ! 91: #ifdef CONFIG_DEBUG_CONSOLE_VIDEO ! 92: if (keyboard_dataready()) ! 93: return (keyboard_readdata()); ! 94: #endif ! 95: return 0; ! 96: } ! 97: ! 98: void cls(void) ! 99: { ! 100: #ifdef CONFIG_DEBUG_CONSOLE_SERIAL ! 101: serial_cls(); ! 102: #endif ! 103: #ifdef CONFIG_DEBUG_CONSOLE_VIDEO ! 104: video_cls(); ! 105: #endif ! 106: } ! 107: ! 108: ! 109: #endif // CONFIG_DEBUG_CONSOLE
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.