]>
git.saurik.com Git - apple/bootx.git/blob - bootx.tproj/ci.subproj/sl_words.c
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
23 * @APPLE_LICENSE_HEADER_END@
26 * sl_words.c - Forth and C code for the sl_words package.
28 * Copyright (c) 1998-2002 Apple Computer, Inc.
36 void InitDebugWords(void);
39 extern const char gMacParts
[];
40 extern const char *gControl2Source
[];
44 long InitSLWords(void)
48 result
= Interpret(0, 1,
52 // Create the slWords pseudo-device
53 " \" /packages\" find-device"
55 " \" sl_words\" device-name"
60 // Define all sl words here.
62 // init the outputLevel
63 " 0 value outputLevel"
65 // slw_set_output_level ( level -- )
66 " : slw_set_output_level"
67 " dup 0= if 0 stdout ! then"
72 " : slw_emit 2 outputLevel <= if emit else drop then ;"
75 " : slw_cr 2 outputLevel <= if cr then ;"
77 // Static init stuff for keyboard
81 // slw_init_keymap ( keyboardIH -- keyMap )
84 " keyMap dup 20 0 fill"
88 " : slw_update_keymap { ; dpth }"
91 " \" get-key-map\" keyboardIH $call-method"
92 " depth dpth - 1 = if 20 then"
94 " dup i 4 * + l@ keyMap i 4 * + tuck l@ or swap l!"
99 // Set up the spin cursor stuff.
101 " 0 value cursorAddr"
106 " 0 value cursorFrames"
107 " 0 value cursorPixelSize"
108 " 0 value cursorStage"
109 " 0 value cursorTime"
110 " 0 value cursorDelay"
114 " screenIH 0<> cursorAddr 0<> and if"
115 " get-msecs dup cursorTime - cursorDelay >= if"
118 " cursorStage 1+ cursorFrames mod dup to cursorStage"
119 " cursorW cursorH * cursorPixelSize * * cursorAddr +"
120 " cursorX cursorY cursorW cursorH"
121 " \" draw-rectangle\" screenIH $call-method"
128 // slw_spin_init ( screenIH cursorAddr cursorX cursorY cursorW cursorH--)
130 " dup FFFF and to cursorH 10 >> drop"
131 " dup FFFF and to cursorW 10 >> to cursorPixelSize"
132 " dup FFFF and to cursorY 10 >> d# 1000 swap / to cursorDelay"
133 " dup FFFF and to cursorX 10 >> to cursorFrames"
134 " to cursorAddr to screenIH"
135 " ['] slw_spin to spin"
138 // slw_pwd ( phandle addr len -- act )
140 " ['] pwd 138 - execute"
143 // slw_sum ( adr len -- sum )
144 " : slw_sum { adr len }"
146 " dup 1 and if 10000 or then"
147 " 1 >> adr i + c@ + ffff and"
153 " 0 0 \" sl_words\" $open-package"
157 if (result
!= kCINoError
) return result
;
158 if (SLWordsIH
== 0) return kCIError
;
160 if (gOFVersion
< kOFVersion3x
) {
161 result
= Interpret(1, 0,
162 " dev /packages/obp-tftp"
165 if (result
!= kCINoError
) return result
;
168 if (gOFVersion
< kOFVersion3x
) {
169 result
= Interpret(1, 0,
170 " dev /packages/mac-parts"
171 " \" lame\" device-name"
176 if (result
!= kCINoError
) return result
;
179 if (gOFVersion
< kOFVersion2x
) {
180 for(cnt
= 0; gControl2Source
[cnt
] != '\0'; cnt
++) {
181 result
= Interpret(0, 0, gControl2Source
[cnt
]);
182 if (result
== kCIError
) return kCIError
;
183 if (result
== kCICatch
) return kCINoError
;
195 void InitDebugWords(void)
199 " : .sc ?state-valid ci-regs 4+ l@ l@ dup 0= \" Bad Stack\" (abort\")"
200 " cr .\" Stack Trace\""
201 " begin dup while dup 8 + l@ cr u. l@ repeat drop ;"
206 void SetOutputLevel(long level
)
208 CallMethod(1, 0, SLWordsIH
, "slw_set_output_level", level
);
212 char *InitKeyMap(CICell keyboardIH
)
217 ret
= CallMethod(1, 1, SLWordsIH
, "slw_init_keymap",
218 keyboardIH
, (CICell
*)&keyMap
);
219 if (ret
!= kCINoError
) return NULL
;
224 void UpdateKeyMap(void)
226 CallMethod(0, 0, SLWordsIH
, "slw_update_keymap");
230 void SpinInit(CICell screenIH
, char *cursorAddr
,
231 long cursorX
, long cursorY
,
232 long cursorW
, long cursorH
,
233 long frames
, long fps
,
234 long pixelSize
, long spare
)
236 CallMethod(6, 0, SLWordsIH
, "slw_spin_init",
237 screenIH
, (long)cursorAddr
,
238 cursorX
| (frames
<< 16),
239 cursorY
| (fps
<< 16),
240 cursorW
| (pixelSize
<< 16),
241 cursorH
| (spare
<< 16));
246 CallMethod(0, 0, SLWordsIH
, "slw_spin");
250 long GetPackageProperty(CICell phandle
, char *propName
,
251 char **propAddr
, long *propLen
)
253 long ret
, nameLen
= strlen(propName
);
255 ret
= Interpret(3, 2, "get-package-property if 0 0 then",
256 (CICell
)propName
, nameLen
, phandle
,
257 (CICell
*)propAddr
, (CICell
*)propLen
);
258 if ((ret
!= kCINoError
) || (*propAddr
== NULL
)) return -1;