]>
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 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
23 * sl_words.c - Forth and C code for the sl_words package.
25 * Copyright (c) 1998-2002 Apple Computer, Inc.
33 void InitDebugWords(void);
36 extern const char gMacParts
[];
37 extern const char *gControl2Source
[];
41 long InitSLWords(void)
45 result
= Interpret(0, 1,
49 // Create the slWords pseudo-device
50 " \" /packages\" find-device"
52 " \" sl_words\" device-name"
57 // Define all sl words here.
59 // init the outputLevel
60 " 0 value outputLevel"
62 // slw_set_output_level ( level -- )
63 " : slw_set_output_level"
64 " dup 0= if 0 stdout ! then"
69 " : slw_emit 2 outputLevel <= if emit else drop then ;"
72 " : slw_cr 2 outputLevel <= if cr then ;"
74 // Static init stuff for keyboard
78 // slw_init_keymap ( keyboardIH -- keyMap )
81 " keyMap dup 20 0 fill"
85 " : slw_update_keymap { ; dpth }"
88 " \" get-key-map\" keyboardIH $call-method"
89 " depth dpth - 1 = if 20 then"
91 " dup i 4 * + l@ keyMap i 4 * + tuck l@ or swap l!"
96 // Set up the spin cursor stuff.
103 " 0 value cursorFrames"
104 " 0 value cursorPixelSize"
105 " 0 value cursorStage"
106 " 0 value cursorTime"
107 " 0 value cursorDelay"
111 " screenIH 0<> cursorAddr 0<> and if"
112 " get-msecs dup cursorTime - cursorDelay >= if"
115 " cursorStage 1+ cursorFrames mod dup to cursorStage"
116 " cursorW cursorH * cursorPixelSize * * cursorAddr +"
117 " cursorX cursorY cursorW cursorH"
118 " \" draw-rectangle\" screenIH $call-method"
125 // slw_spin_init ( screenIH cursorAddr cursorX cursorY cursorW cursorH--)
127 " dup FFFF and to cursorH 10 >> drop"
128 " dup FFFF and to cursorW 10 >> to cursorPixelSize"
129 " dup FFFF and to cursorY 10 >> d# 1000 swap / to cursorDelay"
130 " dup FFFF and to cursorX 10 >> to cursorFrames"
131 " to cursorAddr to screenIH"
132 " ['] slw_spin to spin"
135 // slw_pwd ( phandle addr len -- act )
137 " ['] pwd 138 - execute"
140 // slw_sum ( adr len -- sum )
141 " : slw_sum { adr len }"
143 " dup 1 and if 10000 or then"
144 " 1 >> adr i + c@ + ffff and"
150 " 0 0 \" sl_words\" $open-package"
154 if (result
!= kCINoError
) return result
;
155 if (SLWordsIH
== 0) return kCIError
;
157 if (gOFVersion
< kOFVersion3x
) {
158 result
= Interpret(1, 0,
159 " dev /packages/obp-tftp"
162 if (result
!= kCINoError
) return result
;
165 if (gOFVersion
< kOFVersion3x
) {
166 result
= Interpret(1, 0,
167 " dev /packages/mac-parts"
168 " \" lame\" device-name"
173 if (result
!= kCINoError
) return result
;
176 if (gOFVersion
< kOFVersion2x
) {
177 for(cnt
= 0; gControl2Source
[cnt
] != '\0'; cnt
++) {
178 result
= Interpret(0, 0, gControl2Source
[cnt
]);
179 if (result
== kCIError
) return kCIError
;
180 if (result
== kCICatch
) return kCINoError
;
192 void InitDebugWords(void)
196 " : .sc ?state-valid ci-regs 4+ l@ l@ dup 0= \" Bad Stack\" (abort\")"
197 " cr .\" Stack Trace\""
198 " begin dup while dup 8 + l@ cr u. l@ repeat drop ;"
203 void SetOutputLevel(long level
)
205 CallMethod(1, 0, SLWordsIH
, "slw_set_output_level", level
);
209 char *InitKeyMap(CICell keyboardIH
)
214 ret
= CallMethod(1, 1, SLWordsIH
, "slw_init_keymap",
215 keyboardIH
, (CICell
*)&keyMap
);
216 if (ret
!= kCINoError
) return NULL
;
221 void UpdateKeyMap(void)
223 CallMethod(0, 0, SLWordsIH
, "slw_update_keymap");
227 void SpinInit(CICell screenIH
, char *cursorAddr
,
228 long cursorX
, long cursorY
,
229 long cursorW
, long cursorH
,
230 long frames
, long fps
,
231 long pixelSize
, long spare
)
233 CallMethod(6, 0, SLWordsIH
, "slw_spin_init",
234 screenIH
, (long)cursorAddr
,
235 cursorX
| (frames
<< 16),
236 cursorY
| (fps
<< 16),
237 cursorW
| (pixelSize
<< 16),
238 cursorH
| (spare
<< 16));
243 CallMethod(0, 0, SLWordsIH
, "slw_spin");
247 long GetPackageProperty(CICell phandle
, char *propName
,
248 char **propAddr
, long *propLen
)
250 long ret
, nameLen
= strlen(propName
);
252 ret
= Interpret(3, 2, "get-package-property if 0 0 then",
253 (CICell
)propName
, nameLen
, phandle
,
254 (CICell
*)propAddr
, (CICell
*)propLen
);
255 if ((ret
!= kCINoError
) || (*propAddr
== NULL
)) return -1;