From cc9e1bf4336696340330010d59028e3b8fb9aa7d Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Wed, 28 Jul 2010 21:31:38 -0400 Subject: Add FUNC16() helper macro for converting a 16bit func to a segoff_s. --- src/ata.c | 2 +- src/biosvar.h | 6 ++++++ src/clock.c | 4 ++-- src/floppy.c | 2 +- src/misc.c | 2 +- src/pic.h | 13 +++---------- src/post.c | 49 ++++++++++++++++++------------------------------- src/ps2port.c | 4 ++-- 8 files changed, 34 insertions(+), 48 deletions(-) diff --git a/src/ata.c b/src/ata.c index 2e934be..e9a8df7 100644 --- a/src/ata.c +++ b/src/ata.c @@ -1038,5 +1038,5 @@ ata_setup(void) SET_BDA(disk_control_byte, 0xc0); - enable_hwirq(14, entry_76); + enable_hwirq(14, FUNC16(entry_76)); } diff --git a/src/biosvar.h b/src/biosvar.h index df0df0e..415f958 100644 --- a/src/biosvar.h +++ b/src/biosvar.h @@ -25,6 +25,12 @@ struct rmode_IVT { #define SET_IVT(vector, segoff) \ SET_FARVAR(SEG_IVT, ((struct rmode_IVT *)0)->ivec[vector], segoff) +#define FUNC16(func) ({ \ + ASSERT32FLAT(); \ + extern void func (void); \ + SEGOFF(SEG_BIOS, (u32)func - BUILD_BIOS_ADDR); \ + }) + /**************************************************************** * Bios Data Area (BDA) diff --git a/src/clock.c b/src/clock.c index 6d46501..f6a43e9 100644 --- a/src/clock.c +++ b/src/clock.c @@ -213,8 +213,8 @@ timer_setup(void) SET_BDA(timer_counter, ticks); SET_BDA(timer_rollover, 0); - enable_hwirq(0, entry_08); - enable_hwirq(8, entry_70); + enable_hwirq(0, FUNC16(entry_08)); + enable_hwirq(8, FUNC16(entry_70)); } diff --git a/src/floppy.c b/src/floppy.c index a8942cf..6491b96 100644 --- a/src/floppy.c +++ b/src/floppy.c @@ -139,7 +139,7 @@ floppy_setup(void) outb(0x02, PORT_DMA1_MASK_REG); - enable_hwirq(6, entry_0e); + enable_hwirq(6, FUNC16(entry_0e)); } // Find a floppy type that matches a given image size. diff --git a/src/misc.c b/src/misc.c index 5cb4a01..9db49e3 100644 --- a/src/misc.c +++ b/src/misc.c @@ -66,7 +66,7 @@ mathcp_setup(void) dprintf(3, "math cp init\n"); // 80x87 coprocessor installed SETBITS_BDA(equipment_list_flags, 0x02); - enable_hwirq(13, entry_75); + enable_hwirq(13, FUNC16(entry_75)); } // INT 75 - IRQ13 - MATH COPROCESSOR EXCEPTION diff --git a/src/pic.h b/src/pic.h index 586ef38..c75af3e 100644 --- a/src/pic.h +++ b/src/pic.h @@ -8,6 +8,7 @@ #define __PIC_H #include "ioport.h" // PORT_PIC* +#include "biosvar.h" // SET_IVT // PORT_PIC1 bitdefs #define PIC1_IRQ0 (1<<0) @@ -76,11 +77,8 @@ get_pic2_isr(void) return inb(PORT_PIC2_CMD); } -// post.c -void __set_irq(int vector, void *loc); - static inline void -__enable_hwirq(int hwirq, void (*func)(void)) +enable_hwirq(int hwirq, struct segoff_s func) { int vector; if (hwirq < 8) { @@ -90,14 +88,9 @@ __enable_hwirq(int hwirq, void (*func)(void)) unmask_pic2(1 << (hwirq - 8)); vector = 0x70 + hwirq - 8; } - __set_irq(vector, func); + SET_IVT(vector, func); } -#define enable_hwirq(irq, func) do { \ - extern void func (void); \ - __enable_hwirq(irq, func); \ - } while (0) - void set_pics(u8 irq0, u8 irq8); void pic_setup(void); diff --git a/src/post.c b/src/post.c index 0cb9e57..56e5eb5 100644 --- a/src/post.c +++ b/src/post.c @@ -25,17 +25,6 @@ #include "ps2port.h" // ps2port_setup #include "virtio-blk.h" // virtio_blk_setup -void -__set_irq(int vector, void *loc) -{ - SET_IVT(vector, SEGOFF(SEG_BIOS, (u32)loc - BUILD_BIOS_ADDR)); -} - -#define set_irq(vector, func) do { \ - extern void func (void); \ - __set_irq(vector, func); \ - } while (0) - static void init_ivt(void) { @@ -44,28 +33,28 @@ init_ivt(void) // Initialize all vectors to the default handler. int i; for (i=0; i<256; i++) - set_irq(i, entry_iret_official); + SET_IVT(i, FUNC16(entry_iret_official)); // Initialize all hw vectors to a default hw handler. for (i=0x08; i<=0x0f; i++) - set_irq(i, entry_hwpic1); + SET_IVT(i, FUNC16(entry_hwpic1)); for (i=0x70; i<=0x77; i++) - set_irq(i, entry_hwpic2); + SET_IVT(i, FUNC16(entry_hwpic2)); // Initialize software handlers. - set_irq(0x02, entry_02); - set_irq(0x10, entry_10); - set_irq(0x11, entry_11); - set_irq(0x12, entry_12); - set_irq(0x13, entry_13_official); - set_irq(0x14, entry_14); - set_irq(0x15, entry_15); - set_irq(0x16, entry_16); - set_irq(0x17, entry_17); - set_irq(0x18, entry_18); - set_irq(0x19, entry_19_official); - set_irq(0x1a, entry_1a); - set_irq(0x40, entry_40); + SET_IVT(0x02, FUNC16(entry_02)); + SET_IVT(0x10, FUNC16(entry_10)); + SET_IVT(0x11, FUNC16(entry_11)); + SET_IVT(0x12, FUNC16(entry_12)); + SET_IVT(0x13, FUNC16(entry_13_official)); + SET_IVT(0x14, FUNC16(entry_14)); + SET_IVT(0x15, FUNC16(entry_15)); + SET_IVT(0x16, FUNC16(entry_16)); + SET_IVT(0x17, FUNC16(entry_17)); + SET_IVT(0x18, FUNC16(entry_18)); + SET_IVT(0x19, FUNC16(entry_19_official)); + SET_IVT(0x1a, FUNC16(entry_1a)); + SET_IVT(0x40, FUNC16(entry_40)); // INT 60h-66h reserved for user interrupt for (i=0x60; i<=0x66; i++) @@ -75,7 +64,7 @@ init_ivt(void) // this is used by 'gardian angel' protection system SET_IVT(0x79, SEGOFF(0, 0)); - __set_irq(0x1E, &diskette_param_table2); + SET_IVT(0x1E, SEGOFF(SEG_BIOS, (u32)&diskette_param_table2 - BUILD_BIOS_ADDR)); } static void @@ -277,9 +266,7 @@ _start(void) make_bios_readonly(); // Disable bootsplash if something has hooked int19. - extern void entry_19_official(void); - if (GET_IVT(0x19).segoff - != SEGOFF(SEG_BIOS, (u32)entry_19_official - BUILD_BIOS_ADDR).segoff) + if (GET_IVT(0x19).segoff != FUNC16(entry_19_official).segoff) disable_bootsplash(); // Invoke int 19 to start boot process. diff --git a/src/ps2port.c b/src/ps2port.c index 5b73d23..ccbd2f6 100644 --- a/src/ps2port.c +++ b/src/ps2port.c @@ -453,8 +453,8 @@ ps2port_setup(void) return; dprintf(3, "init ps2port\n"); - enable_hwirq(1, entry_09); - enable_hwirq(12, entry_74); + enable_hwirq(1, FUNC16(entry_09)); + enable_hwirq(12, FUNC16(entry_74)); run_thread(keyboard_init, NULL); } -- cgit v1.1