VirtualBox

source: vbox/trunk/src/VBox/Devices/PC/BIOS/notes.txt@ 67694

Last change on this file since 67694 was 67694, checked in by vboxsync, 7 years ago

BIOS: INT 13h, INT 15h always returns with interrupts enabled.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.3 KB
Line 
1
2 Notes on BIOS usage
3 -------------------
4
5- DOS (including 6.22/7.1) does not need INT 15h or INT 1Ah. Most other
6 operating systems require INT 15h to detect installed memory.
7
8- OS/2 (WSeB/MCP/ACP) and Windows 98 SE are some of the very few operating
9 systems which use the El Torito floppy emulation.
10
11- NetWare 5.1 is one of the *extremely* few users of El Torito hard disk
12 emulation.
13
14- Keystroke check (INT 16h, fn 01h/10h) always enables interrupts on return.
15 DOS POWER.EXE depends on that in some situations.
16
17- MS-DOS 5.0/V setup assumes that INT 13h always returns with interrupts
18 enabled.
19
20- INT 15h also always returns with interrupts enabled (even for unsupported
21 functions).
22
23- MS-DOS 6.2/V is a rare user of the INT 15h keyboard intercept routines.
24
25- Some software uses the model byte at F000:FFFE to determine the system
26 type (PC-DOS 3.0, Norton Utilities 8). Other software first tries INT 15h,
27 fn C0h instead (PC-DOS 3.1, MSD).
28
29- DOS 4.01 (both IBM and Microsoft) calls INT 13h to read from disk with less
30 than 100 bytes of stack space early in the boot sequence. This tends to be
31 a problem especially for the SATA and SCSI code paths.
32
33- Very few guests use the 32-bit PCI BIOS interface. One is OS/2 (but falls
34 back), another is Etherboot.
35
36- OS/2 is the only known guest which can run the 16-bit PCI BIOS in protected
37 mode (but only if the 32-bit PCI BIOS is unavailable).
38
39- NetWare 6.x is the only known guest which uses the PCI BIOS service to read
40 the IRQ routing table.
41
42- Any disk reads which use bus-master DMA (AHCI, IDE BM) must use VDS
43 (Virtual DMA Services) when present. Otherwise any reads/writes when the
44 real mode addresses don't map directly to physical addresses will fail
45 horribly. DOS 6.x with EMM386 is a good testcase (esp. loading drivers
46 into UMBs).
47
48- Many older OSes (especially UNIX based) require the FDPT to contain
49 physical ATA disk geometry; for that reason, disks smaller than ~500MB are
50 easiest to use. Otherwise a "large" BIOS disk option would be required.
51
52- Some really old OSes (Xenix circa 1986-7) do not understand the EBDA idea
53 and clear the memory. For those, the FDPT must be in the BIOS ROM area, or
54 the OS will destroy it (even when it's at 0:300 in the IVT).
55
56- Windows NT (including XP) uses INT 13h/08h to obtain the DPT for each floppy
57 drive. NT assumes a 13-byte DPT which includes the number of tracks. NT will
58 refuse to read more tracks than the DPT specifies and formats as many tracks
59 as the DPT specifies.
60
61- Windows 98 SE boot CD uses 32-bit registers in real mode and will fail in
62 mysterious ways if BIOS trashes high bits of EAX (and likely others).
63
64- PC DOS 6.x/7.x QCONFIG is a rare user of INT 16h fn 0Ah (read keyboard ID).
65
66- DOS POWER.EXE uses the real mode APM interface, OS/2 APM.SYS uses the 16-bit
67 protected mode APM interface, and Windows 9x uses the 32-bit protected mode
68 APM interface.
69
70- Windows 98 is one of the few APM 1.2 users; Windows 95 uses APM 1.1, while
71 newer systems prefer ACPI.
72
73- QNX4 calls 16-bit protected-mode PCI BIOS in an environment where ESP is
74 16-bit but SS is a 32-bit stack segment. In such environments, using the
75 ENTER/LEAVE sequence is fatal if the high word of EBP is non-zero (which
76 it will be with QNX 4.25). LEAVE propagates the high word of EBP into ESP
77 with fatal consequences.
78
79- Plan 9 also runs 16-bit code with a 32-bit stack segment, except Plan 9
80 thinks it counts as real mode. Same ENTER/LEAVE problem as above.
81
82- AIX 1.3 is a rare user of INT 15h/89h (switch to protected mode) service.
83
84- IBM OS/2 1.0/1.1 (but not other versions!) attempt to execute a 286 LOADALL
85 instruction. LOADALL must be emulated for OS/2 to work properly. HIMEM.SYS
86 version 2.03 and later also contains 286 LOADALL code but this will not be
87 executed on 386+ processors.
88
89- IBM and Microsoft OS/2 1.0 use CMOS shutdown status 9 to get back from
90 protected mode without having called INT 15h/87h at all. That makes the
91 status 9 handling a public interface (just like codes 5 and 0Ah) which
92 has to be compatible with other BIOS implementations.
93
94- Windows NT 3.5 and 3.51 with MPS HAL requires that INT 15h/E820h return the
95 I/O APIC range as reserved, or not return any ranges at all just below 4GB.
96 Otherwise the NT kernel will crash early during init due to confusion about
97 the top of memory.
98
99
100
101 286 BIOS
102 --------
103
104 For testing purposes, it's quite useful to have a BIOS that can run in a
105classic PC/AT environment with a 286 CPU. This forces various changes, not
106always obvious:
107
108 - C code can be easily compiled to produce 286-compatible object code
109
110 - 32-bit BIOS services such as APM or PCI BIOS are irrelevant
111
112 - PCI cannot be supported because it requires 32-bit port I/O
113
114 - AHCI cannot be supported because it requires 32-bit port I/O and PCI
115
116 - Switching to protected mode must be done using LMSW instead of CR0
117
118 - Switching back to real mode must reset the CPU (currently triple fault)
119 and regain control by setting up the CMOS shutdown status byte
120
121
122
123 Notes on BIOS implementation
124 ----------------------------
125
126- To return values from functions not declared as __interrupt, the arguments
127 may need to be declared volatile (not ideal, but does the job).
128
129- The way the POST code selectively clears or doesn't clear memory
130 is extremely suspect and will need reworking.
131
132- Need to review string routines wrt direction flag (should be OK now).
133
134- Need to review CMOS access wrt interrupts (possible index reg change by
135 an interrupt handler).
136
137- The POST code zeroes the entire BDA, and then various bits zero specific
138 parts of the BDA again. That's a waste of time.
139
140- After a reset, all interrupts are unmasked. Not sure if that's OK.
141
142- BCC mishandles the following (where buf is an uint8_t array):
143 lba=buf[0x2B]*0x1000000+buf[0x2A]*0x10000+buf[0x29]*0x100+buf[0x28];
144 The buf[x]*100 expression should end up being of type signed int, which
145 causes the sign to be incorrectly propagated. BCC incorrectly keeps
146 the type unsigned.
147
148- The PCI BIOS services are implemented in C, compiled twice as 16-bit and
149 32-bit code. This reduces the development effort and significantly lowers
150 the risk of discrepancies between 16-bit and 32-bit implementation. Care
151 must be taken because the 16-bit implementation can be executed in both
152 real and protected mode.
153
154- APM can be in theory implemented only once for real, 16-bit protected and
155 32-bit protected mode. Unfortunately this is very inconvenient in C since
156 the default stack size changes between 16-bit and 32-bit callers. Therefore
157 real mode APM (which supports most functions) is implemented in C and
158 protected-mode APM is written in assembler for both 16-bit and 32-bit calls,
159 with a small 32->16 thunk.
160
161- The -of switch can be used to avoid generating ENTER/LEAVE instructions.
162 This appears to be an undocumented and perhaps unintentional side effect.
163
164
165 Code size notes (code as of 7/6/2011):
166
167 The following values are the size of the _TEXT segment, i.e. only C code;
168data defined in C is not included, neither are assembly modules.
169
170 Options: Size (hex):
171 -------- -----------
172 -0 -zu -s -oas -ecc 631A
173 -3 -zu -s -oas -ecc 5C1E
174 -0 -zu -s -oas 578A
175 -3 -zu -s -oas 5452
176
177 Both generating 386 code and using register-based calling convention for
178internal functions brings significant size savings (15% when combined).
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette