From: Shao Miller Date: Wed, 23 Jun 2010 03:34:41 +0000 (-0400) Subject: chain: Use CHS typedef and macros X-Git-Tag: syslinux-4.00-pre61~1^2~9 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=778fbd110dc4062c2c15055b2a4d335962fa5e21;p=profile%2Fivi%2Fsyslinux.git chain: Use CHS typedef and macros A DOS partition table entry contains cylinder, head, sector tuples which can be convenient to group together and extract with convenience macros. Currently unused. Signed-off-by: Shao Miller --- diff --git a/com32/modules/chain.c b/com32/modules/chain.c index 9fbb39e..f0ddc38 100644 --- a/com32/modules/chain.c +++ b/com32/modules/chain.c @@ -364,16 +364,23 @@ static int find_disk(uint32_t mbr_sig) return -1; } +/* + * CHS (cylinder, head, sector) value extraction macros. + * Taken from WinVBlock. Does not expand to an lvalue +*/ +#define chs_head(chs) chs[0] +#define chs_sector(chs) (chs[1] & 0x3F) +#define chs_cyl_high(chs) (((uint16_t)(chs[1] & 0xC0)) << 2) +#define chs_cyl_low(chs) ((uint16_t)chs[2]) +#define chs_cylinder(chs) (chs_cyl_high(chs) | chs_cyl_low(chs)) +typedef uint8_t chs[3]; + /* A DOS partition table entry */ struct part_entry { uint8_t active_flag; /* 0x80 if "active" */ - uint8_t start_head; - uint8_t start_sect; - uint8_t start_cyl; + chs start; uint8_t ostype; - uint8_t end_head; - uint8_t end_sect; - uint8_t end_cyl; + chs end; uint32_t start_lba; uint32_t length; } __attribute__ ((packed));