- Give PCI controllers lower unit numbers than legacy controllers.
[cake.git] / rom / exec / addmemlist.c
blobe4c92ea5503312781bdafb43ac76b31f816f01c2
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Add memory to the public list of memory.
6 Lang: english
7 */
8 #include <exec/execbase.h>
9 #include "memory.h"
10 #include <aros/libcall.h>
11 #include <exec/memory.h>
12 #include <proto/exec.h>
14 /*****************************************************************************
16 NAME */
18 AROS_LH5(void, AddMemList,
20 /* SYNOPSIS */
21 AROS_LHA(ULONG, size, D0),
22 AROS_LHA(ULONG, attributes, D1),
23 AROS_LHA(LONG, pri, D2),
24 AROS_LHA(APTR, base, A0),
25 AROS_LHA(STRPTR, name, A1),
27 /* LOCATION */
28 struct ExecBase *, SysBase, 103, Exec)
30 /* FUNCTION
31 Add a new block of memory to the system memory lists.
33 INPUTS
34 size - Size of the block
35 attributes - The attributes the memory will have
36 pri - Priority in the list of MemHeaders
37 base - Base address
38 name - A name associated with the memory
40 RESULT
42 NOTES
43 No argument checking done.
45 EXAMPLE
47 BUGS
49 SEE ALSO
51 INTERNALS
53 ******************************************************************************/
55 AROS_LIBFUNC_INIT
57 struct MemHeader *mh;
59 /* Do I have to look here if it matches some other MemHeader? */
60 mh=(struct MemHeader *)base;
61 mh->mh_Node.ln_Type=NT_MEMORY;
62 mh->mh_Node.ln_Pri=pri;
63 mh->mh_Node.ln_Name=name;
64 mh->mh_Attributes=attributes;
65 mh->mh_First=(struct MemChunk *)((UBYTE *)mh+MEMHEADER_TOTAL);
66 mh->mh_First->mc_Next=NULL;
67 mh->mh_First->mc_Bytes=size-MEMHEADER_TOTAL;
68 mh->mh_Lower=mh->mh_First;
69 mh->mh_Upper=(APTR)((UBYTE *)base+size);
70 mh->mh_Free=mh->mh_First->mc_Bytes;
72 /* Protect the memory list. */
73 Forbid();
74 /* Add MemHeader */
75 Enqueue(&SysBase->MemList,&mh->mh_Node);
76 Permit();
77 AROS_LIBFUNC_EXIT
78 } /* AddMemList */