diff options
author | Michael Brown <mcb30@ipxe.org> | 2020-03-01 11:58:47 +0000 |
---|---|---|
committer | Michael Brown <mcb30@ipxe.org> | 2020-03-01 12:34:45 +0000 |
commit | 49319f1bc9f34b15f061742a8d4f8d3acfdafd42 (patch) | |
tree | 9cf9261296d5e708a2809dc4a0f45d280aba37b2 /src/arch/x86 | |
parent | e3ca2110712f6472465c70f2e83b745ff8a25fcc (diff) | |
download | ipxe-49319f1bc9f34b15f061742a8d4f8d3acfdafd42.zip ipxe-49319f1bc9f34b15f061742a8d4f8d3acfdafd42.tar.gz ipxe-49319f1bc9f34b15f061742a8d4f8d3acfdafd42.tar.bz2 |
[bios] Define macros for constructing partition table entries
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/arch/x86')
-rw-r--r-- | src/arch/x86/prefix/usbdisk.S | 47 |
1 files changed, 37 insertions, 10 deletions
diff --git a/src/arch/x86/prefix/usbdisk.S b/src/arch/x86/prefix/usbdisk.S index 9676406..830f377 100644 --- a/src/arch/x86/prefix/usbdisk.S +++ b/src/arch/x86/prefix/usbdisk.S @@ -9,26 +9,53 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ) #include "mbr.S" /* Partition table: 64 heads, 32 sectors/track (ZIP-drive compatible) */ +#define HEADS 64 +#define SECTORS 32 +#define CYLADDR(cyl) ((((cyl) * HEADS + (((cyl) == 0) & 1)) * SECTORS) * 512) + +#define LOGSTART 0 +#define LOGCOUNT 1 +#define BOOTSTART 1 +#define BOOTCOUNT 2 + + /* Construct a C/H/S address */ + .macro chs cylinder, head, sector + .byte \head + .byte (((\cylinder & 0x300) >> 2) | \sector) + .byte (\cylinder & 0x0ff) + .endm + + /* Construct a linear address */ + .macro linear cylinders, heads, sectors + .long ((((\cylinders * HEADS) + \heads) * SECTORS) + \sectors - 1) + .endm + + /* Construct a partition table entry */ + .macro partition bootflag, type, start, count + .byte \bootflag + chs \start, ((\start == 0) & 1), 1 + .byte \type + chs (\start + \count - 1), (HEADS - 1), SECTORS + linear \start, ((\start == 0) & 1), 1 + linear \count, 0, (1 - (((\start == 0) & 1) * SECTORS)) + .endm + + /* Partition table */ .org 446 .space 16 .space 16 /* Partition 3: log partition (for CONSOLE_INT13) */ - .byte 0x00, 0x01, 0x01, 0x00 - .byte 0xe0, 0x3f, 0x20, 0x00 - .long 0x00000020 - .long 0x000007e0 + partition 0x00, 0xe0, LOGSTART, LOGCOUNT /* Partition 4: boot partition */ - .byte 0x80, 0x00, 0x01, 0x01 - .byte 0xeb, 0x3f, 0x20, 0x02 - .long 0x00000800 - .long 0x00001000 + partition 0x80, 0xeb, BOOTSTART, BOOTCOUNT + /* Disk signature */ .org 510 .byte 0x55, 0xaa /* Skip to start of log partition */ - .org 32 * 512 + .org CYLADDR(LOGSTART) .ascii "iPXE LOG\n\n" /* Skip to start of boot partition */ - .org 2048 * 512 + .org CYLADDR(BOOTSTART) |