about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--baremetal/boot.hex36
-rwxr-xr-xtranslate_subx_baremetal2
-rwxr-xr-xtranslate_subx_baremetal_emulated2
3 files changed, 28 insertions, 12 deletions
diff --git a/baremetal/boot.hex b/baremetal/boot.hex
index 7b29e49f..f9735c9c 100644
--- a/baremetal/boot.hex
+++ b/baremetal/boot.hex
@@ -65,7 +65,7 @@
 #   offset 1800 (address 9400): entrypoint for applications (don't forget to adjust survey_baremetal if this changes)
 
 # Other details of the current memory map:
-#   code: first two default-sized disk tracks get loaded to [0x00007c00, 0x00017800)
+#   code: 4 tracks of disk to [0x00007c00, 0x00027400)
 #   stack grows down from 0x00070000
 #     see below
 #   heap: [0x01000000, 0x02000000)
@@ -107,7 +107,7 @@
   b5 00  # ch <- 0  # cylinder 0
   b6 00  # dh <- 0  # track 0
   b1 02  # cl <- 2  # second sector, 1-based
-  b0 7d  # al <- 125  # number of sectors to read
+  b0 7d  # al <- 125  # number of sectors to read = 2*63 - 1
   # address to write sectors to = es:bx = 0x7e00, contiguous with boot segment
   bb 00 00  # bx <- 0
   8e c3  # es <- bx
@@ -116,6 +116,24 @@
   0f 82 a3 00  # jump-if-carry disk_error [label]
 
 # 2c:
+  # load two more tracks of disk into addresses [0x17800, 0x27400)
+  b4 02  # ah <- 2  # read sectors from disk
+  # dl comes conveniently initialized at boot time with the index of the device being booted
+  b5 00  # ch <- 0  # cylinder 0
+  b6 02  # dh <- 2  # track 0
+  b1 01  # cl <- 1  # first sector, 1-based
+  b0 7e  # al <- 126  # number of sectors to read = 2*63
+  # address to write sectors to = es:bx = 0x17800
+  bb 80 17  # bx <- 0x1780 [label]
+  8e c3  # es <- bx
+  bb 00 00  # bx <- 0
+  cd 13  # int 13h, BIOS disk service
+  0f 82 9b 00  # jump-if-carry disk_error [label]
+  # reset es
+  bb 00 00  # bx <- 0
+  8e c3  # es <- bx
+
+# 39:
   # undo the A20 hack: https://en.wikipedia.org/wiki/A20_line
   # this is from https://github.com/mit-pdos/xv6-public/blob/master/bootasm.S
   # seta20.1:
@@ -126,7 +144,7 @@
   b0 d1  # al <- 0xd1
   e6 64  # port 0x64 <- al
 
-# 36:
+# 43:
   # seta20.2:
   e4 64  # al <- port 0x64
   a8 02  # set zf if bit 1 (second-least significant) is not set
@@ -135,7 +153,7 @@
   b0 df  # al <- 0xdf
   e6 64  # port 0x64 <- al
 
-# 40:
+# 4d:
   # adjust video mode
   b4 4f  # ah <- 4f (VBE)
   b0 02  # al <- 02 (set video mode)
@@ -144,7 +162,7 @@
             # fallback mode: 0x0101 (640x480x256)
   cd 10  # int 10h, Vesa BIOS extensions
 
-# 49:
+# 56:
   # load information for the (hopefully) current video mode
   # mostly just for the address to the linear frame buffer
   b4 4f  # ah <- 4f (VBE)
@@ -153,7 +171,7 @@
   bf 00 81  # di <- 0x8100 (video mode info) [label]
   cd 10
 
-# 55:
+# 62:
   # switch to 32-bit mode
   0f 01 16  # lgdt 00/mod/indirect 010/subop 110/rm/use-disp16
     f8 7c  # *gdt_descriptor [label]
@@ -163,10 +181,8 @@
   ea 00 7d 08 00  # far jump to initialize_32bit_mode after setting cs to the record at offset 8 in the gdt (gdt_code) [label]
 
 # padding
-# 69:
-                           00 00 00 00 00 00 00
-00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
-00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+# 76:
+                  00 00 00 00 00 00 00 00 00 00
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
diff --git a/translate_subx_baremetal b/translate_subx_baremetal
index b8e49042..80f59f2e 100755
--- a/translate_subx_baremetal
+++ b/translate_subx_baremetal
@@ -39,7 +39,7 @@ apps/hex < baremetal/boot.hex  > boot.bin
 cat boot.bin a.bin > disk.bin
 dd if=disk.bin of=disk.img conv=notrunc
 
-if [ `stat --printf="%s" disk.bin` -ge 64512 ]  # 2 tracks * 63 sectors per track * 512 bytes per sector (keep this sync'd with boot.hex)
+if [ `stat --printf="%s" disk.bin` -ge 96768 ]  # 3 tracks * 63 sectors per track * 512 bytes per sector (keep this sync'd with boot.hex)
 then
   echo "disk.bin won't all be loaded on boot"
   exit 1
diff --git a/translate_subx_baremetal_emulated b/translate_subx_baremetal_emulated
index ab18fa19..069983ec 100755
--- a/translate_subx_baremetal_emulated
+++ b/translate_subx_baremetal_emulated
@@ -33,7 +33,7 @@ dd if=/dev/zero of=disk.img count=20160  # 512-byte sectors, so 10MB
 cat boot.bin a.bin > disk.bin
 dd if=disk.bin of=disk.img conv=notrunc
 
-if [ `stat --printf="%s" disk.bin` -ge 64512 ]  # 2 tracks * 63 sectors per track * 512 bytes per sector (keep this sync'd with boot.hex)
+if [ `stat --printf="%s" disk.bin` -ge 96768 ]  # 3 tracks * 63 sectors per track * 512 bytes per sector (keep this sync'd with boot.hex)
 then
   echo "disk.bin won't all be loaded on boot"
   exit 1
span class='oid'>ec73ed12 ^
d1c9392a ^
c56d803c ^
d1c9392a ^

14a38052 ^


d1c9392a ^
e99038ea ^





33352536 ^
86351aaf ^












ec73ed12 ^
86351aaf ^






























ec73ed12 ^
86351aaf ^





























































ec73ed12 ^
86351aaf ^

ec73ed12 ^
86351aaf ^










3d1c4216 ^
86351aaf ^
ec73ed12 ^
86351aaf ^



ec73ed12 ^
86351aaf ^
ec73ed12 ^
86351aaf ^




ec73ed12 ^
86351aaf ^
ec73ed12 ^
86351aaf ^



ec73ed12 ^
3d1c4216 ^
86351aaf ^
ec73ed12 ^
86351aaf ^





3d1c4216 ^
86351aaf ^
ec73ed12 ^
86351aaf ^








3d1c4216 ^
86351aaf ^
ec73ed12 ^
86351aaf ^



ec73ed12 ^
86351aaf ^
ec73ed12 ^
86351aaf ^




ec73ed12 ^
86351aaf ^
ec73ed12 ^
86351aaf ^




ec73ed12 ^
3d1c4216 ^
86351aaf ^
ec73ed12 ^
86351aaf ^





ec73ed12 ^
86351aaf ^
ec73ed12 ^
86351aaf ^



ec73ed12 ^
3d1c4216 ^
86351aaf ^
ec73ed12 ^
86351aaf ^





3d1c4216 ^
86351aaf ^
ec73ed12 ^
86351aaf ^

















d1c9392a ^



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317