]>
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-2000 Apple Computer, Inc.
33 void InitDebugWords(void);
36 extern const char gMacParts
[];
37 extern const char *gControl2Source
[];
41 long InitSLWords(long ofVers
)
45 result
= Interpret_1_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.
102 " 0 value cursorAddr"
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"
119 " cursorStage 1+ 3 mod dup to cursorStage"
120 " cursorW * cursorH * cursorAddr +"
121 " cursorX cursorY cursorW cursorH"
122 " \" draw-rectangle\" screenIH $call-method"
124 " cursorStage 1+ 6 mod dup to cursorStage"
125 " dup 3 > if 6 swap - then dup >r"
126 " 1+ cursorW * cursorPixelSize * cursorAddr +"
127 " cursorX cursorY cursorW cursorH r> 1+ -"
128 " \" draw-rectangle\" screenIH $call-method"
136 // slw_spin_init ( screenIH cursorAddr cursorX cursorY cursorW cursorH --)
138 " to cursorH to cursorW"
139 " to cursorY to cursorX"
140 " to cursorAddr to screenIH"
141 " d# 111 to cursorDelay"
142 " ['] slw_spin to spin"
145 // slw_spin_init2 ( screenIH cursorAddr cursorX cursorY cursorW cursorH--)
148 " to cursorH dup FFFF and to cursorW 10 >> to cursorPixelSize"
149 " to cursorY to cursorX"
150 " to cursorAddr to screenIH"
151 " d# 50 to cursorDelay"
152 " ['] slw_spin to spin"
155 // slw_pwd ( phandle addr len -- act )
157 " ['] pwd 138 - execute"
160 // slw_sum ( adr len -- sum )
161 " : slw_sum { adr len }"
163 " dup 1 and if 10000 or then"
164 " 1 >> adr i + c@ + ffff and"
170 " 0 0 \" sl_words\" $open-package"
172 , ofVers
, &SLWordsIH
);
174 if (result
!= kCINoError
) return result
;
175 if (SLWordsIH
== 0) return kCIError
;
177 if (gOFVersion
< kOFVersion3x
) {
178 result
= Interpret_1_0
180 " dev /packages/obp-tftp"
183 if (result
!= kCINoError
) return result
;
186 if (gOFVersion
< kOFVersion3x
) {
187 result
= Interpret_1_0
189 " dev /packages/mac-parts"
190 " \" lame\" device-name"
195 if (result
!= kCINoError
) return result
;
198 if (gOFVersion
< kOFVersion2x
) {
199 for(cnt
= 0; gControl2Source
[cnt
] != '\0'; cnt
++) {
200 result
= Interpret_0_0(gControl2Source
[cnt
]);
201 if (result
== kCIError
) return kCIError
;
202 if (result
== kCICatch
) return kCINoError
;
214 void InitDebugWords(void)
219 " : .sc ?state-valid ci-regs 4+ l@ l@ dup 0= \" Bad Stack\" (abort\")"
220 " cr .\" Stack Trace\""
221 " begin dup while dup 8 + l@ cr u. l@ repeat drop ;"
226 void SetOutputLevel(long level
)
228 CallMethod_1_0(SLWordsIH
, "slw_set_output_level", level
);
232 char *InitKeyMap(CICell keyboardIH
)
237 ret
= CallMethod_1_1(SLWordsIH
, "slw_init_keymap",
238 keyboardIH
, (CICell
*)&keyMap
);
239 if (ret
!= kCINoError
) return NULL
;
244 void UpdateKeyMap(void)
246 CallMethod_0_0(SLWordsIH
, "slw_update_keymap");
250 void SpinInit(long spinType
, CICell screenIH
, char *cursorAddr
,
251 long cursorX
, long cursorY
, long cursorW
, long cursorH
,
255 CallMethod_6_0(SLWordsIH
, "slw_spin_init",
256 screenIH
, (long)cursorAddr
,
257 cursorX
, cursorY
, cursorW
, cursorH
);
259 CallMethod_6_0(SLWordsIH
, "slw_spin_init2",
260 screenIH
, (long)cursorAddr
,
261 cursorX
, cursorY
, cursorW
| pixelSize
<< 16, cursorH
);
267 CallMethod_0_0(SLWordsIH
, "slw_spin");
270 long GetPackageProperty(CICell phandle
, char *propName
,
271 char **propAddr
, long *propLen
)
273 long ret
, nameLen
= strlen(propName
);
275 ret
= Interpret_3_2("get-package-property if 0 0 then",
276 phandle
, nameLen
, (CICell
)propName
,
277 (CICell
*)propLen
, (CICell
*)propAddr
);
278 if ((ret
!= kCINoError
) || (*propAddr
== NULL
)) return -1;