revert between 56095 -> 55830 in arch
[AROS.git] / rom / exec / addmemlist.c
blobada6162f42babb8dc8224bddeddedde50be07a6a
1 /*
2 Copyright © 1995-2012, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Add memory to the public list of memory.
6 Lang: english
7 */
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"
16 #include "memory.h"
18 /*****************************************************************************
20 NAME */
22 AROS_LH5(void, AddMemList,
24 /* SYNOPSIS */
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),
31 /* LOCATION */
32 struct ExecBase *, SysBase, 103, Exec)
34 /* FUNCTION
35 Add a new block of memory to the system memory lists.
37 INPUTS
38 size - Size of the block
39 attributes - The attributes the memory will have
40 pri - Priority in the list of MemHeaders
41 base - Base address
42 name - A name associated with the memory
44 RESULT
46 NOTES
47 No argument checking done.
49 EXAMPLE
51 BUGS
53 SEE ALSO
55 INTERNALS
57 ******************************************************************************/
59 AROS_LIBFUNC_INIT
61 struct MemHeader *mh;
63 /* If the end is less than (1 << 31), MEMF_31BIT is implied */
64 if (((IPTR)base+size) < (1UL << 31))
65 attributes |= MEMF_31BIT;
66 else
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. */
83 MEM_LOCK;
85 /* Add MemHeader */
86 Enqueue(&SysBase->MemList,&mh->mh_Node);
88 MEM_UNLOCK;
90 AROS_LIBFUNC_EXIT
91 } /* AddMemList */