Bringing flexcat 2.15 into the main branch (again)
[AROS.git] / arch / ppc-chrp / dos / internalunloadseg.c
blob6c654c37c9acb22826e30a362a68949238f93f89
1 /*
2 Copyright © 1995-2013, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 Lang: english
7 */
8 #include "dos_intern.h"
9 #include <proto/exec.h>
10 #include <aros/libcall.h>
11 #include <aros/asmcall.h>
12 #include <exec/libraries.h>
13 #include <proto/kernel.h>
15 #include <proto/dos.h>
17 /* See rom/dos/internalunloadseg.c for documentation */
19 AROS_LH2(BOOL, InternalUnLoadSeg,
20 AROS_LHA(BPTR , seglist , D1),
21 AROS_LHA(VOID_FUNC, freefunc, A1),
22 struct DosLibrary *, DOSBase, 127, Dos)
24 AROS_LIBFUNC_INIT
26 BPTR next;
28 if (seglist)
30 APTR KernelBase = OpenResource("kernel.resource");
32 while (seglist)
34 next = *(BPTR *)BADDR(seglist);
36 char *seg = (ULONG)seglist;
37 seg += (*(LONG *)((LONG)BADDR(seglist) - sizeof(ULONG))) / 2;
38 if (KernelBase)
39 KrnUnregisterModule(seg);
41 AROS_CALL2NR(void, freefunc,
42 AROS_LCA(APTR , (BPTR *)((LONG)BADDR(seglist) - sizeof(ULONG)), A1),
43 AROS_LCA(ULONG, *(LONG *)((LONG)BADDR(seglist) - sizeof(ULONG)), D0),
44 struct Library *, (struct Library *)SysBase
47 seglist = next;
49 return TRUE;
51 else
52 return FALSE;
54 AROS_LIBFUNC_EXIT
55 } /* InternalUnLoadSeg */