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.globl	SonyInvalidateDCache
31.globl	SonyCleanDCache
32.globl	SysGetEntryAddresses
33.globl	SysFindModule
34.globl  HALDelay
35.globl  HALDisplayWake
36.globl  HALDisplayOff_TREO650
37.globl	SysLoadModule
38.globl	SysUnloadModule
39.globl  PceCall
40.globl  PalmCall
41.globl  PalmCall2
42
43AddrPceCall: .DC.L PceCall
44
45@r0,r1
46SonyCleanDCache:
47	stmdb sp!, {r9, lr}
48	ldr r9, AddrPceCall
49	ldr r9, [r9, #0]
50	swi	0xb5
51	ldmia sp!, {r9, pc}
52
53@r0,r1
54SonyInvalidateDCache:
55	stmdb sp!, {r9, lr}
56	ldr r9, AddrPceCall
57	ldr r9, [r9, #0]
58	swi	0xb4
59	ldmia sp!, {r9, pc}
60
61@r0,r1,r2,r3
62SysGetEntryAddresses:
63	stmdb sp!, {r9, lr}
64	ldr r9, AddrPceCall
65	ldr r9, [r9, #0]
66	ldr	ip, [r9, #-8]
67	mov lr, pc
68	ldr	pc, [ip, #2104]
69	ldmia sp!, {r9, pc}
70
71@r0,r1,r2,r3,[sp]
72SysFindModule:
73	ldr ip, [sp, #0]
74	stmdb sp!, {r9, lr}
75	stmdb sp!, {ip}
76	ldr r9, AddrPceCall
77	ldr r9, [r9, #0]
78	ldr	ip, [r9, #-8]
79	mov lr, pc
80	ldr	pc, [ip, #2092]
81	add sp, sp, #4
82	ldmia sp!, {r9, pc}
83
84@r0,r1,r2,r3,[sp]
85SysLoadModule:
86	ldr ip, [sp, #0]
87	stmdb sp!, {r9, lr}
88	stmdb sp!, {ip}
89	ldr r9, AddrPceCall
90	ldr r9, [r9, #0]
91	ldr	ip, [r9, #-8]
92	mov lr, pc
93	ldr	pc, [ip, #2176]
94	add sp, sp, #4
95	ldmia sp!, {r9, pc}
96
97@r0
98SysUnloadModule:
99	stmdb sp!, {r9, lr}
100	ldr r9, AddrPceCall
101	ldr r9, [r9, #0]
102	ldr	ip, [r9, #-8]
103	mov lr, pc
104	ldr	pc, [ip, #2312]
105	ldmia sp!, {r9, pc}
106
107@r0
108HALDelay:
109	stmdb sp!, {r9, lr}
110	ldr r9, AddrPceCall
111	ldr r9, [r9, #0]
112	ldr	ip, [r9, #-4]
113	mov lr, pc
114	ldr	pc, [ip, #0x28]
115	ldmia sp!, {r9, pc}
116
117HALDisplayWake:
118	stmdb sp!, {r9, lr}
119	ldr r9, AddrPceCall
120	ldr r9, [r9, #0]
121	ldr	ip, [r9, #-4]
122	mov lr, pc
123	ldr	pc, [ip, #0x40]
124	ldmia sp!, {r9, pc}
125
126HALDisplayOff_TREO650:
127	stmdb sp!, {r9, lr}
128	ldr r9, AddrPceCall
129	ldr r9, [r9, #0]
130	ldr	ip, [r9, #-4]
131	mov lr, pc
132	ldr	pc, [ip, #0x358]
133	ldmia sp!, {r9, pc}
134
135PalmCall:
136	stmdb sp!, {r9, lr}
137	mov ip, r0
138	mov r0, r1
139	mov r1, r2
140	mov r2, r3
141	ldr r3, [sp, #8]
142	ldr r9, AddrPceCall
143	ldr r9, [r9, #0]
144	mov lr, pc
145	mov pc, ip
146	ldmia sp!, {r9, pc}
147
148PalmCall2:
149	stmdb sp!, {r9, lr}
150
151	sub sp, sp, #16
152	ldr ip, [sp, #8+16+4]
153	ldr r9, [sp, #8+16+8]
154	str ip, [sp, #0]
155	str r9, [sp, #4]
156	ldr ip, [sp, #8+16+12]
157	ldr r9, [sp, #8+16+16]
158	str ip, [sp, #8]
159	str r9, [sp, #12]
160
161	mov ip, r0
162	mov r0, r1
163	mov r1, r2
164	mov r2, r3
165	ldr r3, [sp, #8+16]
166	ldr r9, AddrPceCall
167	ldr r9, [r9, #0]
168	mov lr, pc
169	mov pc, ip
170
171	add sp, sp, #16
172	ldmia sp!, {r9, pc}
173