summaryrefslogtreecommitdiff
path: root/com32
diff options
context:
space:
mode:
authorShao Miller <shao.miller@yrdsb.edu.on.ca>2010-06-28 06:16:27 -0400
committerShao Miller <shao.miller@yrdsb.edu.on.ca>2010-07-10 01:03:07 -0400
commita3e5be2ccec7c50e771f4807c8d3156c2c97330c (patch)
treedc96c6da5a07a6b6bae9331385b115e766a5cdff /com32
parent2cb2149a7c579ad8732053bd3391512daf253502 (diff)
downloadsyslinux-a3e5be2ccec7c50e771f4807c8d3156c2c97330c.tar.gz
chain.c32, libcom32: Move struct gpt as disk_gpt_header
Also moved gpt_sig_magic as disk_gpt_sig_magic. Moving portions of chain.c32 into libcom32. Signed-off-by: Shao Miller <shao.miller@yrdsb.edu.on.ca>
Diffstat (limited to 'com32')
-rw-r--r--com32/include/syslinux/disk.h27
-rw-r--r--com32/modules/chain.c41
2 files changed, 35 insertions, 33 deletions
diff --git a/com32/include/syslinux/disk.h b/com32/include/syslinux/disk.h
index 7c4e276f..37641d06 100644
--- a/com32/include/syslinux/disk.h
+++ b/com32/include/syslinux/disk.h
@@ -112,6 +112,33 @@ struct disk_gpt_part_entry {
char name[72];
} __attribute__ ((packed));
+/* A GPT header */
+struct disk_gpt_header {
+ char sig[8];
+ union {
+ struct {
+ uint16_t minor;
+ uint16_t major;
+ } fields __attribute__ ((packed));
+ uint32_t uint32;
+ char raw[4];
+ } rev __attribute__ ((packed));
+ uint32_t hdr_size;
+ uint32_t chksum;
+ char reserved1[4];
+ uint64_t lba_cur;
+ uint64_t lba_alt;
+ uint64_t lba_first_usable;
+ uint64_t lba_last_usable;
+ struct guid disk_guid;
+ uint64_t lba_table;
+ uint32_t part_count;
+ uint32_t part_size;
+ uint32_t table_chksum;
+ char reserved2[1];
+} __attribute__ ((packed));
+static const char disk_gpt_sig_magic[] = "EFI PART";
+
extern int disk_int13_retry(const com32sys_t * inreg, com32sys_t * outreg);
extern int disk_get_params(int disk, struct disk_info *const diskinfo);
extern void *disk_read_sectors(const struct disk_info *const diskinfo,
diff --git a/com32/modules/chain.c b/com32/modules/chain.c
index f69c9bd5..a703ea09 100644
--- a/com32/modules/chain.c
+++ b/com32/modules/chain.c
@@ -348,35 +348,8 @@ err_alloc:
return NULL;
}
-/* A GPT header */
-struct gpt {
- char sig[8];
- union {
- struct {
- uint16_t minor;
- uint16_t major;
- } fields __attribute__ ((packed));
- uint32_t uint32;
- char raw[4];
- } rev __attribute__ ((packed));
- uint32_t hdr_size;
- uint32_t chksum;
- char reserved1[4];
- uint64_t lba_cur;
- uint64_t lba_alt;
- uint64_t lba_first_usable;
- uint64_t lba_last_usable;
- struct guid disk_guid;
- uint64_t lba_table;
- uint32_t part_count;
- uint32_t part_size;
- uint32_t table_chksum;
- char reserved2[1];
-} __attribute__ ((packed));
-static const char gpt_sig_magic[] = "EFI PART";
-
#if DEBUG
-static void gpt_dump(const struct gpt *gpt)
+static void gpt_dump(const struct disk_gpt_header *gpt)
{
char guid_text[37];
@@ -448,7 +421,7 @@ err_last:
static struct disk_part_iter *get_first_partition(struct disk_part_iter *part)
{
- const struct gpt *gpt_candidate;
+ const struct disk_gpt_header *gpt_candidate;
/*
* Ignore any passed partition iterator. The caller should
@@ -476,8 +449,9 @@ static struct disk_part_iter *get_first_partition(struct disk_part_iter *part)
part->private.mbr_index = -1;
part->next = next_mbr_part;
/* Check for a GPT disk */
- gpt_candidate = (const struct gpt *)(part->block + SECTOR);
- if (!memcmp(gpt_candidate->sig, gpt_sig_magic, sizeof(gpt_sig_magic))) {
+ gpt_candidate = (const struct disk_gpt_header *)(part->block + SECTOR);
+ if (!memcmp
+ (gpt_candidate->sig, disk_gpt_sig_magic, sizeof(disk_gpt_sig_magic))) {
/* LBA for partition table */
uint64_t lba_table;
@@ -537,14 +511,15 @@ static int find_by_guid(const struct guid *gpt_guid,
{
int drive;
bool is_me;
- struct gpt *header;
+ struct disk_gpt_header *header;
for (drive = 0x80; drive <= 0xff; drive++) {
if (disk_get_params(drive, &diskinfo))
continue; /* Drive doesn't exist */
if (!(header = disk_read_sectors(&diskinfo, 1, 1)))
continue; /* Cannot read sector */
- if (memcmp(&header->sig, gpt_sig_magic, sizeof(gpt_sig_magic))) {
+ if (memcmp
+ (&header->sig, disk_gpt_sig_magic, sizeof(disk_gpt_sig_magic))) {
/* Not a GPT disk */
free(header);
continue;