Author: stepan Date: 2006-06-05 14:37:25 +0200 (Mon, 05 Jun 2006) New Revision: 41
Modified: openbios-devel/arch/sparc32/console.c openbios-devel/arch/sparc32/openbios.c openbios-devel/config/examples/cross-sparc32_config.xml openbios-devel/config/examples/sparc32_config.xml Log: sparc32 -20 merge remainder
Modified: openbios-devel/arch/sparc32/console.c =================================================================== --- openbios-devel/arch/sparc32/console.c 2006-06-05 12:35:11 UTC (rev 40) +++ openbios-devel/arch/sparc32/console.c 2006-06-05 12:37:25 UTC (rev 41) @@ -17,10 +17,30 @@
#ifdef CONFIG_DEBUG_CONSOLE_SERIAL
+#define KBD_BASE 0x71000004 #define SERIAL_BASE 0x71100004 #define CTRL(port) (SERIAL_BASE + (port) * 2 + 0) #define DATA(port) (SERIAL_BASE + (port) * 2 + 2)
+/* Conversion routines to/from brg time constants from/to bits + * per second. + */ +#define BRG_TO_BPS(brg, freq) ((freq) / 2 / ((brg) + 2)) +#define BPS_TO_BRG(bps, freq) ((((freq) + (bps)) / (2 * (bps))) - 2) + +#define ZS_CLOCK 4915200 /* Zilog input clock rate. */ +#define ZS_CLOCK_DIVISOR 16 /* Divisor this driver uses. */ + +/* Write Register 3 */ +#define RxENAB 0x1 /* Rx Enable */ + +/* Write Register 5 */ +#define TxENAB 0x8 /* Tx Enable */ + +/* Write Register 14 (Misc control bits) */ +#define BRENAB 1 /* Baud rate generator enable */ +#define BRSRC 2 /* Baud rate generator source */ + static int uart_charav(int port) { return ((inb(CTRL(port)) & 1) != 0); @@ -42,13 +62,20 @@
static void uart_init_line(int port, unsigned long baud) { - outb(3, CTRL(port)); // reg 3 - outb(1, CTRL(port)); // enable rx + outb(3, CTRL(port)); // reg 3 + outb(RxENAB, CTRL(port)); // enable rx
- outb(5, CTRL(port)); // reg 5 - outb(8, CTRL(port)); // enable tx + outb(5, CTRL(port)); // reg 5 + outb(TxENAB, CTRL(port)); // enable tx
- // XXX: baud rate + baud = BPS_TO_BRG(baud, ZS_CLOCK / ZS_CLOCK_DIVISOR); + + outb(12, CTRL(port)); // reg 12 + outb(baud & 0xff, CTRL(port)); + outb(13, CTRL(port)); // reg 13 + outb((baud >> 8) & 0xff, CTRL(port)); + outb(14, CTRL(port)); // reg 14 + outb(BRSRC | BRENAB, CTRL(port)); }
int uart_init(int port, unsigned long speed) @@ -75,6 +102,143 @@ #endif
/* ****************************************************************** + * simple polling video/keyboard console functions + * ****************************************************************** */ + +#ifdef CONFIG_DEBUG_CONSOLE_VIDEO + +#define VMEM_BASE 0x00800000 +#define VMEM_SIZE (1024*768*1) +#define DAC_BASE 0x00200000 +#define DAC_SIZE 16 + +static unsigned char *vmem; +static volatile uint32_t *dac; + +typedef struct osi_fb_info { + unsigned long mphys; + int rb, w, h, depth; +} osi_fb_info_t; + +int TCX_GetFBInfo( osi_fb_info_t *fb ) +{ + fb->w = 1024; + fb->h = 768; + fb->depth = 8; + fb->rb = 1024; + fb->mphys = vmem; + + return 0; +} + +#define openbios_GetFBInfo(x) TCX_GetFBInfo(x) + +#include "../../modules/video.c" +#include "../../modules/console.c" + +static void video_putchar(int c) +{ + char buf[2]; + + buf[0] = c & 0xff; + buf[1] = 0; + + console_draw_str(buf); +} + +static void video_cls(void) +{ + memset((void *)vmem, 0, VMEM_SIZE); +} + +void tcx_init(unsigned long base) +{ +#if 1 + unsigned int i; + + // Create 1:1 mapping for video memory + for (i = 0; i < VMEM_SIZE; i += 4096) { + map_page(base + VMEM_BASE + i, base + VMEM_BASE + i, 0); + } + vmem = (char *)base + VMEM_BASE; +#else + vmem = map_io(base + VMEM_BASE, VMEM_SIZE); +#endif + dac = map_io(base + DAC_BASE, DAC_SIZE); + + console_init(); +} + +static const unsigned char sunkbd_keycode[128] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', 0, 8, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, + 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', '[', ']', + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', ''', '\', 13, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 'z', 'x', 'c', 'v', 'b', 'n', 'm', ',', '.', '/', + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ' ', +}; + +static const unsigned char sunkbd_keycode_shifted[128] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '+', 0, 8, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, + 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', '{', '}', + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', ':', '"', '|', 13, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 'Z', 'X', 'C', 'V', 'B', 'N', 'M', '<', '>', '?', + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ' ', +}; + +static int shiftstate; + +static int +keyboard_dataready(void) +{ + return ((inb(KBD_BASE) & 1) == 1); +} + +static unsigned char +keyboard_readdata(void) +{ + unsigned char ch; + + while (!keyboard_dataready()) { } + + do { + ch = inb(KBD_BASE + 2) & 0xff; + if (ch == 99) + shiftstate |= 1; + else if (ch == 110) + shiftstate |= 2; + else if (ch == 227) + shiftstate &= ~1; + else if (ch == 238) + shiftstate &= ~2; + //printk("getch: %d\n", ch); + } + while ((ch & 0x80) == 0 || ch == 238 || ch == 227); // Wait for key release + //printk("getch rel: %d\n", ch); + ch &= 0x7f; + if (shiftstate) + ch = sunkbd_keycode_shifted[ch]; + else + ch = sunkbd_keycode[ch]; + //printk("getch xlate: %d\n", ch); + + return ch; +} + +#endif + +/* ****************************************************************** * common functions, implementing simple concurrent console * ****************************************************************** */
@@ -83,6 +247,9 @@ #ifdef CONFIG_DEBUG_CONSOLE_SERIAL serial_putchar(c); #endif +#ifdef CONFIG_DEBUG_CONSOLE_VIDEO + video_putchar(c); +#endif return c; }
@@ -92,6 +259,10 @@ if (uart_charav(CONFIG_SERIAL_PORT)) return 1; #endif +#ifdef CONFIG_DEBUG_CONSOLE_VIDEO + if (keyboard_dataready()) + return 1; +#endif return 0; }
@@ -101,6 +272,10 @@ if (uart_charav(CONFIG_SERIAL_PORT)) return (uart_getchar(CONFIG_SERIAL_PORT)); #endif +#ifdef CONFIG_DEBUG_CONSOLE_VIDEO + if (keyboard_dataready()) + return (keyboard_readdata()); +#endif return 0; }
@@ -109,6 +284,10 @@ #ifdef CONFIG_DEBUG_CONSOLE_SERIAL serial_cls(); #endif +#ifdef CONFIG_DEBUG_CONSOLE_VIDEO + video_cls(); +#endif }
+ #endif // CONFIG_DEBUG_CONSOLE
Modified: openbios-devel/arch/sparc32/openbios.c =================================================================== --- openbios-devel/arch/sparc32/openbios.c 2006-06-05 12:35:11 UTC (rev 40) +++ openbios-devel/arch/sparc32/openbios.c 2006-06-05 12:37:25 UTC (rev 41) @@ -18,10 +18,12 @@
void boot(void); void ob_ide_init(void); +void tcx_init(unsigned long base);
#define IOMMU_BASE 0x10000000 /* First page of sun4m IOMMU */ #define SLAVIO_BASE 0x71000000 #define MACIO_BASE 0x70000000 +#define TCX_BASE 0x50000000
static unsigned char intdict[256 * 1024];
@@ -46,10 +48,13 @@
modules_init(); #ifdef CONFIG_DRIVER_SBUS - init_mmu_swift(IOMMU_BASE); - + ob_init_mmu(IOMMU_BASE); ob_sbus_init(); + +#ifdef CONFIG_DEBUG_CONSOLE_VIDEO + init_video(); #endif +#endif #ifdef CONFIG_DRIVER_ESP ob_esp_init(MACIO_BASE); #endif @@ -68,10 +73,16 @@ extern struct mem cmem;
mem_init(&cmem, (char *) &_vmem, (char *)&_evmem); +#ifdef CONFIG_DRIVER_SBUS + init_mmu_swift(IOMMU_BASE); +#endif #ifdef CONFIG_DEBUG_CONSOLE #ifdef CONFIG_DEBUG_CONSOLE_SERIAL uart_init(CONFIG_SERIAL_PORT, CONFIG_SERIAL_SPEED); #endif +#ifdef CONFIG_DEBUG_CONSOLE_VIDEO + tcx_init(TCX_BASE); +#endif /* Clear the screen. */ cls(); #endif @@ -83,9 +94,6 @@ (unsigned long)sys_info.dict_end - (unsigned long)sys_info.dict_start); -#ifdef CONFIG_DEBUG_CONSOLE_VIDEO - video_init(); -#endif #ifdef CONFIG_DEBUG_BOOT printk("forth started.\n"); printk("initializing memory...");
Modified: openbios-devel/config/examples/cross-sparc32_config.xml =================================================================== --- openbios-devel/config/examples/cross-sparc32_config.xml 2006-06-05 12:35:11 UTC (rev 40) +++ openbios-devel/config/examples/cross-sparc32_config.xml 2006-06-05 12:37:25 UTC (rev 41) @@ -26,6 +26,7 @@ <option name="CONFIG_DEBUG_INTERPRETER" type="boolean" value="false"/> <option name="CONFIG_DEBUG_CONSOLE" type="boolean" value="true"/> <option name="CONFIG_DEBUG_CONSOLE_SERIAL" type="boolean" value="true"/> + <option name="CONFIG_DEBUG_CONSOLE_VIDEO" type="boolean" value="true"/> <option name="CONFIG_DEBUG_ESP" type="boolean" value="false"/> <option name="CONFIG_DEBUG_SUN_PARTS" type="boolean" value="false"/> <option name="CONFIG_DEBUG_OBP" type="boolean" value="false"/>
Modified: openbios-devel/config/examples/sparc32_config.xml =================================================================== --- openbios-devel/config/examples/sparc32_config.xml 2006-06-05 12:35:11 UTC (rev 40) +++ openbios-devel/config/examples/sparc32_config.xml 2006-06-05 12:37:25 UTC (rev 41) @@ -26,6 +26,7 @@ <option name="CONFIG_DEBUG_INTERPRETER" type="boolean" value="false"/> <option name="CONFIG_DEBUG_CONSOLE" type="boolean" value="true"/> <option name="CONFIG_DEBUG_CONSOLE_SERIAL" type="boolean" value="true"/> + <option name="CONFIG_DEBUG_CONSOLE_VIDEO" type="boolean" value="true"/> <option name="CONFIG_DEBUG_ESP" type="boolean" value="false"/> <option name="CONFIG_DEBUG_SUN_PARTS" type="boolean" value="false"/> <option name="CONFIG_DEBUG_OBP" type="boolean" value="false"/>