grub2: bring back build of aros-side grub2 tools
[AROS.git] / rom / partition / partition_support.h
blob68775b4c7ab29b7dd81b98bd4e2b2b83e16e1966
1 #ifndef PARTITION_SUPPORT_H
2 #define PARTITION_SUPPORT_H
4 /*
5 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
6 $Id$
8 */
10 #include <libraries/partition.h>
11 #include <utility/tagitem.h>
12 #include <proto/partition.h>
14 #include "partition_intern.h"
16 struct FSFunctionTable;
18 struct FileSysHandle
20 struct Node ln;
21 const struct FSFunctionTable *handler;
22 BOOL boot;
23 /* Handler's private data follows */
26 struct FSFunctionTable
28 BPTR (*loadFileSystem) (struct PartitionBase_intern *, struct FileSysHandle *);
29 LONG (*getFileSystemAttr)(struct Library *, struct FileSysHandle *, const struct TagItem *);
30 void (*freeFileSystem) (struct FileSysHandle *);
33 struct PTFunctionTable
35 ULONG type; /* Partition Table Type */
36 CONST_STRPTR name;
37 LONG (*checkPartitionTable) (struct Library *, struct PartitionHandle *);
38 LONG (*openPartitionTable) (struct Library *, struct PartitionHandle *);
39 void (*closePartitionTable) (struct Library *, struct PartitionHandle *);
40 LONG (*writePartitionTable) (struct Library *, struct PartitionHandle *);
41 LONG (*createPartitionTable) (struct Library *, struct PartitionHandle *);
42 struct PartitionHandle *(*addPartition)(struct Library *, struct PartitionHandle *, struct TagItem *);
43 void (*deletePartition) (struct Library *, struct PartitionHandle *);
44 LONG (*getPartitionTableAttr) (struct Library *, struct PartitionHandle *, struct TagItem *);
45 LONG (*setPartitionTableAttrs) (struct Library *, struct PartitionHandle *, struct TagItem *);
46 LONG (*getPartitionAttr) (struct Library *, struct PartitionHandle *, struct TagItem *);
47 LONG (*setPartitionAttrs) (struct Library *, struct PartitionHandle *, const struct TagItem *);
48 const struct PartitionAttribute *partitionTableAttrs;
49 const struct PartitionAttribute *partitionAttrs;
50 ULONG (*destroyPartitionTable) (struct Library *, struct PartitionHandle *);
51 struct Node *(*findFileSystem) (struct Library *, struct PartitionHandle *, struct TagItem *);
54 struct BootFileSystem
56 struct Node ln;
57 struct FileSysHandle *handle;
60 extern const struct PTFunctionTable * const PartitionSupport[];
62 extern const struct PTFunctionTable PartitionEBR;
63 extern const struct PTFunctionTable PartitionMBR;
64 extern const struct PTFunctionTable PartitionRDB;
65 extern const struct PTFunctionTable PartitionGPT;
66 extern const struct FSFunctionTable FilesystemRDB;
68 LONG PartitionGetGeometry(struct Library *, struct IOExtTD *, struct DriveGeometry *);
69 void PartitionNsdCheck(struct Library *, struct PartitionHandle *);
70 ULONG getStartBlock(struct PartitionHandle *);
71 LONG deviceError(LONG err);
73 void initPartitionHandle(struct PartitionHandle *root, struct PartitionHandle *ph, ULONG first_sector, ULONG count_sector);
74 void setDosType(struct DosEnvec *de, ULONG type);
76 unsigned int Crc32_ComputeBuf(unsigned int inCrc32, const void *buf, unsigned int bufLen);
78 /* read a single block within partition ph */
79 static inline LONG readBlock(struct Library *PartitionBase, struct PartitionHandle *ph, ULONG block, void *mem)
81 return ReadPartitionDataQ(ph, mem, ph->de.de_SizeBlock << 2, block);
84 /* write a single block within partition ph */
85 static inline LONG PartitionWriteBlock(struct Library *PartitionBase, struct PartitionHandle *ph, ULONG block, void *mem)
87 return WritePartitionDataQ(ph, mem, ph->de.de_SizeBlock << 2, block);
90 #define getGeometry PartitionGetGeometry
91 #define writeBlock PartitionWriteBlock
93 #endif /* PARTITION_SUPPORT_H */