vesa_stage.S 15 KB

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