2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
5 Desc: Add a resource to the public list of resources.
9 #include <aros/kernel.h>
10 #include <exec/execbase.h>
11 #include <exec/rawfmt.h>
12 #include <proto/exec.h>
13 #include <proto/kernel.h>
17 #include "exec_debug.h"
18 #include "exec_intern.h"
20 /* Kludge for old kernels */
22 #define KrnStatMemory(...)
25 /*****************************************************************************
29 AROS_LH1(void, AddResource
,
32 AROS_LHA(APTR
, resource
, A1
),
35 struct ExecBase
*, SysBase
, 81, Exec
)
38 Adds a given resource to the system's resource list.
41 resource - Pointer to a ready for use resource.
52 RemResource(), OpenResource()
56 ******************************************************************************/
59 ASSERT_VALID_PTR(resource
);
61 /* Just in case the user forgot them */
62 ((struct Node
*)resource
)->ln_Type
=NT_RESOURCE
;
64 /* Arbitrate for the resource list */
67 /* And add the resource */
68 Enqueue(&SysBase
->ResourceList
,(struct Node
*)resource
);
75 * kernel.resource is the first one to get initialized. After that
76 * some more things can wake up (hostlib.resource for example).
77 * They might want to use AllocMem() and even AllocPooled().
78 * Here we switch off boot mode of the memory manager. Currently we
79 * only set up page size for pool manager. When memory protection
80 * is implemented, more things will be done here.
81 * This allows to use exec pools even in kernel.resource itself.
82 * To do this its startup code needs to be changed to call AddResource()
83 * itself. Right after this exec's pool manager will be up and running.
85 if (!strcmp(((struct Node
*)resource
)->ln_Name
, "kernel.resource"))
87 KernelBase
= resource
;
88 DINIT("Post-kernel init");
90 /* If there's no MMU support, PageSize will stay zero */
91 KrnStatMemory(0, KMS_PageSize
, &PrivExecBase(SysBase
)->PageSize
, TAG_DONE
);
92 DINIT("Memory page size: %lu", PrivExecBase(SysBase
)->PageSize
);
95 * On MMU-less hardware kernel.resource will report zero page size.
96 * In this case we use MEMCHUNK_TOTAL as allocation granularity.
97 * This is because our Allocate() relies on the fact that all chunks
98 * are at least MemChunk-aligned, otherwise we end up in
99 * "Corrupt memory list" alert.
101 if (!PrivExecBase(SysBase
)->PageSize
)
102 PrivExecBase(SysBase
)->PageSize
= MEMCHUNK_TOTAL
;
104 /* We print the notice here because kprintf() works only after KernelBase is set up */
105 if (PrivExecBase(SysBase
)->IntFlags
& EXECF_MungWall
)
106 RawDoFmt("[exec] Mungwall enabled\n", NULL
, (VOID_FUNC
)RAWFMTFUNC_SERIAL
, NULL
);