Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

hdprefix.S 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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 (or end of image) */
  25. movb %cl, %al
  26. negb %al
  27. addb max_sector, %al
  28. incb %al
  29. andb $0x3f, %al
  30. movzbl %al, %eax
  31. movl load_length, %ebx
  32. cmpl %eax, %ebx
  33. ja 2f
  34. movl %ebx, %eax
  35. 2: call *read_sectors
  36. jc load_failed
  37. /* Update %es */
  38. movw %es, %bx
  39. shll $5, %eax
  40. addw %ax, %bx
  41. movw %bx, %es
  42. shrl $5, %eax
  43. /* Update LBA address */
  44. addl %eax, %edi
  45. adcl $0, %esi
  46. /* Update CHS address */
  47. andb $0xc0, %cl
  48. orb $0x01, %cl
  49. incb %dh
  50. cmpb max_head, %dh
  51. jbe 3f
  52. xorb %dh, %dh
  53. incb %ch
  54. jnc 3f
  55. addb $0xc0, %cl
  56. 3:
  57. /* Loop until whole image is read */
  58. subl %eax, load_length
  59. ja 1b
  60. ljmp $BOOT_SEG, $start_image
  61. max_sector:
  62. .byte 0
  63. max_head:
  64. .byte 0
  65. load_length:
  66. .long 0
  67. .section ".zinfo.fixup", "a", @progbits /* Compressor fixups */
  68. .ascii "ADDL"
  69. .long load_length
  70. .long 512
  71. .long 0
  72. .previous
  73. load_failed:
  74. movw $10f, %si
  75. jmp boot_error
  76. 10: .asciz "Could not load iPXE\r\n"
  77. .org 510
  78. .byte 0x55, 0xaa
  79. start_image:
  80. /* Install iPXE */
  81. call install
  82. /* Set up real-mode stack */
  83. movw %bx, %ss
  84. movw $_estack16, %sp
  85. /* Jump to .text16 segment */
  86. pushw %ax
  87. pushw $1f
  88. lret
  89. .section ".text16", "awx", @progbits
  90. 1:
  91. /* Run iPXE */
  92. virtcall main
  93. /* Uninstall iPXE */
  94. call uninstall
  95. /* Boot next device */
  96. int $0x18