[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 ROM_AREA_START 0xE0000
19 #define ROM_AREA_END 0xFFFFF
20 #define BDA_SEGMENT 0x40
21 #define BIOS_PIC_MASTER_INT 0x08
22 #define BIOS_PIC_SLAVE_INT 0x70
23 #define BIOS_SEGMENT 0xF000
24
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
31 #define CONSOLE_FONT_HEIGHT 8
32 #define BIOS_KBD_BUFFER_SIZE 16
33 #define BIOS_EQUIPMENT_LIST 0x2C // HACK: Disable FPU for now
34 #define BIOS_DEFAULT_VIDEO_MODE 0x03
35 #define BIOS_MAX_PAGES 8
36 #define BIOS_PAGE_SIZE 0x1000
37 #define BIOS_MAX_VIDEO_MODE 0x13
38 #define DEFAULT_ATTRIBUTE 0x07
39 #define GRAPHICS_VIDEO_SEG 0xA000
40 #define TEXT_VIDEO_SEG 0xB800
41
42 enum
43 {
44 SCROLL_DIRECTION_UP,
45 SCROLL_DIRECTION_DOWN,
46 SCROLL_DIRECTION_LEFT,
47 SCROLL_DIRECTION_RIGHT
48 };
49
50 #pragma pack(push, 1)
51
52 typedef struct
53 {
54 WORD SerialPorts[4];
55 WORD ParallelPorts[3];
56 WORD EbdaSegment; // Sometimes, ParallelPort
57 WORD EquipmentList;
58 BYTE Reserved0; // Errors in PCjr infrared keyboard link
59 WORD MemorySize;
60 WORD Reserved1; // Scratch pad for manufacturing error tests
61 WORD KeybdShiftFlags;
62 BYTE AlternateKeypad;
63 WORD KeybdBufferHead;
64 WORD KeybdBufferTail;
65 WORD KeybdBuffer[BIOS_KBD_BUFFER_SIZE];
66 BYTE DriveRecalibrate;
67 BYTE DriveMotorStatus;
68 BYTE MotorShutdownCounter;
69 BYTE LastDisketteOperation;
70 BYTE Reserved2[7];
71 BYTE VideoMode;
72 WORD ScreenColumns;
73 WORD VideoPageSize;
74 WORD VideoPageOffset;
75 WORD CursorPosition[BIOS_MAX_PAGES];
76 BYTE CursorEndLine;
77 BYTE CursorStartLine;
78 BYTE VideoPage;
79 WORD CrtBasePort;
80 BYTE CrtModeControl;
81 BYTE CrtColorPaletteMask;
82 DWORD Uptime;
83 BYTE Reserved3;
84 DWORD TickCounter;
85 BYTE MidnightPassed;
86 BYTE BreakFlag;
87 WORD SoftReset;
88 BYTE LastDiskOperation;
89 BYTE NumDisks;
90 BYTE DriveControlByte;
91 BYTE DiskPortOffset;
92 BYTE LptTimeOut[4];
93 BYTE ComTimeOut[4];
94 WORD KeybdBufferStart;
95 WORD KeybdBufferEnd;
96 BYTE ScreenRows;
97 WORD CharacterHeight;
98 } BIOS_DATA_AREA, *PBIOS_DATA_AREA;
99
100 #pragma pack(pop)
101
102 /* FUNCTIONS ******************************************************************/
103
104 extern PBIOS_DATA_AREA Bda;
105
106 BOOLEAN BiosInitialize(VOID);
107 VOID BiosCleanup(VOID);
108 BYTE BiosGetVideoMode(VOID);
109 BOOLEAN BiosSetVideoMode(BYTE ModeNumber);
110 WORD BiosPeekCharacter(VOID);
111 WORD BiosGetCharacter(VOID);
112 VOID BiosSetCursorPosition(BYTE Row, BYTE Column, BYTE Page);
113 VOID BiosVideoService(LPWORD Stack);
114 VOID BiosEquipmentService(LPWORD Stack);
115 VOID BiosKeyboardService(LPWORD Stack);
116 VOID BiosTimeService(LPWORD Stack);
117 VOID BiosHandleIrq(BYTE IrqNumber, LPWORD Stack);
118 VOID BiosSystemTimerInterrupt(LPWORD Stack);
119 VOID BiosPrintCharacter(CHAR Character, BYTE Attribute, BYTE Page);
120 BOOLEAN BiosScrollWindow(
121 INT Direction,
122 DWORD Amount,
123 SMALL_RECT Rectangle,
124 BYTE Page,
125 BYTE FillAttribute
126 );
127
128 #endif // _BIOS_H_
129
130 /* EOF */