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