diff options
-rw-r--r-- | Makefile | 7 | ||||
-rw-r--r-- | TODO | 4 | ||||
-rw-r--r-- | src/biosvar.h | 9 | ||||
-rw-r--r-- | src/boot.c | 5 | ||||
-rw-r--r-- | src/cbt.c | 40 | ||||
-rw-r--r-- | src/config.h | 4 | ||||
-rw-r--r-- | src/disk.h | 22 | ||||
-rw-r--r-- | src/floppy.c | 55 | ||||
-rw-r--r-- | src/floppy_dbt.c | 24 | ||||
-rw-r--r-- | src/post.c | 8 | ||||
-rw-r--r-- | src/romlayout.S | 16 | ||||
-rw-r--r-- | src/system.c | 1 | ||||
-rw-r--r-- | src/util.h | 2 |
13 files changed, 134 insertions, 63 deletions
@@ -11,6 +11,7 @@ OUT=out/ SRC16=floppy.c disk.c system.c clock.c serial.c kbd.c mouse.c output.c \ boot.c ata.c SRC32=post.c output.c +TABLESRC=font.c cbt.c floppy_dbt.c cc-option = $(shell if test -z "`$(1) $(2) -S -o /dev/null -xc \ /dev/null 2>&1`"; then echo "$(2)"; else echo "$(3)"; fi ;) @@ -25,7 +26,8 @@ CFLAGS = $(COMMONCFLAGS) -g CFLAGS16 = $(COMMONCFLAGS) -DMODE16 -fno-jump-tables CFLAGS16WHOLE = $(CFLAGS16) -g -fwhole-program -all: $(OUT) $(OUT)rom.bin +TABLETMP=$(addprefix $(OUT), $(patsubst %.c,%.16.s,$(TABLESRC))) +all: $(OUT) $(OUT)rom.bin $(TABLETMP) # Run with "make V=1" to see the actual compile commands ifdef V @@ -64,7 +66,8 @@ $(OUT)blob.16.s: @echo " Generating whole program assembler $@" $(Q)$(CC) $(CFLAGS16WHOLE) -S -combine -c $(addprefix src/, $(SRC16)) -o $@ -$(OUT)romlayout16.o: romlayout.S $(OUT)blob.proc.16.s $(OUT)font.proc.16.s $(OUT)cbt.proc.16.s +TABLEASM=$(addprefix $(OUT), $(patsubst %.c,%.proc.16.s,$(TABLESRC))) +$(OUT)romlayout16.o: romlayout.S $(OUT)blob.proc.16.s $(TABLEASM) @echo " Generating 16bit layout of $@" $(Q)$(CC) $(CFLAGS16) -c $< -o $@ @@ -1,5 +1,7 @@ Find out why ubuntu compiles are failing. Find work around. +Audit all sti/cli calls. + Code assumes ebda segment is static - it doesn't read 0x40e. See if using an ld script for 16bit mode is a good idea. @@ -9,8 +11,6 @@ is unnecessary. Fix makefiles so that they rebuild the required files automatically. -Make sure gdt/idt tables are properly aligned - Cleanup setting of ES on GET/SET_BDA Make sure inline assembly isn't preventing inlining of calling diff --git a/src/biosvar.h b/src/biosvar.h index c34bb66..5f362a0 100644 --- a/src/biosvar.h +++ b/src/biosvar.h @@ -326,9 +326,12 @@ set_cf(struct bregs *regs, int cond) ****************************************************************/ struct bios_config_table_s { - // XXX - u8 x; -}; + u16 size; + u8 model; + u8 submodel; + u8 biosrev; + u8 feature1, feature2, feature3, feature4, feature5; +} PACKED; extern struct bios_config_table_s BIOS_CONFIG_TABLE; @@ -11,6 +11,11 @@ #include "cmos.h" // inb_cmos #include "ata.h" // ata_detect +// We need a copy of this string, but we are not actually a PnP BIOS, +// so make sure it is *not* aligned, so OSes will not see it if they +// scan. +char pnp_string[] VISIBLE __attribute__((aligned (2))) = " $PnP"; + //-------------------------------------------------------------------------- // print_boot_device // displays the boot device @@ -1,8 +1,42 @@ +// BIOS configuration table. +// +// Copyright (C) 2008 Kevin O'Connor <kevin@koconnor.net> +// Copyright (C) 2002 MandrakeSoft S.A. +// +// This file may be distributed under the terms of the GNU GPLv3 license. + #include "biosvar.h" // CONFIG_BIOS_TABLE -// bios variables +// DMA channel 3 used by hard disk BIOS +#define CBT_F1_DMA3USED (1<<7) +// 2nd interrupt controller (8259) installed +#define CBT_F1_2NDPIC (1<<6) +// Real-Time Clock installed +#define CBT_F1_RTC (1<<5) +// INT 15/AH=4Fh called upon INT 09h +#define CBT_F1_INT154F (1<<4) +// wait for external event (INT 15/AH=41h) supported +#define CBT_F1_WAITEXT (1<<3) +// extended BIOS area allocated (usually at top of RAM) +#define CBT_F1_EBDA (1<<2) +// bus is Micro Channel instead of ISA +#define CBT_F1_MCA (1<<1) +// system has dual bus (Micro Channel + ISA) +#define CBT_F1_MCAISA (1<<0) + +// INT 16/AH=09h (keyboard functionality) supported +#define CBT_F2_INT1609 (1<<6) struct bios_config_table_s BIOS_CONFIG_TABLE = { - // XXX - 18, + .size = sizeof(BIOS_CONFIG_TABLE) - 2, + .model = CONFIG_MODEL_ID, + .submodel = CONFIG_SUBMODEL_ID, + .biosrev = CONFIG_BIOS_REVISION, + .feature1 = ( + CBT_F1_2NDPIC | CBT_F1_RTC | CBT_F1_EBDA + | (CONFIG_KBD_CALL_INT15_4F ? CBT_F1_INT154F : 0)), + .feature2 = CBT_F2_INT1609, + .feature3 = 0, + .feature4 = 0, + .feature5 = 0, }; diff --git a/src/config.h b/src/config.h index feb8f27..a440201 100644 --- a/src/config.h +++ b/src/config.h @@ -13,4 +13,8 @@ #define CONFIG_STACK_SEGMENT 0x00 #define CONFIG_STACK_OFFSET 0xfffe +#define CONFIG_MODEL_ID 0xFC +#define CONFIG_SUBMODEL_ID 0x00 +#define CONFIG_BIOS_REVISION 0x01 + #endif // config.h @@ -65,6 +65,28 @@ struct int13dpt_s { #define SET_INT13DPT(regs,var,val) \ SET_FARVAR((regs)->ds, ((struct int13dpt_s*)((regs)->si+0))->var, (val)) +// Floppy "Disk Base Table" +struct floppy_dbt_s { + u8 specify1; + u8 specify2; + u8 shutoff_ticks; + u8 bps_code; + u8 sectors; + u8 interblock_len; + u8 data_len; + u8 gap_len; + u8 fill_byte; + u8 settle_time; + u8 startup_time; +}; + +struct floppy_ext_dbt_s { + struct floppy_dbt_s dbt; + // Extra fields + u8 max_track; + u8 data_rate; + u8 drive_type; +}; // floppy.c void floppy_13(struct bregs *regs, u8 drive); diff --git a/src/floppy.c b/src/floppy.c index 0ff22a2..9131d98 100644 --- a/src/floppy.c +++ b/src/floppy.c @@ -14,44 +14,27 @@ #define BX_FLOPPY_ON_CNT 37 /* 2 seconds */ -// XXX - //.org 0xefc7 - -// Since no provisions are made for multiple drive types, most -// values in this table are ignored. I set parameters for 1.44M -// floppy here -char diskette_param_table[11] = { - 0xAF, - 0x02, // head load time 0000001, DMA used - 0x25, - 0x02, - 18, - 0x1B, - 0xFF, - 0x6C, - 0xF6, - 0x0F, - 0x08, -}; - // New diskette parameter table adding 3 parameters from IBM // Since no provisions are made for multiple drive types, most // values in this table are ignored. I set parameters for 1.44M // floppy here -char diskette_param_table2[14] VISIBLE = { - 0xAF, - 0x02, // head load time 0000001, DMA used - 0x25, - 0x02, - 18, - 0x1B, - 0xFF, - 0x6C, - 0xF6, - 0x0F, - 0x08, - 79, // maximum track - 0, // data transfer rate - 4, // drive type in cmos +struct floppy_ext_dbt_s diskette_param_table2 VISIBLE = { + .dbt = { + .specify1 = 0xAF, + .specify2 = 0x02, // head load time 0000001, DMA used + .shutoff_ticks = 0x25, + .bps_code = 0x02, + .sectors = 18, + .interblock_len = 0x1B, + .data_len = 0xFF, + .gap_len = 0x6C, + .fill_byte = 0xF6, + .settle_time = 0x0F, + .startup_time = 0x08, + }, + .max_track = 79, // maximum track + .data_rate = 0, // data transfer rate + .drive_type = 4, // drive type in cmos }; // Oddities: @@ -196,7 +179,7 @@ floppy_cmd(struct bregs *regs, u16 count, u8 *cmd, u8 cmdlen) // read mode_register = 0x46; - DEBUGF("floppy dma c2"); + //DEBUGF("floppy dma c2\n"); outb(0x06, PORT_DMA1_MASK_REG); outb(0x00, PORT_DMA1_CLEAR_FF_REG); // clear flip-flop outb(base_address, PORT_DMA_ADDR_2); @@ -660,7 +643,7 @@ floppy_1308(struct bregs *regs, u8 drive) /* set es & di to point to 11 byte diskette param table in ROM */ regs->es = SEG_BIOS; - regs->di = (u16)diskette_param_table2; + regs->di = (u16)&diskette_param_table2; /* disk status not changed upon success */ } diff --git a/src/floppy_dbt.c b/src/floppy_dbt.c new file mode 100644 index 0000000..dc8ebc0 --- /dev/null +++ b/src/floppy_dbt.c @@ -0,0 +1,24 @@ +// Floppy controller parameter table. +// +// Copyright (C) 2002 MandrakeSoft S.A. +// +// This file may be distributed under the terms of the GNU GPLv3 license. + +#include "disk.h" // diskette_param_table + +// Since no provisions are made for multiple drive types, most +// values in this table are ignored. I set parameters for 1.44M +// floppy here +struct floppy_dbt_s diskette_param_table VISIBLE = { + .specify1 = 0xAF, + .specify2 = 0x02, // head load time 0000001, DMA used + .shutoff_ticks = 0x25, + .bps_code = 0x02, + .sectors = 18, + .interblock_len = 0x1B, + .data_len = 0xFF, + .gap_len = 0x6C, + .fill_byte = 0xF6, + .settle_time = 0x0F, + .startup_time = 0x08, +}; @@ -33,7 +33,7 @@ init_bda() int i; for (i=0; i<256; i++) { - bda->ivecs[i].seg = 0xf000; + bda->ivecs[i].seg = SEG_BIOS; bda->ivecs[i].offset = OFFSET_dummy_iret_handler; } @@ -451,8 +451,8 @@ callrom(u16 seg, u16 offset) { struct bregs br; memset(&br, 0, sizeof(br)); - br.es = 0xf000; - br.di = OFFSET_pnp_string; + br.es = SEG_BIOS; + br.di = OFFSET_pnp_string + 1; // starts 1 past for alignment br.cs = seg; br.ip = offset; call16(&br); @@ -533,7 +533,7 @@ post() init_boot_vectors(); rom_scan(0xc8000, 0xe0000); - callrom(0xf000, OFFSET_begin_boot); + callrom(SEG_BIOS, OFFSET_begin_boot); } static void diff --git a/src/romlayout.S b/src/romlayout.S index 4a067e1..0a4bf5d 100644 --- a/src/romlayout.S +++ b/src/romlayout.S @@ -224,6 +224,7 @@ rombios32_gdt_48: .word rombios32_gdt .word 0x000f + .balign 8 rombios32_gdt: .word 0, 0, 0, 0 .word 0, 0, 0, 0 @@ -236,15 +237,6 @@ rombios32_gdt: // 16 bit data segment base=0x0 limit=0xffff (REAL_MODE_DS) .word 0xffff, 0, 0x9300, 0x0000 -// We need a copy of this string, but we are not actually a PnP BIOS, -// so make sure it is *not* aligned, so OSes will not see it if they -// scan. - .align 2 - .byte 0 - .globl pnp_string -pnp_string: - .ascii "$PnP" - /**************************************************************** * Interrupt entry points @@ -342,7 +334,8 @@ entry_18: IRQ_ENTRY 0e .org 0xefc7 - // XXX - Diskette Controller Parameter Table +.include "out/floppy_dbt.proc.16.s" + .text .org 0xefd2 IRQ_ENTRY 17 @@ -404,8 +397,7 @@ dummy_iret_handler: .ascii "06/23/99" .org 0xfffe - // XXX - model byte 0xFC = AT - .byte 0xfc + .byte CONFIG_MODEL_ID .byte 0x00 .end diff --git a/src/system.c b/src/system.c index be38c3d..310a17e 100644 --- a/src/system.c +++ b/src/system.c @@ -250,6 +250,7 @@ handle_15c0(struct bregs *regs) { regs->es = SEG_BIOS; regs->bx = (u16)&BIOS_CONFIG_TABLE; + handle_ret(regs, 0); } static void @@ -82,7 +82,7 @@ void call16(struct bregs *callregs) static inline void __call16_int(struct bregs *callregs, u16 offset) { - callregs->cs = 0xf000; + callregs->cs = SEG_BIOS; callregs->ip = offset; call16(callregs); } |