Print this page
NEX-16819 loader UEFI support
Includes work by Toomas Soome <tsoome@me.com>
Upstream commits:
loader: pxe receive cleanup
9475 libefi: Do not return only if ReceiveFilter
installboot: should support efi system partition
8931 boot1.efi: scan all display modes rather than
loader: spinconsole updates
loader: gfx experiment to try GOP Blt() function.
sha1 build test
loader: add sha1 hash calculation
common/sha1: update for loader build
loader: biosdisk rework
uts: 32-bit kernel FB needs mapping in low memory
uts: add diag-device
uts: boot console mirror with diag-device
uts: enable very early console on ttya
kmdb: add diag-device as input/output device
uts: test VGA memory exclusion from mapping
uts: clear boot mapping and protect boot pages test
uts: add dboot map debug printf
uts: need to release FB pages in release_bootstrap()
uts: add screenmap ioctl
uts: update sys/queue.h
loader: add illumos uts/common to include path
loader: tem/gfx font cleanup
loader: vbe checks
uts: gfx_private set KD_TEXT when KD_RESETTEXT is
uts: gfx 8-bit update
loader: gfx 8-bit fix
loader: always set media size from partition.
uts: MB2 support for 32-bit kernel
loader: x86 should have tem 80x25
uts: x86 should have tem 80x25
uts: font update
loader: font update
uts: tem attributes
loader: tem.c comment added
uts: use font module
loader: add font module
loader: build rules for new font setup
uts: gfx_private update for new font structure
uts: early boot update for new font structure
uts: font update
uts: font build rules update for new fonts
uts: tem update to new font structure
loader: module.c needs to include tem_impl.h
uts: gfx_private 8x16 font rework
uts: make font_lookup public
loader: font rework
uts: font rework
9259 libefi: efi_alloc_and_read should check for PMBR
uts: tem utf-8 support
loader: implement tem utf-8 support
loader: tem should be able to display UTF-8
7784 uts: console input should support utf-8
7796 uts: ldterm default to utf-8
uts: do not reset serial console
uts: set up colors even if tem is not console
uts: add type for early boot properties
uts: gfx_private experiment with drm and vga
uts: gfx_private should use setmode drm callback.
uts: identify FB types and set up gfx_private based
loader: replace gop and vesa with framebuffer
uts: boot needs simple tem to support mdb
uts: boot_keyboard should emit esc sequences for
uts: gfx_private FB showuld be written by line
kmdb: set terminal window size
uts: gfx_private needs to keep track of early boot FB
pnglite: move pnglite to usr/src/common
loader: gfx_fb
ficl-sys: add gfx primitives
loader: add illumos.png logo
ficl: add fb-putimage
loader: add png support
loader: add alpha blending for gfx_fb
loader: use term-drawrect for menu frame
ficl: add simple gfx words
uts: provide fb_info via fbgattr dev_specific array.
uts: gfx_private add alpha blending
uts: update sys/ascii.h
uts: tem OSC support (incomplete)
uts: implement env module support and use data from
uts: tem get colors from early boot data
loader: use crc32 from libstand (libz)
loader: optimize for size
loader: pass tem info to the environment
loader: import tem for loader console
loader: UEFI loader needs to set ISADIR based on
loader: need UEFI32 support
8918 loader.efi: add vesa edid support
uts: tem_safe_pix_clear_prom_output() should only
uts: tem_safe_pix_clear_entire_screen() should use
uts: tem_safe_check_first_time() should query cursor
uts: tem implement cls callback & visual_io v4
uts: gfx_vgatext use block cursor for vgatext
uts: gfx_private implement cls callback & visual_io
uts: gfx_private bitmap framebuffer implementation
uts: early start frame buffer console support
uts: font functions should check the input char
uts: font rendering should support 16/24/32bit depths
uts: use smallest font as fallback default.
uts: update terminal dimensions based on selected
7834 uts: vgatext should use gfx_private
uts: add spacing property to 8859-1.bdf
terminfo: add underline for sun-color
terminfo: sun-color has 16 colors
uts: add font load callback type
loader: do not repeat int13 calls with error 0x20 and
8905 loader: add skein/edonr support
8904 common/crypto: make skein and edonr loader
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
Reviewed by: Sanjay Nadkarni <sanjay.nadkarni@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
Revert "NEX-16819 loader UEFI support"
This reverts commit ec06b9fc617b99234e538bf2e7e4d02a24993e0c.
Reverting due to failures in the zfs-tests and the sharefs-tests
NEX-16819 loader UEFI support
Includes work by Toomas Soome <tsoome@me.com>
Upstream commits:
loader: pxe receive cleanup
9475 libefi: Do not return only if ReceiveFilter
installboot: should support efi system partition
8931 boot1.efi: scan all display modes rather than
loader: spinconsole updates
loader: gfx experiment to try GOP Blt() function.
sha1 build test
loader: add sha1 hash calculation
common/sha1: update for loader build
loader: biosdisk rework
uts: 32-bit kernel FB needs mapping in low memory
uts: add diag-device
uts: boot console mirror with diag-device
uts: enable very early console on ttya
kmdb: add diag-device as input/output device
uts: test VGA memory exclusion from mapping
uts: clear boot mapping and protect boot pages test
uts: add dboot map debug printf
uts: need to release FB pages in release_bootstrap()
uts: add screenmap ioctl
uts: update sys/queue.h
loader: add illumos uts/common to include path
loader: tem/gfx font cleanup
loader: vbe checks
uts: gfx_private set KD_TEXT when KD_RESETTEXT is
uts: gfx 8-bit update
loader: gfx 8-bit fix
loader: always set media size from partition.
uts: MB2 support for 32-bit kernel
loader: x86 should have tem 80x25
uts: x86 should have tem 80x25
uts: font update
loader: font update
uts: tem attributes
loader: tem.c comment added
uts: use font module
loader: add font module
loader: build rules for new font setup
uts: gfx_private update for new font structure
uts: early boot update for new font structure
uts: font update
uts: font build rules update for new fonts
uts: tem update to new font structure
loader: module.c needs to include tem_impl.h
uts: gfx_private 8x16 font rework
uts: make font_lookup public
loader: font rework
uts: font rework
libefi: efi_alloc_and_read should check for PMBR
uts: tem utf-8 support
loader: implement tem utf-8 support
loader: tem should be able to display UTF-8
7784 uts: console input should support utf-8
7796 uts: ldterm default to utf-8
uts: do not reset serial console
uts: set up colors even if tem is not console
uts: add type for early boot properties
uts: gfx_private experiment with drm and vga
uts: gfx_private should use setmode drm callback.
uts: identify FB types and set up gfx_private based
loader: replace gop and vesa with framebuffer
uts: boot needs simple tem to support mdb
uts: boot_keyboard should emit esc sequences for
uts: gfx_private FB showuld be written by line
kmdb: set terminal window size
uts: gfx_private needs to keep track of early boot FB
pnglite: move pnglite to usr/src/common
loader: gfx_fb
ficl-sys: add gfx primitives
loader: add illumos.png logo
ficl: add fb-putimage
loader: add png support
loader: add alpha blending for gfx_fb
loader: use term-drawrect for menu frame
ficl: add simple gfx words
uts: provide fb_info via fbgattr dev_specific array.
uts: gfx_private add alpha blending
uts: update sys/ascii.h
uts: tem OSC support (incomplete)
uts: implement env module support and use data from
uts: tem get colors from early boot data
loader: use crc32 from libstand (libz)
loader: optimize for size
loader: pass tem info to the environment
loader: import tem for loader console
loader: UEFI loader needs to set ISADIR based on
loader: need UEFI32 support
8918 loader.efi: add vesa edid support
uts: tem_safe_pix_clear_prom_output() should only
uts: tem_safe_pix_clear_entire_screen() should use
uts: tem_safe_check_first_time() should query cursor
uts: tem implement cls callback & visual_io v4
uts: gfx_vgatext use block cursor for vgatext
uts: gfx_private implement cls callback & visual_io
uts: gfx_private bitmap framebuffer implementation
uts: early start frame buffer console support
uts: font functions should check the input char
uts: font rendering should support 16/24/32bit depths
uts: use smallest font as fallback default.
uts: update terminal dimensions based on selected
7834 uts: vgatext should use gfx_private
uts: add spacing property to 8859-1.bdf
terminfo: add underline for sun-color
terminfo: sun-color has 16 colors
uts: add font load callback type
loader: do not repeat int13 calls with error 0x20 and
8905 loader: add skein/edonr support
8904 common/crypto: make skein and edonr loader
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
Reviewed by: Sanjay Nadkarni <sanjay.nadkarni@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
| Split |
Close |
| Expand all |
| Collapse all |
--- old/usr/src/common/ficl/loader.c
+++ new/usr/src/common/ficl/loader.c
1 1 /*
2 2 * Copyright (c) 2000 Daniel Capo Sobral
3 3 * All rights reserved.
4 4 *
5 5 * Redistribution and use in source and binary forms, with or without
6 6 * modification, are permitted provided that the following conditions
7 7 * are met:
8 8 * 1. Redistributions of source code must retain the above copyright
9 9 * notice, this list of conditions and the following disclaimer.
10 10 * 2. Redistributions in binary form must reproduce the above copyright
11 11 * notice, this list of conditions and the following disclaimer in the
12 12 * documentation and/or other materials provided with the distribution.
13 13 *
14 14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 24 * SUCH DAMAGE.
25 25 *
26 26 * $FreeBSD$
27 27 */
28 28
29 29 /*
30 30 * l o a d e r . c
31 31 * Additional FICL words designed for FreeBSD's loader
32 32 */
33 33
34 34 #ifndef _STANDALONE
35 35 #include <sys/types.h>
36 36 #include <sys/stat.h>
37 37 #include <dirent.h>
38 38 #include <fcntl.h>
39 39 #include <stdio.h>
40 40 #include <stdlib.h>
41 41 #include <unistd.h>
42 42 #include <strings.h>
43 43 #include <termios.h>
|
↓ open down ↓ |
43 lines elided |
↑ open up ↑ |
44 44 #else
45 45 #include <stand.h>
46 46 #include "bootstrap.h"
47 47 #endif
48 48 #ifdef _STANDALONE
49 49 #include <uuid.h>
50 50 #else
51 51 #include <uuid/uuid.h>
52 52 #endif
53 53 #include <string.h>
54 +#include <gfx_fb.h>
54 55 #include "ficl.h"
55 56
56 57 /*
57 58 * FreeBSD's loader interaction words and extras
58 59 *
59 60 * setenv ( value n name n' -- )
60 61 * setenv? ( value n name n' flag -- )
61 62 * getenv ( addr n -- addr' n' | -1 )
62 63 * unsetenv ( addr n -- )
63 64 * copyin ( addr addr' len -- )
64 65 * copyout ( addr addr' len -- )
65 66 * findfile ( name len type len' -- addr )
66 67 * ccall ( [[...[p10] p9] ... p1] n addr -- result )
67 68 * uuid-from-string ( addr n -- addr' )
68 69 * uuid-to-string ( addr' -- addr n | -1 )
69 70 * .# ( value -- )
70 71 */
71 72
72 73 void
74 +ficl_fb_putimage(ficlVm *pVM)
75 +{
76 + char *namep, *name;
77 + int names, ret = 0;
78 + png_t png;
79 +
80 + FICL_STACK_CHECK(ficlVmGetDataStack(pVM), 2, 1);
81 +
82 + names = ficlStackPopInteger(ficlVmGetDataStack(pVM));
83 + namep = (char *)ficlStackPopPointer(ficlVmGetDataStack(pVM));
84 +
85 + name = ficlMalloc(names+1);
86 + if (!name)
87 + ficlVmThrowError(pVM, "Error: out of memory");
88 + strncpy(name, namep, names);
89 + name[names] = '\0';
90 +
91 + if ((ret = png_open(&png, name)) != PNG_NO_ERROR) {
92 + ret = 0;
93 + ficlFree(name);
94 + ficlStackPushInteger(ficlVmGetDataStack(pVM), ret);
95 + return;
96 + }
97 +
98 + if (gfx_fb_putimage(&png) == 0)
99 + ret = -1; /* success */
100 + png_close(&png);
101 + ficlFree(name);
102 + ficlStackPushInteger(ficlVmGetDataStack(pVM), ret);
103 +}
104 +
105 +void
106 +ficl_fb_setpixel(ficlVm *pVM)
107 +{
108 + uint32_t x, y;
109 +
110 + FICL_STACK_CHECK(ficlVmGetDataStack(pVM), 2, 0);
111 +
112 + y = ficlStackPopInteger(ficlVmGetDataStack(pVM));
113 + x = ficlStackPopInteger(ficlVmGetDataStack(pVM));
114 + gfx_fb_setpixel(x, y);
115 +}
116 +
117 +void
118 +ficl_fb_line(ficlVm *pVM)
119 +{
120 + uint32_t x0, y0, x1, y1, wd;
121 +
122 + FICL_STACK_CHECK(ficlVmGetDataStack(pVM), 5, 0);
123 +
124 + wd = ficlStackPopInteger(ficlVmGetDataStack(pVM));
125 + y1 = ficlStackPopInteger(ficlVmGetDataStack(pVM));
126 + x1 = ficlStackPopInteger(ficlVmGetDataStack(pVM));
127 + y0 = ficlStackPopInteger(ficlVmGetDataStack(pVM));
128 + x0 = ficlStackPopInteger(ficlVmGetDataStack(pVM));
129 + gfx_fb_line(x0, y0, x1, y1, wd);
130 +}
131 +
132 +void
133 +ficl_fb_bezier(ficlVm *pVM)
134 +{
135 + uint32_t x0, y0, x1, y1, x2, y2, width;
136 +
137 + FICL_STACK_CHECK(ficlVmGetDataStack(pVM), 7, 0);
138 +
139 + width = ficlStackPopInteger(ficlVmGetDataStack(pVM));
140 + y2 = ficlStackPopInteger(ficlVmGetDataStack(pVM));
141 + x2 = ficlStackPopInteger(ficlVmGetDataStack(pVM));
142 + y1 = ficlStackPopInteger(ficlVmGetDataStack(pVM));
143 + x1 = ficlStackPopInteger(ficlVmGetDataStack(pVM));
144 + y0 = ficlStackPopInteger(ficlVmGetDataStack(pVM));
145 + x0 = ficlStackPopInteger(ficlVmGetDataStack(pVM));
146 + gfx_fb_bezier(x0, y0, x1, y1, x2, y2, width);
147 +}
148 +
149 +void
150 +ficl_fb_drawrect(ficlVm *pVM)
151 +{
152 + uint32_t x1, x2, y1, y2, fill;
153 +
154 + FICL_STACK_CHECK(ficlVmGetDataStack(pVM), 5, 0);
155 +
156 + fill = ficlStackPopInteger(ficlVmGetDataStack(pVM));
157 + y2 = ficlStackPopInteger(ficlVmGetDataStack(pVM));
158 + x2 = ficlStackPopInteger(ficlVmGetDataStack(pVM));
159 + y1 = ficlStackPopInteger(ficlVmGetDataStack(pVM));
160 + x1 = ficlStackPopInteger(ficlVmGetDataStack(pVM));
161 + gfx_fb_drawrect(x1, y1, x2, y2, fill);
162 +}
163 +
164 +void
165 +ficl_term_drawrect(ficlVm *pVM)
166 +{
167 + uint32_t x1, x2, y1, y2;
168 +
169 + FICL_STACK_CHECK(ficlVmGetDataStack(pVM), 4, 0);
170 +
171 + y2 = ficlStackPopInteger(ficlVmGetDataStack(pVM));
172 + x2 = ficlStackPopInteger(ficlVmGetDataStack(pVM));
173 + y1 = ficlStackPopInteger(ficlVmGetDataStack(pVM));
174 + x1 = ficlStackPopInteger(ficlVmGetDataStack(pVM));
175 + gfx_term_drawrect(x1, y1, x2, y2);
176 +}
177 +
178 +void
73 179 ficlSetenv(ficlVm *pVM)
74 180 {
75 181 char *name, *value;
76 182 char *namep, *valuep;
77 183 int names, values;
78 184
79 185 FICL_STACK_CHECK(ficlVmGetDataStack(pVM), 4, 0);
80 186
81 187 names = ficlStackPopInteger(ficlVmGetDataStack(pVM));
82 188 namep = (char *)ficlStackPopPointer(ficlVmGetDataStack(pVM));
83 189 values = ficlStackPopInteger(ficlVmGetDataStack(pVM));
84 190 valuep = (char *)ficlStackPopPointer(ficlVmGetDataStack(pVM));
85 191
86 192 name = (char *)ficlMalloc(names+1);
87 193 if (!name)
88 194 ficlVmThrowError(pVM, "Error: out of memory");
89 195 strncpy(name, namep, names);
90 196 name[names] = '\0';
91 197 value = (char *)ficlMalloc(values+1);
92 198 if (!value)
93 199 ficlVmThrowError(pVM, "Error: out of memory");
94 200 strncpy(value, valuep, values);
95 201 value[values] = '\0';
96 202
97 203 setenv(name, value, 1);
98 204 ficlFree(name);
99 205 ficlFree(value);
100 206 }
101 207
102 208 void
103 209 ficlSetenvq(ficlVm *pVM)
104 210 {
105 211 char *name, *value;
106 212 char *namep, *valuep;
107 213 int names, values, overwrite;
108 214
109 215 FICL_STACK_CHECK(ficlVmGetDataStack(pVM), 5, 0);
110 216
111 217 overwrite = ficlStackPopInteger(ficlVmGetDataStack(pVM));
112 218 names = ficlStackPopInteger(ficlVmGetDataStack(pVM));
113 219 namep = (char *)ficlStackPopPointer(ficlVmGetDataStack(pVM));
114 220 values = ficlStackPopInteger(ficlVmGetDataStack(pVM));
115 221 valuep = (char *)ficlStackPopPointer(ficlVmGetDataStack(pVM));
116 222
117 223 name = (char *)ficlMalloc(names+1);
118 224 if (!name)
119 225 ficlVmThrowError(pVM, "Error: out of memory");
120 226 strncpy(name, namep, names);
121 227 name[names] = '\0';
122 228 value = (char *)ficlMalloc(values+1);
123 229 if (!value)
124 230 ficlVmThrowError(pVM, "Error: out of memory");
125 231 strncpy(value, valuep, values);
126 232 value[values] = '\0';
127 233
128 234 setenv(name, value, overwrite);
129 235 ficlFree(name);
130 236 ficlFree(value);
131 237 }
132 238
133 239 void
134 240 ficlGetenv(ficlVm *pVM)
135 241 {
136 242 char *name, *value;
137 243 char *namep;
138 244 int names;
139 245
140 246 FICL_STACK_CHECK(ficlVmGetDataStack(pVM), 2, 2);
141 247
142 248 names = ficlStackPopInteger(ficlVmGetDataStack(pVM));
143 249 namep = (char *)ficlStackPopPointer(ficlVmGetDataStack(pVM));
144 250
145 251 name = (char *)ficlMalloc(names+1);
146 252 if (!name)
147 253 ficlVmThrowError(pVM, "Error: out of memory");
148 254 strncpy(name, namep, names);
149 255 name[names] = '\0';
150 256
151 257 value = getenv(name);
152 258 ficlFree(name);
153 259
154 260 if (value != NULL) {
155 261 ficlStackPushPointer(ficlVmGetDataStack(pVM), value);
156 262 ficlStackPushInteger(ficlVmGetDataStack(pVM), strlen(value));
157 263 } else
158 264 ficlStackPushInteger(ficlVmGetDataStack(pVM), -1);
159 265 }
160 266
161 267 void
162 268 ficlUnsetenv(ficlVm *pVM)
163 269 {
164 270 char *name;
165 271 char *namep;
166 272 int names;
167 273
168 274 FICL_STACK_CHECK(ficlVmGetDataStack(pVM), 2, 0);
169 275
170 276 names = ficlStackPopInteger(ficlVmGetDataStack(pVM));
171 277 namep = (char *)ficlStackPopPointer(ficlVmGetDataStack(pVM));
172 278
173 279 name = (char *)ficlMalloc(names+1);
174 280 if (!name)
175 281 ficlVmThrowError(pVM, "Error: out of memory");
176 282 strncpy(name, namep, names);
177 283 name[names] = '\0';
178 284
179 285 unsetenv(name);
180 286 ficlFree(name);
181 287 }
182 288
183 289 void
184 290 ficlCopyin(ficlVm *pVM)
185 291 {
186 292 #ifdef _STANDALONE
187 293 void* src;
188 294 vm_offset_t dest;
189 295 size_t len;
190 296 #endif
191 297
192 298 FICL_STACK_CHECK(ficlVmGetDataStack(pVM), 3, 0);
193 299
194 300 #ifdef _STANDALONE
195 301 len = ficlStackPopInteger(ficlVmGetDataStack(pVM));
196 302 dest = ficlStackPopInteger(ficlVmGetDataStack(pVM));
197 303 src = ficlStackPopPointer(ficlVmGetDataStack(pVM));
198 304 archsw.arch_copyin(src, dest, len);
199 305 #else
200 306 (void) ficlStackPopInteger(ficlVmGetDataStack(pVM));
201 307 (void) ficlStackPopInteger(ficlVmGetDataStack(pVM));
202 308 (void) ficlStackPopPointer(ficlVmGetDataStack(pVM));
203 309 #endif
204 310 }
205 311
206 312 void
207 313 ficlCopyout(ficlVm *pVM)
208 314 {
209 315 #ifdef _STANDALONE
210 316 void* dest;
211 317 vm_offset_t src;
212 318 size_t len;
213 319 #endif
214 320
215 321 FICL_STACK_CHECK(ficlVmGetDataStack(pVM), 3, 0);
216 322
217 323 #ifdef _STANDALONE
218 324 len = ficlStackPopInteger(ficlVmGetDataStack(pVM));
219 325 dest = ficlStackPopPointer(ficlVmGetDataStack(pVM));
220 326 src = ficlStackPopInteger(ficlVmGetDataStack(pVM));
221 327 archsw.arch_copyout(src, dest, len);
222 328 #else
223 329 (void) ficlStackPopInteger(ficlVmGetDataStack(pVM));
224 330 (void) ficlStackPopPointer(ficlVmGetDataStack(pVM));
225 331 (void) ficlStackPopInteger(ficlVmGetDataStack(pVM));
226 332 #endif
227 333 }
228 334
229 335 void
230 336 ficlFindfile(ficlVm *pVM)
231 337 {
232 338 #ifdef _STANDALONE
233 339 char *name, *type;
234 340 char *namep, *typep;
235 341 int names, types;
236 342 #endif
237 343 struct preloaded_file *fp;
238 344
239 345 FICL_STACK_CHECK(ficlVmGetDataStack(pVM), 4, 1);
240 346
241 347 #ifdef _STANDALONE
242 348 types = ficlStackPopInteger(ficlVmGetDataStack(pVM));
243 349 typep = (char *)ficlStackPopPointer(ficlVmGetDataStack(pVM));
244 350 names = ficlStackPopInteger(ficlVmGetDataStack(pVM));
245 351 namep = (char *)ficlStackPopPointer(ficlVmGetDataStack(pVM));
246 352
247 353 name = (char *)ficlMalloc(names+1);
248 354 if (!name)
249 355 ficlVmThrowError(pVM, "Error: out of memory");
250 356 strncpy(name, namep, names);
251 357 name[names] = '\0';
252 358 type = (char *)ficlMalloc(types+1);
253 359 if (!type)
254 360 ficlVmThrowError(pVM, "Error: out of memory");
255 361 strncpy(type, typep, types);
256 362 type[types] = '\0';
257 363
258 364 fp = file_findfile(name, type);
259 365 #else
260 366 (void) ficlStackPopInteger(ficlVmGetDataStack(pVM));
261 367 (void) ficlStackPopPointer(ficlVmGetDataStack(pVM));
262 368 (void) ficlStackPopInteger(ficlVmGetDataStack(pVM));
263 369 (void) ficlStackPopPointer(ficlVmGetDataStack(pVM));
264 370
265 371 fp = NULL;
266 372 #endif
267 373 ficlStackPushPointer(ficlVmGetDataStack(pVM), fp);
268 374 }
269 375
270 376 void
271 377 ficlCcall(ficlVm *pVM)
272 378 {
273 379 int (*func)(int, ...);
274 380 int result, p[10];
275 381 int nparam, i;
276 382
277 383 FICL_STACK_CHECK(ficlVmGetDataStack(pVM), 2, 0);
278 384
279 385 func = (int (*)(int, ...))ficlStackPopPointer(ficlVmGetDataStack(pVM));
280 386 nparam = ficlStackPopInteger(ficlVmGetDataStack(pVM));
281 387
282 388 FICL_STACK_CHECK(ficlVmGetDataStack(pVM), nparam, 1);
283 389
284 390 for (i = 0; i < nparam; i++)
285 391 p[i] = ficlStackPopInteger(ficlVmGetDataStack(pVM));
286 392
287 393 result = func(p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7], p[8],
288 394 p[9]);
289 395
290 396 ficlStackPushInteger(ficlVmGetDataStack(pVM), result);
291 397 }
292 398
293 399 void
294 400 ficlUuidFromString(ficlVm *pVM)
295 401 {
296 402 char *uuid;
297 403 char *uuid_ptr;
298 404 int uuid_size;
299 405 uuid_t *u;
300 406 #ifdef _STANDALONE
301 407 uint32_t status;
302 408 #else
303 409 int status;
304 410 #endif
305 411
306 412 FICL_STACK_CHECK(ficlVmGetDataStack(pVM), 2, 0);
307 413
308 414 uuid_size = ficlStackPopInteger(ficlVmGetDataStack(pVM));
309 415 uuid_ptr = ficlStackPopPointer(ficlVmGetDataStack(pVM));
310 416
311 417 uuid = ficlMalloc(uuid_size + 1);
312 418 if (!uuid)
313 419 ficlVmThrowError(pVM, "Error: out of memory");
314 420 (void) memcpy(uuid, uuid_ptr, uuid_size);
315 421 uuid[uuid_size] = '\0';
316 422
317 423 u = ficlMalloc(sizeof (*u));
318 424 #ifdef _STANDALONE
319 425 uuid_from_string(uuid, u, &status);
320 426 ficlFree(uuid);
321 427 if (status != uuid_s_ok) {
322 428 ficlFree(u);
323 429 u = NULL;
324 430 }
325 431 #else
326 432 status = uuid_parse(uuid, *u);
327 433 ficlFree(uuid);
328 434 if (status != 0) {
329 435 ficlFree(u);
330 436 u = NULL;
331 437 }
332 438 #endif
333 439 ficlStackPushPointer(ficlVmGetDataStack(pVM), u);
334 440 }
335 441
336 442 void
337 443 ficlUuidToString(ficlVm *pVM)
338 444 {
339 445 char *uuid;
340 446 uuid_t *u;
341 447 #ifdef _STANDALONE
342 448 uint32_t status;
343 449 #endif
344 450
345 451 FICL_STACK_CHECK(ficlVmGetDataStack(pVM), 1, 0);
346 452
347 453 u = ficlStackPopPointer(ficlVmGetDataStack(pVM));
348 454 #ifdef _STANDALONE
349 455 uuid_to_string(u, &uuid, &status);
350 456 if (status == uuid_s_ok) {
351 457 ficlStackPushPointer(ficlVmGetDataStack(pVM), uuid);
352 458 ficlStackPushInteger(ficlVmGetDataStack(pVM), strlen(uuid));
353 459 } else
354 460 #else
355 461 uuid = ficlMalloc(UUID_PRINTABLE_STRING_LENGTH);
356 462 if (uuid != NULL) {
357 463 uuid_unparse(*u, uuid);
358 464 ficlStackPushPointer(ficlVmGetDataStack(pVM), uuid);
359 465 ficlStackPushInteger(ficlVmGetDataStack(pVM), strlen(uuid));
360 466 } else
361 467 #endif
362 468 ficlStackPushInteger(ficlVmGetDataStack(pVM), -1);
363 469 }
364 470
365 471 /*
366 472 * f i c l E x e c F D
367 473 * reads in text from file fd and passes it to ficlExec()
368 474 * returns FICL_VM_STATUS_OUT_OF_TEXT on success or the ficlExec() error
369 475 * code on failure.
370 476 */
371 477 #define nLINEBUF 256
372 478 int
373 479 ficlExecFD(ficlVm *pVM, int fd)
374 480 {
375 481 char cp[nLINEBUF];
376 482 int nLine = 0, rval = FICL_VM_STATUS_OUT_OF_TEXT;
377 483 char ch;
378 484 ficlCell id;
379 485 ficlString s;
380 486
381 487 id = pVM->sourceId;
382 488 pVM->sourceId.i = fd+1; /* in loader we can get 0, there is no stdin */
383 489
384 490 /* feed each line to ficlExec */
385 491 while (1) {
386 492 int status, i;
387 493
388 494 i = 0;
389 495 while ((status = read(fd, &ch, 1)) > 0 && ch != '\n')
390 496 cp[i++] = ch;
391 497 nLine++;
392 498 if (!i) {
393 499 if (status < 1)
394 500 break;
395 501 continue;
396 502 }
397 503 if (cp[i] == '\n')
398 504 cp[i] = '\0';
399 505
400 506 FICL_STRING_SET_POINTER(s, cp);
401 507 FICL_STRING_SET_LENGTH(s, i);
402 508
403 509 rval = ficlVmExecuteString(pVM, s);
404 510 if (rval != FICL_VM_STATUS_QUIT &&
405 511 rval != FICL_VM_STATUS_USER_EXIT &&
406 512 rval != FICL_VM_STATUS_OUT_OF_TEXT) {
407 513 pVM->sourceId = id;
408 514 (void) ficlVmEvaluate(pVM, "");
409 515 return (rval);
410 516 }
411 517 }
412 518 pVM->sourceId = id;
413 519
414 520 /*
415 521 * Pass an empty line with SOURCE-ID == -1 to flush
416 522 * any pending REFILLs (as required by FILE wordset)
417 523 */
418 524 (void) ficlVmEvaluate(pVM, "");
419 525
420 526 if (rval == FICL_VM_STATUS_USER_EXIT)
421 527 ficlVmThrow(pVM, FICL_VM_STATUS_USER_EXIT);
422 528
423 529 return (rval);
424 530 }
425 531
426 532 static void displayCellNoPad(ficlVm *pVM)
427 533 {
428 534 ficlCell c;
429 535 FICL_STACK_CHECK(ficlVmGetDataStack(pVM), 1, 0);
430 536
431 537 c = ficlStackPop(ficlVmGetDataStack(pVM));
432 538 ficlLtoa((c).i, pVM->pad, pVM->base);
433 539 ficlVmTextOut(pVM, pVM->pad);
434 540 }
435 541
436 542 /*
437 543 * isdir? - Return whether an fd corresponds to a directory.
438 544 *
439 545 * isdir? ( fd -- bool )
440 546 */
441 547 static void
442 548 isdirQuestion(ficlVm *pVM)
443 549 {
444 550 struct stat sb;
445 551 ficlInteger flag;
446 552 int fd;
447 553
448 554 FICL_STACK_CHECK(ficlVmGetDataStack(pVM), 1, 1);
449 555
450 556 fd = ficlStackPopInteger(ficlVmGetDataStack(pVM));
451 557 flag = FICL_FALSE;
452 558 do {
453 559 if (fd < 0)
454 560 break;
455 561 if (fstat(fd, &sb) < 0)
456 562 break;
457 563 if (!S_ISDIR(sb.st_mode))
458 564 break;
459 565 flag = FICL_TRUE;
460 566 } while (0);
461 567 ficlStackPushInteger(ficlVmGetDataStack(pVM), flag);
462 568 }
463 569
464 570 /*
465 571 * fopen - open a file and return new fd on stack.
466 572 *
467 573 * fopen ( ptr count mode -- fd )
468 574 */
469 575 extern char *get_dev(const char *);
470 576
471 577 static void
472 578 pfopen(ficlVm *pVM)
473 579 {
474 580 int mode, fd, count;
475 581 char *ptr, *name;
476 582 #ifndef _STANDALONE
477 583 char *tmp;
478 584 #endif
479 585
480 586 FICL_STACK_CHECK(ficlVmGetDataStack(pVM), 3, 1);
481 587
482 588 mode = ficlStackPopInteger(ficlVmGetDataStack(pVM)); /* get mode */
483 589 count = ficlStackPopInteger(ficlVmGetDataStack(pVM)); /* get count */
484 590 ptr = ficlStackPopPointer(ficlVmGetDataStack(pVM)); /* get ptr */
485 591
486 592 if ((count < 0) || (ptr == NULL)) {
487 593 ficlStackPushInteger(ficlVmGetDataStack(pVM), -1);
488 594 return;
489 595 }
490 596
491 597 /* ensure that the string is null terminated */
492 598 name = (char *)malloc(count+1);
493 599 bcopy(ptr, name, count);
494 600 name[count] = 0;
495 601 #ifndef _STANDALONE
496 602 tmp = get_dev(name);
497 603 free(name);
498 604 name = tmp;
499 605 #endif
500 606
501 607 /* open the file */
502 608 fd = open(name, mode);
503 609 free(name);
504 610 ficlStackPushInteger(ficlVmGetDataStack(pVM), fd);
505 611 }
506 612
507 613 /*
508 614 * fclose - close a file who's fd is on stack.
509 615 * fclose ( fd -- )
510 616 */
511 617 static void
512 618 pfclose(ficlVm *pVM)
513 619 {
514 620 int fd;
515 621
516 622 FICL_STACK_CHECK(ficlVmGetDataStack(pVM), 1, 0);
517 623
518 624 fd = ficlStackPopInteger(ficlVmGetDataStack(pVM)); /* get fd */
519 625 if (fd != -1)
520 626 close(fd);
521 627 }
522 628
523 629 /*
524 630 * fread - read file contents
525 631 * fread ( fd buf nbytes -- nread )
526 632 */
527 633 static void
528 634 pfread(ficlVm *pVM)
529 635 {
530 636 int fd, len;
531 637 char *buf;
532 638
533 639 FICL_STACK_CHECK(ficlVmGetDataStack(pVM), 3, 1);
534 640
535 641 len = ficlStackPopInteger(ficlVmGetDataStack(pVM));
536 642 buf = ficlStackPopPointer(ficlVmGetDataStack(pVM)); /* get buffer */
537 643 fd = ficlStackPopInteger(ficlVmGetDataStack(pVM)); /* get fd */
538 644 if (len > 0 && buf && fd != -1)
539 645 ficlStackPushInteger(ficlVmGetDataStack(pVM),
540 646 read(fd, buf, len));
541 647 else
542 648 ficlStackPushInteger(ficlVmGetDataStack(pVM), -1);
543 649 }
544 650
545 651 /*
546 652 * fopendir - open directory
547 653 *
548 654 * fopendir ( addr len -- ptr TRUE | FALSE )
549 655 */
550 656 static void pfopendir(ficlVm *pVM)
551 657 {
552 658 #ifndef _STANDALONE
553 659 DIR *dir;
554 660 char *tmp;
555 661 #else
556 662 struct stat sb;
557 663 int fd;
558 664 #endif
559 665 int count;
560 666 char *ptr, *name;
561 667 ficlInteger flag = FICL_FALSE;
562 668
563 669 FICL_STACK_CHECK(ficlVmGetDataStack(pVM), 2, 1);
564 670
565 671 count = ficlStackPopInteger(ficlVmGetDataStack(pVM));
566 672 ptr = ficlStackPopPointer(ficlVmGetDataStack(pVM)); /* get ptr */
567 673
568 674 if ((count < 0) || (ptr == NULL)) {
569 675 ficlStackPushInteger(ficlVmGetDataStack(pVM), -1);
570 676 return;
571 677 }
572 678 /* ensure that the string is null terminated */
573 679 name = (char *)malloc(count+1);
574 680 bcopy(ptr, name, count);
575 681 name[count] = 0;
576 682 #ifndef _STANDALONE
577 683 tmp = get_dev(name);
578 684 free(name);
579 685 name = tmp;
580 686 #else
581 687 fd = open(name, O_RDONLY);
582 688 free(name);
583 689 do {
584 690 if (fd < 0)
585 691 break;
586 692 if (fstat(fd, &sb) < 0)
587 693 break;
588 694 if (!S_ISDIR(sb.st_mode))
589 695 break;
590 696 flag = FICL_TRUE;
591 697 ficlStackPushInteger(ficlVmGetDataStack(pVM), fd);
592 698 ficlStackPushInteger(ficlVmGetDataStack(pVM), flag);
593 699 return;
594 700 } while (0);
595 701
596 702 if (fd >= 0)
597 703 close(fd);
598 704
599 705 ficlStackPushInteger(ficlVmGetDataStack(pVM), flag);
600 706 return;
601 707 #endif
602 708 #ifndef _STANDALONE
603 709 dir = opendir(name);
604 710 if (dir == NULL) {
605 711 ficlStackPushInteger(ficlVmGetDataStack(pVM), flag);
606 712 return;
607 713 } else
608 714 flag = FICL_TRUE;
609 715
610 716 ficlStackPushPointer(ficlVmGetDataStack(pVM), dir);
611 717 ficlStackPushInteger(ficlVmGetDataStack(pVM), flag);
612 718 #endif
613 719 }
614 720
615 721 /*
616 722 * freaddir - read directory contents
617 723 * freaddir ( fd -- ptr len TRUE | FALSE )
618 724 */
619 725 static void
620 726 pfreaddir(ficlVm *pVM)
621 727 {
622 728 #ifndef _STANDALONE
623 729 static DIR *dir = NULL;
624 730 #else
625 731 int fd;
626 732 #endif
627 733 struct dirent *d = NULL;
628 734
629 735 FICL_STACK_CHECK(ficlVmGetDataStack(pVM), 1, 3);
630 736 /*
631 737 * libstand readdir does not always return . nor .. so filter
632 738 * them out to have consistent behaviour.
633 739 */
634 740 #ifndef _STANDALONE
635 741 dir = ficlStackPopPointer(ficlVmGetDataStack(pVM));
636 742 if (dir != NULL)
637 743 do {
638 744 d = readdir(dir);
639 745 if (d != NULL && strcmp(d->d_name, ".") == 0)
640 746 continue;
641 747 if (d != NULL && strcmp(d->d_name, "..") == 0)
642 748 continue;
643 749 break;
644 750 } while (d != NULL);
645 751 #else
646 752 fd = ficlStackPopInteger(ficlVmGetDataStack(pVM));
647 753 if (fd != -1)
648 754 do {
649 755 d = readdirfd(fd);
650 756 if (d != NULL && strcmp(d->d_name, ".") == 0)
651 757 continue;
652 758 if (d != NULL && strcmp(d->d_name, "..") == 0)
653 759 continue;
654 760 break;
655 761 } while (d != NULL);
656 762 #endif
657 763 if (d != NULL) {
658 764 ficlStackPushPointer(ficlVmGetDataStack(pVM), d->d_name);
659 765 ficlStackPushInteger(ficlVmGetDataStack(pVM),
660 766 strlen(d->d_name));
661 767 ficlStackPushInteger(ficlVmGetDataStack(pVM), FICL_TRUE);
662 768 } else {
663 769 ficlStackPushInteger(ficlVmGetDataStack(pVM), FICL_FALSE);
664 770 }
665 771 }
666 772
667 773 /*
668 774 * fclosedir - close a dir on stack.
669 775 *
670 776 * fclosedir ( fd -- )
671 777 */
672 778 static void
673 779 pfclosedir(ficlVm *pVM)
674 780 {
675 781 #ifndef _STANDALONE
676 782 DIR *dir;
677 783 #else
678 784 int fd;
679 785 #endif
680 786
681 787 FICL_STACK_CHECK(ficlVmGetDataStack(pVM), 1, 0);
682 788
683 789 #ifndef _STANDALONE
684 790 dir = ficlStackPopPointer(ficlVmGetDataStack(pVM)); /* get dir */
685 791 if (dir != NULL)
686 792 closedir(dir);
687 793 #else
688 794 fd = ficlStackPopInteger(ficlVmGetDataStack(pVM)); /* get fd */
689 795 if (fd != -1)
690 796 close(fd);
691 797 #endif
692 798 }
693 799
694 800 /*
695 801 * fload - interpret file contents
696 802 *
697 803 * fload ( fd -- )
698 804 */
699 805 static void pfload(ficlVm *pVM)
700 806 {
701 807 int fd;
702 808
703 809 FICL_STACK_CHECK(ficlVmGetDataStack(pVM), 1, 0);
704 810
705 811 fd = ficlStackPopInteger(ficlVmGetDataStack(pVM)); /* get fd */
706 812 if (fd != -1)
707 813 ficlExecFD(pVM, fd);
708 814 }
709 815
710 816 /*
711 817 * fwrite - write file contents
712 818 *
713 819 * fwrite ( fd buf nbytes -- nwritten )
714 820 */
715 821 static void
716 822 pfwrite(ficlVm *pVM)
717 823 {
718 824 int fd, len;
719 825 char *buf;
720 826
721 827 FICL_STACK_CHECK(ficlVmGetDataStack(pVM), 3, 1);
722 828
723 829 len = ficlStackPopInteger(ficlVmGetDataStack(pVM)); /* bytes to read */
724 830 buf = ficlStackPopPointer(ficlVmGetDataStack(pVM)); /* get buffer */
725 831 fd = ficlStackPopInteger(ficlVmGetDataStack(pVM)); /* get fd */
726 832 if (len > 0 && buf && fd != -1)
727 833 ficlStackPushInteger(ficlVmGetDataStack(pVM),
728 834 write(fd, buf, len));
729 835 else
730 836 ficlStackPushInteger(ficlVmGetDataStack(pVM), -1);
731 837 }
732 838
733 839 /*
734 840 * fseek - seek to a new position in a file
735 841 *
736 842 * fseek ( fd ofs whence -- pos )
737 843 */
738 844 static void
739 845 pfseek(ficlVm *pVM)
740 846 {
741 847 int fd, pos, whence;
742 848
743 849 FICL_STACK_CHECK(ficlVmGetDataStack(pVM), 3, 1);
744 850
745 851 whence = ficlStackPopInteger(ficlVmGetDataStack(pVM));
746 852 pos = ficlStackPopInteger(ficlVmGetDataStack(pVM));
747 853 fd = ficlStackPopInteger(ficlVmGetDataStack(pVM));
748 854 ficlStackPushInteger(ficlVmGetDataStack(pVM), lseek(fd, pos, whence));
749 855 }
750 856
751 857 /*
752 858 * key - get a character from stdin
753 859 *
754 860 * key ( -- char )
755 861 */
756 862 static void
757 863 key(ficlVm *pVM)
758 864 {
759 865 FICL_STACK_CHECK(ficlVmGetDataStack(pVM), 0, 1);
760 866
761 867 ficlStackPushInteger(ficlVmGetDataStack(pVM), getchar());
762 868 }
763 869
764 870 /*
765 871 * key? - check for a character from stdin (FACILITY)
766 872 * key? ( -- flag )
767 873 */
768 874 static void
769 875 keyQuestion(ficlVm *pVM)
770 876 {
771 877 #ifndef _STANDALONE
772 878 char ch = -1;
773 879 struct termios oldt;
774 880 struct termios newt;
775 881 #endif
776 882
777 883 FICL_STACK_CHECK(ficlVmGetDataStack(pVM), 0, 1);
778 884
779 885 #ifndef _STANDALONE
780 886 tcgetattr(STDIN_FILENO, &oldt);
781 887 newt = oldt;
782 888 newt.c_lflag &= ~(ICANON | ECHO);
783 889 newt.c_cc[VMIN] = 0;
784 890 newt.c_cc[VTIME] = 0;
785 891 tcsetattr(STDIN_FILENO, TCSANOW, &newt);
786 892 ch = getchar();
787 893 tcsetattr(STDIN_FILENO, TCSANOW, &oldt);
788 894
789 895 if (ch != -1)
790 896 (void) ungetc(ch, stdin);
791 897
792 898 ficlStackPushInteger(ficlVmGetDataStack(pVM),
793 899 ch != -1? FICL_TRUE : FICL_FALSE);
794 900 #else
795 901 ficlStackPushInteger(ficlVmGetDataStack(pVM),
796 902 ischar()? FICL_TRUE : FICL_FALSE);
797 903 #endif
798 904 }
799 905
800 906 /*
801 907 * seconds - gives number of seconds since beginning of time
802 908 *
803 909 * beginning of time is defined as:
804 910 *
805 911 * BTX - number of seconds since midnight
806 912 * FreeBSD - number of seconds since Jan 1 1970
807 913 *
808 914 * seconds ( -- u )
809 915 */
810 916 static void
811 917 pseconds(ficlVm *pVM)
812 918 {
813 919 FICL_STACK_CHECK(ficlVmGetDataStack(pVM), 0, 1);
814 920
815 921 ficlStackPushUnsigned(ficlVmGetDataStack(pVM),
816 922 (ficlUnsigned) time(NULL));
817 923 }
818 924
819 925 /*
820 926 * ms - wait at least that many milliseconds (FACILITY)
821 927 * ms ( u -- )
822 928 */
823 929 static void
824 930 ms(ficlVm *pVM)
825 931 {
826 932 FICL_STACK_CHECK(ficlVmGetDataStack(pVM), 1, 0);
827 933
828 934 #ifndef _STANDALONE
829 935 usleep(ficlStackPopUnsigned(ficlVmGetDataStack(pVM)) * 1000);
830 936 #else
831 937 delay(ficlStackPopUnsigned(ficlVmGetDataStack(pVM)) * 1000);
832 938 #endif
833 939 }
834 940
835 941 /*
836 942 * fkey - get a character from a file
837 943 * fkey ( file -- char )
838 944 */
839 945 static void
840 946 fkey(ficlVm *pVM)
841 947 {
842 948 int i, fd;
843 949 char ch;
844 950
845 951 FICL_STACK_CHECK(ficlVmGetDataStack(pVM), 1, 1);
846 952
847 953 fd = ficlStackPopInteger(ficlVmGetDataStack(pVM));
848 954 i = read(fd, &ch, 1);
849 955 ficlStackPushInteger(ficlVmGetDataStack(pVM), i > 0 ? ch : -1);
850 956 }
851 957
852 958 /*
853 959 * Retrieves free space remaining on the dictionary
854 960 */
855 961 static void
856 962 freeHeap(ficlVm *pVM)
857 963 {
858 964 ficlStackPushInteger(ficlVmGetDataStack(pVM),
859 965 ficlDictionaryCellsAvailable(ficlVmGetDictionary(pVM)));
860 966 }
861 967
862 968 /*
863 969 * f i c l C o m p i l e P l a t f o r m
864 970 * Build FreeBSD platform extensions into the system dictionary
865 971 */
866 972 void
867 973 ficlSystemCompilePlatform(ficlSystem *pSys)
868 974 {
869 975 ficlDictionary *dp = ficlSystemGetDictionary(pSys);
870 976 ficlDictionary *env = ficlSystemGetEnvironment(pSys);
871 977 #ifdef _STANDALONE
872 978 ficlCompileFcn **fnpp;
873 979 #endif
874 980
875 981 FICL_SYSTEM_ASSERT(pSys, dp);
876 982 FICL_SYSTEM_ASSERT(pSys, env);
877 983
878 984 ficlDictionarySetPrimitive(dp, ".#", displayCellNoPad,
879 985 FICL_WORD_DEFAULT);
880 986 ficlDictionarySetPrimitive(dp, "isdir?", isdirQuestion,
881 987 FICL_WORD_DEFAULT);
882 988 ficlDictionarySetPrimitive(dp, "fopen", pfopen, FICL_WORD_DEFAULT);
883 989 ficlDictionarySetPrimitive(dp, "fclose", pfclose, FICL_WORD_DEFAULT);
884 990 ficlDictionarySetPrimitive(dp, "fread", pfread, FICL_WORD_DEFAULT);
885 991 ficlDictionarySetPrimitive(dp, "fopendir", pfopendir,
886 992 FICL_WORD_DEFAULT);
887 993 ficlDictionarySetPrimitive(dp, "freaddir", pfreaddir,
888 994 FICL_WORD_DEFAULT);
889 995 ficlDictionarySetPrimitive(dp, "fclosedir", pfclosedir,
890 996 FICL_WORD_DEFAULT);
891 997 ficlDictionarySetPrimitive(dp, "fload", pfload, FICL_WORD_DEFAULT);
892 998 ficlDictionarySetPrimitive(dp, "fkey", fkey, FICL_WORD_DEFAULT);
893 999 ficlDictionarySetPrimitive(dp, "fseek", pfseek, FICL_WORD_DEFAULT);
894 1000 ficlDictionarySetPrimitive(dp, "fwrite", pfwrite, FICL_WORD_DEFAULT);
895 1001 ficlDictionarySetPrimitive(dp, "key", key, FICL_WORD_DEFAULT);
896 1002 ficlDictionarySetPrimitive(dp, "key?", keyQuestion, FICL_WORD_DEFAULT);
897 1003 ficlDictionarySetPrimitive(dp, "ms", ms, FICL_WORD_DEFAULT);
898 1004 ficlDictionarySetPrimitive(dp, "seconds", pseconds, FICL_WORD_DEFAULT);
899 1005 ficlDictionarySetPrimitive(dp, "heap?", freeHeap, FICL_WORD_DEFAULT);
900 1006
901 1007 ficlDictionarySetPrimitive(dp, "setenv", ficlSetenv, FICL_WORD_DEFAULT);
902 1008 ficlDictionarySetPrimitive(dp, "setenv?", ficlSetenvq,
903 1009 FICL_WORD_DEFAULT);
904 1010 ficlDictionarySetPrimitive(dp, "getenv", ficlGetenv, FICL_WORD_DEFAULT);
905 1011 ficlDictionarySetPrimitive(dp, "unsetenv", ficlUnsetenv,
906 1012 FICL_WORD_DEFAULT);
|
↓ open down ↓ |
824 lines elided |
↑ open up ↑ |
907 1013 ficlDictionarySetPrimitive(dp, "copyin", ficlCopyin, FICL_WORD_DEFAULT);
908 1014 ficlDictionarySetPrimitive(dp, "copyout", ficlCopyout,
909 1015 FICL_WORD_DEFAULT);
910 1016 ficlDictionarySetPrimitive(dp, "findfile", ficlFindfile,
911 1017 FICL_WORD_DEFAULT);
912 1018 ficlDictionarySetPrimitive(dp, "ccall", ficlCcall, FICL_WORD_DEFAULT);
913 1019 ficlDictionarySetPrimitive(dp, "uuid-from-string", ficlUuidFromString,
914 1020 FICL_WORD_DEFAULT);
915 1021 ficlDictionarySetPrimitive(dp, "uuid-to-string", ficlUuidToString,
916 1022 FICL_WORD_DEFAULT);
1023 + ficlDictionarySetPrimitive(dp, "fb-setpixel", ficl_fb_setpixel,
1024 + FICL_WORD_DEFAULT);
1025 + ficlDictionarySetPrimitive(dp, "fb-line", ficl_fb_line,
1026 + FICL_WORD_DEFAULT);
1027 + ficlDictionarySetPrimitive(dp, "fb-bezier", ficl_fb_bezier,
1028 + FICL_WORD_DEFAULT);
1029 + ficlDictionarySetPrimitive(dp, "fb-drawrect", ficl_fb_drawrect,
1030 + FICL_WORD_DEFAULT);
1031 + ficlDictionarySetPrimitive(dp, "fb-putimage", ficl_fb_putimage,
1032 + FICL_WORD_DEFAULT);
1033 + ficlDictionarySetPrimitive(dp, "term-drawrect", ficl_term_drawrect,
1034 + FICL_WORD_DEFAULT);
917 1035 #ifdef _STANDALONE
918 1036 /* Register words from linker set. */
919 1037 SET_FOREACH(fnpp, Xficl_compile_set)
920 1038 (*fnpp)(pSys);
921 1039 #endif
922 1040
923 1041 #if defined(__i386__) || defined(__amd64__)
924 1042 ficlDictionarySetConstant(env, "arch-i386", FICL_TRUE);
925 1043 ficlDictionarySetConstant(env, "arch-sparc", FICL_FALSE);
926 1044 #endif
927 1045 #ifdef __sparc
928 1046 ficlDictionarySetConstant(env, "arch-i386", FICL_FALSE);
929 1047 ficlDictionarySetConstant(env, "arch-sparc", FICL_TRUE);
930 1048 #endif
931 1049 }
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX