2007-11-03 Marco Gerards <marco@gnu.org>
* term/i386/pc/vga_text.c: Include <grub/cpu/io.h>. (CRTC_ADDR_PORT): New macro. (CRTC_DATA_PORT): Likewise. (CRTC_CURSOR): Likewise. (CRTC_CURSOR_ADDR_HIGH): Likewise. (CRTC_CURSOR_ADDR_LOW): Likewise. (update_cursor): New function. (grub_console_real_putchar): Call `update_cursor'. (grub_console_gotoxy): Likewise. (grub_console_cls): Set the default color when clearing the screen. (grub_console_setcursor): Implemented.
This commit is contained in:
parent
bb06ab2eb2
commit
be7ac41e14
2 changed files with 44 additions and 4 deletions
15
ChangeLog
15
ChangeLog
|
@ -1,3 +1,18 @@
|
|||
2007-11-03 Marco Gerards <marco@gnu.org>
|
||||
|
||||
* term/i386/pc/vga_text.c: Include <grub/cpu/io.h>.
|
||||
(CRTC_ADDR_PORT): New macro.
|
||||
(CRTC_DATA_PORT): Likewise.
|
||||
(CRTC_CURSOR): Likewise.
|
||||
(CRTC_CURSOR_ADDR_HIGH): Likewise.
|
||||
(CRTC_CURSOR_ADDR_LOW): Likewise.
|
||||
(update_cursor): New function.
|
||||
(grub_console_real_putchar): Call `update_cursor'.
|
||||
(grub_console_gotoxy): Likewise.
|
||||
(grub_console_cls): Set the default color when clearing the
|
||||
screen.
|
||||
(grub_console_setcursor): Implemented.
|
||||
|
||||
2007-11-03 Marco Gerards <marco@gnu.org>
|
||||
|
||||
* disk/ata.c (grub_ata_pio_read): Don't wait for the command to
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
*/
|
||||
|
||||
#include <grub/machine/console.h>
|
||||
#include <grub/cpu/io.h>
|
||||
#include <grub/types.h>
|
||||
|
||||
#define COLS 80
|
||||
|
@ -26,6 +27,13 @@ static int grub_curr_x, grub_curr_y;
|
|||
|
||||
#define VGA_TEXT_SCREEN 0xb8000
|
||||
|
||||
#define CRTC_ADDR_PORT 0x3D4
|
||||
#define CRTC_DATA_PORT 0x3D5
|
||||
|
||||
#define CRTC_CURSOR 0x0a
|
||||
#define CRTC_CURSOR_ADDR_HIGH 0x0e
|
||||
#define CRTC_CURSOR_ADDR_LOW 0x0f
|
||||
|
||||
static void
|
||||
screen_write_char (int x, int y, short c)
|
||||
{
|
||||
|
@ -38,6 +46,16 @@ screen_read_char (int x, int y)
|
|||
return ((short *) VGA_TEXT_SCREEN)[y * COLS + x];
|
||||
}
|
||||
|
||||
static void
|
||||
update_cursor (void)
|
||||
{
|
||||
unsigned int pos = grub_curr_y * COLS + grub_curr_x;
|
||||
grub_outb (CRTC_CURSOR_ADDR_HIGH, CRTC_ADDR_PORT);
|
||||
grub_outb (pos >> 8, CRTC_DATA_PORT);
|
||||
grub_outb (CRTC_CURSOR_ADDR_LOW, CRTC_ADDR_PORT);
|
||||
grub_outb (pos & 0xFF, CRTC_DATA_PORT);
|
||||
}
|
||||
|
||||
static void
|
||||
inc_y ()
|
||||
{
|
||||
|
@ -78,9 +96,12 @@ grub_console_real_putchar (int c)
|
|||
grub_curr_x = 0;
|
||||
break;
|
||||
default:
|
||||
screen_write_char (grub_curr_x, grub_curr_y, c | (grub_console_cur_color << 8));
|
||||
screen_write_char (grub_curr_x,
|
||||
grub_curr_y, c | (grub_console_cur_color << 8));
|
||||
inc_x ();
|
||||
}
|
||||
|
||||
update_cursor ();
|
||||
}
|
||||
|
||||
grub_uint16_t
|
||||
|
@ -94,6 +115,7 @@ grub_console_gotoxy (grub_uint8_t x, grub_uint8_t y)
|
|||
{
|
||||
grub_curr_x = x;
|
||||
grub_curr_y = y;
|
||||
update_cursor ();
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -101,11 +123,14 @@ grub_console_cls ()
|
|||
{
|
||||
int i;
|
||||
for (i = 0; i < ROWS * COLS; i++)
|
||||
((short *) VGA_TEXT_SCREEN)[i] = ' ';
|
||||
((short *) VGA_TEXT_SCREEN)[i] = ' ' | (grub_console_cur_color << 8);
|
||||
}
|
||||
|
||||
void
|
||||
grub_console_setcursor (int on __attribute__ ((unused)))
|
||||
grub_console_setcursor (int on)
|
||||
{
|
||||
/* Not implemented. */
|
||||
grub_uint8_t old;
|
||||
grub_outb (CRTC_CURSOR, CRTC_ADDR_PORT);
|
||||
old = grub_inb (CRTC_DATA_PORT);
|
||||
grub_outb ((old & ~(on << 5)), CRTC_DATA_PORT);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue