summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShao Miller <shao.miller@yrdsb.edu.on.ca>2010-06-22 23:34:41 -0400
committerShao Miller <shao.miller@yrdsb.edu.on.ca>2010-06-22 23:34:41 -0400
commit778fbd110dc4062c2c15055b2a4d335962fa5e21 (patch)
treebfce535a8fde9ca998ebbf3d4799ae905cfed958
parent46f213176b98649ff013aea1db431fe00155f369 (diff)
downloadsyslinux-778fbd110dc4062c2c15055b2a4d335962fa5e21.tar.gz
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 <shao.miller@yrdsb.edu.on.ca>
-rw-r--r--com32/modules/chain.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/com32/modules/chain.c b/com32/modules/chain.c
index 9fbb39e8..f0ddc389 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));