You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

hdprefix.S 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
  2. #include <librm.h>
  3. .text
  4. .arch i386
  5. .section ".prefix", "awx", @progbits
  6. .code16
  7. .org 0
  8. .globl _hd_start
  9. _hd_start:
  10. movw $load_image, %bp
  11. jmp find_active_partition
  12. #include "bootpart.S"
  13. load_image:
  14. /* Get disk geometry */
  15. pushal
  16. pushw %es
  17. movb $0x08, %ah
  18. int $0x13
  19. jc load_failed
  20. movb %cl, max_sector
  21. movb %dh, max_head
  22. popw %es
  23. popal
  24. 1: /* Read to end of current track */
  25. movb %cl, %al
  26. negb %al
  27. addb max_sector, %al
  28. incb %al
  29. andb $0x3f, %al
  30. movzbl %al, %eax
  31. call *read_sectors
  32. jc load_failed
  33. /* Update %es */
  34. movw %es, %bx
  35. shll $5, %eax
  36. addw %ax, %bx
  37. movw %bx, %es
  38. shrl $5, %eax
  39. /* Update LBA address */
  40. addl %eax, %edi
  41. adcl $0, %esi
  42. /* Update CHS address */
  43. andb $0xc0, %cl
  44. orb $0x01, %cl
  45. incb %dh
  46. cmpb max_head, %dh
  47. jbe 2f
  48. xorb %dh, %dh
  49. incb %ch
  50. jnc 2f
  51. addb $0xc0, %cl
  52. 2:
  53. /* Loop until whole image is read */
  54. subl %eax, load_length
  55. ja 1b
  56. ljmp $BOOT_SEG, $start_image
  57. max_sector:
  58. .byte 0
  59. max_head:
  60. .byte 0
  61. load_length:
  62. .long 0
  63. .section ".zinfo.fixup", "a", @progbits /* Compressor fixups */
  64. .ascii "ADDL"
  65. .long load_length
  66. .long 512
  67. .long 0
  68. .previous
  69. load_failed:
  70. movw $10f, %si
  71. jmp boot_error
  72. 10: .asciz "Could not load iPXE\r\n"
  73. .org 510
  74. .byte 0x55, 0xaa
  75. start_image:
  76. /* Install iPXE */
  77. call install
  78. /* Set up real-mode stack */
  79. movw %bx, %ss
  80. movw $_estack16, %sp
  81. /* Jump to .text16 segment */
  82. pushw %ax
  83. pushw $1f
  84. lret
  85. .section ".text16", "awx", @progbits
  86. 1:
  87. /* Run iPXE */
  88. virtcall main
  89. /* Uninstall iPXE */
  90. call uninstall
  91. /* Boot next device */
  92. int $0x18