2007-10-03 Robert Millan <rmh@aybabtu.com>
* include/grub/i386/io.h: New file. * commands/i386/pc/play.c (inb): Removed. (outb): Removed. Include grub/cpu/io.h. Replace inb() with grub_inb() and outb() with grub_outb(). * term/i386/pc/serial.c: Likewise. * term/i386/pc/vga.c: Likewise.
This commit is contained in:
parent
1a477ed638
commit
5c58b791cc
6 changed files with 120 additions and 93 deletions
|
@ -66,26 +66,6 @@ static unsigned char *vga_font;
|
|||
static unsigned char saved_map_mask;
|
||||
static int page = 0;
|
||||
|
||||
/* Read a byte from a port. */
|
||||
static inline unsigned char
|
||||
inb (unsigned short port)
|
||||
{
|
||||
unsigned char value;
|
||||
|
||||
asm volatile ("inb %w1, %0" : "=a" (value) : "Nd" (port));
|
||||
asm volatile ("outb %%al, $0x80" : : );
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
/* Write a byte to a port. */
|
||||
static inline void
|
||||
outb (unsigned short port, unsigned char value)
|
||||
{
|
||||
asm volatile ("outb %b0, %w1" : : "a" (value), "Nd" (port));
|
||||
asm volatile ("outb %%al, $0x80" : : );
|
||||
}
|
||||
|
||||
#define SEQUENCER_ADDR_PORT 0x3C4
|
||||
#define SEQUENCER_DATA_PORT 0x3C5
|
||||
#define MAP_MASK_REGISTER 0x02
|
||||
|
@ -106,7 +86,7 @@ static inline void
|
|||
wait_vretrace (void)
|
||||
{
|
||||
/* Wait until there is a vertical retrace. */
|
||||
while (! (inb (INPUT_STATUS1_REGISTER) & INPUT_STATUS1_VERTR_BIT));
|
||||
while (! (grub_inb (INPUT_STATUS1_REGISTER) & INPUT_STATUS1_VERTR_BIT));
|
||||
}
|
||||
|
||||
/* Get Map Mask Register. */
|
||||
|
@ -116,12 +96,12 @@ get_map_mask (void)
|
|||
unsigned char old_addr;
|
||||
unsigned char old_data;
|
||||
|
||||
old_addr = inb (SEQUENCER_ADDR_PORT);
|
||||
outb (SEQUENCER_ADDR_PORT, MAP_MASK_REGISTER);
|
||||
old_addr = grub_inb (SEQUENCER_ADDR_PORT);
|
||||
grub_outb (SEQUENCER_ADDR_PORT, MAP_MASK_REGISTER);
|
||||
|
||||
old_data = inb (SEQUENCER_DATA_PORT);
|
||||
old_data = grub_inb (SEQUENCER_DATA_PORT);
|
||||
|
||||
outb (SEQUENCER_ADDR_PORT, old_addr);
|
||||
grub_outb (SEQUENCER_ADDR_PORT, old_addr);
|
||||
|
||||
return old_data;
|
||||
}
|
||||
|
@ -132,12 +112,12 @@ set_map_mask (unsigned char mask)
|
|||
{
|
||||
unsigned char old_addr;
|
||||
|
||||
old_addr = inb (SEQUENCER_ADDR_PORT);
|
||||
outb (SEQUENCER_ADDR_PORT, MAP_MASK_REGISTER);
|
||||
old_addr = grub_inb (SEQUENCER_ADDR_PORT);
|
||||
grub_outb (SEQUENCER_ADDR_PORT, MAP_MASK_REGISTER);
|
||||
|
||||
outb (SEQUENCER_DATA_PORT, mask);
|
||||
grub_outb (SEQUENCER_DATA_PORT, mask);
|
||||
|
||||
outb (SEQUENCER_ADDR_PORT, old_addr);
|
||||
grub_outb (SEQUENCER_ADDR_PORT, old_addr);
|
||||
}
|
||||
|
||||
/* Set Read Map Register. */
|
||||
|
@ -146,12 +126,12 @@ set_read_map (unsigned char map)
|
|||
{
|
||||
unsigned char old_addr;
|
||||
|
||||
old_addr = inb (GRAPHICS_ADDR_PORT);
|
||||
old_addr = grub_inb (GRAPHICS_ADDR_PORT);
|
||||
|
||||
outb (GRAPHICS_ADDR_PORT, READ_MAP_REGISTER);
|
||||
outb (GRAPHICS_DATA_PORT, map);
|
||||
grub_outb (GRAPHICS_ADDR_PORT, READ_MAP_REGISTER);
|
||||
grub_outb (GRAPHICS_DATA_PORT, map);
|
||||
|
||||
outb (GRAPHICS_ADDR_PORT, old_addr);
|
||||
grub_outb (GRAPHICS_ADDR_PORT, old_addr);
|
||||
}
|
||||
|
||||
/* Set start address. */
|
||||
|
@ -160,15 +140,15 @@ set_start_address (unsigned int start)
|
|||
{
|
||||
unsigned char old_addr;
|
||||
|
||||
old_addr = inb (CRTC_ADDR_PORT);
|
||||
old_addr = grub_inb (CRTC_ADDR_PORT);
|
||||
|
||||
outb (CRTC_ADDR_PORT, START_ADDR_LOW_REGISTER);
|
||||
outb (CRTC_DATA_PORT, start & 0xFF);
|
||||
grub_outb (CRTC_ADDR_PORT, START_ADDR_LOW_REGISTER);
|
||||
grub_outb (CRTC_DATA_PORT, start & 0xFF);
|
||||
|
||||
outb (CRTC_ADDR_PORT, START_ADDR_HIGH_REGISTER);
|
||||
outb (CRTC_DATA_PORT, start >> 8);
|
||||
grub_outb (CRTC_ADDR_PORT, START_ADDR_HIGH_REGISTER);
|
||||
grub_outb (CRTC_DATA_PORT, start >> 8);
|
||||
|
||||
outb (CRTC_ADDR_PORT, old_addr);
|
||||
grub_outb (CRTC_ADDR_PORT, old_addr);
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue