From 778fbd110dc4062c2c15055b2a4d335962fa5e21 Mon Sep 17 00:00:00 2001 From: Shao Miller Date: Tue, 22 Jun 2010 23:34:41 -0400 Subject: [PATCH] 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 --- com32/modules/chain.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) 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)); -- 2.7.4