2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 $Id: internalunloadseg.c 29642 2008-10-02 00:06:13Z mazze $
8 #include "dos_intern.h"
9 #include <proto/exec.h>
10 #include <proto/kernel.h>
11 #include <aros/libcall.h>
12 #include <aros/asmcall.h>
13 #include <exec/libraries.h>
15 /*****************************************************************************
18 #include <proto/dos.h>
20 AROS_LH2(BOOL
, InternalUnLoadSeg
,
23 AROS_LHA(BPTR
, seglist
, D1
),
24 AROS_LHA(VOID_FUNC
, freefunc
, A1
),
27 struct DosLibrary
*, DOSBase
, 127, Dos
)
30 Unloads a seglist loaded with InternalLoadSeg().
34 freefunc - Function to be called to free memory
37 DOSTRUE if everything wents O.K.
49 *****************************************************************************/
54 void *KernelBase
= OpenResource("kernel.resource");
58 #if AROS_MODULES_DEBUG
59 extern struct MinList debug_seglist
;
60 extern struct MinList free_debug_segnodes
;
61 struct debug_segnode
*segnode
;
64 ForeachNode(&debug_seglist
, segnode
)
66 if (segnode
->seglist
== seglist
)
68 /* use the same free function as loadseg ! */
70 while ((si
= (struct seginfo
*)REMHEAD(&segnode
->seginfos
)))
72 AROS_CALL2NR(void, freefunc
,
73 AROS_LCA(APTR
, (APTR
)si
, A1
),
74 AROS_LCA(ULONG
, (ULONG
)sizeof(struct seginfo
), D0
),
75 struct Library
*, (struct Library
*)SysBase
80 ADDHEAD(&free_debug_segnodes
, segnode
);
89 next
= *(BPTR
*)BADDR(seglist
);
91 char *seg
= (ULONG
)seglist
;
92 seg
+= (*(LONG
*)((LONG
)BADDR(seglist
) - sizeof(ULONG
))) / 2;
93 KrnUnregisterModule(seg
);
95 AROS_CALL2NR(void, freefunc
,
96 AROS_LCA(APTR
, (BPTR
*)((LONG
)BADDR(seglist
) - sizeof(ULONG
)), A1
),
97 AROS_LCA(ULONG
, *(LONG
*)((LONG
)BADDR(seglist
) - sizeof(ULONG
)), D0
),
98 struct Library
*, (struct Library
*)SysBase
109 } /* InternalUnLoadSeg */