Less sloppy handling of IoErr().
[AROS.git] / rom / partition / partitionami_init.c
blob96b108e5d49f2b499dd814cb4d60b21b366149bd
1 /*
2 Copyright © 1995-2002, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: AmigaOS specific partition initialization code.
6 Lang: English.
7 */
9 /****************************************************************************************/
11 #include <exec/libraries.h>
12 #include <exec/resident.h>
13 #include <proto/exec.h>
15 #include <libraries/partition.h>
16 #include "platform.h"
17 #include "partition_support.h"
19 /****************************************************************************************/
21 #define VERSION 1
22 #define REVISION 0
24 #define NAME_STRING "partition.library"
25 #define VERSION_STRING "$VER: partition 1.0 (25.08.2002)\r\n"
28 /****************************************************************************************/
30 extern const char name[];
31 extern const char version[];
32 extern const APTR inittable[4];
33 extern void *const functable[];
34 extern struct PartitionBase * SAVEDS ASM libinit();
35 extern const char libend;
37 /****************************************************************************************/
39 int entry(void) {
40 return -1;
43 /****************************************************************************************/
45 const struct Resident ROMTag =
47 RTC_MATCHWORD,
48 (struct Resident *)&ROMTag,
49 (APTR)&libend,
50 RTF_AUTOINIT,
51 VERSION,
52 NT_LIBRARY,
54 (char *)name,
55 (char *)&version[6],
56 (ULONG *)inittable
59 /****************************************************************************************/
61 const char name[] = NAME_STRING;
62 const char version[] = VERSION_STRING;
64 const APTR inittable[4] =
66 (APTR)sizeof(struct PartitionBase),
67 (APTR)functable,
68 NULL,
69 (APTR)&libinit
72 /****************************************************************************************/
74 struct PartitionBase * SAVEDS ASM libinit
76 REGPARAM(d0, struct PartitionBase *, PartitionBase),
77 REGPARAM(a0, BPTR, segList)
81 PartitionBase->lh.lh_SysBase = *(struct ExecBase **)4L;
82 PartitionBase->lh.lh_SegList = segList;
83 PartitionBase->lh.lh_LibNode.lib_Node.ln_Type = NT_LIBRARY;
84 PartitionBase->lh.lh_LibNode.lib_Node.ln_Name = (char *)name;
85 PartitionBase->lh.lh_LibNode.lib_Flags = LIBF_SUMUSED|LIBF_CHANGED;
86 PartitionBase->lh.lh_LibNode.lib_Version = VERSION;
87 PartitionBase->lh.lh_LibNode.lib_Revision = REVISION;
88 PartitionBase->lh.lh_LibNode.lib_IdString = (char *)&version[6];
89 PartitionBase->tables = (struct PartitionTableInfo **)PartitionSupport;
90 return PartitionBase;
93 SAVEDS ASM BPTR libExpunge(REGPARAM(a6, struct PartitionBase *, PartitionBase)) {
94 BPTR retval;
96 if (PartitionBase->lh.lh_LibNode.lib_OpenCnt != 0)
98 PartitionBase->lh.lh_LibNode.lib_Flags |= LIBF_DELEXP;
99 return NULL;
101 Remove(&PartitionBase->lh.lh_LibNode.lib_Node);
102 retval = PartitionBase->lh.lh_SegList;
103 FreeMem
105 (char *)PartitionBase - PartitionBase->lh.lh_LibNode.lib_NegSize,
106 PartitionBase->lh.lh_LibNode.lib_NegSize + PartitionBase->lh.lh_LibNode.lib_PosSize
108 return retval;
111 SAVEDS ASM struct PartitionBase *libOpen
113 REGPARAM(a6, struct PartitionBase *, PartitionBase),
114 REGPARAM(d0, ULONG, version)
117 PartitionBase->lh.lh_LibNode.lib_Flags &= ~LIBF_DELEXP;
118 PartitionBase->lh.lh_LibNode.lib_OpenCnt++;
119 return PartitionBase;
122 SAVEDS ASM BPTR libClose(REGPARAM(a6, struct PartitionBase *, PartitionBase)) {
124 PartitionBase->lh.lh_LibNode.lib_OpenCnt--;
125 if ((PartitionBase->lh.lh_LibNode.lib_Flags & LIBF_DELEXP) != 0)
127 if (PartitionBase->lh.lh_LibNode.lib_OpenCnt == 0)
128 return libExpunge(PartitionBase);
129 PartitionBase->lh.lh_LibNode.lib_Flags &= ~LIBF_DELEXP;
131 return NULL;
134 SAVEDS ASM int libNull(REGPARAM(a6, struct PartitionBase *, PartitionBase)) {
135 return 0;
138 extern void Partition_OpenRootPartition(void);
139 extern void Partition_CloseRootPartition(void);
140 extern void Partition_OpenPartitionTable(void);
141 extern void Partition_ClosePartitionTable(void);
142 extern void Partition_WritePartitionTable(void);
143 extern void Partition_CreatePartitionTable(void);
144 extern void Partition_AddPartition(void);
145 extern void Partition_DeletePartition(void);
146 extern void Partition_GetPartitionTableAttrs(void);
147 extern void Partition_SetPartitionTableAttrs(void);
148 extern void Partition_GetPartitionAttrs(void);
149 extern void Partition_SetPartitionAttrs(void);
150 extern void Partition_QueryPartitionTableAttrs(void);
151 extern void Partition_QueryPartitionAttrs(void);
152 extern void Partition_DestroyPartitionTable(void);
155 void *const functable[]=
157 libOpen,
158 libClose,
159 libExpunge,
160 libNull,
161 Partition_OpenRootPartition, /* 5 */
162 Partition_CloseRootPartition,
163 Partition_OpenPartitionTable,
164 Partition_ClosePartitionTable,
165 Partition_WritePartitionTable,
166 Partition_CreatePartitionTable, /* 10 */
167 Partition_AddPartition,
168 Partition_DeletePartition,
169 Partition_GetPartitionTableAttrs,
170 Partition_SetPartitionTableAttrs,
171 Partition_GetPartitionAttrs, /* 15 */
172 Partition_SetPartitionAttrs,
173 Partition_QueryPartitionTableAttrs,
174 Partition_QueryPartitionAttrs,
175 Partition_DestroyPartitionTable,
176 (void *)-1L
179 const char libend = 0;