[syslinux:master] chain: Use CHS typedef and macros
syslinux-bot for Shao Miller
shao.miller at yrdsb.edu.on.ca
Fri Jun 25 14:12:19 PDT 2010
Commit-ID: 778fbd110dc4062c2c15055b2a4d335962fa5e21
Gitweb: http://syslinux.zytor.com/commit/778fbd110dc4062c2c15055b2a4d335962fa5e21
Author: Shao Miller <shao.miller at yrdsb.edu.on.ca>
AuthorDate: Tue, 22 Jun 2010 23:34:41 -0400
Committer: Shao Miller <shao.miller at yrdsb.edu.on.ca>
CommitDate: Tue, 22 Jun 2010 23:34:41 -0400
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 at yrdsb.edu.on.ca>
---
com32/modules/chain.c | 19 +++++++++++++------
1 files 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));
More information about the Syslinux-commits
mailing list