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.5KB

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