home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / misc / emu / AROSdev.lha / AROS / rom / exec / addmemlist.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-01-09  |  2.5 KB  |  107 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: addmemlist.c,v 1.8 1997/01/01 03:46:04 ldp Exp $
  4.     $Log: addmemlist.c,v $
  5.     Revision 1.8  1997/01/01 03:46:04  ldp
  6.     Committed Amiga native (support) code
  7.  
  8.     Changed clib to proto
  9.  
  10.     Revision 1.7  1996/12/10 13:51:35  aros
  11.     Moved all #include's in the first column so makedepend can see it.
  12.  
  13.     Revision 1.6  1996/10/24 15:50:41  aros
  14.     Use the official AROS macros over the __AROS versions.
  15.  
  16.     Revision 1.5  1996/10/19 17:07:23  aros
  17.     Include <aros/machine.h> instead of machine.h
  18.  
  19.     Revision 1.4  1996/08/13 13:55:56  digulla
  20.     Replaced AROS_LA by AROS_LHA
  21.     Replaced some AROS_LH*I by AROS_LH*
  22.     Sorted and added includes
  23.  
  24.     Revision 1.3  1996/08/01 17:41:02  digulla
  25.     Added standard header for all files
  26.  
  27.     Desc:
  28.     Lang:
  29. */
  30. #include <exec/execbase.h>
  31. #include <aros/machine.h>
  32. #include "memory.h"
  33. #include <aros/libcall.h>
  34. #include <exec/memory.h>
  35. #include <proto/exec.h>
  36.  
  37. /*****************************************************************************
  38.  
  39.     NAME */
  40.  
  41. AROS_LH5(void, AddMemList,
  42.  
  43. /*  SYNOPSIS */
  44.     AROS_LHA(ULONG,  size,       D0),
  45.     AROS_LHA(ULONG,  attributes, D1),
  46.     AROS_LHA(LONG,   pri,        D2),
  47.     AROS_LHA(APTR,   base,       A0),
  48.     AROS_LHA(STRPTR, name,       A1),
  49.  
  50. /*  LOCATION */
  51.     struct ExecBase *, SysBase, 103, Exec)
  52.  
  53. /*  FUNCTION
  54.     Add a new block of memory to the system memory lists.
  55.  
  56.     INPUTS
  57.     size       - Size of the block
  58.     attributes - The attributes the memory will have
  59.     pri       - Priority in the list of MemHeaders
  60.     base       - Base address
  61.     name       - A name associated with the memory
  62.  
  63.     RESULT
  64.  
  65.     NOTES
  66.     No argument checking done.
  67.  
  68.     EXAMPLE
  69.  
  70.     BUGS
  71.  
  72.     SEE ALSO
  73.  
  74.     INTERNALS
  75.  
  76.     HISTORY
  77.     8-10-95    created by m. fleischer
  78.        16-10-95    increased portability
  79.  
  80. ******************************************************************************/
  81. {
  82.     AROS_LIBFUNC_INIT
  83.  
  84.     struct MemHeader *mh;
  85.  
  86.     /* Do I have to look here if it matches some other MemHeader? */
  87.     mh=(struct MemHeader *)base;
  88.     mh->mh_Node.ln_Type=NT_MEMORY;
  89.     mh->mh_Node.ln_Pri=pri;
  90.     mh->mh_Node.ln_Name=name;
  91.     mh->mh_Attributes=attributes;
  92.     mh->mh_First=(struct MemChunk *)((UBYTE *)mh+MEMHEADER_TOTAL);
  93.     mh->mh_First->mc_Next=NULL;
  94.     mh->mh_First->mc_Bytes=size-MEMHEADER_TOTAL;
  95.     mh->mh_Lower=mh->mh_First;
  96.     mh->mh_Upper=(APTR)((UBYTE *)base+size);
  97.     mh->mh_Free=mh->mh_First->mc_Bytes;
  98.  
  99.     /* Protect the memory list. */
  100.     Forbid();
  101.     /* Add MemHeader */
  102.     Enqueue(&SysBase->MemList,&mh->mh_Node);
  103.     Permit();
  104.     AROS_LIBFUNC_EXIT
  105. } /* AddMemList */
  106.  
  107.