vesa_stage.S 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673
  1. /*
  2. * VESA real-mode stage: runs at 0x7E00 before protected mode.
  3. *
  4. * Called by the boot sector in real mode (CS=0, IP=0x7E00).
  5. * Probes the E820 map, loads the compressed command-pack rootfs in 16 KB
  6. * chunks through the 0x3000 staging buffer and copies each chunk straight
  7. * above the 8 MB VGA-shadow reserve (PACK_HIGH_ADDR) with a temporary
  8. * flat protected-mode rep movsb. The X201 BIOS silently turns the
  9. * equivalent INT 15h AH=87h block move into zeros for this range, which
  10. * left the kernel with an empty pack. The stage then walks the VBE mode
  11. * list and picks the best mode (highest resolution,
  12. * >= 16 bpp, LFB, fits in VRAM), writes the mode info to 0x600 and the boot
  13. * info to 0x500, then enables A20, enters protected mode and jumps to
  14. * kernel_entry. Because the pack never occupies the low gap behind the
  15. * kernel, the pack size is bounded by RAM, not by 0x60000..0x9FBFF, and the
  16. * kernel BSS/boot stack may extend far past 0x60000.
  17. *
  18. * If no VESA mode works, boots in text mode (valid=0 at 0x600).
  19. */
  20. .code16
  21. .section .text.stage2, "ax", @progbits
  22. .globl _vesa_stage
  23. /* E820 map constants (must match mm.h). */
  24. .equ E820_MAGIC, 0xE820E820
  25. .equ E820_BUF_END, 0x1008 + 32*24 /* 32 entries * 24 bytes */
  26. /* Rootfs/boot-info constants (must match rootfs.h / bootinfo.h). */
  27. .equ ROOTFS_VERSION, 1
  28. .equ PACK_MAX, 0x200000 /* 2 MB compressed rootfs cap */
  29. .equ PACK_HIGH_ADDR, 0x900000 /* above the 8 MB VGA-shadow reserve */
  30. .equ BOOT_INFO_MAGIC, 0x4E425349
  31. .equ BOOT_INFO_VERSION, 2
  32. .equ BOOT_INFO_WORDS, 12
  33. _vesa_stage:
  34. xorw %ax, %ax
  35. movw %ax, %ds
  36. movw %ax, %es
  37. cld
  38. movb %dl, stage_drive
  39. /* Ask the BIOS whether this drive supports EDD LBA reads. USB sticks
  40. * are sometimes presented as floppies (DL=0); the CHS geometry used
  41. * below cannot reach a rootfs image there. */
  42. movb stage_drive, %dl
  43. movb $0x41, %ah
  44. movw $0x55AA, %bx
  45. int $0x13
  46. jc 1f
  47. cmpw $0xAA55, %bx
  48. jne 1f
  49. testb $0x01, %cl
  50. jz 1f
  51. movb $1, use_lba
  52. 1: xorw %ax, %ax
  53. movw %ax, %ds
  54. movw %ax, %es
  55. /* No UEFI boot-info block on the BIOS path (see bootinfo.h). The boot
  56. * sector used 0x500 as its disk-address packet, so clear the magic;
  57. * write_bootinfo fills in the real block before the PM jump. */
  58. movl $0, 0x500
  59. /* ---- Probe INT 15h E820 memory map into 0:0x1000 ----
  60. * Layout (see mm.h): [magic u32][count u32][24-byte entries...].
  61. * Stored below the kernel (0x7E00) so it survives kexec reloads,
  62. * which re-run kernel_main but not this real-mode stage. */
  63. movl $E820_MAGIC, 0x1000 /* magic */
  64. movl $0, 0x1004 /* count = 0 */
  65. xorl %ebx, %ebx /* continuation value */
  66. movl $0x1008, %edi /* ES:DI -> first entry */
  67. e820_loop:
  68. xorw %ax, %ax
  69. movw %ax, %es /* (re)set ES for the BIOS buffer */
  70. movl $0xE820, %eax
  71. movl $0x534D4150, %edx /* "SMAP" */
  72. movl $24, %ecx
  73. int $0x15
  74. jc e820_done /* CF set -> unsupported / done */
  75. cmpl $0x534D4150, %eax
  76. jne e820_done /* not "SMAP" -> done */
  77. cmpb $20, %cl
  78. jb e820_done /* too short -> stop */
  79. movl $0, 20(%edi) /* zero ACPI attrs (BIOS may write 20 B) */
  80. incl 0x1004 /* count++ */
  81. addl $24, %edi
  82. testl %ebx, %ebx
  83. jz e820_done /* continuation == 0 -> done */
  84. cmpl $E820_BUF_END, %edi
  85. jae e820_done /* buffer full -> stop */
  86. jmp e820_loop
  87. e820_done:
  88. /* ---- Rootfs: load the command pack directly to high memory ----
  89. * The pack is a gzip blob behind a one-sector NBROOT1 header (rootfs.h).
  90. * Each 16 KB chunk is read into 0x3000 and copied to PACK_HIGH_ADDR with
  91. * INT 15h AH=87h, so the size is no longer limited by the
  92. * 0x60000..0x9FBFF low gap. A20 must be on before the first high write;
  93. * the old path enabled it only at stage_finish. The kernel sanitizes
  94. * CR4/EFER after this BIOS call (the X201 leaves translation state
  95. * behind). */
  96. call enable_a20
  97. xorw %ax, %ax
  98. movw %ax, %ds
  99. movw %ax, %es
  100. movl 0x7C42, %eax /* boot-sector pack_lba field */
  101. movl %eax, pack_lba
  102. movl $0, pack_addr
  103. movl $0, pack_bytes
  104. movw $msg_pack, %si
  105. call print_str
  106. movzbl stage_drive, %eax
  107. call print_hex32
  108. movw $msg_lba, %si
  109. call print_str
  110. movl pack_lba, %eax
  111. call print_hex32
  112. movw $msg_e, %si
  113. call print_str
  114. movzbl use_lba, %eax
  115. addl $'0', %eax
  116. movb $0x0E, %ah
  117. movb $0x00, %bh
  118. int $0x10
  119. movw $msg_m, %si
  120. call print_str
  121. cmpb $0x80, stage_drive
  122. jb 1f
  123. movb $'L', %al
  124. jmp 2f
  125. 1: movb $'C', %al
  126. 2: movb $0x0E, %ah
  127. movb $0x00, %bh
  128. int $0x10
  129. movw $msg_end, %si
  130. call print_str
  131. xorw %ax, %ax
  132. movw %ax, %ds
  133. movw %ax, %es
  134. /* Read and validate the header, then copy the payload in 16 KB
  135. * chunks (32 sectors) through the 0x3000 staging buffer. */
  136. cmpl $0, pack_lba
  137. je pack_fail
  138. movl pack_lba, %eax
  139. movw $1, %cx
  140. call read_sectors
  141. jc pack_fail
  142. /* Validate the header at 0x3000: "NBROOT1\0", version 1. */
  143. movl $0x3000, %esi
  144. movl 0(%esi), %eax
  145. cmpl $0x4F52424E, %eax /* "NBRO" */
  146. jne pack_fail
  147. movl 4(%esi), %eax
  148. cmpl $0x0031544F, %eax /* "OT1\0" */
  149. jne pack_fail
  150. cmpl $ROOTFS_VERSION, 8(%esi)
  151. jne pack_fail
  152. movl 12(%esi), %eax /* pack_bytes */
  153. testl %eax, %eax
  154. jz pack_fail
  155. cmpl $PACK_MAX, %eax
  156. ja pack_fail
  157. movl %eax, pack_bytes
  158. movw $msg_dot, %si
  159. call print_str
  160. movl $0, pack_off
  161. load_loop:
  162. movl pack_off, %eax
  163. cmpl pack_bytes, %eax
  164. jae load_ok
  165. movl pack_bytes, %ecx
  166. subl %eax, %ecx
  167. addl $511, %ecx
  168. shrl $9, %ecx
  169. cmpl $32, %ecx
  170. jbe 1f
  171. movl $32, %ecx
  172. 1: movl %ecx, chunk_sectors
  173. movl pack_off, %eax
  174. shrl $9, %eax
  175. addl pack_lba, %eax
  176. incl %eax /* pack data starts after the header */
  177. call read_sectors
  178. jc pack_fail
  179. movl chunk_sectors, %eax
  180. shll $9, %eax
  181. movl %eax, copy_len
  182. movl $PACK_HIGH_ADDR, %eax
  183. addl pack_off, %eax
  184. movl %eax, copy_dst
  185. call pm_copy
  186. movl chunk_sectors, %eax
  187. shll $9, %eax
  188. addl %eax, pack_off
  189. movw $msg_dot, %si
  190. call print_str
  191. jmp load_loop
  192. load_ok:
  193. movl $PACK_HIGH_ADDR, pack_addr
  194. movw $msg_ok, %si
  195. call print_str
  196. jmp pack_done
  197. pack_fail:
  198. movw $msg_fail, %si
  199. call print_str
  200. pack_clear:
  201. movl $0, pack_addr
  202. movl $0, pack_bytes
  203. pack_done:
  204. /* read_sectors leaves ES at the staging segment; the VBE calls below
  205. * expect a normal zero segment. */
  206. xorw %ax, %ax
  207. movw %ax, %ds
  208. movw %ax, %es
  209. /* ---- VBE Controller Info into 0:0x2000 ---- */
  210. movw $0x2000, %di
  211. movw $0x4256, (%di) /* "VB" */
  212. movw $0x3245, 2(%di) /* "E2" */
  213. movw $0x4F00, %ax
  214. int $0x10
  215. cmpw $0x004F, %ax
  216. jnz vesa_no_vbe
  217. /* Save VRAM size (offset 0x12: TotalMemory in 64KB blocks). */
  218. movw 0x12(%di), %ax
  219. testw %ax, %ax
  220. jnz 1f
  221. movw $0xFFFF, %ax
  222. 1: movw %ax, vram_64k
  223. /* Get mode list pointer (offset 0x0E: far pointer seg:off). */
  224. movw 0x200E, %si /* offset (buffer at 0x2000) */
  225. movw 0x2010, %ax /* segment */
  226. movw %ax, %fs /* FS:SI = mode list */
  227. /* ---- Walk mode list, pick best mode ---- */
  228. movw $0, best_mode
  229. movl $0, best_score
  230. walk_modes:
  231. movw %fs:(%si), %cx
  232. cmpw $0xFFFF, %cx
  233. jz walk_done
  234. addw $2, %si
  235. /* Query mode info: VBE 4F01h into 0:0x2200. */
  236. pushw %si
  237. pushw %cx
  238. xorw %ax, %ax
  239. movw %ax, %es
  240. movw $0x2200, %di
  241. movw $0x4F01, %ax
  242. int $0x10
  243. popw %cx
  244. popw %si
  245. cmpw $0x004F, %ax
  246. jnz walk_modes
  247. /* Check: supported (bit 0) + graphics (bit 4) + LFB (bit 7). */
  248. movw 0x2200, %ax
  249. andw $0x0091, %ax
  250. cmpw $0x0091, %ax
  251. jnz walk_modes
  252. /* Check: BitsPerPixel >= 16. */
  253. cmpb $16, 0x2219
  254. jb walk_modes
  255. /* TODO: Remove this width cap when display scaling is improved. */
  256. cmpw $1280, 0x2212
  257. ja walk_modes
  258. /* Check: fits in VRAM. */
  259. movw 0x2210, %ax
  260. mulw 0x2214
  261. testw %ax, %ax
  262. jz 2f
  263. incw %dx
  264. 2: cmpw vram_64k, %dx
  265. ja walk_modes
  266. /* Score = width * height + bpp. */
  267. movzwl 0x2212, %eax
  268. movzwl 0x2214, %edx
  269. imull %edx, %eax
  270. movzbl 0x2219, %edx
  271. addl %edx, %eax
  272. cmpl best_score, %eax
  273. jbe walk_modes
  274. movl %eax, best_score
  275. movw %cx, best_mode
  276. /* Save mode info block to 0:0x2400. */
  277. pushw %si
  278. pushw %cx
  279. movw $0x2200, %si
  280. movw $0x2400, %di
  281. movw $128, %cx
  282. cld
  283. rep movsw
  284. popw %cx
  285. popw %si
  286. jmp walk_modes
  287. walk_done:
  288. /* Did we find a mode? */
  289. movw best_mode, %cx
  290. testw %cx, %cx
  291. jz vesa_no_vbe
  292. /* ---- Set the mode ---- */
  293. movw %cx, %bx
  294. orw $0x4000, %bx /* LFB */
  295. movw $0x4F02, %ax
  296. int $0x10
  297. cmpw $0x004F, %ax
  298. jnz vesa_no_vbe
  299. /* ---- Fill 0x600 boot FB info from saved block at 0x2400 ---- */
  300. movw $0x600, %bx
  301. movb $1, (%bx)
  302. movw 0x2412, %ax
  303. movw %ax, 1(%bx) /* width */
  304. movw 0x2414, %ax
  305. movw %ax, 3(%bx) /* height */
  306. movw 0x2410, %ax
  307. movw %ax, 5(%bx) /* pitch */
  308. movb 0x2419, %al
  309. movb %al, 7(%bx) /* bpp */
  310. movw 0x2428, %ax
  311. movw %ax, 8(%bx) /* lfb_base lo */
  312. movw 0x242A, %ax
  313. movw %ax, 10(%bx) /* lfb_base hi */
  314. movw vram_64k, %ax
  315. movw %ax, 12(%bx) /* vram_64k */
  316. jmp stage_finish
  317. vesa_no_vbe:
  318. /* No VESA: stay in text mode, mark fb info invalid. */
  319. movw $0x600, %bx
  320. movb $0, (%bx)
  321. stage_finish:
  322. /* The pack is loaded (A20 is already on); finish boot info and enter
  323. * protected mode. */
  324. call write_bootinfo
  325. jmp enter_pm
  326. /* ---- A20 ---------------------------------------------------------------- */
  327. enable_a20:
  328. movw $0x2401, %ax
  329. int $0x15
  330. call a20_wait
  331. movb $0xD1, %al
  332. outb %al, $0x64
  333. call a20_wait
  334. movb $0xDF, %al
  335. outb %al, $0x60
  336. call a20_wait
  337. inb $0x92, %al
  338. testb $0x02, %al
  339. jnz 1f
  340. orb $0x02, %al
  341. andb $0xFE, %al
  342. outb %al, $0x92
  343. 1: ret
  344. a20_wait:
  345. inb $0x64, %al
  346. testb $0x02, %al
  347. jnz a20_wait
  348. ret
  349. /* ---- Read sectors via INT 13h ------------------------------------------
  350. * in: eax = LBA, cx = sector count
  351. * out: data at 0x3000, CF set on failure
  352. * Clobbers all general registers. */
  353. read_sectors:
  354. /* One INT 13h per run of sectors, not per sector: EDD transfers the
  355. * whole chunk (<= 32 sectors into the 16 KB 0x3000 buffer), CHS
  356. * transfers up to the end of the current track (the buffer never
  357. * crosses a 64 KB ISA DMA boundary). The old per-sector loop made
  358. * ~3600 BIOS calls for a 1.8 MB rootfs. A BIOS that refuses a
  359. * multi-sector request falls back to one sector per call for the
  360. * rest of this read, so the old behaviour is the failure path. */
  361. movl %eax, rd_lba
  362. movw %cx, rd_left
  363. movw $0, rd_off
  364. movw $0, rd_tries
  365. movb $0, rd_single
  366. read_retry:
  367. xorw %ax, %ax
  368. movw %ax, %ds
  369. movw rd_left, %ax
  370. cmpb $0, rd_single
  371. je 1f
  372. movw $1, %ax
  373. 1: movw %ax, rd_count
  374. movw $0x0300, %ax
  375. movw %ax, %es
  376. movb stage_drive, %dl
  377. cmpb $0x80, %dl
  378. jb read_chs
  379. read_lba:
  380. /* EDD LBA read */
  381. movw $0x10, 0x500
  382. movw rd_count, %ax
  383. movw %ax, 0x502
  384. movw rd_off, %bx
  385. movw %bx, 0x504
  386. movw $0x0300, 0x506
  387. movl rd_lba, %eax
  388. movl %eax, 0x508
  389. movl $0, 0x50C
  390. movw $0x500, %si
  391. movb $0x42, %ah
  392. jmp read_int
  393. read_chs:
  394. movw rd_lba, %ax
  395. xorw %dx, %dx
  396. movw $18, %di
  397. divw %di /* ax = track index, dx = sector - 1 */
  398. movw $18, %bx
  399. subw %dx, %bx /* sectors left on this track */
  400. cmpw rd_count, %bx
  401. jae 2f
  402. movw %bx, rd_count
  403. 2: movb %dl, %cl
  404. incb %cl
  405. xorw %dx, %dx
  406. movw $2, %di
  407. divw %di
  408. movb %dl, %dh
  409. movb %al, %ch
  410. movb stage_drive, %dl
  411. movb $0x02, %ah
  412. movb rd_count, %al
  413. movw rd_off, %bx
  414. read_int:
  415. int $0x13
  416. jnc read_ok
  417. /* Reset the drive. A refused multi-sector request switches to the
  418. * single-sector path; a single sector gets a few retries. */
  419. pushw %cx
  420. movb stage_drive, %dl
  421. xorw %ax, %ax
  422. int $0x13
  423. popw %cx
  424. cmpw $1, rd_count
  425. je 3f
  426. movb $1, rd_single
  427. jmp read_retry
  428. 3: incw rd_tries
  429. cmpw $3, rd_tries
  430. jb read_retry
  431. stc
  432. ret
  433. read_ok:
  434. movzwl rd_count, %eax
  435. addl %eax, rd_lba
  436. shlw $9, %ax
  437. addw %ax, rd_off
  438. movw rd_count, %ax
  439. subw %ax, rd_left
  440. jnz read_retry
  441. clc
  442. ret
  443. /* ---- Print a NUL-terminated string with the BIOS teletype ------------- */
  444. print_str:
  445. pushw %ax
  446. pushw %bx
  447. movb $0x0E, %ah
  448. xorw %bx, %bx
  449. 1: lodsb
  450. testb %al, %al
  451. jz 2f
  452. int $0x10
  453. jmp 1b
  454. 2: popw %bx
  455. popw %ax
  456. ret
  457. /* ---- Flat protected-mode copy -----------------------------------------
  458. * The X201 BIOS silently turns INT 15h AH=87h into zeros for this range.
  459. * Enter temporary protected mode, copy with a flat rep movsb, then return
  460. * to real mode. SS/ESP are left untouched; only DS/ES are widened. */
  461. pm_copy:
  462. cli
  463. lgdt stage2_gdtr
  464. movl %cr0, %eax
  465. orl $1, %eax
  466. movl %eax, %cr0
  467. .byte 0x66, 0xea
  468. .long pm_copy32
  469. .word 0x08
  470. .code32
  471. pm_copy32:
  472. movw $0x10, %ax
  473. movw %ax, %ds
  474. movw %ax, %es
  475. cld
  476. movl $0x3000, %esi
  477. movl copy_dst, %edi
  478. movl copy_len, %ecx
  479. rep movsb
  480. /* Leave through a 16-bit protected-mode code segment before
  481. * clearing PE, then return to real mode. */
  482. .byte 0xea
  483. .long pm_copy16pm
  484. .word 0x18
  485. .code16
  486. pm_copy16pm:
  487. movl %cr0, %eax
  488. andl $0xfffffffe, %eax
  489. movl %eax, %cr0
  490. .byte 0xea
  491. .word pm_copy16
  492. .word 0x0000
  493. pm_copy16:
  494. xorw %ax, %ax
  495. movw %ax, %ds
  496. movw %ax, %es
  497. movw %ax, %fs
  498. movw %ax, %gs
  499. ret
  500. /* ---- Hex print (EAX, 8 digits) ----------------------------------------- */
  501. print_hex32:
  502. movl $8, %ecx
  503. jmp print_hex
  504. print_hex:
  505. pushal
  506. movl %eax, %ebx
  507. 1: roll $4, %ebx
  508. movl %ebx, %eax
  509. andl $0x0F, %eax
  510. cmpl $10, %eax
  511. jb 2f
  512. addl $55, %eax
  513. jmp 3f
  514. 2: addl $48, %eax
  515. 3: pushl %ebx
  516. pushl %ecx
  517. movb $0x0E, %ah
  518. xorw %bx, %bx
  519. int $0x10
  520. popl %ecx
  521. popl %ebx
  522. loop 1b
  523. popal
  524. ret
  525. /* ---- Boot-info block at 0x500 (bootinfo.h) ----------------------------
  526. * twelve dwords: magic, version, checksum, rsdp, flags, pack_addr,
  527. * pack_size, reserved[5]; the checksum makes the sum zero. */
  528. write_bootinfo:
  529. xorw %ax, %ax
  530. movw %ax, %ds
  531. movl $BOOT_INFO_MAGIC, 0x500
  532. movl $BOOT_INFO_VERSION, 0x504
  533. movl $0, 0x508
  534. movl $0, 0x50C
  535. movl $0, 0x510
  536. movl pack_addr, %eax
  537. movl %eax, 0x514
  538. movl pack_bytes, %eax
  539. movl %eax, 0x518
  540. movl $0, 0x51C
  541. movl $0, 0x520
  542. movl $0, 0x524
  543. movl $0, 0x528
  544. movl $0, 0x52C
  545. xorl %eax, %eax
  546. movl $0x500, %esi
  547. movl $BOOT_INFO_WORDS, %ecx
  548. 1: addl (%esi), %eax
  549. addl $4, %esi
  550. loop 1b
  551. negl %eax
  552. movl %eax, 0x508
  553. ret
  554. /* ---- Protected-mode entry ---------------------------------------------- */
  555. enter_pm:
  556. cli
  557. lgdt stage2_gdtr
  558. movl %cr0, %eax
  559. orl $1, %eax
  560. movl %eax, %cr0
  561. .byte 0x66, 0xea
  562. .long stage2_pm
  563. .word 0x08
  564. .code32
  565. stage2_pm:
  566. movw $0x10, %ax
  567. movw %ax, %ds
  568. movw %ax, %es
  569. movw %ax, %fs
  570. movw %ax, %gs
  571. movw %ax, %ss
  572. movl $__boot_stack_top, %esp
  573. jmp kernel_entry
  574. .align 4
  575. stage2_gdt:
  576. .quad 0
  577. .word 0xffff, 0x0000
  578. .byte 0x00, 0x9a, 0xcf, 0x00
  579. .word 0xffff, 0x0000
  580. .byte 0x00, 0x92, 0xcf, 0x00
  581. /* 16-bit code: base 0, 4 GB limit, D=0 */
  582. .word 0xffff, 0x0000
  583. .byte 0x00, 0x9a, 0x8f, 0x00
  584. stage2_gdt_end:
  585. stage2_gdtr:
  586. .word stage2_gdt_end - stage2_gdt - 1
  587. .long stage2_gdt
  588. /* ---- Stage variables --------------------------------------------------- */
  589. .align 4
  590. stage_drive: .byte 0
  591. use_lba: .byte 0
  592. pack_lba: .long 0
  593. pack_bytes: .long 0
  594. pack_addr: .long 0
  595. pack_off: .long 0
  596. chunk_sectors: .long 0
  597. copy_dst: .long 0
  598. copy_len: .long 0
  599. rd_lba: .long 0
  600. rd_off: .word 0
  601. rd_left: .word 0
  602. rd_count: .word 0
  603. rd_single: .byte 0
  604. rd_tries: .word 0
  605. msg_pack: .asciz "Loading rootfs [d="
  606. msg_lba: .asciz " lba="
  607. msg_e: .asciz " e="
  608. msg_m: .asciz " m="
  609. msg_end: .asciz "]... "
  610. msg_dot: .asciz "."
  611. msg_ok: .asciz " ok\r\n"
  612. msg_fail: .asciz " failed\r\n"
  613. .align 2
  614. vram_64k:
  615. .word 0
  616. best_mode:
  617. .word 0
  618. best_score:
  619. .long 0