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.

usbdisk.S 1.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
  2. #include <config/console.h>
  3. .text
  4. .arch i386
  5. .section ".prefix", "awx", @progbits
  6. .code16
  7. .org 0
  8. #include "mbr.S"
  9. /* Partition table: 64 heads, 32 sectors/track (ZIP-drive compatible) */
  10. #define HEADS 64
  11. #define SECTORS 32
  12. #define CYLADDR(cyl) ((((cyl) * HEADS + (((cyl) == 0) & 1)) * SECTORS) * 512)
  13. #ifdef CONSOLE_INT13
  14. #define LOGPART 1
  15. #define LOGSTART 0
  16. #define LOGCOUNT 1
  17. #define BOOTSTART 1
  18. #define BOOTCOUNT 2
  19. #else /* CONSOLE_INT13 */
  20. #define LOGPART 0
  21. #define BOOTSTART 0
  22. #define BOOTCOUNT 2
  23. #endif /* CONSOLE_INT13 */
  24. /* Construct a C/H/S address */
  25. .macro chs cylinder, head, sector
  26. .byte \head
  27. .byte (((\cylinder & 0x300) >> 2) | \sector)
  28. .byte (\cylinder & 0x0ff)
  29. .endm
  30. /* Construct a linear address */
  31. .macro linear cylinders, heads, sectors
  32. .long ((((\cylinders * HEADS) + \heads) * SECTORS) + \sectors - 1)
  33. .endm
  34. /* Construct a partition table entry */
  35. .macro partition bootflag, type, start, count
  36. .byte \bootflag
  37. chs \start, ((\start == 0) & 1), 1
  38. .byte \type
  39. chs (\start + \count - 1), (HEADS - 1), SECTORS
  40. linear \start, ((\start == 0) & 1), 1
  41. linear \count, 0, (1 - (((\start == 0) & 1) * SECTORS))
  42. .endm
  43. /* Partition table */
  44. .org 446
  45. .space 16
  46. .space 16
  47. /* Partition 3: log partition (for CONSOLE_INT13) */
  48. .if LOGPART
  49. partition 0x00, 0xe0, LOGSTART, LOGCOUNT
  50. .else
  51. .space 16
  52. .endif
  53. /* Partition 4: boot partition */
  54. partition 0x80, 0xeb, BOOTSTART, BOOTCOUNT
  55. /* Disk signature */
  56. .org 510
  57. .byte 0x55, 0xaa
  58. /* Skip to start of log partition */
  59. .if LOGPART
  60. .org CYLADDR(LOGSTART)
  61. .ascii "iPXE LOG\n\n"
  62. .endif
  63. /* Skip to start of boot partition */
  64. .org CYLADDR(BOOTSTART)