1 /*****************************************************************************
2  *
3  * Copyright (c) 2008-2010, CoreCodec, Inc.
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are met:
8  *     * Redistributions of source code must retain the above copyright
9  *       notice, this list of conditions and the following disclaimer.
10  *     * Redistributions in binary form must reproduce the above copyright
11  *       notice, this list of conditions and the following disclaimer in the
12  *       documentation and/or other materials provided with the distribution.
13  *     * Neither the name of CoreCodec, Inc. nor the
14  *       names of its contributors may be used to endorse or promote products
15  *       derived from this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY CoreCodec, Inc. ``AS IS'' AND ANY
18  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20  * DISCLAIMED. IN NO EVENT SHALL CoreCodec, Inc. BE LIABLE FOR ANY
21  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  *
28  ****************************************************************************/
29 
30 #ifndef __PACE_H
31 #define __PACE_H
32 
33 #if defined(TARGET_PALMOS)
34 
35 #include <PalmOS.h>
36 #include <CoreTraps.h>
37 #include <UIResources.h>
38 #include <Rect.h>
39 #include <SystemMgr.h>
40 #include <Form.h>
41 #include <Extensions/ExpansionMgr/ExpansionMgr.h>
42 #include <Extensions/ExpansionMgr/VFSMgr.h>
43 #include <PalmOSGlue/MemGlue.h>
44 #include <PceNativeCall.h>
45 #include <PalmOSGlue/SysGlue.h>
46 #include <PalmOSGlue/FrmGlue.h>
47 #include <DLServer.h>
48 #include <DateTime.h>
49 
50 #if PALMOS_SDK_VERSION < 0x0541
51 #error Please update to Palm OS 5 SDK R4
52 #endif
53 
54 typedef struct sysregs
55 {
56 	void* GOT;
57 	void* SysReg;
58 
59 } sysregs;
60 
61 void SaveSysRegs(sysregs* p);
62 void LoadSysRegs(sysregs* p);
63 
64 extern Int32 GetOEMSleepMode();
65 extern Err SetOEMSleepMode(Int32 Mode);
66 
67 extern void* PealLoadModule(uint16_t FtrId,Boolean Mem,Boolean OnlyFtr,Boolean MemSema);
68 extern void PealFreeModule(void*);
69 extern void* PealGetSymbol(void*,const tchar_t* Name);
70 
71 extern Err SysGetEntryAddresses(UInt32 refNum, UInt32 entryNumStart,
72 		UInt32 entryNumEnd, void **addressP);
73 extern Err SysFindModule(UInt32 dbType, UInt32 dbCreator, UInt16 rsrcID,
74 		UInt32 flags, UInt32 *refNumP);
75 extern Err SysLoadModule(UInt32 dbType, UInt32 dbCreator, UInt16 rsrcID,
76 		UInt32 flags, UInt32 *refNumP);
77 extern Err SysUnloadModule(UInt32 refNum);
78 extern void HALDelay(UInt32 microSec);
79 extern void HALDisplayWake();
80 extern void HALDisplayOff_TREO650();
81 
82 extern void SonyCleanDCache(void*, UInt32);
83 extern void SonyInvalidateDCache(void*, UInt32);
84 
85 extern int PalmCall(void* Func,...); //0..4
86 extern int PalmCall2(void* Func,...); //5..8
87 
88 #if defined(_MSC_VER)
89 #define PALMCALL0(Func) Func()
90 #define PALMCALL1(Func,a) Func(a)
91 #define PALMCALL2(Func,a,b) Func(a,b)
92 #define PALMCALL3(Func,a,b,c) Func(a,b,c)
93 #define PALMCALL4(Func,a,b,c,d) Func(a,b,c,d)
94 #define PALMCALL5(Func,a,b,c,d,e) Func(a,b,c,d,e)
95 #define PALMCALL6(Func,a,b,c,d,e,f) Func(a,b,c,d,e,f)
96 #define PALMCALL7(Func,a,b,c,d,e,f,g) Func(a,b,c,d,e,f,g)
97 #define PALMCALL8(Func,a,b,c,d,e,f,g,h) Func(a,b,c,d,e,f,g,h)
98 #else
99 #define PALMCALL0(Func) PalmCall(Func)
100 #define PALMCALL1(Func,a) PalmCall(Func,a)
101 #define PALMCALL2(Func,a,b) PalmCall(Func,a,b)
102 #define PALMCALL3(Func,a,b,c) PalmCall(Func,a,b,c)
103 #define PALMCALL4(Func,a,b,c,d) PalmCall(Func,a,b,c,d)
104 #define PALMCALL5(Func,a,b,c,d,e) PalmCall2(Func,a,b,c,d,e)
105 #define PALMCALL6(Func,a,b,c,d,e,f) PalmCall2(Func,a,b,c,d,e,f)
106 #define PALMCALL7(Func,a,b,c,d,e,f,g) PalmCall2(Func,a,b,c,d,e,f,g)
107 #define PALMCALL8(Func,a,b,c,d,e,f,g,h) PalmCall2(Func,a,b,c,d,e,f,g,h)
108 #endif
109 
110 typedef uint16_t m68kcallback[12];
111 extern void* m68kCallBack(m68kcallback,NativeFuncType*);
112 
113 typedef Boolean FormEventHandlerExType(EventType *eventP, void* This);
114 
115 extern void FrmSetEventHandlerEx(FormType *formP,FormEventHandlerExType *handler,void* This);
116 
117 extern Boolean FrmCallEventHandlerEx(FormType *Form, EventType* eventP);
118 
119 typedef struct SysAppLaunchCmdOpenDBType2
120 {
121 	UInt16		cardNo;
122 	UInt16		dbID[2];
123 
124 } SysAppLaunchCmdOpenDBType2;
125 
126 typedef struct vfspath
127 {
128 	UInt16 volRefNum;
129 	Char path[256];
130 } vfspath;
131 
132 #if defined(IX86)
133 NativeFuncType* IX86CallBack(const char* Func,char* Buffer);
134 #endif
135 
136 #endif
137 #endif
138