$(OUT)%.lds: %.lds.S
@echo " Precompiling $<"
- $(Q)$(CPP) -P $< -o $@
+ $(Q)$(CPP) -P -D__ASSEMBLY__ $< -o $@
$(OUT)blob.16.s: ; $(call whole-compile, $(CFLAGS16) -S, $(addprefix src/, $(SRC16)),$@)
TABLEASM=$(addprefix $(OUT), $(patsubst %.c,%.proc.16.s,$(TABLESRC)))
$(OUT)romlayout16.o: romlayout.S $(OUT)blob.16.s $(TABLEASM)
@echo " Generating 16bit layout of $@"
- $(Q)$(CC) $(CFLAGS16) -c $< -o $@
+ $(Q)$(CC) $(CFLAGS16) -c -D__ASSEMBLY__ $< -o $@
$(OUT)romlayout32.o: ; $(call whole-compile, $(CFLAGS), $(addprefix src/, $(SRC32)),$@)
#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
#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));
: "+c"(count), "+S"(data) : "d"(port) : "memory");
}
+#endif // !__ASSEMBLY__
+
#endif // ioport.h
//
// 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
/****************************************************************
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
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
// 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
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);
}