12cc3aad0a95606e9f819c693aaf03f4f6ebe04a
[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 ROM_AREA_START 0xE0000
19 #define ROM_AREA_END 0xFFFFF
20 #define BDA_SEGMENT 0x40
21
22 #define BIOS_PIC_MASTER_INT 0x08
23 #define BIOS_PIC_SLAVE_INT 0x70
24
25 #define BIOS_SEGMENT 0xF000
26
27 #define BIOS_VIDEO_INTERRUPT 0x10
28 #define BIOS_EQUIPMENT_INTERRUPT 0x11
29 #define BIOS_MEMORY_SIZE 0x12
30 #define BIOS_KBD_INTERRUPT 0x16
31 #define BIOS_TIME_INTERRUPT 0x1A
32 #define BIOS_SYS_TIMER_INTERRUPT 0x1C
33
34 #define CONSOLE_FONT_HEIGHT 8
35 #define BIOS_KBD_BUFFER_SIZE 16
36 #define BIOS_EQUIPMENT_LIST 0x2C // HACK: Disable FPU for now
37 #define BIOS_DEFAULT_VIDEO_MODE 0x03
38 #define BIOS_MAX_PAGES 8
39 #define BIOS_PAGE_SIZE 0x1000
40 #define BIOS_MAX_VIDEO_MODE 0x13
41 #define DEFAULT_ATTRIBUTE 0x07
42 #define GRAPHICS_VIDEO_SEG 0xA000
43 #define TEXT_VIDEO_SEG 0xB800
44
45 #define BDA_KBDFLAG_RSHIFT (1 << 0)
46 #define BDA_KBDFLAG_LSHIFT (1 << 1)
47 #define BDA_KBDFLAG_CTRL (1 << 2)
48 #define BDA_KBDFLAG_ALT (1 << 3)
49 #define BDA_KBDFLAG_SCROLL_ON (1 << 4)
50 #define BDA_KBDFLAG_NUMLOCK_ON (1 << 5)
51 #define BDA_KBDFLAG_CAPSLOCK_ON (1 << 6)
52 #define BDA_KBDFLAG_INSERT_ON (1 << 7)
53 #define BDA_KBDFLAG_RALT (1 << 8)
54 #define BDA_KBDFLAG_LALT (1 << 9)
55 #define BDA_KBDFLAG_SYSRQ (1 << 10)
56 #define BDA_KBDFLAG_PAUSE (1 << 11)
57 #define BDA_KBDFLAG_SCROLL (1 << 12)
58 #define BDA_KBDFLAG_NUMLOCK (1 << 13)
59 #define BDA_KBDFLAG_CAPSLOCK (1 << 14)
60 #define BDA_KBDFLAG_INSERT (1 << 15)
61
62 enum
63 {
64 SCROLL_DIRECTION_UP,
65 SCROLL_DIRECTION_DOWN,
66 SCROLL_DIRECTION_LEFT,
67 SCROLL_DIRECTION_RIGHT
68 };
69
70 #pragma pack(push, 1)
71
72 /*
73 * BIOS Data Area at 0040:XXXX
74 *
75 * See: http://webpages.charter.net/danrollins/techhelp/0093.HTM
76 * and: http://www.bioscentral.com/misc/bda.htm
77 * for more information.
78 */
79 typedef struct
80 {
81 WORD SerialPorts[4]; // 0x00
82 WORD ParallelPorts[3]; // 0x08
83 WORD EbdaSegment; // 0x0e - ParallelPort in PC/XT
84 WORD EquipmentList; // 0x10
85 BYTE Reserved0; // 0x12 - Errors in PCjr infrared keyboard link
86 WORD MemorySize; // 0x13
87 WORD Reserved1; // 0x15 - Scratch pad for manufacturing error tests
88 WORD KeybdShiftFlags; // 0x17
89 BYTE AlternateKeypad; // 0x19
90 WORD KeybdBufferHead; // 0x1a
91 WORD KeybdBufferTail; // 0x1c
92 WORD KeybdBuffer[BIOS_KBD_BUFFER_SIZE]; // 0x1e
93 BYTE DriveRecalibrate; // 0x3e
94 BYTE DriveMotorStatus; // 0x3f
95 BYTE MotorShutdownCounter; // 0x40
96 BYTE LastDisketteOperation; // 0x41
97 BYTE Reserved2[7]; // 0x42
98 BYTE VideoMode; // 0x49
99 WORD ScreenColumns; // 0x4a
100 WORD VideoPageSize; // 0x4c
101 WORD VideoPageOffset; // 0x4e
102 WORD CursorPosition[BIOS_MAX_PAGES]; // 0x50
103 BYTE CursorEndLine; // 0x60
104 BYTE CursorStartLine; // 0x61
105 BYTE VideoPage; // 0x62
106 WORD CrtBasePort; // 0x63
107 BYTE CrtModeControl; // 0x65
108 BYTE CrtColorPaletteMask; // 0x66
109 BYTE CassetteData[5]; // 0x67
110 DWORD TickCounter; // 0x6c
111 BYTE MidnightPassed; // 0x70
112 BYTE BreakFlag; // 0x71
113 WORD SoftReset; // 0x72
114 BYTE LastDiskOperation; // 0x74
115 BYTE NumDisks; // 0x75
116 BYTE DriveControlByte; // 0x76
117 BYTE DiskPortOffset; // 0x77
118 BYTE LptTimeOut[4]; // 0x78
119 BYTE ComTimeOut[4]; // 0x7c
120 WORD KeybdBufferStart; // 0x80
121 WORD KeybdBufferEnd; // 0x82
122 BYTE ScreenRows; // 0x84
123 WORD CharacterHeight; // 0x85
124 BYTE EGAFlags[2]; // 0x87
125 BYTE VGAFlags[2]; // 0x89
126 DWORD Reserved3; // 0x8b
127 BYTE Reserved4; // 0x8f
128 BYTE Reserved5[2]; // 0x90
129 BYTE Reserved6[2]; // 0x92
130 BYTE Reserved7[2]; // 0x94
131 WORD Reserved8; // 0x96
132 DWORD Reserved9; // 0x98
133 DWORD Reserved10; // 0x9c
134 DWORD Reserved11[2]; // 0xa0
135 DWORD EGAPtr; // 0xa8
136 BYTE Reserved12[68]; // 0xac
137 BYTE Reserved13[16]; // 0xf0
138
139 DWORD Reserved14; // 0x100
140 BYTE Reserved15[12]; // 0x104
141 BYTE Reserved16[17]; // 0x110
142 BYTE Reserved17[15]; // 0x121
143 BYTE Reserved18[3]; // 0x130
144 } BIOS_DATA_AREA, *PBIOS_DATA_AREA;
145
146 C_ASSERT(sizeof(BIOS_DATA_AREA) == 0x133);
147
148 #pragma pack(pop)
149
150 /* FUNCTIONS ******************************************************************/
151
152 extern PBIOS_DATA_AREA Bda;
153
154 BOOLEAN BiosInitialize(VOID);
155 VOID BiosCleanup(VOID);
156 BYTE BiosGetVideoMode(VOID);
157 BOOLEAN BiosSetVideoMode(BYTE ModeNumber);
158 WORD BiosPeekCharacter(VOID);
159 WORD BiosGetCharacter(VOID);
160 VOID BiosSetCursorPosition(BYTE Row, BYTE Column, BYTE Page);
161 VOID BiosVideoService(LPWORD Stack);
162 VOID BiosEquipmentService(LPWORD Stack);
163 VOID BiosGetMemorySize(LPWORD Stack);
164 VOID BiosKeyboardService(LPWORD Stack);
165 VOID BiosTimeService(LPWORD Stack);
166 VOID BiosHandleIrq(BYTE IrqNumber, LPWORD Stack);
167 VOID BiosSystemTimerInterrupt(LPWORD Stack);
168 VOID BiosPrintCharacter(CHAR Character, BYTE Attribute, BYTE Page);
169 BOOLEAN BiosScrollWindow(
170 INT Direction,
171 DWORD Amount,
172 SMALL_RECT Rectangle,
173 BYTE Page,
174 BYTE FillAttribute
175 );
176
177 #endif // _BIOS_H_
178
179 /* EOF */