2 Copyright © 1995-2012, The AROS Development Team. All rights reserved.
5 Desc: Add memory to the public list of memory.
9 #include <aros/debug.h>
10 #include <exec/execbase.h>
11 #include <aros/libcall.h>
12 #include <exec/memory.h>
13 #include <proto/exec.h>
14 #include <proto/kernel.h>
16 #include "exec_intern.h"
19 AROS_LH5(void, AddMemList
,
20 AROS_LHA(IPTR
, size
, D0
),
21 AROS_LHA(ULONG
, attributes
, D1
),
22 AROS_LHA(LONG
, pri
, D2
),
23 AROS_LHA(APTR
, base
, A0
),
24 AROS_LHA(STRPTR
, name
, A1
),
25 struct ExecBase
*, SysBase
, 103, Exec
)
31 /* We may be called by some special boot ROM (UAE extra Chip RAM)
32 * or user may manually add some memory region(s).
33 * We need to remove invalid mapping in MMU debugging mode.
35 KrnSetProtection((void*)base
, size
, (attributes
& MEMF_CHIP
) ?
36 MAP_Readable
| MAP_Writable
| MAP_Executable
| MAP_CacheInhibit
:
37 MAP_Readable
| MAP_Writable
| MAP_Executable
);
39 mh
=(struct MemHeader
*)base
;
40 mh
->mh_Node
.ln_Type
=NT_MEMORY
;
41 mh
->mh_Node
.ln_Pri
=pri
;
42 mh
->mh_Node
.ln_Name
=name
;
43 mh
->mh_Attributes
=attributes
;
44 mh
->mh_First
=(struct MemChunk
*)((UBYTE
*)mh
+MEMHEADER_TOTAL
);
45 mh
->mh_First
->mc_Next
=NULL
;
46 mh
->mh_First
->mc_Bytes
=size
-MEMHEADER_TOTAL
;
47 mh
->mh_Lower
=mh
->mh_First
;
48 mh
->mh_Upper
=(APTR
)((UBYTE
*)base
+size
);
49 mh
->mh_Free
=mh
->mh_First
->mc_Bytes
;
51 /* Protect the memory list. */
55 Enqueue(&SysBase
->MemList
,&mh
->mh_Node
);