version 1.1.1.1, 2008/06/03 10:38:41 |
version 1.1.1.1.2.1, 2008/08/13 17:12:23 |
|
|
*/ |
*/ |
|
|
#include <driver.h> |
#include <driver.h> |
#include <cpu.h> |
#include <cpufunc.h> |
|
#include <console.h> |
#include <sys/tty.h> |
#include <sys/tty.h> |
|
|
#define CRTC_INDEX 0x3d4 |
#define CRTC_INDEX 0x3d4 |
|
|
static int console_init(void); |
static int console_init(void); |
static int console_read(device_t, char *, size_t *, int); |
static int console_read(device_t, char *, size_t *, int); |
static int console_write(device_t, char *, size_t *, int); |
static int console_write(device_t, char *, size_t *, int); |
static int console_ioctl(device_t, int, u_long); |
static int console_ioctl(device_t, u_long, void *); |
|
|
/* |
/* |
* Driver structure |
* Driver structure |
|
|
/* init */ console_init, |
/* init */ console_init, |
}; |
}; |
|
|
|
/* |
|
* Device I/O table |
|
*/ |
static struct devio console_io = { |
static struct devio console_io = { |
/* open */ NULL, |
/* open */ NULL, |
/* close */ NULL, |
/* close */ NULL, |
|
|
{ |
{ |
int i; |
int i; |
|
|
memcpy(vram, vram + cols, cols * (rows - 1) * 2); |
memcpy(vram, vram + cols, (size_t)(cols * (rows - 1) * 2)); |
for (i = 0; i < cols; i++) |
for (i = 0; i < cols; i++) |
vram[cols * (rows - 1) + i] = ' ' | (attrib << 8); |
vram[cols * (rows - 1) + i] = ' ' | (attrib << 8); |
} |
} |
|
|
|
|
irq_lock(); |
irq_lock(); |
outb(0x0e, CRTC_INDEX); |
outb(0x0e, CRTC_INDEX); |
outb((u_char)((pos >> 8) & 0xff), CRTC_DATA); |
outb((pos >> 8) & 0xff, CRTC_DATA); |
outb(0x0f, CRTC_INDEX); |
outb(0x0f, CRTC_INDEX); |
outb((u_char)(pos & 0xff), CRTC_DATA); |
outb(pos & 0xff, CRTC_DATA); |
irq_unlock(); |
irq_unlock(); |
} |
} |
|
|
static void |
static void |
reset_cursor(void) |
reset_cursor(void) |
{ |
{ |
int offset; |
u_int offset; |
|
|
irq_lock(); |
irq_lock(); |
outb(0x0e, CRTC_INDEX); |
outb(0x0e, CRTC_INDEX); |
offset = inb(CRTC_DATA); |
offset = (u_int)inb(CRTC_DATA); |
offset <<= 8; |
offset <<= 8; |
outb(0x0f, CRTC_INDEX); |
outb(0x0f, CRTC_INDEX); |
offset += inb(CRTC_DATA); |
offset += (u_int)inb(CRTC_DATA); |
pos_x = offset % cols; |
pos_x = offset % cols; |
pos_y = offset / cols; |
pos_y = offset / cols; |
irq_unlock(); |
irq_unlock(); |
|
|
* I/O control |
* I/O control |
*/ |
*/ |
static int |
static int |
console_ioctl(device_t dev, int cmd, u_long arg) |
console_ioctl(device_t dev, u_long cmd, void *arg) |
{ |
{ |
|
|
return tty_ioctl(&console_tty, cmd, (void *)arg); |
return tty_ioctl(&console_tty, cmd, arg); |
} |
} |
|
|
/* |
/* |
|
|
if (c == '\0') |
if (c == '\0') |
break; |
break; |
put_char(c); |
put_char(c); |
|
|
#if defined(CONFIG_DIAG_BOCHS) |
#if defined(CONFIG_DIAG_BOCHS) |
if (inb(0xe9) == 0xe9) { |
if (inb(0xe9) == 0xe9) { |
if (c == '\n') |
if (c == '\n') |
|
|
debug_attach(diag_print); |
debug_attach(diag_print); |
#endif |
#endif |
tty_register(&console_io, &console_tty, console_output); |
tty_register(&console_io, &console_tty, console_output); |
console_tty.t_winsize.ws_row = rows; |
console_tty.t_winsize.ws_row = (u_short)rows; |
console_tty.t_winsize.ws_col = cols; |
console_tty.t_winsize.ws_col = (u_short)cols; |
return 0; |
return 0; |
} |
} |