mirror of
https://gitlab.com/qemu-project/openbios.git
synced 2024-02-13 08:34:06 +08:00
sparc32 -20 merge remainder
git-svn-id: svn://coreboot.org/openbios/openbios-devel@41 f158a5a8-5612-0410-a976-696ce0be7e32
This commit is contained in:
@@ -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_putchar(int port, unsigned char c)
|
||||
|
||||
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)
|
||||
@@ -74,6 +101,143 @@ static void serial_cls(void)
|
||||
|
||||
#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
|
||||
* ****************************************************************** */
|
||||
@@ -82,6 +246,9 @@ int putchar(int c)
|
||||
{
|
||||
#ifdef CONFIG_DEBUG_CONSOLE_SERIAL
|
||||
serial_putchar(c);
|
||||
#endif
|
||||
#ifdef CONFIG_DEBUG_CONSOLE_VIDEO
|
||||
video_putchar(c);
|
||||
#endif
|
||||
return c;
|
||||
}
|
||||
@@ -91,6 +258,10 @@ int availchar(void)
|
||||
#ifdef CONFIG_DEBUG_CONSOLE_SERIAL
|
||||
if (uart_charav(CONFIG_SERIAL_PORT))
|
||||
return 1;
|
||||
#endif
|
||||
#ifdef CONFIG_DEBUG_CONSOLE_VIDEO
|
||||
if (keyboard_dataready())
|
||||
return 1;
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
@@ -100,6 +271,10 @@ int getchar(void)
|
||||
#ifdef CONFIG_DEBUG_CONSOLE_SERIAL
|
||||
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 @@ void cls(void)
|
||||
#ifdef CONFIG_DEBUG_CONSOLE_SERIAL
|
||||
serial_cls();
|
||||
#endif
|
||||
#ifdef CONFIG_DEBUG_CONSOLE_VIDEO
|
||||
video_cls();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#endif // CONFIG_DEBUG_CONSOLE
|
||||
|
||||
Reference in New Issue
Block a user