summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkrw <krw@openbsd.org>2016-01-25 21:51:23 +0000
committerkrw <krw@openbsd.org>2016-01-25 21:51:23 +0000
commit318599320582bc329a852f1b0947b2a9ccbbb47a (patch)
treec70768ccee86f21c6cb035737cf5d3fdd2e7986b
parentFix a crash as found by sthen@ (diff)
downloadwireguard-openbsd-318599320582bc329a852f1b0947b2a9ccbbb47a.tar.xz
wireguard-openbsd-318599320582bc329a852f1b0947b2a9ccbbb47a.zip
Tweak fields in struct dpme to be more consistent with Apple's info.
Better comments, make all reserved fields uint8_t arrays, don't claim uint32_t fields are actually pointers.
-rw-r--r--sbin/pdisk/convert.c4
-rw-r--r--sbin/pdisk/dpme.h61
-rw-r--r--sbin/pdisk/dump.c32
-rw-r--r--sbin/pdisk/validate.c8
4 files changed, 43 insertions, 62 deletions
diff --git a/sbin/pdisk/convert.c b/sbin/pdisk/convert.c
index 13782840540..ee595cc457b 100644
--- a/sbin/pdisk/convert.c
+++ b/sbin/pdisk/convert.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: convert.c,v 1.23 2016/01/23 23:25:58 krw Exp $ */
+ /* $OpenBSD: convert.c,v 1.24 2016/01/25 21:51:23 krw Exp $ */
/*
* convert.c - Little-endian conversion
@@ -57,9 +57,7 @@ convert_dpme(struct dpme *dpme, int to_cpu_form)
reverse4((uint8_t *)&dpme->dpme_boot_block);
reverse4((uint8_t *)&dpme->dpme_boot_bytes);
reverse4((uint8_t *)&dpme->dpme_load_addr);
- reverse4((uint8_t *)&dpme->dpme_load_addr_2);
reverse4((uint8_t *)&dpme->dpme_goto_addr);
- reverse4((uint8_t *)&dpme->dpme_goto_addr_2);
reverse4((uint8_t *)&dpme->dpme_checksum);
#endif
return 0;
diff --git a/sbin/pdisk/dpme.h b/sbin/pdisk/dpme.h
index e2df488138b..98e77761339 100644
--- a/sbin/pdisk/dpme.h
+++ b/sbin/pdisk/dpme.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: dpme.h,v 1.19 2016/01/24 01:38:32 krw Exp $ */
+/* $OpenBSD: dpme.h,v 1.20 2016/01/25 21:51:23 krw Exp $ */
/*
* dpme.h - Disk Partition Map Entry (dpme)
@@ -47,19 +47,15 @@
#define DPISTRLEN 32
-/*
- * Since block0 is assumed to be the same size as the physical sector size,
- * support is limited to 512-byte sector devices!
- */
struct block0 {
- uint16_t sbSig; /* unique value for SCSI block 0 */
- uint16_t sbBlkSize; /* block size of device */
- uint32_t sbBlkCount; /* number of blocks on device */
- uint16_t sbDevType; /* device type */
- uint16_t sbDevId; /* device id */
- uint32_t sbData; /* not used */
- uint16_t sbDrvrCount; /* driver descriptor count */
- uint16_t sbMap[247]; /* descriptor map */
+ uint16_t sbSig; /* unique value for SCSI block 0 */
+ uint16_t sbBlkSize; /* block size of device */
+ uint32_t sbBlkCount; /* number of blocks on device */
+ uint16_t sbDevType; /* device type */
+ uint16_t sbDevId; /* device id */
+ uint32_t sbData; /* not used */
+ uint16_t sbDrvrCount; /* driver descriptor count */
+ uint16_t sbMap[247]; /* descriptor map */
};
/*
@@ -80,18 +76,16 @@ struct ddmap {
* support is limited to 512-byte sector devices!
*/
struct dpme {
- uint16_t dpme_signature;
- uint16_t dpme_reserved_1;
- uint32_t dpme_map_entries;
- uint32_t dpme_pblock_start;
- uint32_t dpme_pblocks;
- char dpme_name[DPISTRLEN]; /* name of partition */
- char dpme_type[DPISTRLEN]; /* type of partition */
- uint32_t dpme_lblock_start;
- uint32_t dpme_lblocks;
+ uint16_t dpme_signature; /* "PM" */
+ uint8_t dpme_reserved_1[2];
+ uint32_t dpme_map_entries; /* # of partition entries */
+ uint32_t dpme_pblock_start; /* physical block start of partition */
+ uint32_t dpme_pblocks; /* physical block count of partition */
+ char dpme_name[DPISTRLEN]; /* name of partition */
+ char dpme_type[DPISTRLEN]; /* type of partition */
+ uint32_t dpme_lblock_start; /* logical block start of partition */
+ uint32_t dpme_lblocks; /* logical block count of partition */
uint32_t dpme_flags;
-#define DPME_DISKDRIVER (1<<9)
-#define DPME_CHAINABLE (1<<8)
#define DPME_OS_SPECIFIC_1 (1<<8)
#define DPME_OS_SPECIFIC_2 (1<<7)
#define DPME_OS_PIC_CODE (1<<6)
@@ -101,16 +95,15 @@ struct dpme {
#define DPME_IN_USE (1<<2)
#define DPME_ALLOCATED (1<<1)
#define DPME_VALID (1<<0)
- uint32_t dpme_boot_block;
- uint32_t dpme_boot_bytes;
- uint8_t *dpme_load_addr;
- uint8_t *dpme_load_addr_2;
- uint8_t *dpme_goto_addr;
- uint8_t *dpme_goto_addr_2;
- uint32_t dpme_checksum;
- char dpme_process_id[16];
- uint32_t dpme_boot_args[32];
- uint32_t dpme_reserved_3[62];
+ uint32_t dpme_boot_block; /* logical block start of boot code */
+ uint32_t dpme_boot_bytes; /* byte count of boot code */
+ uint16_t dpme_load_addr; /* memory address of boot code */
+ uint8_t dpme_reserved_2[4];
+ uint32_t dpme_goto_addr; /* memory jump address of boot code */
+ uint8_t dpme_reserved_3[4];
+ uint32_t dpme_checksum; /* of the boot code. */
+ char dpme_processor_id[16]; /* processor type */
+ uint8_t dpme_reserved_4[376];
};
#endif /* __dpme__ */
diff --git a/sbin/pdisk/dump.c b/sbin/pdisk/dump.c
index 4762cc0037b..58aa072768a 100644
--- a/sbin/pdisk/dump.c
+++ b/sbin/pdisk/dump.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dump.c,v 1.51 2016/01/25 03:26:54 jsg Exp $ */
+/* $OpenBSD: dump.c,v 1.52 2016/01/25 21:51:23 krw Exp $ */
/*
* dump.c - dumping partition maps
@@ -217,7 +217,7 @@ show_data_structures(struct partition_map_header *map)
printf("%2ld: %20.32s ",
entry->disk_address, p->dpme_type);
printf("%7u @ %-7u ", p->dpme_pblocks, p->dpme_pblock_start);
- printf("%c%c%c%c%c%c%c%c%c%c%c%c ",
+ printf("%c%c%c%c%c%c%c%c%c ",
(p->dpme_flags & DPME_VALID) ? 'V' : '.',
(p->dpme_flags & DPME_ALLOCATED) ? 'A' : '.',
(p->dpme_flags & DPME_IN_USE) ? 'I' : '.',
@@ -226,10 +226,7 @@ show_data_structures(struct partition_map_header *map)
(p->dpme_flags & DPME_WRITABLE) ? 'W' : '.',
(p->dpme_flags & DPME_OS_PIC_CODE) ? 'P' : '.',
(p->dpme_flags & DPME_OS_SPECIFIC_2) ? '2' : '.',
- (p->dpme_flags & DPME_CHAINABLE) ? 'C' : '.',
- (p->dpme_flags & DPME_DISKDRIVER) ? 'D' : '.',
- (p->dpme_flags & (1 << 30)) ? 'M' : '.',
- (p->dpme_flags & (1 << 31)) ? 'X' : '.');
+ (p->dpme_flags & DPME_OS_SPECIFIC_1) ? '1' : '.');
if (p->dpme_lblock_start != 0 || p->dpme_pblocks !=
p->dpme_lblocks) {
printf("(%u @ %u)", p->dpme_lblocks,
@@ -247,11 +244,9 @@ show_data_structures(struct partition_map_header *map)
printf("%7u ", p->dpme_boot_block);
printf("%7u ", p->dpme_boot_bytes);
printf("%8x ", (uint32_t) p->dpme_load_addr);
- printf("%8x ", (uint32_t) p->dpme_load_addr_2);
printf("%8x ", (uint32_t) p->dpme_goto_addr);
- printf("%8x ", (uint32_t) p->dpme_goto_addr_2);
printf("%8x ", p->dpme_checksum);
- printf("%.32s", p->dpme_process_id);
+ printf("%.32s", p->dpme_processor_id);
printf("\n");
}
printf("\n");
@@ -273,7 +268,6 @@ full_dump_partition_entry(struct partition_map_header *map, int ix)
}
p = cur->dpme;
printf(" signature: 0x%x\n", p->dpme_signature);
- printf(" reserved1: 0x%x\n", p->dpme_reserved_1);
printf(" number of map entries: %u\n", p->dpme_map_entries);
printf(" physical start: %10u length: %10u\n",
p->dpme_pblock_start, p->dpme_pblocks);
@@ -310,16 +304,18 @@ full_dump_partition_entry(struct partition_map_header *map, int ix)
printf(" boot start block: %10u\n", p->dpme_boot_block);
printf("boot length (in bytes): %10u\n", p->dpme_boot_bytes);
- printf(" load address: 0x%08x 0x%08x\n",
- (uint32_t) p->dpme_load_addr, (uint32_t) p->dpme_load_addr_2);
- printf(" start address: 0x%08x 0x%08x\n",
- (uint32_t) p->dpme_goto_addr, (uint32_t) p->dpme_goto_addr_2);
+ printf(" load address: 0x%08x\n", p->dpme_load_addr);
+ printf(" start address: 0x%08x\n", p->dpme_goto_addr);
printf(" checksum: 0x%08x\n", p->dpme_checksum);
- printf(" processor: '%.32s'\n", p->dpme_process_id);
- printf("boot args field -");
- dump_block((unsigned char *)p->dpme_boot_args, 32 * 4);
+ printf(" processor: '%.32s'\n", p->dpme_processor_id);
+ printf("dpme_reserved_1 -");
+ dump_block(p->dpme_reserved_1, sizeof(p->dpme_reserved_1));
+ printf("dpme_reserved_2 -");
+ dump_block(p->dpme_reserved_2, sizeof(p->dpme_reserved_2));
printf("dpme_reserved_3 -");
- dump_block((unsigned char *)p->dpme_reserved_3, 62 * 4);
+ dump_block(p->dpme_reserved_3, sizeof(p->dpme_reserved_3));
+ printf("dpme_reserved_4 -");
+ dump_block(p->dpme_reserved_3, sizeof(p->dpme_reserved_4));
}
diff --git a/sbin/pdisk/validate.c b/sbin/pdisk/validate.c
index 3e021058f2b..79d09b906b7 100644
--- a/sbin/pdisk/validate.c
+++ b/sbin/pdisk/validate.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: validate.c,v 1.38 2016/01/25 03:26:54 jsg Exp $ */
+/* $OpenBSD: validate.c,v 1.39 2016/01/25 21:51:23 krw Exp $ */
/*
* validate.c -
@@ -281,12 +281,6 @@ validate_map(struct partition_map_header *map)
printf("\tsignature is 0x%x, should be 0x%x\n",
dpme->dpme_signature, DPME_SIGNATURE);
}
- /* reserved1 == 0 */
- if (dpme->dpme_reserved_1 != 0) {
- printed = 1;
- printf("\treserved word is 0x%x, should be 0\n",
- dpme->dpme_reserved_1);
- }
/* entry count matches */
if (dpme->dpme_map_entries != limit) {
printed = 1;