Add Allwinner Technology to the vendor ID list
[AROS.git] / rom / exec / memory.h
blobe6b88151a5455da19aa00cb780d3338604e8a846
1 /*
2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 Lang:
7 */
8 #ifndef _MEMORY_H_
9 #define _MEMORY_H_
11 #include <exec/lists.h>
12 #include <exec/semaphores.h>
13 #include <exec/memory.h>
14 #include <stddef.h>
17 * EXPERIMENTAL: use semaphore protection instead of Forbid()/Permit() for
18 * system memory allocation routines.
19 * In case of problems use definitions below.
21 * Many m68k programs assume forbid state won't get broken.
23 #ifndef __mc68000
24 #define MEM_LOCK ObtainSemaphore(&PrivExecBase(SysBase)->MemListSem)
25 #define MEM_LOCK_SHARED ObtainSemaphoreShared(&PrivExecBase(SysBase)->MemListSem)
26 #define MEM_UNLOCK ReleaseSemaphore(&PrivExecBase(SysBase)->MemListSem)
27 #else
28 #define MEM_LOCK Forbid()
29 #define MEM_LOCK_SHARED Forbid()
30 #define MEM_UNLOCK Permit()
31 #endif
33 #define POOL_MAGIC AROS_MAKE_ID('P','o','O','l')
35 /* Private Pool structure */
36 struct Pool
38 struct MinList PuddleList;
39 ULONG Requirements;
40 ULONG PuddleSize;
41 ULONG PoolMagic;
44 struct ProtectedPool
46 struct Pool pool;
47 struct SignalSemaphore sem;
50 struct Block
52 struct MinNode Node;
53 ULONG Size;
56 struct checkMemHandlersState
58 struct Node *cmhs_CurNode;
59 struct MemHandlerData cmhs_Data;
62 struct TraceLocation;
64 struct MemHeaderAllocatorCtx;
66 /* Returns existing or allocates new ctx */
67 struct MemHeaderAllocatorCtx * mhac_GetSysCtx(struct MemHeader * mh, struct ExecBase * SysBase);
68 void mhac_PoolMemHeaderSetup(struct MemHeader * mh, struct ProtectedPool * pool);
69 ULONG mhac_GetCtxSize();
70 /* Clears ctx if it already exists for a given MemHeader */
71 void mhac_ClearSysCtx(struct MemHeader * mh, struct ExecBase * SysBase);
73 struct MemHeader *FindMem(APTR address, struct ExecBase *SysBase);
74 APTR stdAlloc(struct MemHeader *mh, struct MemHeaderAllocatorCtx *mhac, IPTR byteSize, ULONG requirements, struct TraceLocation *loc, struct ExecBase *SysBase);
75 void stdDealloc(struct MemHeader *freeList, struct MemHeaderAllocatorCtx *mhac, APTR memoryBlock, IPTR byteSize, struct TraceLocation *loc, struct ExecBase *SysBase);
77 APTR InternalAllocAbs(APTR location, IPTR byteSize, struct ExecBase *SysBase);
78 void InternalFreeMem(APTR location, IPTR byteSize, struct TraceLocation *loc, struct ExecBase *SysBase);
79 APTR AllocMemHeader(IPTR size, ULONG flags, struct TraceLocation *loc, struct ExecBase *SysBase);
80 void FreeMemHeader(APTR addr, struct TraceLocation *loc, struct ExecBase *SysBase);
82 APTR InternalAllocPooled(APTR poolHeader, IPTR memSize, ULONG flags, struct TraceLocation *loc, struct ExecBase *SysBase);
83 void InternalFreePooled(APTR poolHeader, APTR memory, IPTR memSize, struct TraceLocation *loc, struct ExecBase *SysBase);
85 ULONG checkMemHandlers(struct checkMemHandlersState *cmhs, struct ExecBase *SysBase);
87 APTR nommu_AllocMem(IPTR byteSize, ULONG flags, struct TraceLocation *loc, struct ExecBase *SysBase);
88 APTR nommu_AllocAbs(APTR location, IPTR byteSize, struct ExecBase *SysBase);
89 void nommu_FreeMem(APTR memoryBlock, IPTR byteSize, struct TraceLocation *loc, struct ExecBase *SysBase);
90 IPTR nommu_AvailMem(ULONG attributes, struct ExecBase *SysBase);
92 #define PME_FREE_NO_CHUNK 1
93 #define PME_FREE_INV_POOL 2
94 #define PME_FREE_MXD_POOL 3
95 #define PME_ALLOC_INV_POOL 4
96 #define PME_DEL_POOL_INV_POOL 5
98 void PoolManagerAlert(ULONG code, ULONG flags, IPTR memSize, APTR memory, APTR poolHeaderMH, APTR poolHeader);
100 #define BLOCK_TOTAL \
101 ((sizeof(struct Block)+AROS_WORSTALIGN-1)&~(AROS_WORSTALIGN-1))
103 #endif