aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2008-11-16 09:17:02 -0500
committerKevin O'Connor <kevin@koconnor.net>2008-11-16 09:17:02 -0500
commitd9a8b2dfef3eeed05a6f4e958bd327ac9a593b38 (patch)
treefe2d6c446ef22c1d0d51b6828d20dd6f9ea12b9f /src
parent8820a10e732c08e5c8224a2f1456a629b9bc5d98 (diff)
downloadseabios-d9a8b2dfef3eeed05a6f4e958bd327ac9a593b38.tar.gz
Cleanup a20 code.
Fix two apparent bugs - set_a20() returned new status instead of old status and handle_152402() checked wrong bit. Add bit definition for the a20 enable bit: A20_ENABLE_BIT Allow ioport.h #defines to be used in romlayout.S.
Diffstat (limited to 'src')
-rw-r--r--src/ioport.h11
-rw-r--r--src/romlayout.S15
-rw-r--r--src/system.c8
3 files changed, 19 insertions, 15 deletions
diff --git a/src/ioport.h b/src/ioport.h
index 196fe531..633ed0ed 100644
--- a/src/ioport.h
+++ b/src/ioport.h
@@ -6,8 +6,6 @@
#ifndef __IOPORT_H
#define __IOPORT_H
-#include "types.h" // u8
-
#define PORT_DMA_ADDR_2 0x0004
#define PORT_DMA_CNT_2 0x0005
#define PORT_DMA1_MASK_REG 0x000a
@@ -46,9 +44,12 @@
#define PORT_QEMU_CFG_DATA 0x0511
#define PORT_BIOS_APM 0x8900
-// PORT_KBD_CTRLB bitdefs
-#define KBD_REFRESH (1<<4)
+// PORT_A20 bitdefs
+#define A20_ENABLE_BIT 0x02
+#ifndef __ASSEMBLY__
+
+#include "types.h" // u8
static inline void outb(u8 value, u16 port) {
__asm__ __volatile__("outb %b0, %w1" : : "a"(value), "Nd"(port));
@@ -101,4 +102,6 @@ static inline void outsl(u16 port, u32 *data, u32 count) {
: "+c"(count), "+S"(data) : "d"(port) : "memory");
}
+#endif // !__ASSEMBLY__
+
#endif // ioport.h
diff --git a/src/romlayout.S b/src/romlayout.S
index f7c2b022..e7c08bc4 100644
--- a/src/romlayout.S
+++ b/src/romlayout.S
@@ -5,7 +5,8 @@
//
// This file may be distributed under the terms of the GNU GPLv3 license.
-#include "config.h"
+#include "config.h" // CONFIG_*
+#include "ioport.h" // PORT_A20
/****************************************************************
@@ -145,9 +146,9 @@ transition32:
cli
// enable a20
- inb $0x92, %al
- orb $0x02, %al
- outb %al, $0x92
+ inb $PORT_A20, %al
+ orb $A20_ENABLE_BIT, %al
+ outb %al, $PORT_A20
// Set segment descriptors
lidt %cs:pmode_IDT_info
@@ -190,9 +191,9 @@ __call16_from32:
movw %ax, %gs
// disable a20
- inb $0x92, %al
- andb $~0x02, %al
- outb %al, $0x92
+ inb $PORT_A20, %al
+ andb $~A20_ENABLE_BIT, %al
+ outb %al, $PORT_A20
// Jump to 16bit mode
ljmpw $SEG32_MODE16_CS, $1f
diff --git a/src/system.c b/src/system.c
index f4e42635..11b1cc8c 100644
--- a/src/system.c
+++ b/src/system.c
@@ -19,12 +19,12 @@ set_a20(u8 cond)
// get current setting first
u8 newval, oldval = inb(PORT_A20);
if (cond)
- newval = oldval | 0x02;
+ newval = oldval | A20_ENABLE_BIT;
else
- newval = oldval & ~0x02;
+ newval = oldval & ~A20_ENABLE_BIT;
outb(newval, PORT_A20);
- return (newval & 0x02) != 0;
+ return (oldval & A20_ENABLE_BIT) != 0;
}
static void
@@ -44,7 +44,7 @@ handle_152401(struct bregs *regs)
static void
handle_152402(struct bregs *regs)
{
- regs->al = !!(inb(PORT_A20) & 0x20);
+ regs->al = (inb(PORT_A20) & A20_ENABLE_BIT) != 0;
set_code_success(regs);
}