Forgotten commit. Added automount.
[AROS.git] / rom / exec / memory.h
blobd58382e99c6b6ee85ff6f171d76cfbd2a42d03f5
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 * 31.01.2011: disabled, because creates problems:
22 * 1. FindMem() can be called from within supervisor mode
23 * 2. FreeMem() can be called from within RemTask() in order to free task structure itself.
24 * This eventually leads to trashing memory (semaphore is owned by removed task).
25 * Can be turned on again only after addressing these issues.
27 #define MEM_LOCK ObtainSemaphore(&PrivExecBase(SysBase)->MemListSem)
28 #define MEM_LOCK_SHARED ObtainSemaphoreShared(&PrivExecBase(SysBase)->MemListSem)
29 #define MEM_UNLOCK ReleaseSemaphore(&PrivExecBase(SysBase)->MemListSem)
31 #define MEM_LOCK Forbid()
32 #define MEM_LOCK_SHARED Forbid()
33 #define MEM_UNLOCK Permit()
36 /* Private Pool structure */
37 struct Pool
39 struct MinList PuddleList;
40 ULONG Requirements;
41 ULONG PuddleSize;
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 MemHeader *FindMem(APTR address, struct ExecBase *SysBase);
65 APTR stdAlloc(struct MemHeader *mh, IPTR byteSize, ULONG requirements, struct TraceLocation *loc, struct ExecBase *SysBase);
66 void stdDealloc(struct MemHeader *freeList, APTR memoryBlock, IPTR byteSize, struct TraceLocation *loc, struct ExecBase *SysBase);
68 APTR InternalAllocAbs(APTR location, IPTR byteSize, struct ExecBase *SysBase);
69 void InternalFreeMem(APTR location, IPTR byteSize, struct TraceLocation *loc, struct ExecBase *SysBase);
70 APTR AllocMemHeader(IPTR size, ULONG flags, struct TraceLocation *loc, struct ExecBase *SysBase);
71 void FreeMemHeader(APTR addr, struct TraceLocation *loc, struct ExecBase *SysBase);
73 APTR InternalAllocPooled(APTR poolHeader, IPTR memSize, ULONG flags, struct TraceLocation *loc, struct ExecBase *SysBase);
74 void InternalFreePooled(APTR memory, IPTR memSize, struct TraceLocation *loc, struct ExecBase *SysBase);
76 ULONG checkMemHandlers(struct checkMemHandlersState *cmhs, struct ExecBase *SysBase);
78 APTR nommu_AllocMem(IPTR byteSize, ULONG flags, struct TraceLocation *loc, struct ExecBase *SysBase);
79 APTR nommu_AllocAbs(APTR location, IPTR byteSize, struct ExecBase *SysBase);
80 void nommu_FreeMem(APTR memoryBlock, IPTR byteSize, struct TraceLocation *loc, struct ExecBase *SysBase);
81 IPTR nommu_AvailMem(ULONG attributes, struct ExecBase *SysBase);
83 #define BLOCK_TOTAL \
84 ((sizeof(struct Block)+AROS_WORSTALIGN-1)&~(AROS_WORSTALIGN-1))
86 #endif