2006-04-26 16:39:16 +00:00
|
|
|
/*
|
|
|
|
|
* Copyright (C) 2003, 2004 Stefan Reinauer
|
|
|
|
|
*
|
|
|
|
|
* See the file "COPYING" for further information about
|
|
|
|
|
* the copyright and warranty status of this work.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "openbios/config.h"
|
2010-03-14 14:21:02 +00:00
|
|
|
#include "kernel/kernel.h"
|
2010-03-14 15:19:41 +00:00
|
|
|
#include "drivers/drivers.h"
|
2006-04-26 16:39:16 +00:00
|
|
|
#include "openbios.h"
|
2009-01-02 14:53:33 +00:00
|
|
|
#include "video_subr.h"
|
2010-03-14 15:05:53 +00:00
|
|
|
#include "libopenbios/ofmem.h"
|
2006-04-26 16:39:16 +00:00
|
|
|
|
|
|
|
|
#ifdef CONFIG_DEBUG_CONSOLE
|
|
|
|
|
|
2006-06-05 12:37:25 +00:00
|
|
|
/* ******************************************************************
|
|
|
|
|
* simple polling video/keyboard console functions
|
|
|
|
|
* ****************************************************************** */
|
|
|
|
|
|
|
|
|
|
#ifdef CONFIG_DEBUG_CONSOLE_VIDEO
|
|
|
|
|
|
2007-05-19 12:55:01 +00:00
|
|
|
#define VMEM_BASE 0x00800000ULL
|
2006-06-05 12:37:25 +00:00
|
|
|
#define VMEM_SIZE (1024*768*1)
|
2007-05-19 12:55:01 +00:00
|
|
|
#define DAC_BASE 0x00200000ULL
|
2006-06-05 12:37:25 +00:00
|
|
|
#define DAC_SIZE 16
|
|
|
|
|
|
2008-12-05 18:31:27 +00:00
|
|
|
unsigned char *vmem;
|
2009-01-02 14:53:33 +00:00
|
|
|
volatile uint32_t *dac;
|
2006-06-05 12:37:25 +00:00
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
2007-05-19 12:55:01 +00:00
|
|
|
void tcx_init(uint64_t base)
|
2006-06-05 12:37:25 +00:00
|
|
|
{
|
|
|
|
|
vmem = map_io(base + VMEM_BASE, VMEM_SIZE);
|
|
|
|
|
dac = map_io(base + DAC_BASE, DAC_SIZE);
|
|
|
|
|
|
|
|
|
|
console_init();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
2006-04-26 16:39:16 +00:00
|
|
|
/* ******************************************************************
|
|
|
|
|
* common functions, implementing simple concurrent console
|
|
|
|
|
* ****************************************************************** */
|
|
|
|
|
|
|
|
|
|
int putchar(int c)
|
|
|
|
|
{
|
|
|
|
|
#ifdef CONFIG_DEBUG_CONSOLE_SERIAL
|
|
|
|
|
serial_putchar(c);
|
2006-06-05 12:37:25 +00:00
|
|
|
#endif
|
|
|
|
|
#ifdef CONFIG_DEBUG_CONSOLE_VIDEO
|
|
|
|
|
video_putchar(c);
|
2006-04-26 16:39:16 +00:00
|
|
|
#endif
|
|
|
|
|
return c;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int availchar(void)
|
|
|
|
|
{
|
|
|
|
|
#ifdef CONFIG_DEBUG_CONSOLE_SERIAL
|
|
|
|
|
if (uart_charav(CONFIG_SERIAL_PORT))
|
|
|
|
|
return 1;
|
2006-06-05 12:37:25 +00:00
|
|
|
#endif
|
|
|
|
|
#ifdef CONFIG_DEBUG_CONSOLE_VIDEO
|
|
|
|
|
if (keyboard_dataready())
|
|
|
|
|
return 1;
|
2006-04-26 16:39:16 +00:00
|
|
|
#endif
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int getchar(void)
|
|
|
|
|
{
|
|
|
|
|
#ifdef CONFIG_DEBUG_CONSOLE_SERIAL
|
|
|
|
|
if (uart_charav(CONFIG_SERIAL_PORT))
|
|
|
|
|
return (uart_getchar(CONFIG_SERIAL_PORT));
|
2006-06-05 12:37:25 +00:00
|
|
|
#endif
|
|
|
|
|
#ifdef CONFIG_DEBUG_CONSOLE_VIDEO
|
|
|
|
|
if (keyboard_dataready())
|
|
|
|
|
return (keyboard_readdata());
|
2006-04-26 16:39:16 +00:00
|
|
|
#endif
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void cls(void)
|
|
|
|
|
{
|
|
|
|
|
#ifdef CONFIG_DEBUG_CONSOLE_SERIAL
|
|
|
|
|
serial_cls();
|
|
|
|
|
#endif
|
2006-06-05 12:37:25 +00:00
|
|
|
#ifdef CONFIG_DEBUG_CONSOLE_VIDEO
|
|
|
|
|
video_cls();
|
|
|
|
|
#endif
|
2006-04-26 16:39:16 +00:00
|
|
|
}
|
|
|
|
|
|
2006-06-05 12:37:25 +00:00
|
|
|
|
2006-04-26 16:39:16 +00:00
|
|
|
#endif // CONFIG_DEBUG_CONSOLE
|