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

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