Skip to content

Commit 93f224a

Browse files
committed
Allow an arbitrary number of partitions to work with a single disk device
Uses the MetaImgFile approach from joevt/dingusppc@c0773fe and mihaip/dingusppc@51019e4 to use a single disk device to open multiple images (specified via colon separators)
1 parent de5b944 commit 93f224a

8 files changed

Lines changed: 1802 additions & 21 deletions

File tree

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
/*
2+
File: AppleDiskPartitions.h
3+
4+
Contains: The Apple disk partition scheme as defined in Inside Macintosh: Volume V.
5+
6+
Version: Technology: Mac OS 9
7+
Release: Universal Interfaces 3.4.2
8+
9+
Copyright: © 2000-2002 by Apple Computer, Inc., all rights reserved
10+
11+
Bugs?: For bug reports, consult the following page on
12+
the World Wide Web:
13+
14+
http://developer.apple.com/bugreporter/
15+
16+
*/
17+
#ifndef __APPLEDISKPARTITIONS__
18+
#define __APPLEDISKPARTITIONS__
19+
20+
#include "HFSVolumes.h"
21+
#include <cinttypes>
22+
23+
#pragma pack(push, 1)
24+
25+
/* Block 0 Definitions */
26+
enum {
27+
sbSIGWord = 0x4552, /* signature word for Block 0 ('ER') */
28+
sbMac = 1 /* system type for Mac */
29+
};
30+
31+
/* Partition Map Signatures */
32+
enum {
33+
pMapSIG = 0x504D, /* partition map signature ('PM') */
34+
pdSigWord = 0x5453, /* partition map signature ('TS') */
35+
oldPMSigWord = pdSigWord,
36+
newPMSigWord = pMapSIG
37+
};
38+
39+
40+
/* Driver Descriptor Map */
41+
struct Block0 {
42+
uint16_t sbSig; /* 00 unique value for SCSI block 0 */
43+
uint16_t sbBlkSize; /* 02 block size of device */
44+
uint32_t sbBlkCount; /* 04 number of blocks on device */
45+
uint16_t sbDevType; /* 08 device type */
46+
uint16_t sbDevId; /* 0A device id */
47+
uint32_t sbData; /* 0C not used */
48+
uint16_t sbDrvrCount; /* 10 driver descriptor count */
49+
uint32_t ddBlock; /* 12 1st driver's starting block */
50+
uint16_t ddSize; /* 16 size of 1st driver (512-byte blks) */
51+
uint16_t ddType; /* 18 system type (1 for Mac+) */
52+
uint16_t ddPad[243]; /* 1A ARRAY[0..242] OF INTEGER; not used */
53+
};
54+
55+
typedef struct Block0 Block0;
56+
57+
static_assert(sizeof(Block0) == 0x200);
58+
59+
/* Driver descriptor */
60+
struct DDMap {
61+
uint32_t ddBlock; /* 1st driver's starting block */
62+
uint16_t ddSize; /* size of 1st driver (512-byte blks) */
63+
uint16_t ddType; /* system type (1 for Mac+) */
64+
};
65+
typedef struct DDMap DDMap;
66+
/* Constants for the ddType field of the DDMap structure. */
67+
enum {
68+
kDriverTypeMacSCSI = 0x0001,
69+
kDriverTypeMacATA = 0x0701,
70+
kDriverTypeMacSCSIChained = 0xFFFF,
71+
kDriverTypeMacATAChained = 0xF8FF
72+
};
73+
74+
/* Partition Map Entry */
75+
struct Partition {
76+
uint16_t pmSig; /* 0 unique value for map entry blk */
77+
uint16_t pmSigPad; /* 2 currently unused */
78+
uint32_t pmMapBlkCnt; /* 4 # of blks in partition map */
79+
uint32_t pmPyPartStart; /* 8 physical start blk of partition */
80+
uint32_t pmPartBlkCnt; /* C # of blks in this partition */
81+
uint8_t pmPartName[32]; /* 0x10 ASCII partition name */
82+
uint8_t pmParType[32]; /* 0x30 ASCII partition type */
83+
uint32_t pmLgDataStart; /* 0x50 log. # of partition's 1st data blk */
84+
uint32_t pmDataCnt; /* 0x54 # of blks in partition's data area */
85+
uint32_t pmPartStatus; /* 0x58 bit field for partition status */
86+
uint32_t pmLgBootStart; /* 0x5C log. blk of partition's boot code */
87+
uint32_t pmBootSize; /* 0x60 number of bytes in boot code */
88+
uint32_t pmBootAddr; /* 0x64 memory load address of boot code */
89+
uint32_t pmBootAddr2; /* 0x68 currently unused */
90+
uint32_t pmBootEntry; /* 0x6C entry point of boot code */
91+
uint32_t pmBootEntry2; /* 0x70 currently unused */
92+
uint32_t pmBootCksum; /* 0x74 checksum of boot code */
93+
uint8_t pmProcessor[16]; /* 0x78 ASCII for the processor type */
94+
uint16_t pmPad[188]; /* 0x88 ARRAY[0..187] OF INTEGER; not used */
95+
}; /* 0x200 */
96+
typedef struct Partition Partition;
97+
98+
/* Flags for the pmPartStatus field of the Partition data structure. */
99+
enum {
100+
kPartitionAUXIsValid = 0x00000001,
101+
kPartitionAUXIsAllocated = 0x00000002,
102+
kPartitionAUXIsInUse = 0x00000004,
103+
kPartitionAUXIsBootValid = 0x00000008,
104+
kPartitionAUXIsReadable = 0x00000010,
105+
kPartitionAUXIsWriteable = 0x00000020,
106+
kPartitionAUXIsBootCodePositionIndependent = 0x00000040,
107+
kPartitionIsWriteable = 0x00000020,
108+
kPartitionIsMountedAtStartup = 0x40000000,
109+
kPartitionIsStartup = (long)0x80000000,
110+
kPartitionIsChainCompatible = 0x00000100,
111+
kPartitionIsRealDeviceDriver = 0x00000200,
112+
kPartitionCanChainToNext = 0x00000400
113+
};
114+
115+
116+
117+
118+
/* Well known driver signatures, stored in the first four byte of pmPad. */
119+
enum {
120+
kPatchDriverSignature = FOUR_CHAR_CODE('ptDR'), /* SCSI and ATA[PI] patch driver */
121+
kSCSIDriverSignature = 0x00010600, /* SCSI hard disk driver */
122+
kATADriverSignature = FOUR_CHAR_CODE('wiki'), /* ATA hard disk driver */
123+
kSCSICDDriverSignature = FOUR_CHAR_CODE('CDvr'), /* SCSI CD-ROM driver */
124+
kATAPIDriverSignature = FOUR_CHAR_CODE('ATPI'), /* ATAPI CD-ROM driver */
125+
kDriveSetupHFSSignature = FOUR_CHAR_CODE('DSU1') /* Drive Setup HFS partition */
126+
};
127+
128+
#pragma pack(pop)
129+
130+
#endif /* __APPLEDISKPARTITIONS__ */

0 commit comments

Comments
 (0)