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>
15 #include "exec_intern.h"
18 /*****************************************************************************
22 AROS_LH5(void, AddMemList
,
25 AROS_LHA(IPTR
, size
, D0
),
26 AROS_LHA(ULONG
, attributes
, D1
),
27 AROS_LHA(LONG
, pri
, D2
),
28 AROS_LHA(APTR
, base
, A0
),
29 AROS_LHA(STRPTR
, name
, A1
),
32 struct ExecBase
*, SysBase
, 103, Exec
)
35 Add a new block of memory to the system memory lists.
38 size - Size of the block
39 attributes - The attributes the memory will have
40 pri - Priority in the list of MemHeaders
42 name - A name associated with the memory
47 No argument checking done.
57 ******************************************************************************/
63 /* If the end is less than (1 << 31), MEMF_31BIT is implied */
64 if (((IPTR
)base
+size
) < (1UL << 31))
65 attributes
|= MEMF_31BIT
;
67 attributes
&= ~MEMF_31BIT
;
69 /* Do I have to look here if it matches some other MemHeader? */
70 mh
=(struct MemHeader
*)base
;
71 mh
->mh_Node
.ln_Type
=NT_MEMORY
;
72 mh
->mh_Node
.ln_Pri
=pri
;
73 mh
->mh_Node
.ln_Name
=name
;
74 mh
->mh_Attributes
=attributes
;
75 mh
->mh_First
=(struct MemChunk
*)((UBYTE
*)mh
+MEMHEADER_TOTAL
);
76 mh
->mh_First
->mc_Next
=NULL
;
77 mh
->mh_First
->mc_Bytes
=size
-MEMHEADER_TOTAL
;
78 mh
->mh_Lower
=mh
->mh_First
;
79 mh
->mh_Upper
=(APTR
)((UBYTE
*)base
+size
);
80 mh
->mh_Free
=mh
->mh_First
->mc_Bytes
;
82 /* Protect the memory list. */
86 Enqueue(&SysBase
->MemList
,&mh
->mh_Node
);