Fix IO memory access .. SB128 driver makes noises in VMWare - CMI is untested (Curren...
[AROS.git] / rom / exec / addmemlist.c
blob055909069bf65d3ba670bf4bea71e116795e4e54
1 /*
2 Copyright © 1995-2011, 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(ULONG, 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 /* Do I have to look here if it matches some other MemHeader? */
64 mh=(struct MemHeader *)base;
65 mh->mh_Node.ln_Type=NT_MEMORY;
66 mh->mh_Node.ln_Pri=pri;
67 mh->mh_Node.ln_Name=name;
68 mh->mh_Attributes=attributes;
69 mh->mh_First=(struct MemChunk *)((UBYTE *)mh+MEMHEADER_TOTAL);
70 mh->mh_First->mc_Next=NULL;
71 mh->mh_First->mc_Bytes=size-MEMHEADER_TOTAL;
72 mh->mh_Lower=mh->mh_First;
73 mh->mh_Upper=(APTR)((UBYTE *)base+size);
74 mh->mh_Free=mh->mh_First->mc_Bytes;
76 /* Protect the memory list. */
77 MEM_LOCK;
79 /* Add MemHeader */
80 Enqueue(&SysBase->MemList,&mh->mh_Node);
82 MEM_UNLOCK;
84 AROS_LIBFUNC_EXIT
85 } /* AddMemList */