diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2009-01-17 18:49:20 -0500 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2009-01-17 18:49:20 -0500 |
commit | 308537650feeabcd953283e828cf7f51495c11c5 (patch) | |
tree | c4cfb8b1e44679ac41abe68e25071a549a41c329 /src/misc.c | |
parent | 095e89bc0b9238ae88383484ca006a3e7af873ad (diff) | |
download | seabios-308537650feeabcd953283e828cf7f51495c11c5.tar.gz |
Move variables from assembler to C code.
Define macro VAR16FIXED for declaring a variable at a fixed location.
Introduce new file src/misc.c, and move non int15 calls from system.c
to it.
Implement all fixed location variables in C code.
Move IDT/GDT defs to misc.c. Remove unused gdt entry 1.
Diffstat (limited to 'src/misc.c')
-rw-r--r-- | src/misc.c | 193 |
1 files changed, 193 insertions, 0 deletions
diff --git a/src/misc.c b/src/misc.c new file mode 100644 index 00000000..0c5f608d --- /dev/null +++ b/src/misc.c @@ -0,0 +1,193 @@ +// Code for misc 16bit handlers and variables. +// +// 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 LGPLv3 license. + +#include "bregs.h" // struct bregs +#include "biosvar.h" // GET_BDA +#include "util.h" // debug_enter +#include "pic.h" // enable_hwirq + +// Amount of continuous ram under 4Gig +u32 RamSize VAR16_32; +// Amount of continuous ram >4Gig +u64 RamSizeOver4G; + + +/**************************************************************** + * Misc 16bit ISRs + ****************************************************************/ + +// INT 12h Memory Size Service Entry Point +void VISIBLE16 +handle_12(struct bregs *regs) +{ + debug_enter(regs, DEBUG_HDL_12); + regs->ax = GET_BDA(mem_size_kb); +} + +// INT 11h Equipment List Service Entry Point +void VISIBLE16 +handle_11(struct bregs *regs) +{ + debug_enter(regs, DEBUG_HDL_11); + regs->ax = GET_BDA(equipment_list_flags); +} + +// INT 05h Print Screen Service Entry Point +void VISIBLE16 +handle_05(struct bregs *regs) +{ + debug_enter(regs, DEBUG_HDL_05); +} + +// INT 10h Video Support Service Entry Point +void VISIBLE16 +handle_10(struct bregs *regs) +{ + debug_enter(regs, DEBUG_HDL_10); + // dont do anything, since the VGA BIOS handles int10h requests +} + +void VISIBLE16 +handle_nmi() +{ + debug_isr(DEBUG_ISR_nmi); + BX_PANIC("NMI Handler called\n"); +} + +void +mathcp_setup() +{ + dprintf(3, "math cp init\n"); + // 80x87 coprocessor installed + SETBITS_BDA(equipment_list_flags, 0x02); + enable_hwirq(13, entry_75); +} + +// INT 75 - IRQ13 - MATH COPROCESSOR EXCEPTION +void VISIBLE16 +handle_75() +{ + debug_isr(DEBUG_ISR_75); + + // clear irq13 + outb(0, PORT_MATH_CLEAR); + // clear interrupt + eoi_pic2(); + // legacy nmi call + u32 eax=0, flags; + call16_simpint(0x02, &eax, &flags); +} + + +/**************************************************************** + * BIOS_CONFIG_TABLE + ****************************************************************/ + +// 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 VAR16FIXED(0xe6f5) = { + .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, +}; + + +/**************************************************************** + * GDT and IDT tables + ****************************************************************/ + +struct descloc_s { + u16 length; + u32 addr; +} PACKED; + +// Real mode IDT descriptor +struct descloc_s rmode_IDT_info VAR16_32 = { + .length = sizeof(struct rmode_IVT) - 1, + .addr = (u32)MAKE_FARPTR(SEG_IVT, 0), +}; + +// Dummy IDT that forces a machine shutdown if an irq happens in +// protected mode. +u8 dummy_IDT VAR16_32; + +// Protected mode IDT descriptor +struct descloc_s pmode_IDT_info VAR16_32 = { + .length = sizeof(dummy_IDT) - 1, + .addr = (u32)MAKE_FARPTR(SEG_BIOS, &dummy_IDT), +}; + +// GDT +u64 rombios32_gdt[] VAR16_32 __aligned(8) = { + // First entry can't be used. + 0x0000000000000000LL, + // 32 bit flat code segment (SEG32_MODE32_CS) + 0x00cf9b000000ffffLL, + // 32 bit flat data segment (SEG32_MODE32_DS) + 0x00cf93000000ffffLL, + // 16 bit code segment base=0xf0000 limit=0xffff (SEG32_MODE16_CS) + 0x00009b0f0000ffffLL, + // 16 bit data segment base=0x0 limit=0xffff (SEG32_MODE16_DS) + 0x000093000000ffffLL, + // 16 bit code segment base=0 limit=0xffffffff (SEG32_MODE16BIG_CS) + 0x008f9b000000ffffLL, + // 16 bit data segment base=0 limit=0xffffffff (SEG32_MODE16BIG_DS) + 0x008f93000000ffffLL, +}; + +// GDT descriptor +struct descloc_s rombios32_gdt_48 VAR16_32 = { + .length = sizeof(rombios32_gdt) - 1, + .addr = (u32)MAKE_FARPTR(SEG_BIOS, rombios32_gdt), +}; + + +/**************************************************************** + * Misc fixed vars + ****************************************************************/ + +char BiosCopyright[] VAR16FIXED(0xff00) = + "(c) 2002 MandrakeSoft S.A. Written by Kevin Lawton & the Bochs team."; + +// BIOS build date +char BiosDate[] VAR16FIXED(0xfff5) = "06/23/99"; + +u8 BiosModelId VAR16FIXED(0xfffe) = CONFIG_MODEL_ID; + +u8 BiosChecksum VAR16FIXED(0xffff); + +// XXX - Initial Interrupt Vector Offsets Loaded by POST +u8 InitVectors[13] VAR16FIXED(0xfef3); + +// XXX - INT 1D - SYSTEM DATA - VIDEO PARAMETER TABLES +u8 VideoParams[88] VAR16FIXED(0xf0a4); |