1 /*
2  * Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
3  * Copyright (c) 2015, Pluribus Networks, Inc.
4  *
5  * This program and the accompanying materials are licensed and made
6  * available under the terms and conditions of the BSD License which
7  * accompanies this distribution.  The full text of the license may be
8  * found at http://opensource.org/licenses/bsd-license.php
9  *
10  * THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"
11  * BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER
12  * EXPRESS OR IMPLIED.
13  */
14 #ifndef _BIOS_INTERFACE_
15 #define _BIOS_INTERFACE_
16 
17 /*
18   40:00-01 Com1
19   40:02-03 Com2
20   40:04-05 Com3
21   40:06-07 Com4
22   40:08-09 Lpt1
23   40:0A-0B Lpt2
24   40:0C-0D Lpt3
25   40:0E-0E Ebda segment
26   40:10-11 MachineConfig
27   40:12    Bda12 - skip
28   40:13-14 MemSize below 1MB
29   40:15-16 Bda15_16 - skip
30   40:17    Keyboard Status 1
31   40:18    Keyboard Status 2
32   40:19    Bda19 - skip
33   40:1A-1B Key buffer head
34   40:1C-1D Key buffer tail
35   40:1E-3D Key buffer
36   40:3E-3F FloppyData 3E = Calibration status 3F = Motor status
37   40:40    FloppyTimeout
38   40:41-49 Bda41_49 - skip
39   40:4A    Text Columns
40   40:4B-4F Bda4B_4F - skip
41   40:50-5F Cursor postion
42   40:60-6B Bda60_6B - skip
43   40:6C-6F Timer Counter
44   40:70-74 Bda70_74 - skip
45   40:75    Number of HDD drives
46   40:76-77 Bda76_77 - skip
47   40:78-79 78 = Lpt1 timeout, 79 = Lpt2 timeout
48   40:7A-7B 7A = Lpt3 timeout, 7B = Lpt4 timeout
49   40:7C-7D 7C = Com1 timeout, 7D = Com2 timeout
50   40:7E-7F 7E = Com3 timeout, 7F = Com4 timeout
51   40:80-81 Pointer to start of key buffer
52   40:82-83 Pointer to end of key buffer
53   40:84    Number of text rows minus 1
54   40:85-86 Number of scan lines per character
55   40:87    Video mode options
56   40:88    Video features bit and switches
57   40:89    Video display data area
58   40:8A    Video Display Combination Code (DCC)
59   40:8B-8F Bda8B_8F - skip
60   40:90    Floppy data rate
61   40:91-95 Bda91_95 - skip
62   40:96    Keyboard Status 3
63   40:97    Keyboard Status 4
64   40:98-101 skip
65 */
66 #pragma pack(1)
67 typedef struct {
68   UINT16  Com1;
69   UINT16  Com2;
70   UINT16  Com3;
71   UINT16  Com4;
72   UINT16  Lpt1;
73   UINT16  Lpt2;
74   UINT16  Lpt3;
75   UINT16  Ebda;
76   UINT16  MachineConfig;
77   UINT8   Bda12;
78   UINT16  MemSize;
79   UINT8   Bda15_16[0x02];
80   UINT8   KeyboardStatus1;
81   UINT8   KeyboardStatus2;
82   UINT8   Bda19;
83   UINT16  KeyBufferHead;
84   UINT16  KeyBufferTail;
85   UINT16  KeyBuffer[0x10];
86   UINT16  FloppyData;
87   UINT8   FloppyTimeout;
88   UINT8   Bda41_49[0x09];
89   UINT8   TextColumns;
90   UINT8   Bda4B_4F[0x05];
91   UINT16  CursorPosition[0x08];
92   UINT8   Bda60_6B[0xC];
93   UINT32  TimerCounter;
94   UINT8   Bda70_74[0x5];
95   UINT8   NumberOfDrives;
96   UINT8   Bda76_77[0x02];
97   UINT16  Lpt1_2Timeout;
98   UINT16  Lpt3_4Timeout;
99   UINT16  Com1_2Timeout;
100   UINT16  Com3_4Timeout;
101   UINT16  KeyBufferStart;
102   UINT16  KeyBufferEnd;
103   UINT8   TextRowsMinusOne;
104   UINT16  ScanLinesPerChar;
105   UINT8   VideoModeOptions;
106   UINT8   VideoFeatureBitsSwitches;
107   UINT8   VideoDisplayDataArea;
108   UINT8   VideoDCC;
109   UINT8   Bda8B_8F[0x05];
110   UINT8   FloppyXRate;
111   UINT8   Bda91_95[0x05];
112   UINT8   KeyboardStatus3;
113   UINT8   KeyboardStatus4;
114 } BDA;
115 #pragma pack()
116 
117 //
118 // 0040:0017 - KEYBOARD - STATUS FLAGS 1
119 //   7 Insert active
120 //   6 Caps Lock active
121 //   5 Num Lock active
122 //   4 Scroll Lock active
123 //   3 either Alt pressed
124 //   2 either Ctrl pressed
125 //   1 Left Shift pressed
126 //   0 Right Shift pressed
127 #define KBSF1_INSERT_BIT             (0x1 << 7)
128 #define KBSF1_CAPS_LOCK_BIT          (0x1 << 6)
129 #define KBSF1_NUM_LOCK_BIT           (0x1 << 5)
130 #define KBSF1_SCROLL_LOCK_BIT        (0x1 << 4)
131 #define KBSF1_ALT_PRESSED            (0x1 << 3)
132 #define KBSF1_CTRL_PRESSED           (0x1 << 2)
133 #define KBSF1_LEFT_SHIFT_PRESSED     (0x1 << 1)
134 #define KBSF1_RIGHT_SHIFT_PRESSED    (0x1 << 0)
135 
136 // 0040:0018 - KEYBOARD - STATUS FLAGS 2
137 //   7: insert key is depressed
138 //   6: caps-lock key is depressed
139 //   5: num-lock key is depressed
140 //   4: scroll lock key is depressed
141 //   3: suspend key has been toggled
142 //   2: system key is pressed and held
143 //   1: left ALT key is pressed
144 //   0: left CTRL key is pressed
145 #define KBSF2_SUSPEND_PRESSED        (0x1 << 3)
146 #define KBSF2_SYSREQ_PRESSED         (0x1 << 2)
147 #define KBSF2_LEFT_ALT_PRESSED       (0x1 << 1)
148 #define KBSF2_LEFT_CTRL_PRESSED      (0x1 << 0)
149 
150 // 0040:0096 - KEYBOARD - STATUS FLAGS 3
151 //   4: 101/102 enhanced keyboard installed
152 //   1: last scancode was E0
153 //   0: last scancode was E1
154 #define KBSF3_LAST_CODE_WAS_E1       (0x1 << 0)
155 #define KBSF3_LAST_CODE_WAS_E0       (0x1 << 1)
156 #define KBSF3_ENHANCED_KBD           (0x1 << 4)
157 
158 // 0040:0097 - KEYBOARD - STATUS FLAGS 4
159 
160 #endif
161