Updated PCI IDs to latest snapshot.
[tangerine.git] / arch / ppc-chrp / dos / internalunloadseg.c
blob82aaf0342ce0b24d065a96e535e21f5bfd322ce9
1 /*
2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 $Id: internalunloadseg.c 29642 2008-10-02 00:06:13Z mazze $
5 Desc:
6 Lang: english
7 */
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 /*****************************************************************************
17 NAME */
18 #include <proto/dos.h>
20 AROS_LH2(BOOL, InternalUnLoadSeg,
22 /* SYNOPSIS */
23 AROS_LHA(BPTR , seglist , D1),
24 AROS_LHA(VOID_FUNC, freefunc, A1),
26 /* LOCATION */
27 struct DosLibrary *, DOSBase, 127, Dos)
29 /* FUNCTION
30 Unloads a seglist loaded with InternalLoadSeg().
32 INPUTS
33 seglist - Seglist
34 freefunc - Function to be called to free memory
36 RESULT
37 DOSTRUE if everything wents O.K.
39 NOTES
41 EXAMPLE
43 BUGS
45 SEE ALSO
47 INTERNALS
49 *****************************************************************************/
51 AROS_LIBFUNC_INIT
53 BPTR next;
54 void *KernelBase = OpenResource("kernel.resource");
56 if (seglist)
58 #if AROS_MODULES_DEBUG
59 extern struct MinList debug_seglist;
60 extern struct MinList free_debug_segnodes;
61 struct debug_segnode *segnode;
63 Forbid();
64 ForeachNode(&debug_seglist, segnode)
66 if (segnode->seglist == seglist)
68 /* use the same free function as loadseg ! */
69 struct seginfo *si;
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
79 REMOVE(segnode);
80 ADDHEAD(&free_debug_segnodes, segnode);
81 break;
84 Permit();
85 #endif
87 while (seglist)
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
101 seglist = next;
103 return TRUE;
105 else
106 return FALSE;
108 AROS_LIBFUNC_EXIT
109 } /* InternalUnLoadSeg */