mpw/toolbox/mm.h

131 lines
2.9 KiB
C
Raw Normal View History

2013-02-08 03:49:20 +00:00
#ifndef __mpw_mm_h__
#define __mpw_mm_h__
2013-02-08 03:12:30 +00:00
#include <cstdint>
2015-02-07 17:30:12 +00:00
#include <macos/tool_return.h>
2013-02-08 03:12:30 +00:00
namespace MM
{
// native functions.
namespace Native
{
2013-02-18 02:54:45 +00:00
2013-07-05 17:56:06 +00:00
void MemoryInfo(uint32_t address);
2013-02-18 02:54:45 +00:00
void PrintMemoryStats();
uint16_t NewHandle(uint32_t size, bool clear, uint32_t &handle);
uint16_t NewHandle(uint32_t size, bool clear, uint32_t &handle, uint32_t &ptr);
2013-02-17 20:07:32 +00:00
uint16_t NewPtr(uint32_t size, bool clear, uint32_t &pointer);
uint16_t DisposeHandle(uint32_t handle);
uint16_t DisposePtr(uint32_t pointer);
2013-06-27 02:50:30 +00:00
uint16_t GetHandleSize(uint32_t handle, uint32_t &handleSize);
uint16_t SetHandleSize(uint32_t handle, uint32_t newSize);
uint16_t ReallocHandle(uint32_t handle, uint32_t newSize);
2013-08-03 23:17:15 +00:00
uint16_t HSetRBit(uint32_t handle);
uint16_t HClrRBit(uint32_t handle);
2013-08-17 23:01:25 +00:00
uint16_t HLock(uint32_t handle);
uint16_t HUnlock(uint32_t handle);
}
bool Init(uint8_t *memory, uint32_t memorySize, uint32_t globals, uint32_t stack);
2013-02-18 02:54:45 +00:00
2015-02-07 17:30:12 +00:00
struct HandleInfo
{
uint32_t address = 0;
uint32_t size = 0;
bool locked = false;
bool purgeable = false;
bool resource = false;
HandleInfo(uint32_t a = 0, uint32_t s = 0) :
address(a), size(s)
{}
};
using MacOS::tool_return;
tool_return<HandleInfo> GetHandleInfo(uint32_t handle);
tool_return<uint32_t> GetHandleSize(uint32_t handle);
2013-02-08 04:44:58 +00:00
uint16_t BlockMove(uint16_t trap);
2013-02-15 05:08:22 +00:00
uint32_t CompactMem(uint16_t trap);
2013-03-30 22:45:20 +00:00
uint32_t MaxMem(uint16_t trap);
2013-05-17 23:05:03 +00:00
uint32_t MaxBlock(uint16_t trap);
2013-03-30 22:45:20 +00:00
uint32_t FreeMem(uint16_t trap);
2013-04-01 03:49:59 +00:00
uint16_t ReserveMem(uint16_t trap);
2014-12-15 00:51:49 +00:00
uint32_t PurgeSpace(uint16_t trap);
2013-03-30 22:45:20 +00:00
2013-04-01 03:49:59 +00:00
2013-02-15 04:08:56 +00:00
uint16_t DisposeHandle(uint16_t trap);
2013-02-16 20:37:55 +00:00
uint16_t DisposePtr(uint16_t trap);
2013-03-04 02:54:53 +00:00
uint16_t EmptyHandle(uint16_t trap);
uint16_t ReallocHandle(uint16_t trap);
2013-02-16 20:37:55 +00:00
uint32_t GetHandleSize(uint16_t);
uint32_t GetPtrSize(uint16_t);
2013-02-15 04:08:56 +00:00
uint16_t NewHandle(uint16_t trap);
2013-02-16 20:37:55 +00:00
uint16_t NewPtr(uint16_t trap);
2013-02-16 01:33:00 +00:00
uint16_t SetHandleSize(uint16_t);
2013-02-16 20:37:55 +00:00
uint16_t SetPtrSize(uint16_t);
2014-12-20 18:03:02 +00:00
uint32_t RecoverHandle(uint16_t);
2013-08-03 23:17:50 +00:00
uint16_t HGetState(uint16_t trap);
2015-01-05 16:56:33 +00:00
uint16_t HSetState(uint16_t trap);
2013-08-03 23:17:50 +00:00
2013-02-16 20:37:55 +00:00
uint16_t HLock(uint16_t trap);
uint16_t HUnlock(uint16_t trap);
2013-02-19 23:28:29 +00:00
2013-02-25 04:20:38 +00:00
uint16_t HPurge(uint16_t trap);
2015-01-14 19:26:49 +00:00
uint16_t HNoPurge(uint16_t trap);
2015-01-14 19:26:49 +00:00
uint16_t HSetRBit(uint16_t trap);
uint16_t HClrRBit(uint16_t trap);
2013-02-19 23:28:29 +00:00
uint16_t MoveHHi(uint16_t trap);
2013-02-25 22:33:26 +00:00
uint32_t StripAddress(uint16_t trap);
2013-02-26 23:32:39 +00:00
// operating system utility routines
uint16_t HandAndHand(uint16_t trap);
uint16_t HandToHand(uint16_t trap);
uint16_t PtrAndHand(uint16_t trap);
uint16_t PtrToHand(uint16_t trap);
uint16_t PtrToXHand(uint16_t trap);
2013-06-27 02:50:53 +00:00
uint32_t StackSpace(uint16_t trap);
uint16_t HandleZone(uint16_t trap);
2013-06-27 03:50:08 +00:00
uint16_t GetZone(uint16_t trap);
uint16_t SetZone(uint16_t trap);
2014-07-24 15:37:21 +00:00
uint16_t MaxApplZone(uint16_t trap);
2014-12-15 00:52:08 +00:00
// OS Dispatch
uint16_t TempMaxMem(void);
2014-12-18 19:40:03 +00:00
uint16_t TempFreeMem(void);
2014-12-28 23:15:27 +00:00
uint16_t TempNewHandle(void);
uint16_t TempHLock(void);
uint16_t TempHUnlock(void);
uint16_t TempDisposeHandle(void);
2013-02-08 03:12:30 +00:00
}
2013-02-15 05:08:22 +00:00
2013-02-08 03:12:30 +00:00
#endif