From 2b6bc8a596bd41ae5e7c5b6709ae44b40a491491 Mon Sep 17 00:00:00 2001 From: Laurent Vivier Date: Thu, 18 Jun 2009 22:00:27 +0200 Subject: [PATCH] Add GetPhysical() trap Signed-off-by: Laurent Vivier --- libmacos/macos/memory.h | 26 ++++++++++++++++++++++++++ libmacos/macos/traps.h | 25 +++++++++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/libmacos/macos/memory.h b/libmacos/macos/memory.h index 37289b2..969feb4 100644 --- a/libmacos/macos/memory.h +++ b/libmacos/macos/memory.h @@ -7,6 +7,7 @@ #ifndef __MACOS_MEMORY_H__ #define __MACOS_MEMORY_H__ +#include #include #ifdef __mc68000__ @@ -28,5 +29,30 @@ static inline void* NewPtr(unsigned long byteCount) return ptr; } + +typedef struct MemoryBlock { + void *address; + unsigned long count; +} MemoryBlock; + +typedef struct LogicalToPhysicalTable { + MemoryBlock logical; + MemoryBlock physical[8]; +} LogicalToPhysicalTable; + +static inline OSErr GetPhysical(LogicalToPhysicalTable *addresses, + unsigned long *physicalEntryCount) +{ + register OSErr ret asm("%%d0"); + + asm("move.l %1, %%a0\n" + "move.l %2, %%a1\n" + MemoryDispatch(_GetPhysical) + : "=d" (ret) : "a" (addresses), "a" (physicalEntryCount) + : UNPRESERVED_REGS ); + + return ret; +} + #endif /* __mc68000__ */ #endif /* __MACOS_MEMORY_H__ */ diff --git a/libmacos/macos/traps.h b/libmacos/macos/traps.h index ffe6cd2..bbacc04 100644 --- a/libmacos/macos/traps.h +++ b/libmacos/macos/traps.h @@ -25,6 +25,7 @@ #define _PBStatusSync 0xA005 #define _DvrRemove 0xA03E #define _ReadXPRam 0xA051 +#define _MemoryDispatch 0xA05C #define _SlotManager 0xA06E #define _HWPriv 0xA098 #define _SCSIDispatch 0xA815 @@ -106,4 +107,28 @@ HWPrivSelector(selector)" /* "#selector" */\n" \ Trap(_HWPriv) +/* + * Memory Dispatch selectors + * + */ + +#define _HoldMemory 0x0000 +#define _UnholdMemory 0x0001 +#define _LockMemory 0x0002 +#define _UnlockMemory 0x0003 +#define _LockMemoryContiguous 0x0004 +#define _GetPhysical 0x0005 +#define _LockMemoryForOutput 0x000A +#define _MakeMemoryResident 0x000B +#define _ReleaseMemoryData 0x000C +#define _MakeMemoryNonResident 0x000D +#define _FlushMemory 0x000E +#define _GetVolumeVirtualMemoryInfo 0x000F + +#define MemoryDispatchSelector(a) " move.l #"#a", %%d0" + +#define MemoryDispatch(selector) \ + MemoryDispatchSelector(selector)" /* "#selector" */\n" \ + Trap(_MemoryDispatch) + #endif /* __MACOS_TRAPS_H__ */