diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2009-01-02 14:19:43 -0500 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2009-01-02 14:19:43 -0500 |
commit | 8c0e372c2afaee5e19b46f720687beeb6740cb73 (patch) | |
tree | 6aa692ed59ffaad8d125754e232196cdb58e5b3f | |
parent | 0560034c29ef99239b910524f027a4d708038197 (diff) | |
download | seabios-hppa-8c0e372c2afaee5e19b46f720687beeb6740cb73.zip seabios-hppa-8c0e372c2afaee5e19b46f720687beeb6740cb73.tar.gz seabios-hppa-8c0e372c2afaee5e19b46f720687beeb6740cb73.tar.bz2 |
The BDA is at segment 0x0040 not 0x0000.
The interrupt vector table is technically at 0x0000.
-rw-r--r-- | src/biosvar.h | 23 | ||||
-rw-r--r-- | src/config.h | 3 | ||||
-rw-r--r-- | src/kbd.c | 10 | ||||
-rw-r--r-- | src/post.c | 30 | ||||
-rw-r--r-- | src/resume.c | 2 |
5 files changed, 37 insertions, 31 deletions
diff --git a/src/biosvar.h b/src/biosvar.h index 2fb4b8d..5c948ca 100644 --- a/src/biosvar.h +++ b/src/biosvar.h @@ -12,19 +12,28 @@ /**************************************************************** - * Bios Data Area (BDA) + * Interupt vector table ****************************************************************/ struct ivec { - u16 offset; - u16 seg; + union { + struct { + u16 offset; + u16 seg; + }; + u32 segoff; + }; }; +#define SET_IVT(vector, seg, off) \ + SET_FARVAR(SEG_IVT, ((struct ivec *)0)[vector].segoff, ((seg) << 16) | (off)) + + +/**************************************************************** + * Bios Data Area (BDA) + ****************************************************************/ + struct bios_data_area_s { - // 00:00 - struct ivec ivecs[256]; - // 30:00 -// u8 stack[256]; // 40:00 u16 port_com[4]; u16 port_lpt[3]; diff --git a/src/config.h b/src/config.h index 13a023a..1ff4606 100644 --- a/src/config.h +++ b/src/config.h @@ -107,8 +107,9 @@ #define BUILD_START_FIXED 0xe050 // Important real-mode segments +#define SEG_IVT 0x0000 +#define SEG_BDA 0x0040 #define SEG_BIOS 0xf000 -#define SEG_BDA 0x0000 // Segment definitions in protected mode (see rombios32_gdt in romlayout.S) #define SEG32_MODE32_CS (2 << 3) @@ -83,7 +83,7 @@ void kbd_setup() { dprintf(3, "init keyboard\n"); - u16 x = offsetof(struct bios_data_area_s, kbd_buf) - 0x400; + u16 x = offsetof(struct bios_data_area_s, kbd_buf); SET_BDA(kbd_mode, 0x10); SET_BDA(kbd_buf_head, x); SET_BDA(kbd_buf_tail, x); @@ -117,8 +117,8 @@ enqueue_key(u8 scan_code, u8 ascii_code) if (buffer_tail == buffer_head) return 0; - SET_FARVAR(SEG_BDA, *(u8*)(temp_tail+0x400+0), ascii_code); - SET_FARVAR(SEG_BDA, *(u8*)(temp_tail+0x400+1), scan_code); + SET_FARVAR(SEG_BDA, *(u8*)(temp_tail+0), ascii_code); + SET_FARVAR(SEG_BDA, *(u8*)(temp_tail+1), scan_code); SET_BDA(kbd_buf_tail, buffer_tail); return 1; } @@ -141,8 +141,8 @@ dequeue_key(struct bregs *regs, int incr, int extended) cpu_relax(); } - u8 ascii_code = GET_FARVAR(SEG_BDA, *(u8*)(buffer_head+0x400+0)); - u8 scan_code = GET_FARVAR(SEG_BDA, *(u8*)(buffer_head+0x400+1)); + u8 ascii_code = GET_FARVAR(SEG_BDA, *(u8*)(buffer_head+0)); + u8 scan_code = GET_FARVAR(SEG_BDA, *(u8*)(buffer_head+1)); if ((ascii_code == 0xF0 && scan_code != 0) || (ascii_code == 0xE0 && !extended)) ascii_code = 0; @@ -18,13 +18,10 @@ #include "bregs.h" // struct bregs #include "boot.h" // IPL -#define bda ((struct bios_data_area_s *)MAKE_FARPTR(SEG_BDA, 0)) - void __set_irq(int vector, void *loc) { - SET_BDA(ivecs[vector].seg, SEG_BIOS); - SET_BDA(ivecs[vector].offset, (u32)loc - BUILD_BIOS_ADDR); + SET_IVT(vector, SEG_BIOS, (u32)loc - BUILD_BIOS_ADDR); } #define set_irq(vector, func) do { \ @@ -33,10 +30,9 @@ __set_irq(int vector, void *loc) } while (0) static void -init_bda() +init_ivt() { - dprintf(3, "init bda\n"); - memset(bda, 0, sizeof(*bda)); + dprintf(3, "init ivt\n"); // Initialize all vectors to a dummy handler. int i; @@ -66,15 +62,19 @@ init_bda() // set vector 0x79 to zero // this is used by 'gardian angel' protection system - SET_BDA(ivecs[0x79].seg, 0); - SET_BDA(ivecs[0x79].offset, 0); + SET_IVT(0x79, 0, 0); __set_irq(0x1E, &diskette_param_table2); } static void -init_ebda() +init_bda() { + dprintf(3, "init bda\n"); + + struct bios_data_area_s *bda = MAKE_FARPTR(SEG_BDA, 0); + memset(bda, 0, sizeof(*bda)); + int esize = DIV_ROUND_UP(sizeof(struct extended_bios_data_area_s), 1024); SET_BDA(mem_size_kb, 640 - esize); u16 eseg = FARPTR_TO_SEG((640 - esize) * 1024); @@ -83,12 +83,8 @@ init_ebda() struct extended_bios_data_area_s *ebda = get_ebda_ptr(); memset(ebda, 0, sizeof(*ebda)); ebda->size = esize; - SET_BDA(ivecs[0x41].seg, eseg); - SET_BDA(ivecs[0x41].offset - , offsetof(struct extended_bios_data_area_s, fdpt[0])); - SET_BDA(ivecs[0x46].seg, eseg); - SET_BDA(ivecs[0x46].offset - , offsetof(struct extended_bios_data_area_s, fdpt[1])); + SET_IVT(0x41, eseg, offsetof(struct extended_bios_data_area_s, fdpt[0])); + SET_IVT(0x46, eseg, offsetof(struct extended_bios_data_area_s, fdpt[1])); } static void @@ -190,8 +186,8 @@ init_boot_vectors() static void post() { + init_ivt(); init_bda(); - init_ebda(); pic_setup(); timer_setup(); diff --git a/src/resume.c b/src/resume.c index 9db8cad..4ff3133 100644 --- a/src/resume.c +++ b/src/resume.c @@ -60,7 +60,7 @@ handle_resume(u8 status) // NO BREAK case 0x0a: // resume execution by jump via 40h:0067h -#define bda ((struct bios_data_area_s *)0) +#define bda ((struct bios_data_area_s *)MAKE_FARPTR(SEG_BDA, 0)) asm volatile( "movw %%ax, %%ds\n" "ljmpw *%0\n" |