reactos/subsystems/ntvdm/bios/bios.h

130 lines
5.2 KiB
C
Raw Normal View History

/*
* COPYRIGHT: GPL - See COPYING in the top level directory
* PROJECT: ReactOS Virtual DOS Machine
* FILE: bios.h
* PURPOSE: VDM BIOS
* PROGRAMMERS: Aleksandar Andrejevic <theflash AT sdf DOT lonestar DOT org>
*/
#ifndef _BIOS_H_
#define _BIOS_H_
/* INCLUDES *******************************************************************/
#include "ntvdm.h"
[NTVDM] - Move all the hardware initialization to EmulatorInitialize (since emulator.c can be viewed as support functions for emulating a PC motherboard) --> PS2 and VGA go there. - Break bios.c into bios.c and kbdbios.c (the keyboard bios module) (according to the IBM documentation as well as other emulator sources or SeaBIOS or...). - Move Exception handling from int32.c to emulator.c, because it's something tight to the emulator, not to the interrupt system by itself (yet it happens that INT 00h to 07h are commonly set to some exception handlers). In the bios.c, initialize those vectors with the default exception handler. - Handling IRQs is done fully in bios.c now: introduce PicSetIRQMask and EnableHwIRQ helper functions (adapted from their equivalents from SeaBIOS) that allows the bios to set (and activate in the PIC) a given IRQ with its corresponding handler. Also introduce PicIRQComplete that serves as a PIC IRQ completer (i.e. sends the EOI to the right PIC(s)). - Continuing on that, at the moment I set dumb default PIC IRQ handlers for IRQ 08h - 0Fh and IRQ 70h - 77h). - By default I disable all the IRQs; there are then set on-demand with EnableHwIRQ. - Rework the POST (aka. BiosInitialize function): * the memory size is now get from the CMOS (as well as the extended memory size via INT 12h, AH=88h), * then we initialize the interrupts, * then platform hardware (ie. the chips) are initialized, * and finally the keyboard and video bioses. - As said before, move memory sizes into the CMOS. - Simplify video bios initialization. svn path=/branches/ntvdm/; revision=61796
2014-01-25 00:21:51 +00:00
#include "kbdbios.h"
#include "vidbios.h"
/* DEFINES ********************************************************************/
#define ROM_AREA_START 0xE0000
#define ROM_AREA_END 0xFFFFF
#define BDA_SEGMENT 0x40
#define BIOS_SEGMENT 0xF000
#define BIOS_PIC_MASTER_INT 0x08
#define BIOS_PIC_SLAVE_INT 0x70
#define BIOS_EQUIPMENT_INTERRUPT 0x11
#define BIOS_MEMORY_SIZE 0x12
#define BIOS_MISC_INTERRUPT 0x15
#define BIOS_TIME_INTERRUPT 0x1A
#define BIOS_SYS_TIMER_INTERRUPT 0x1C
[NTVDM] - Move all the hardware initialization to EmulatorInitialize (since emulator.c can be viewed as support functions for emulating a PC motherboard) --> PS2 and VGA go there. - Break bios.c into bios.c and kbdbios.c (the keyboard bios module) (according to the IBM documentation as well as other emulator sources or SeaBIOS or...). - Move Exception handling from int32.c to emulator.c, because it's something tight to the emulator, not to the interrupt system by itself (yet it happens that INT 00h to 07h are commonly set to some exception handlers). In the bios.c, initialize those vectors with the default exception handler. - Handling IRQs is done fully in bios.c now: introduce PicSetIRQMask and EnableHwIRQ helper functions (adapted from their equivalents from SeaBIOS) that allows the bios to set (and activate in the PIC) a given IRQ with its corresponding handler. Also introduce PicIRQComplete that serves as a PIC IRQ completer (i.e. sends the EOI to the right PIC(s)). - Continuing on that, at the moment I set dumb default PIC IRQ handlers for IRQ 08h - 0Fh and IRQ 70h - 77h). - By default I disable all the IRQs; there are then set on-demand with EnableHwIRQ. - Rework the POST (aka. BiosInitialize function): * the memory size is now get from the CMOS (as well as the extended memory size via INT 12h, AH=88h), * then we initialize the interrupts, * then platform hardware (ie. the chips) are initialized, * and finally the keyboard and video bioses. - As said before, move memory sizes into the CMOS. - Simplify video bios initialization. svn path=/branches/ntvdm/; revision=61796
2014-01-25 00:21:51 +00:00
#define BIOS_EQUIPMENT_LIST 0x2C // HACK: Disable FPU for now
/*
* BIOS Data Area at 0040:XXXX
*
* See: http://webpages.charter.net/danrollins/techhelp/0093.HTM
* and: http://www.bioscentral.com/misc/bda.htm
* for more information.
*/
#pragma pack(push, 1)
typedef struct
{
WORD SerialPorts[4]; // 0x00
WORD ParallelPorts[3]; // 0x08
WORD EbdaSegment; // 0x0e - ParallelPort in PC/XT
WORD EquipmentList; // 0x10
BYTE Reserved0; // 0x12 - Errors in PCjr infrared keyboard link
WORD MemorySize; // 0x13
WORD Reserved1; // 0x15 - Scratch pad for manufacturing error tests
WORD KeybdShiftFlags; // 0x17
BYTE AlternateKeypad; // 0x19
WORD KeybdBufferHead; // 0x1a
WORD KeybdBufferTail; // 0x1c
WORD KeybdBuffer[BIOS_KBD_BUFFER_SIZE]; // 0x1e
BYTE DriveRecalibrate; // 0x3e
BYTE DriveMotorStatus; // 0x3f
BYTE MotorShutdownCounter; // 0x40
BYTE LastDisketteOperation; // 0x41
BYTE Reserved2[7]; // 0x42
BYTE VideoMode; // 0x49
WORD ScreenColumns; // 0x4a
WORD VideoPageSize; // 0x4c
WORD VideoPageOffset; // 0x4e
WORD CursorPosition[BIOS_MAX_PAGES]; // 0x50
BYTE CursorEndLine; // 0x60
BYTE CursorStartLine; // 0x61
BYTE VideoPage; // 0x62
WORD CrtBasePort; // 0x63
BYTE CrtModeControl; // 0x65
BYTE CrtColorPaletteMask; // 0x66
BYTE CassetteData[5]; // 0x67
DWORD TickCounter; // 0x6c
BYTE MidnightPassed; // 0x70
BYTE BreakFlag; // 0x71
WORD SoftReset; // 0x72
BYTE LastDiskOperation; // 0x74
BYTE NumDisks; // 0x75
BYTE DriveControlByte; // 0x76
BYTE DiskPortOffset; // 0x77
BYTE LptTimeOut[4]; // 0x78
BYTE ComTimeOut[4]; // 0x7c
WORD KeybdBufferStart; // 0x80
WORD KeybdBufferEnd; // 0x82
BYTE ScreenRows; // 0x84
WORD CharacterHeight; // 0x85
BYTE EGAFlags[2]; // 0x87
BYTE VGAFlags[2]; // 0x89
DWORD Reserved3; // 0x8b
BYTE Reserved4; // 0x8f
BYTE Reserved5[2]; // 0x90
BYTE Reserved6[2]; // 0x92
BYTE Reserved7[2]; // 0x94
WORD Reserved8; // 0x96
DWORD Reserved9; // 0x98
DWORD Reserved10; // 0x9c
DWORD Reserved11[2]; // 0xa0
DWORD EGAPtr; // 0xa8
BYTE Reserved12[68]; // 0xac
BYTE Reserved13[16]; // 0xf0
DWORD Reserved14; // 0x100
BYTE Reserved15[12]; // 0x104
BYTE Reserved16[17]; // 0x110
BYTE Reserved17[15]; // 0x121
BYTE Reserved18[3]; // 0x130
} BIOS_DATA_AREA, *PBIOS_DATA_AREA;
#pragma pack(pop)
C_ASSERT(sizeof(BIOS_DATA_AREA) == 0x133);
/* FUNCTIONS ******************************************************************/
extern PBIOS_DATA_AREA Bda;
[NTVDM] - Move all the hardware initialization to EmulatorInitialize (since emulator.c can be viewed as support functions for emulating a PC motherboard) --> PS2 and VGA go there. - Break bios.c into bios.c and kbdbios.c (the keyboard bios module) (according to the IBM documentation as well as other emulator sources or SeaBIOS or...). - Move Exception handling from int32.c to emulator.c, because it's something tight to the emulator, not to the interrupt system by itself (yet it happens that INT 00h to 07h are commonly set to some exception handlers). In the bios.c, initialize those vectors with the default exception handler. - Handling IRQs is done fully in bios.c now: introduce PicSetIRQMask and EnableHwIRQ helper functions (adapted from their equivalents from SeaBIOS) that allows the bios to set (and activate in the PIC) a given IRQ with its corresponding handler. Also introduce PicIRQComplete that serves as a PIC IRQ completer (i.e. sends the EOI to the right PIC(s)). - Continuing on that, at the moment I set dumb default PIC IRQ handlers for IRQ 08h - 0Fh and IRQ 70h - 77h). - By default I disable all the IRQs; there are then set on-demand with EnableHwIRQ. - Rework the POST (aka. BiosInitialize function): * the memory size is now get from the CMOS (as well as the extended memory size via INT 12h, AH=88h), * then we initialize the interrupts, * then platform hardware (ie. the chips) are initialized, * and finally the keyboard and video bioses. - As said before, move memory sizes into the CMOS. - Simplify video bios initialization. svn path=/branches/ntvdm/; revision=61796
2014-01-25 00:21:51 +00:00
/**HACK!!**/typedef VOID (WINAPI *EMULATOR_INT32_PROC)(LPWORD Stack);/**HACK!!**/
VOID EnableHwIRQ(UCHAR hwirq, EMULATOR_INT32_PROC func);
VOID PicIRQComplete(LPWORD Stack);
BOOLEAN BiosInitialize(HANDLE ConsoleInput, HANDLE ConsoleOutput);
VOID BiosCleanup(VOID);
#endif // _BIOS_H_
/* EOF */