Belarusian
[AROS.git] / rom / exec / initcode.c
blob1b9fecbcf9e476d6f738a67f3e24ae1d3e471d81
1 /*
2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Initialize resident modules
6 Lang: english
7 */
8 #include "exec_intern.h"
9 #include <exec/resident.h>
10 #include <proto/exec.h>
12 #include "exec_debug.h"
13 #ifndef DEBUG_InitCode
14 # define DEBUG_InitCode 0
15 #endif
16 #undef DEBUG
17 #if DEBUG_InitCode
18 # define DEBUG 1
19 #endif
20 #include <aros/debug.h>
22 /*****************************************************************************
24 NAME */
26 AROS_LH2(void, InitCode,
28 /* SYNOPSIS */
29 AROS_LHA(ULONG, startClass, D0),
30 AROS_LHA(ULONG, version, D1),
32 /* LOCATION */
33 struct ExecBase *, SysBase, 12, Exec)
35 /* FUNCTION
36 Traverse the ResModules array and InitResident() all modules with
37 versions greater than or equal to version, and of a class equal to
38 startClass.
40 INPUTS
41 startClass - which type of module to start
42 version - a version number
44 RESULT
46 NOTES
48 EXAMPLE
50 BUGS
52 SEE ALSO
54 INTERNALS
56 *****************************************************************************/
58 AROS_LIBFUNC_INIT
60 IPTR *list = SysBase->ResModules;
62 D(bug("enter InitCode(0x%x, %d)\n", startClass, version));
64 if(list)
66 while(*list)
68 /* on amiga, if bit 31 is set then this points to another list of
69 * modules rather than pointing to a single module. bit 31 is
70 * inconvenient on architectures where code may be loaded above
71 * 2GB. on these platforms we assume aligned pointers and use bit
72 * 0 instead */
73 #ifdef __mc68000__
74 if(*list & 0x80000000) list = (IPTR *)(*list & 0x7fffffff);
75 #else
76 if(*list & 0x1) list = (IPTR *)(*list & ~(IPTR)0x1);
77 #endif
79 if( (((struct Resident *)*list)->rt_Version >= (UBYTE)version)
80 && (((struct Resident *)*list)->rt_Flags & (UBYTE)startClass) )
82 D(bug("calling InitResident(\"%s\", NULL)\n",
83 ((struct Resident *)(*list))->rt_Name));
84 InitResident((struct Resident *)*list, 0);
86 else
87 D(bug("NOT calling InitResident(\"%s\", NULL)\n",
88 ((struct Resident *)(*list))->rt_Name)
90 list++;
94 D(bug("leave InitCode(0x%x, %d)\n", startClass, version));
96 AROS_LIBFUNC_EXIT
97 } /* InitCode */