[NTVDM]
[reactos.git] / subsystems / ntvdm / bios.h
1 /*
2 * COPYRIGHT: GPL - See COPYING in the top level directory
3 * PROJECT: ReactOS Virtual DOS Machine
4 * FILE: bios.h
5 * PURPOSE: VDM BIOS (header file)
6 * PROGRAMMERS: Aleksandar Andrejevic <theflash AT sdf DOT lonestar DOT org>
7 */
8
9 #ifndef _BIOS_H_
10 #define _BIOS_H_
11
12 /* INCLUDES *******************************************************************/
13
14 #include "ntvdm.h"
15
16 /* DEFINES ********************************************************************/
17
18 #define CONSOLE_VIDEO_MEM_END 0xBFFFF
19 #define ROM_AREA_START 0xC0000
20 #define ROM_AREA_END 0xFFFFF
21 #define BDA_SEGMENT 0x40
22 #define BIOS_PIC_MASTER_INT 0x08
23 #define BIOS_PIC_SLAVE_INT 0x70
24 #define BIOS_SEGMENT 0xF000
25 #define BIOS_VIDEO_INTERRUPT 0x10
26 #define BIOS_EQUIPMENT_INTERRUPT 0x11
27 #define BIOS_KBD_INTERRUPT 0x16
28 #define BIOS_TIME_INTERRUPT 0x1A
29 #define BIOS_SYS_TIMER_INTERRUPT 0x1C
30 #define CONSOLE_FONT_HEIGHT 8
31 #define BIOS_KBD_BUFFER_SIZE 16
32 #define BIOS_EQUIPMENT_LIST 0x2C // HACK: Disable FPU for now
33 #define BIOS_DEFAULT_VIDEO_MODE 0x03
34 #define BIOS_MAX_PAGES 8
35 #define BIOS_MAX_VIDEO_MODE 0x13
36
37 typedef struct
38 {
39 DWORD Width;
40 DWORD Height;
41 BOOLEAN Text;
42 BYTE Bpp;
43 BOOLEAN Gray;
44 BYTE Pages;
45 WORD Segment;
46 } VIDEO_MODE;
47
48 #pragma pack(push, 1)
49
50 typedef struct
51 {
52 WORD SerialPorts[4];
53 WORD ParallelPorts[3];
54 WORD EbdaSegment;
55 WORD EquipmentList;
56 BYTE Reserved0;
57 WORD MemorySize;
58 WORD Reserved1;
59 WORD KeyboardFlags;
60 BYTE AlternateKeypad;
61 WORD KeybdBufferHead;
62 WORD KeybdBufferTail;
63 WORD KeybdBuffer[BIOS_KBD_BUFFER_SIZE];
64 BYTE DriveRecalibrate;
65 BYTE DriveMotorStatus;
66 BYTE MotorShutdownCounter;
67 BYTE LastDisketteOperation;
68 BYTE Reserved2[7];
69 BYTE VideoMode;
70 WORD ScreenColumns;
71 WORD VideoPageSize;
72 WORD VideoPageOffset;
73 WORD CursorPosition[BIOS_MAX_PAGES];
74 BYTE CursorEndLine;
75 BYTE CursorStartLine;
76 BYTE VideoPage;
77 WORD CrtBasePort;
78 BYTE CrtModeControl;
79 BYTE CrtColorPaletteMask;
80 DWORD Uptime;
81 BYTE Reserved3;
82 DWORD TickCounter;
83 BYTE MidnightPassed;
84 BYTE BreakFlag;
85 WORD SoftReset;
86 BYTE LastDiskOperation;
87 BYTE NumDisks;
88 BYTE DriveControlByte;
89 BYTE DiskPortOffset;
90 BYTE LptTimeOut[4];
91 BYTE ComTimeOut[4];
92 WORD KeybdBufferStart;
93 WORD KeybdBufferEnd;
94 } BIOS_DATA_AREA, *PBIOS_DATA_AREA;
95
96 #pragma pack(pop)
97
98 /* FUNCTIONS ******************************************************************/
99
100 BOOLEAN BiosInitialize();
101 VOID BiosCleanup();
102 VOID BiosUpdateConsole(ULONG StartAddress, ULONG EndAddress);
103 VOID BiosUpdateVideoMemory(ULONG StartAddress, ULONG EndAddress);
104 inline DWORD BiosGetVideoMemoryStart();
105 inline VOID BiosVerticalRefresh();
106 WORD BiosPeekCharacter();
107 WORD BiosGetCharacter();
108 VOID BiosVideoService();
109 VOID BiosEquipmentService();
110 VOID BiosKeyboardService();
111 VOID BiosTimeService();
112 VOID BiosHandleIrq(BYTE IrqNumber);
113 VOID BiosSystemTimerInterrupt();
114
115 #endif