acc5a175b604dc58cd633ff143ab5101176eea3f
[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_MAX_VIDEO_MODE 0x13
42 #define DEFAULT_ATTRIBUTE 0x07
43
44 #define GRAPHICS_VIDEO_SEG 0xA000
45 #define TEXT_VIDEO_SEG 0xB800
46
47 #define BDA_KBDFLAG_RSHIFT (1 << 0)
48 #define BDA_KBDFLAG_LSHIFT (1 << 1)
49 #define BDA_KBDFLAG_CTRL (1 << 2)
50 #define BDA_KBDFLAG_ALT (1 << 3)
51 #define BDA_KBDFLAG_SCROLL_ON (1 << 4)
52 #define BDA_KBDFLAG_NUMLOCK_ON (1 << 5)
53 #define BDA_KBDFLAG_CAPSLOCK_ON (1 << 6)
54 #define BDA_KBDFLAG_INSERT_ON (1 << 7)
55 #define BDA_KBDFLAG_RALT (1 << 8)
56 #define BDA_KBDFLAG_LALT (1 << 9)
57 #define BDA_KBDFLAG_SYSRQ (1 << 10)
58 #define BDA_KBDFLAG_PAUSE (1 << 11)
59 #define BDA_KBDFLAG_SCROLL (1 << 12)
60 #define BDA_KBDFLAG_NUMLOCK (1 << 13)
61 #define BDA_KBDFLAG_CAPSLOCK (1 << 14)
62 #define BDA_KBDFLAG_INSERT (1 << 15)
63
64 enum
65 {
66 SCROLL_DIRECTION_UP,
67 SCROLL_DIRECTION_DOWN,
68 SCROLL_DIRECTION_LEFT,
69 SCROLL_DIRECTION_RIGHT
70 };
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 #pragma pack(push, 1)
80 typedef struct
81 {
82 WORD SerialPorts[4]; // 0x00
83 WORD ParallelPorts[3]; // 0x08
84 WORD EbdaSegment; // 0x0e - ParallelPort in PC/XT
85 WORD EquipmentList; // 0x10
86 BYTE Reserved0; // 0x12 - Errors in PCjr infrared keyboard link
87 WORD MemorySize; // 0x13
88 WORD Reserved1; // 0x15 - Scratch pad for manufacturing error tests
89 WORD KeybdShiftFlags; // 0x17
90 BYTE AlternateKeypad; // 0x19
91 WORD KeybdBufferHead; // 0x1a
92 WORD KeybdBufferTail; // 0x1c
93 WORD KeybdBuffer[BIOS_KBD_BUFFER_SIZE]; // 0x1e
94 BYTE DriveRecalibrate; // 0x3e
95 BYTE DriveMotorStatus; // 0x3f
96 BYTE MotorShutdownCounter; // 0x40
97 BYTE LastDisketteOperation; // 0x41
98 BYTE Reserved2[7]; // 0x42
99 BYTE VideoMode; // 0x49
100 WORD ScreenColumns; // 0x4a
101 WORD VideoPageSize; // 0x4c
102 WORD VideoPageOffset; // 0x4e
103 WORD CursorPosition[BIOS_MAX_PAGES]; // 0x50
104 BYTE CursorEndLine; // 0x60
105 BYTE CursorStartLine; // 0x61
106 BYTE VideoPage; // 0x62
107 WORD CrtBasePort; // 0x63
108 BYTE CrtModeControl; // 0x65
109 BYTE CrtColorPaletteMask; // 0x66
110 BYTE CassetteData[5]; // 0x67
111 DWORD TickCounter; // 0x6c
112 BYTE MidnightPassed; // 0x70
113 BYTE BreakFlag; // 0x71
114 WORD SoftReset; // 0x72
115 BYTE LastDiskOperation; // 0x74
116 BYTE NumDisks; // 0x75
117 BYTE DriveControlByte; // 0x76
118 BYTE DiskPortOffset; // 0x77
119 BYTE LptTimeOut[4]; // 0x78
120 BYTE ComTimeOut[4]; // 0x7c
121 WORD KeybdBufferStart; // 0x80
122 WORD KeybdBufferEnd; // 0x82
123 BYTE ScreenRows; // 0x84
124 WORD CharacterHeight; // 0x85
125 BYTE EGAFlags[2]; // 0x87
126 BYTE VGAFlags[2]; // 0x89
127 DWORD Reserved3; // 0x8b
128 BYTE Reserved4; // 0x8f
129 BYTE Reserved5[2]; // 0x90
130 BYTE Reserved6[2]; // 0x92
131 BYTE Reserved7[2]; // 0x94
132 WORD Reserved8; // 0x96
133 DWORD Reserved9; // 0x98
134 DWORD Reserved10; // 0x9c
135 DWORD Reserved11[2]; // 0xa0
136 DWORD EGAPtr; // 0xa8
137 BYTE Reserved12[68]; // 0xac
138 BYTE Reserved13[16]; // 0xf0
139
140 DWORD Reserved14; // 0x100
141 BYTE Reserved15[12]; // 0x104
142 BYTE Reserved16[17]; // 0x110
143 BYTE Reserved17[15]; // 0x121
144 BYTE Reserved18[3]; // 0x130
145 } BIOS_DATA_AREA, *PBIOS_DATA_AREA;
146 #pragma pack(pop)
147
148 C_ASSERT(sizeof(BIOS_DATA_AREA) == 0x133);
149
150 /* FUNCTIONS ******************************************************************/
151
152 extern PBIOS_DATA_AREA Bda;
153
154 WORD BiosPeekCharacter(VOID);
155 WORD BiosGetCharacter(VOID);
156 VOID BiosPrintCharacter(CHAR Character, BYTE Attribute, BYTE Page);
157
158 BOOLEAN BiosInitialize(VOID);
159 VOID BiosCleanup(VOID);
160 VOID BiosHandleIrq(BYTE IrqNumber, LPWORD Stack);
161
162 #endif // _BIOS_H_
163
164 /* EOF */