1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188
|
/* -*- mode: C++; tab-width: 4 -*- */
/* ===================================================================== *\
Copyright (c) 1999-2001 Palm, Inc. or its subsidiaries.
All rights reserved.
This file is part of the Palm OS Emulator.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
\* ===================================================================== */
#ifndef EmPalmFunction_h
#define EmPalmFunction_h
#include "EmCPU.h" // GetPC
struct SystemCallContext;
void EmPalmFunctionInit (void);
#define FOR_EACH_FUNCTION(DO_TO_FUNCTION) \
DO_TO_FUNCTION(cj_kptkdelete) \
DO_TO_FUNCTION(dns_decode_name) \
DO_TO_FUNCTION(BackspaceChar) \
DO_TO_FUNCTION(Crc16CalcBlock) \
DO_TO_FUNCTION(DmWrite) \
DO_TO_FUNCTION(ECValidateField) \
DO_TO_FUNCTION(EggOfInfiniteWisdom) \
DO_TO_FUNCTION(ExpInit) \
DO_TO_FUNCTION(FindShowResults) \
DO_TO_FUNCTION(FindSaveFindStr) \
DO_TO_FUNCTION(FldDelete) \
DO_TO_FUNCTION(FntDefineFont) \
DO_TO_FUNCTION(GrfProcessStroke) \
DO_TO_FUNCTION(HsPrvInit) \
DO_TO_FUNCTION(HsPrvInitCard) \
DO_TO_FUNCTION(MemMove) \
DO_TO_FUNCTION(MenuHandleEvent) \
DO_TO_FUNCTION(NetLibBitMove) \
DO_TO_FUNCTION(NetPrvSettingSet) \
DO_TO_FUNCTION(NetPrvTaskMain) \
DO_TO_FUNCTION(PrvCompressedInnerBitBlt)\
DO_TO_FUNCTION(PrvConvertDepth1To2BW) \
DO_TO_FUNCTION(PrvDrawSliderControl) \
DO_TO_FUNCTION(PrvFindMemoryLeaks) \
DO_TO_FUNCTION(PrvGetExpGlobals) \
DO_TO_FUNCTION(PrvGetVFSGlobals) \
DO_TO_FUNCTION(PrvGetIntlMgrGlobalsP) \
DO_TO_FUNCTION(PrvSetIntlMgrGlobalsP) \
DO_TO_FUNCTION(PrvMisAlignedForwardInnerBitBlt) \
DO_TO_FUNCTION(PrvMisAlignedBackwardInnerBitBlt) \
DO_TO_FUNCTION(PrvSystemTimerProc) \
DO_TO_FUNCTION(PrvReleaseExpGlobals) \
DO_TO_FUNCTION(PrvReleaseVFSGlobals) \
DO_TO_FUNCTION(SecPrvRandomSeed) \
DO_TO_FUNCTION(SysAppExit) \
DO_TO_FUNCTION(SysLaunch) \
DO_TO_FUNCTION(TsmGlueGetFepGlobals) \
DO_TO_FUNCTION(VFSInit) \
DO_TO_FUNCTION(_CerticomMemCpy) \
// Declare a bunch of InFoo(emuptr) functions that can be used
// to determine if a memory location is within a particular
// Palm OS function.
//
// Note that the following macro used to declare just one function
// that took a default emuptr parameter set to gCPU->GetPC ().
// However, gcc 2.95.x and 2.96.x ran into internal compiler errors
// trying to compile it (egcs 1.1.x and gcc 3.0 appear to be OK).
// So the single function was broken into two, avoiding the error.
#ifdef BROKEN_VIRTUAL_DEFAULT_ARGUMENTS
#define DECLARE_FUNCTION(fn_name) \
Bool In##fn_name (emuptr); \
inline Bool In##fn_name () { return In##fn_name (gCPU->GetPC ()); }
#else
#define DECLARE_FUNCTION(fn_name) \
Bool In##fn_name (emuptr = gCPU->GetPC ());
#endif
FOR_EACH_FUNCTION(DECLARE_FUNCTION)
#undef DECLARE_FUNCTION
// Inline function to turn a trap word (0xA###) into an index into the
// trap table. The method used here (masking off the uppermost nybble
// instead of, say, subtracting sysTrapBase) matches the ROM.
inline uint16 SysTrapIndex (uint16 trapWord)
{
return (uint16) (trapWord & ~0xF000);
}
inline uint16 LibTrapIndex (uint16 trapWord)
{
return (uint16) (SysTrapIndex (trapWord) - SysTrapIndex (sysLibTrapBase));
}
inline Bool IsSystemTrap (uint16 trapWord)
{
return SysTrapIndex (trapWord) < SysTrapIndex (sysLibTrapBase);
}
inline Bool IsLibraryTrap (uint16 trapWord)
{
return !IsSystemTrap (trapWord);
}
#define kProscribedDocumentedSystemUseOnly 1
#define kProscribedUndocumentedSystemUseOnly 2
#define kProscribedKernelUseOnly 3
#define kProscribedObsolete 4
#define kProscribedGhost 5
#define kProscribedSystemUseOnlyAnyway 6
#define kProscribedRare 7
Bool ProscribedFunction (const SystemCallContext& context);
int GetProscribedReason (const SystemCallContext& context);
emuptr GetFunctionAddress (uint16 trapWord, uint32 extra = sysInvalidRefNum, Bool digDeep = false);
emuptr GetLibFunctionAddress (uint16 trapWord, UInt16 refNum, Bool digDeep);
emuptr GetSysFunctionAddress (uint16 trapWord, uint32 extra, Bool digDeep);
emuptr GetStdDispatchAddress (emuptr entryPt, uint32 regD2);
emuptr GetFlpEmDispatchAddress (emuptr entryPt, uint32 regD2);
emuptr GetIntlDispatchAddress (emuptr entryPt, uint32 regD2);
class EmUnimplementedFunctionException
{
public:
EmUnimplementedFunctionException (long n = 0) :
fLibIndex (n)
{
}
long fLibIndex;
};
class EmInvalidRefNumException
{
public:
EmInvalidRefNumException (long n = 0, long m = sysInvalidRefNum) :
fLibIndex (n),
fMaxRefNum (m)
{
}
long fLibIndex;
long fMaxRefNum;
};
char* GetTrapName (const SystemCallContext&, Bool digDeep = false);
char* GetTrapName (uint16 trapWord, uint32 extra = sysInvalidRefNum, Bool digDeep = false);
void FindTrapName (uint16 trapWord, char* nameP, uint32 extra = sysInvalidRefNum, Bool digDeep = false);
// Llamagraphics, Inc: Added nameCapacity argument so that callers
// can retrieve more than 31 character function names. The default
// capacity is 32, so callers that don't provide the extra argument
// will get the same result as before.
void FindFunctionName (emuptr addr,
char* nameP,
emuptr* startAddrP = NULL,
emuptr* endAddrP = NULL,
long nameCapacity = 32);
emuptr FindFunctionStart (emuptr addr);
emuptr FindFunctionEnd (emuptr addr);
Bool EndOfFunctionSequence (emuptr addr);
// Llamagraphics, Inc: Added nameCapacity argument so that callers
// can retrieve more than 31 character function names. The default
// capacity is 32, so callers that don't provide the extra argument
// will get the same result as before.
void GetMacsbugInfo (emuptr eof, char* name, long nameCapacity, emuptr* sof);
void MacsbugNameLength (emuptr addr, uint8* length, Bool* isFixed, emuptr* namePtr);
Bool ValidMacsbugChar (uint8 ch);
#endif /* EmPalmFunction_h */
|