1 |
dpavlin |
1 |
/* |
2 |
|
|
* PearPC |
3 |
|
|
* part.h |
4 |
|
|
* |
5 |
|
|
* Copyright (C) 2003 Sebastian Biallas (sb@biallas.net) |
6 |
|
|
* |
7 |
|
|
* This program is free software; you can redistribute it and/or modify |
8 |
|
|
* it under the terms of the GNU General Public License version 2 as |
9 |
|
|
* published by the Free Software Foundation. |
10 |
|
|
* |
11 |
|
|
* This program is distributed in the hope that it will be useful, |
12 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 |
|
|
* GNU General Public License for more details. |
15 |
|
|
* |
16 |
|
|
* You should have received a copy of the GNU General Public License |
17 |
|
|
* along with this program; if not, write to the Free Software |
18 |
|
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
19 |
|
|
*/ |
20 |
|
|
|
21 |
|
|
#ifndef __PART_H__ |
22 |
|
|
#define __PART_H__ |
23 |
|
|
|
24 |
|
|
#include "tools/data.h" |
25 |
|
|
#include "io/ide/idedevice.h" |
26 |
|
|
#include "system/types.h" |
27 |
|
|
#include "fs.h" |
28 |
|
|
|
29 |
|
|
enum BootMethod { |
30 |
|
|
BM_none, |
31 |
|
|
BM_direct, |
32 |
|
|
BM_chrp |
33 |
|
|
}; |
34 |
|
|
|
35 |
|
|
typedef File *(*InstantiateBootFile)(File *aDevice, void *privData); |
36 |
|
|
typedef FileSystem *(*InstantiateFileSystem)(File *aDevice, int partnum); |
37 |
|
|
|
38 |
|
|
class PartitionEntry: public Object { |
39 |
|
|
public: |
40 |
|
|
int mPartNum; |
41 |
|
|
char *mName; |
42 |
|
|
char *mType; |
43 |
|
|
FileOfs mOffset; |
44 |
|
|
FileOfs mLength; |
45 |
|
|
|
46 |
|
|
BootMethod mBootMethod; |
47 |
|
|
InstantiateBootFile mInstantiateBootFile; |
48 |
|
|
void * mInstantiateBootFilePrivData; |
49 |
|
|
InstantiateFileSystem mInstantiateFileSystem; |
50 |
|
|
// mMethod == BM_direct only |
51 |
|
|
uint64 mBootImageLoadAddr; |
52 |
|
|
uint64 mBootImageEntrypoint; |
53 |
|
|
|
54 |
|
|
PartitionEntry(int partnum, const char *aName, const char *aType, |
55 |
|
|
uint64 aOffset, uint64 aLength); |
56 |
|
|
virtual ~PartitionEntry(); |
57 |
|
|
}; |
58 |
|
|
|
59 |
|
|
class PartitionMap: public Object { |
60 |
|
|
protected: |
61 |
|
|
Array * mEntries; |
62 |
|
|
File * mDevice; |
63 |
|
|
uint mDeviceBlocksize; |
64 |
|
|
public: |
65 |
|
|
PartitionMap(File *aDevice, uint aDeviceBlocksize); |
66 |
|
|
virtual ~PartitionMap(); |
67 |
|
|
|
68 |
|
|
Enumerator *getPartitions(); |
69 |
|
|
virtual void getType(String &result); |
70 |
|
|
protected: |
71 |
|
|
PartitionEntry *addPartition(int partnum, const char *name, const char *type, uint64 offset, uint64 length); |
72 |
|
|
}; |
73 |
|
|
|
74 |
|
|
class PartitionMapFDisk: public PartitionMap { |
75 |
|
|
public: |
76 |
|
|
PartitionMapFDisk(File *aDevice, uint aDeviceBlocksize); |
77 |
|
|
virtual void getType(String &result); |
78 |
|
|
}; |
79 |
|
|
|
80 |
|
|
class PartitionMapFDiskSingle: public PartitionMap { |
81 |
|
|
public: |
82 |
|
|
PartitionMapFDiskSingle(File *aDevice, uint aDeviceBlocksize, const char *type); |
83 |
|
|
virtual void getType(String &result); |
84 |
|
|
}; |
85 |
|
|
|
86 |
|
|
class PartitionMapApple: public PartitionMap { |
87 |
|
|
public: |
88 |
|
|
PartitionMapApple(File *aDevice, uint aDeviceBlocksize); |
89 |
|
|
virtual void getType(String &result); |
90 |
|
|
}; |
91 |
|
|
|
92 |
|
|
class PartitionMapAppleSingle: public PartitionMap { |
93 |
|
|
public: |
94 |
|
|
PartitionMapAppleSingle(File *aDevice, uint aDeviceBlocksize, const char *type); |
95 |
|
|
virtual void getType(String &result); |
96 |
|
|
}; |
97 |
|
|
|
98 |
|
|
PartitionMap *partitions_get_map(File *aDevice, uint aDeviceBlocksize); |
99 |
|
|
|
100 |
|
|
#endif |