2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
5 Desc: Build a library or device from a resident structure.
9 #include <aros/asmcall.h>
10 #include "exec_intern.h"
11 #include <exec/devices.h>
13 #include "exec_debug.h"
14 #ifndef DEBUG_InitResident
15 # define DEBUG_InitResident 0
18 #if DEBUG_InitResident
21 #include <aros/debug.h>
24 /*****************************************************************************
27 #include <exec/resident.h>
29 #include <proto/exec.h>
31 AROS_LH2(APTR
, InitResident
,
34 AROS_LHA(struct Resident
*, resident
, A1
),
35 AROS_LHA(BPTR
, segList
, D1
),
38 struct ExecBase
*, SysBase
, 17, Exec
)
41 Test the resident structure and build the library or device
42 with the information given therein. The Init() vector is
43 called and the base address returned.
45 The Init() vector is called with the following registers:
51 resident - Pointer to resident structure.
52 segList - Pointer to loaded module, 0 for resident modules.
55 A pointer returned from the Init() vector. Usually this is the
56 base of the library/device/resource. NULL for failure.
59 AUTOINIT modules are automatically added to the correct exec list.
60 Non AUTOINIT modules have to do all the work themselves.
70 ******************************************************************************/
74 D(bug("InitResident $%lx (\"%s\")\n", resident
, resident
->rt_Name
));
76 /* Check for validity */
77 if(resident
->rt_MatchWord
!= RTC_MATCHWORD
||
78 resident
->rt_MatchTag
!= resident
)
81 /* Depending on the autoinit flag... */
82 if(resident
->rt_Flags
& RTF_AUTOINIT
)
84 /* ...initialize automatically... */
92 struct init
*init
= (struct init
*)resident
->rt_Init
;
93 struct Library
*library
;
96 Make the library. Don't call the Init routine yet, but delay
97 that until we can copy stuff from the tag to the libbase.
99 library
= MakeLibrary(init
->vectors
, init
->structure
,
100 NULL
, init
->dSize
, segList
);
105 Copy over the interesting stuff from the ROMtag, and set the
106 library state to indicate that this lib has changed and
107 should be checksummed at the next opportunity.
109 Don't copy the priority, because a tag's priority doesn't
110 mean the same as a lib's priority.
112 library
->lib_Node
.ln_Type
= resident
->rt_Type
;
113 library
->lib_Node
.ln_Name
= resident
->rt_Name
;
114 if (resident
->rt_Type
!= NT_RESOURCE
)
116 library
->lib_Version
= resident
->rt_Version
;
117 library
->lib_IdString
= resident
->rt_IdString
;
118 library
->lib_Flags
= LIBF_SUMUSED
|LIBF_CHANGED
;
120 if (resident
->rt_Flags
& RTF_EXTENDED
)
122 library
->lib_Revision
= resident
->rt_Revision
;
127 Call the library init vector, if set.
131 library
= AROS_UFC3(struct Library
*, init
->init
,
132 AROS_UFCA(struct Library
*, library
, D0
),
133 AROS_UFCA(BPTR
, segList
, A0
),
134 AROS_UFCA(struct ExecBase
*, SysBase
, A6
)
139 Test the library base, in case the init routine failed in
145 Add the initialized module to the system.
147 switch(resident
->rt_Type
)
150 AddDevice((struct Device
*)library
);
153 case NT_HIDD
: /* XXX Remove when new Hidd system ok. */
157 AddResource(library
);
167 /* ...or let the library do it. */
168 return AROS_UFC3(struct Library
*, resident
->rt_Init
,
169 AROS_UFCA(ULONG
, 0L, D0
),
170 AROS_UFCA(BPTR
, segList
, A0
),
171 AROS_UFCA(struct ExecBase
*, SysBase
, A6
)