2 Copyright © 1995-2002, The AROS Development Team. All rights reserved.
5 Desc: AmigaOS specific partition initialization code.
9 /****************************************************************************************/
11 #include <exec/libraries.h>
12 #include <exec/resident.h>
13 #include <proto/exec.h>
15 #include <libraries/partition.h>
17 #include "partition_support.h"
19 /****************************************************************************************/
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 /****************************************************************************************/
43 /****************************************************************************************/
45 const struct Resident ROMTag
=
48 (struct Resident
*)&ROMTag
,
59 /****************************************************************************************/
61 const char name
[] = NAME_STRING
;
62 const char version
[] = VERSION_STRING
;
64 const APTR inittable
[4] =
66 (APTR
)sizeof(struct PartitionBase
),
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
;
93 SAVEDS ASM BPTR
libExpunge(REGPARAM(a6
, struct PartitionBase
*, PartitionBase
)) {
96 if (PartitionBase
->lh
.lh_LibNode
.lib_OpenCnt
!= 0)
98 PartitionBase
->lh
.lh_LibNode
.lib_Flags
|= LIBF_DELEXP
;
101 Remove(&PartitionBase
->lh
.lh_LibNode
.lib_Node
);
102 retval
= PartitionBase
->lh
.lh_SegList
;
105 (char *)PartitionBase
- PartitionBase
->lh
.lh_LibNode
.lib_NegSize
,
106 PartitionBase
->lh
.lh_LibNode
.lib_NegSize
+ PartitionBase
->lh
.lh_LibNode
.lib_PosSize
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
;
134 SAVEDS ASM
int libNull(REGPARAM(a6
, struct PartitionBase
*, PartitionBase
)) {
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
[]=
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
,
179 const char libend
= 0;