17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*25cf1a30Sjl139090 * Common Development and Distribution License (the "License"). 6*25cf1a30Sjl139090 * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 22*25cf1a30Sjl139090 * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 23*25cf1a30Sjl139090 * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 277c478bd9Sstevel@tonic-gate 287c478bd9Sstevel@tonic-gate #include <stdio.h> 297c478bd9Sstevel@tonic-gate #include <stdlib.h> 307c478bd9Sstevel@tonic-gate #include <stddef.h> 317c478bd9Sstevel@tonic-gate #include <string.h> 327c478bd9Sstevel@tonic-gate 337c478bd9Sstevel@tonic-gate #include <fcode/private.h> 347c478bd9Sstevel@tonic-gate #include <fcode/log.h> 357c478bd9Sstevel@tonic-gate 367c478bd9Sstevel@tonic-gate #include <fcdriver/fcdriver.h> 377c478bd9Sstevel@tonic-gate 387c478bd9Sstevel@tonic-gate #define MIN_VALUES 100 397c478bd9Sstevel@tonic-gate 407c478bd9Sstevel@tonic-gate static void 417c478bd9Sstevel@tonic-gate check_my_self(fcode_env_t *env, char *fn) 427c478bd9Sstevel@tonic-gate { 437c478bd9Sstevel@tonic-gate if (!MYSELF) 447c478bd9Sstevel@tonic-gate forth_abort(env, "%s: MYSELF is NULL", fn); 457c478bd9Sstevel@tonic-gate } 467c478bd9Sstevel@tonic-gate 477c478bd9Sstevel@tonic-gate uint_t 487c478bd9Sstevel@tonic-gate get_number_of_parent_address_cells(fcode_env_t *env) 497c478bd9Sstevel@tonic-gate { 507c478bd9Sstevel@tonic-gate uint_t ncells; 517c478bd9Sstevel@tonic-gate device_t *d; 527c478bd9Sstevel@tonic-gate static char func_name[] = "get_number_of_parent_address_cells"; 537c478bd9Sstevel@tonic-gate 547c478bd9Sstevel@tonic-gate if (MYSELF == NULL) /* Kludge for testing */ 557c478bd9Sstevel@tonic-gate return (2); 567c478bd9Sstevel@tonic-gate d = MYSELF->device; 577c478bd9Sstevel@tonic-gate ncells = d->parent_adr_cells; 587c478bd9Sstevel@tonic-gate if (ncells == 0) { 597c478bd9Sstevel@tonic-gate ncells = get_default_intprop(env, "#address-cells", d->parent, 607c478bd9Sstevel@tonic-gate 2); 617c478bd9Sstevel@tonic-gate if (ncells > MAX_MY_ADDR) { 627c478bd9Sstevel@tonic-gate log_message(MSG_ERROR, "%s: %s:" 637c478bd9Sstevel@tonic-gate " ncells (%d) > MAX_MY_ADDR (%d)\n", func_name, 647c478bd9Sstevel@tonic-gate get_path(env, d->parent), ncells, MAX_MY_ADDR); 657c478bd9Sstevel@tonic-gate ncells = MAX_MY_ADDR; 667c478bd9Sstevel@tonic-gate } 677c478bd9Sstevel@tonic-gate d->parent_adr_cells = ncells; 687c478bd9Sstevel@tonic-gate } 697c478bd9Sstevel@tonic-gate return (ncells); 707c478bd9Sstevel@tonic-gate } 717c478bd9Sstevel@tonic-gate 727c478bd9Sstevel@tonic-gate instance_t * 737c478bd9Sstevel@tonic-gate create_ihandle(fcode_env_t *env, device_t *phandle, instance_t *parent) 747c478bd9Sstevel@tonic-gate { 757c478bd9Sstevel@tonic-gate instance_t *ihandle; 767c478bd9Sstevel@tonic-gate int i; 777c478bd9Sstevel@tonic-gate 787c478bd9Sstevel@tonic-gate ihandle = MALLOC(sizeof (instance_t)); 797c478bd9Sstevel@tonic-gate 807c478bd9Sstevel@tonic-gate i = max(phandle->data_size[INIT_DATA], MIN_VALUES); 817c478bd9Sstevel@tonic-gate ihandle->data[INIT_DATA] = MALLOC(sizeof (fstack_t) * i); 827c478bd9Sstevel@tonic-gate memcpy(ihandle->data[INIT_DATA], phandle->init_data, 837c478bd9Sstevel@tonic-gate (size_t) (sizeof (fstack_t) * i)); 847c478bd9Sstevel@tonic-gate 857c478bd9Sstevel@tonic-gate i = max(phandle->data_size[UINIT_DATA], MIN_VALUES); 867c478bd9Sstevel@tonic-gate ihandle->data[UINIT_DATA] = MALLOC(sizeof (fstack_t) * i); 877c478bd9Sstevel@tonic-gate 887c478bd9Sstevel@tonic-gate ihandle->my_space = phandle->my_space; 897c478bd9Sstevel@tonic-gate memcpy(ihandle->my_addr, phandle->my_addr, sizeof (ihandle->my_addr)); 907c478bd9Sstevel@tonic-gate ihandle->parent = parent; 917c478bd9Sstevel@tonic-gate ihandle->device = phandle; 927c478bd9Sstevel@tonic-gate return (ihandle); 937c478bd9Sstevel@tonic-gate } 947c478bd9Sstevel@tonic-gate 957c478bd9Sstevel@tonic-gate device_t * 967c478bd9Sstevel@tonic-gate create_phandle(fcode_env_t *env, device_t *parent) 977c478bd9Sstevel@tonic-gate { 987c478bd9Sstevel@tonic-gate device_t *phandle; 997c478bd9Sstevel@tonic-gate 1007c478bd9Sstevel@tonic-gate phandle = MALLOC(sizeof (device_t)); 1017c478bd9Sstevel@tonic-gate phandle->init_data = MALLOC(sizeof (fstack_t) * MIN_VALUES); 1027c478bd9Sstevel@tonic-gate phandle->data_size[INIT_DATA] = 0; 1037c478bd9Sstevel@tonic-gate phandle->data_size[UINIT_DATA] = 0; 1047c478bd9Sstevel@tonic-gate phandle->parent = parent; 1057c478bd9Sstevel@tonic-gate return (phandle); 1067c478bd9Sstevel@tonic-gate } 1077c478bd9Sstevel@tonic-gate 1087c478bd9Sstevel@tonic-gate 1097c478bd9Sstevel@tonic-gate static void 1107c478bd9Sstevel@tonic-gate do_push_package(fcode_env_t *env, device_t *d) 1117c478bd9Sstevel@tonic-gate { 1127c478bd9Sstevel@tonic-gate do_previous(env); 1137c478bd9Sstevel@tonic-gate do_also(env); 1147c478bd9Sstevel@tonic-gate if (d != NULL) { 1157c478bd9Sstevel@tonic-gate CONTEXT = (token_t *)(&d->vocabulary); 1167c478bd9Sstevel@tonic-gate debug_msg(DEBUG_CONTEXT, "CONTEXT:push_package: %s%d/%p/%p\n", 1177c478bd9Sstevel@tonic-gate get_path(env, d), env->order_depth, CONTEXT, env->current); 1187c478bd9Sstevel@tonic-gate } 1197c478bd9Sstevel@tonic-gate } 1207c478bd9Sstevel@tonic-gate 1217c478bd9Sstevel@tonic-gate static void 1227c478bd9Sstevel@tonic-gate push_package(fcode_env_t *env) 1237c478bd9Sstevel@tonic-gate { 1247c478bd9Sstevel@tonic-gate device_t *d; 1257c478bd9Sstevel@tonic-gate phandle_t ph; 1267c478bd9Sstevel@tonic-gate 1277c478bd9Sstevel@tonic-gate CHECK_DEPTH(env, 1, "push-package"); 1287c478bd9Sstevel@tonic-gate ph = POP(DS); 1297c478bd9Sstevel@tonic-gate CONVERT_PHANDLE(env, d, ph); 1307c478bd9Sstevel@tonic-gate do_push_package(env, d); 1317c478bd9Sstevel@tonic-gate } 1327c478bd9Sstevel@tonic-gate 1337c478bd9Sstevel@tonic-gate static void 1347c478bd9Sstevel@tonic-gate pop_package(fcode_env_t *env) 1357c478bd9Sstevel@tonic-gate { 1367c478bd9Sstevel@tonic-gate do_previous(env); 1377c478bd9Sstevel@tonic-gate do_definitions(env); 1387c478bd9Sstevel@tonic-gate } 1397c478bd9Sstevel@tonic-gate 1407c478bd9Sstevel@tonic-gate static void 1417c478bd9Sstevel@tonic-gate interpose(fcode_env_t *env) 1427c478bd9Sstevel@tonic-gate { 1437c478bd9Sstevel@tonic-gate TODO; /* interpose - not yet implemented */ 1447c478bd9Sstevel@tonic-gate } 1457c478bd9Sstevel@tonic-gate 1467c478bd9Sstevel@tonic-gate void 1477c478bd9Sstevel@tonic-gate activate_device(fcode_env_t *env, device_t *d) 1487c478bd9Sstevel@tonic-gate { 1497c478bd9Sstevel@tonic-gate env->current_device = d; 1507c478bd9Sstevel@tonic-gate do_push_package(env, d); 1517c478bd9Sstevel@tonic-gate do_definitions(env); 1527c478bd9Sstevel@tonic-gate } 1537c478bd9Sstevel@tonic-gate 1547c478bd9Sstevel@tonic-gate void 1557c478bd9Sstevel@tonic-gate deactivate_device(fcode_env_t *env, device_t *d) 1567c478bd9Sstevel@tonic-gate { 1577c478bd9Sstevel@tonic-gate env->current_device = d; 1587c478bd9Sstevel@tonic-gate do_previous(env); 1597c478bd9Sstevel@tonic-gate if (d != NULL) { 1607c478bd9Sstevel@tonic-gate CONTEXT = (token_t *)(&d->vocabulary); 1617c478bd9Sstevel@tonic-gate debug_msg(DEBUG_CONTEXT, "CONTEXT:deactivate_device:" 1627c478bd9Sstevel@tonic-gate " %s%d/%p/%p\n", get_path(env, d), env->order_depth, 1637c478bd9Sstevel@tonic-gate CONTEXT, env->current); 1647c478bd9Sstevel@tonic-gate } 1657c478bd9Sstevel@tonic-gate do_definitions(env); 1667c478bd9Sstevel@tonic-gate } 1677c478bd9Sstevel@tonic-gate 1687c478bd9Sstevel@tonic-gate /* 1697c478bd9Sstevel@tonic-gate * Starfire hack to set '/' device_type to 'upa' 1707c478bd9Sstevel@tonic-gate */ 1717c478bd9Sstevel@tonic-gate #include <sys/systeminfo.h> 1727c478bd9Sstevel@tonic-gate static void 1737c478bd9Sstevel@tonic-gate starfire_hack(fcode_env_t *env) 1747c478bd9Sstevel@tonic-gate { 1757c478bd9Sstevel@tonic-gate char platform[100]; 1767c478bd9Sstevel@tonic-gate 1777c478bd9Sstevel@tonic-gate sysinfo(SI_PLATFORM, platform, sizeof (platform)); 1787c478bd9Sstevel@tonic-gate if (strcmp(platform, "SUNW,Ultra-Enterprise-10000") == 0 && 1797c478bd9Sstevel@tonic-gate find_property(env->root_node, "device_type") == NULL) { 1807c478bd9Sstevel@tonic-gate create_string_prop(env, "device_type", "upa"); 1817c478bd9Sstevel@tonic-gate } 1827c478bd9Sstevel@tonic-gate } 1837c478bd9Sstevel@tonic-gate 1847c478bd9Sstevel@tonic-gate void 1857c478bd9Sstevel@tonic-gate root_node(fcode_env_t *env) 1867c478bd9Sstevel@tonic-gate { 1877c478bd9Sstevel@tonic-gate do_also(env); 1887c478bd9Sstevel@tonic-gate activate_device(env, env->root_node); 1897c478bd9Sstevel@tonic-gate starfire_hack(env); 1907c478bd9Sstevel@tonic-gate } 1917c478bd9Sstevel@tonic-gate 1927c478bd9Sstevel@tonic-gate void 1937c478bd9Sstevel@tonic-gate child_node(fcode_env_t *env) 1947c478bd9Sstevel@tonic-gate { 1957c478bd9Sstevel@tonic-gate device_t *d; 1967c478bd9Sstevel@tonic-gate 1977c478bd9Sstevel@tonic-gate CHECK_DEPTH(env, 1, "child"); 1987c478bd9Sstevel@tonic-gate CONVERT_PHANDLE(env, d, TOS); 1997c478bd9Sstevel@tonic-gate TOS = (fstack_t)d->child; 2007c478bd9Sstevel@tonic-gate REVERT_PHANDLE(env, TOS, d->child); 2017c478bd9Sstevel@tonic-gate } 2027c478bd9Sstevel@tonic-gate 2037c478bd9Sstevel@tonic-gate void 2047c478bd9Sstevel@tonic-gate peer_node(fcode_env_t *env) 2057c478bd9Sstevel@tonic-gate { 2067c478bd9Sstevel@tonic-gate device_t *d; 2077c478bd9Sstevel@tonic-gate 2087c478bd9Sstevel@tonic-gate CHECK_DEPTH(env, 1, "peer"); 2097c478bd9Sstevel@tonic-gate CONVERT_PHANDLE(env, d, TOS); 2107c478bd9Sstevel@tonic-gate REVERT_PHANDLE(env, TOS, d->peer); 2117c478bd9Sstevel@tonic-gate } 2127c478bd9Sstevel@tonic-gate 2137c478bd9Sstevel@tonic-gate void 2147c478bd9Sstevel@tonic-gate new_device(fcode_env_t *env) 2157c478bd9Sstevel@tonic-gate { 2167c478bd9Sstevel@tonic-gate device_t *phandle, *parent; 2177c478bd9Sstevel@tonic-gate device_t *peer; 2187c478bd9Sstevel@tonic-gate 2197c478bd9Sstevel@tonic-gate check_my_self(env, "new-device"); 2207c478bd9Sstevel@tonic-gate 2217c478bd9Sstevel@tonic-gate parent = MYSELF->device; 2227c478bd9Sstevel@tonic-gate phandle = create_phandle(env, parent); 2237c478bd9Sstevel@tonic-gate MYSELF = create_ihandle(env, phandle, MYSELF); 2247c478bd9Sstevel@tonic-gate activate_device(env, phandle); 2257c478bd9Sstevel@tonic-gate if (parent->child) { 2267c478bd9Sstevel@tonic-gate /* Insert new child at end of peer list */ 2277c478bd9Sstevel@tonic-gate for (peer = parent->child; peer->peer; peer = peer->peer) 2287c478bd9Sstevel@tonic-gate ; 2297c478bd9Sstevel@tonic-gate peer->peer = phandle; 2307c478bd9Sstevel@tonic-gate } else 2317c478bd9Sstevel@tonic-gate parent->child = phandle; /* First child */ 2327c478bd9Sstevel@tonic-gate ALLOCATE_PHANDLE(env); 2337c478bd9Sstevel@tonic-gate } 2347c478bd9Sstevel@tonic-gate 2357c478bd9Sstevel@tonic-gate void 2367c478bd9Sstevel@tonic-gate finish_device(fcode_env_t *env) 2377c478bd9Sstevel@tonic-gate { 2387c478bd9Sstevel@tonic-gate fstack_t *mem; 2397c478bd9Sstevel@tonic-gate device_t *my_dev, *parent_dev; 2407c478bd9Sstevel@tonic-gate instance_t *parent, *myself = MYSELF; 2417c478bd9Sstevel@tonic-gate int n; 2427c478bd9Sstevel@tonic-gate 2437c478bd9Sstevel@tonic-gate check_my_self(env, "finish-device"); 2447c478bd9Sstevel@tonic-gate ASSERT(myself->device); 2457c478bd9Sstevel@tonic-gate ASSERT(env->current_device); 2467c478bd9Sstevel@tonic-gate n = myself->device->data_size[INIT_DATA]; 2477c478bd9Sstevel@tonic-gate 2487c478bd9Sstevel@tonic-gate /* 2497c478bd9Sstevel@tonic-gate * Paranoia.. reserve a little more instance data than we need 2507c478bd9Sstevel@tonic-gate */ 2517c478bd9Sstevel@tonic-gate mem = MALLOC(sizeof (fstack_t) * (n+8)); 2527c478bd9Sstevel@tonic-gate memcpy(mem, MYSELF->device->init_data, sizeof (fstack_t) * n); 2537c478bd9Sstevel@tonic-gate FREE(myself->device->init_data); 2547c478bd9Sstevel@tonic-gate my_dev = myself->device; 2557c478bd9Sstevel@tonic-gate my_dev->init_data = mem; 2567c478bd9Sstevel@tonic-gate parent = MYSELF->parent; 2577c478bd9Sstevel@tonic-gate parent_dev = env->current_device->parent; 2587c478bd9Sstevel@tonic-gate FREE(MYSELF); 2597c478bd9Sstevel@tonic-gate MYSELF = parent; 2607c478bd9Sstevel@tonic-gate activate_device(env, parent_dev); 2617c478bd9Sstevel@tonic-gate } 2627c478bd9Sstevel@tonic-gate 2637c478bd9Sstevel@tonic-gate static void 2647c478bd9Sstevel@tonic-gate create_internal_value(fcode_env_t *env, char *name, int offset, int token) 2657c478bd9Sstevel@tonic-gate { 2667c478bd9Sstevel@tonic-gate header(env, name, strlen(name), 0); 2677c478bd9Sstevel@tonic-gate COMPILE_TOKEN(&noop); 2687c478bd9Sstevel@tonic-gate EXPOSE_ACF; 2697c478bd9Sstevel@tonic-gate if (token) { 2707c478bd9Sstevel@tonic-gate SET_TOKEN(token, 0, name, LINK_TO_ACF(env->lastlink)); 2717c478bd9Sstevel@tonic-gate } 2727c478bd9Sstevel@tonic-gate PUSH(DS, offset); 2737c478bd9Sstevel@tonic-gate lcomma(env); 2747c478bd9Sstevel@tonic-gate set_internal_value_actions(env); 2757c478bd9Sstevel@tonic-gate } 2767c478bd9Sstevel@tonic-gate 2777c478bd9Sstevel@tonic-gate static void 2787c478bd9Sstevel@tonic-gate create_my_self(fcode_env_t *env) 2797c478bd9Sstevel@tonic-gate { 2807c478bd9Sstevel@tonic-gate int offset = offsetof(fcode_env_t, my_self); 2817c478bd9Sstevel@tonic-gate 2827c478bd9Sstevel@tonic-gate create_internal_value(env, "my-self", offset, 0x203); 2837c478bd9Sstevel@tonic-gate } 2847c478bd9Sstevel@tonic-gate 2857c478bd9Sstevel@tonic-gate static void 2867c478bd9Sstevel@tonic-gate create_my_space(fcode_env_t *env) 2877c478bd9Sstevel@tonic-gate { 2887c478bd9Sstevel@tonic-gate int offset = offsetof(instance_t, my_space); 2897c478bd9Sstevel@tonic-gate 2907c478bd9Sstevel@tonic-gate create_internal_value(env, "my-space", -offset, 0x103); 2917c478bd9Sstevel@tonic-gate } 2927c478bd9Sstevel@tonic-gate 2937c478bd9Sstevel@tonic-gate void 2947c478bd9Sstevel@tonic-gate my_address(fcode_env_t *env) 2957c478bd9Sstevel@tonic-gate { 2967c478bd9Sstevel@tonic-gate fstack_t *adr_ptr; 2977c478bd9Sstevel@tonic-gate uint_t ncells; 2987c478bd9Sstevel@tonic-gate 2997c478bd9Sstevel@tonic-gate check_my_self(env, "my-address"); 3007c478bd9Sstevel@tonic-gate ncells = get_number_of_parent_address_cells(env); 3017c478bd9Sstevel@tonic-gate adr_ptr = MYSELF->my_addr; 3027c478bd9Sstevel@tonic-gate while (--ncells) { 3037c478bd9Sstevel@tonic-gate PUSH(DS, *adr_ptr); 3047c478bd9Sstevel@tonic-gate adr_ptr++; 3057c478bd9Sstevel@tonic-gate } 3067c478bd9Sstevel@tonic-gate } 3077c478bd9Sstevel@tonic-gate 3087c478bd9Sstevel@tonic-gate void 3097c478bd9Sstevel@tonic-gate my_unit(fcode_env_t *env) 3107c478bd9Sstevel@tonic-gate { 3117c478bd9Sstevel@tonic-gate check_my_self(env, "my-unit"); 3127c478bd9Sstevel@tonic-gate my_address(env); 3137c478bd9Sstevel@tonic-gate PUSH(DS, MYSELF->my_space); 3147c478bd9Sstevel@tonic-gate } 3157c478bd9Sstevel@tonic-gate 3167c478bd9Sstevel@tonic-gate static void 3177c478bd9Sstevel@tonic-gate my_args(fcode_env_t *env) 3187c478bd9Sstevel@tonic-gate { 3197c478bd9Sstevel@tonic-gate check_my_self(env, "my-args"); 3207c478bd9Sstevel@tonic-gate PUSH(DS, (fstack_t)MYSELF->my_args); 3217c478bd9Sstevel@tonic-gate PUSH(DS, (fstack_t)MYSELF->my_args_len); 3227c478bd9Sstevel@tonic-gate } 3237c478bd9Sstevel@tonic-gate 3247c478bd9Sstevel@tonic-gate int 3257c478bd9Sstevel@tonic-gate call_my_parent(fcode_env_t *env, char *method) 3267c478bd9Sstevel@tonic-gate { 3277c478bd9Sstevel@tonic-gate push_a_string(env, method); 3287c478bd9Sstevel@tonic-gate dollar_call_parent(env); 3297c478bd9Sstevel@tonic-gate return (env->last_error); 3307c478bd9Sstevel@tonic-gate } 3317c478bd9Sstevel@tonic-gate 3327c478bd9Sstevel@tonic-gate void 3337c478bd9Sstevel@tonic-gate set_args(fcode_env_t *env) 3347c478bd9Sstevel@tonic-gate { 3357c478bd9Sstevel@tonic-gate int args_len; 3367c478bd9Sstevel@tonic-gate common_data_t *cdp; 3377c478bd9Sstevel@tonic-gate uint_t ncells; 3387c478bd9Sstevel@tonic-gate fstack_t *adr_ptr, *adr_ptr1, space; 3397c478bd9Sstevel@tonic-gate 3407c478bd9Sstevel@tonic-gate CHECK_DEPTH(env, 4, "set-args"); 3417c478bd9Sstevel@tonic-gate 3427c478bd9Sstevel@tonic-gate check_my_self(env, "set-args"); 3437c478bd9Sstevel@tonic-gate 3447c478bd9Sstevel@tonic-gate /* 3457c478bd9Sstevel@tonic-gate * Handle args argument of set-args. 3467c478bd9Sstevel@tonic-gate */ 3477c478bd9Sstevel@tonic-gate if (MYSELF->my_args) { 3487c478bd9Sstevel@tonic-gate FREE(MYSELF->my_args); 3497c478bd9Sstevel@tonic-gate MYSELF->my_args = NULL; 3507c478bd9Sstevel@tonic-gate } 3517c478bd9Sstevel@tonic-gate two_swap(env); 3527c478bd9Sstevel@tonic-gate MYSELF->my_args = pop_a_duped_string(env, &args_len); 3537c478bd9Sstevel@tonic-gate MYSELF->my_args_len = args_len; 3547c478bd9Sstevel@tonic-gate 3557c478bd9Sstevel@tonic-gate if (call_my_parent(env, "decode-unit")) 3567c478bd9Sstevel@tonic-gate forth_abort(env, "set-args: decode-unit failed"); 3577c478bd9Sstevel@tonic-gate 3587c478bd9Sstevel@tonic-gate ncells = get_number_of_parent_address_cells(env); 3597c478bd9Sstevel@tonic-gate 3607c478bd9Sstevel@tonic-gate /* 3617c478bd9Sstevel@tonic-gate * Kludge: For GP2, my-space comes from decode-unit hi.address. 3627c478bd9Sstevel@tonic-gate * for PCI, my-space from decode-unit won't have the bus#, so we need 3637c478bd9Sstevel@tonic-gate * to get it from config_address. Unfortunately, there is no easy 3647c478bd9Sstevel@tonic-gate * way to figure out here which one we're looking at. We take the 3657c478bd9Sstevel@tonic-gate * expediant of or'ing the two values together. 3667c478bd9Sstevel@tonic-gate */ 3677c478bd9Sstevel@tonic-gate space = POP(DS); /* pop phys.hi */ 3687c478bd9Sstevel@tonic-gate if ((cdp = (common_data_t *)env->private) != NULL) 3697c478bd9Sstevel@tonic-gate space |= cdp->fc.config_address; 3707c478bd9Sstevel@tonic-gate 3717c478bd9Sstevel@tonic-gate MYSELF->device->my_space = MYSELF->my_space = space; 3727c478bd9Sstevel@tonic-gate 3737c478bd9Sstevel@tonic-gate adr_ptr = MYSELF->my_addr; 3747c478bd9Sstevel@tonic-gate adr_ptr1 = MYSELF->device->my_addr; 3757c478bd9Sstevel@tonic-gate while (--ncells) { 3767c478bd9Sstevel@tonic-gate *adr_ptr++ = *adr_ptr1++ = POP(DS); 3777c478bd9Sstevel@tonic-gate } 3787c478bd9Sstevel@tonic-gate } 3797c478bd9Sstevel@tonic-gate 3807c478bd9Sstevel@tonic-gate void 3817c478bd9Sstevel@tonic-gate my_parent(fcode_env_t *env) 3827c478bd9Sstevel@tonic-gate { 3837c478bd9Sstevel@tonic-gate check_my_self(env, "my-parent"); 3847c478bd9Sstevel@tonic-gate PUSH(DS, (fstack_t)MYSELF->parent); 3857c478bd9Sstevel@tonic-gate } 3867c478bd9Sstevel@tonic-gate 3877c478bd9Sstevel@tonic-gate instance_t * 3887c478bd9Sstevel@tonic-gate open_instance_chain(fcode_env_t *env, device_t *phandle, int exec) 3897c478bd9Sstevel@tonic-gate { 3907c478bd9Sstevel@tonic-gate instance_t *parent; 3917c478bd9Sstevel@tonic-gate 3927c478bd9Sstevel@tonic-gate if (!phandle) 3937c478bd9Sstevel@tonic-gate return (NULL); 3947c478bd9Sstevel@tonic-gate parent = open_instance_chain(env, phandle->parent, exec); 3957c478bd9Sstevel@tonic-gate return (create_ihandle(env, phandle, parent)); 3967c478bd9Sstevel@tonic-gate } 3977c478bd9Sstevel@tonic-gate 3987c478bd9Sstevel@tonic-gate void 3997c478bd9Sstevel@tonic-gate close_instance_chain(fcode_env_t *env, instance_t *ihandle, int exec) 4007c478bd9Sstevel@tonic-gate { 4017c478bd9Sstevel@tonic-gate instance_t *parent; 4027c478bd9Sstevel@tonic-gate 4037c478bd9Sstevel@tonic-gate if (ihandle) { 4047c478bd9Sstevel@tonic-gate parent = ihandle->parent; 4057c478bd9Sstevel@tonic-gate close_instance_chain(env, parent, exec); 4067c478bd9Sstevel@tonic-gate if (ihandle->my_args) 4077c478bd9Sstevel@tonic-gate FREE(ihandle->my_args); 4087c478bd9Sstevel@tonic-gate FREE(ihandle); 4097c478bd9Sstevel@tonic-gate } 4107c478bd9Sstevel@tonic-gate } 4117c478bd9Sstevel@tonic-gate 4127c478bd9Sstevel@tonic-gate void 4137c478bd9Sstevel@tonic-gate begin_package(fcode_env_t *env) 4147c478bd9Sstevel@tonic-gate { 4157c478bd9Sstevel@tonic-gate fstack_t ok; 4167c478bd9Sstevel@tonic-gate char *name; 4177c478bd9Sstevel@tonic-gate 4187c478bd9Sstevel@tonic-gate CHECK_DEPTH(env, 6, "begin-package"); 4197c478bd9Sstevel@tonic-gate two_dup(env); 4207c478bd9Sstevel@tonic-gate name = pop_a_string(env, NULL); 4217c478bd9Sstevel@tonic-gate find_package(env); 4227c478bd9Sstevel@tonic-gate ok = POP(DS); 4237c478bd9Sstevel@tonic-gate if (ok) { 4247c478bd9Sstevel@tonic-gate PUSH(DS, 0); 4257c478bd9Sstevel@tonic-gate PUSH(DS, 0); 4267c478bd9Sstevel@tonic-gate rot(env); 4277c478bd9Sstevel@tonic-gate open_package(env); 4287c478bd9Sstevel@tonic-gate MYSELF = (instance_t *)POP(DS); 4297c478bd9Sstevel@tonic-gate check_my_self(env, "begin-package"); 4307c478bd9Sstevel@tonic-gate new_device(env); 4317c478bd9Sstevel@tonic-gate set_args(env); 4327c478bd9Sstevel@tonic-gate } else { 4337c478bd9Sstevel@tonic-gate log_message(MSG_INFO, "Package '%s' not found\n", name); 4347c478bd9Sstevel@tonic-gate } 4357c478bd9Sstevel@tonic-gate } 4367c478bd9Sstevel@tonic-gate 4377c478bd9Sstevel@tonic-gate void 4387c478bd9Sstevel@tonic-gate open_package(fcode_env_t *env) 4397c478bd9Sstevel@tonic-gate { 4407c478bd9Sstevel@tonic-gate device_t *phandle; 4417c478bd9Sstevel@tonic-gate instance_t *ihandle; 4427c478bd9Sstevel@tonic-gate int len; 4437c478bd9Sstevel@tonic-gate 4447c478bd9Sstevel@tonic-gate CHECK_DEPTH(env, 3, "open-package"); 4457c478bd9Sstevel@tonic-gate CONVERT_PHANDLE(env, phandle, POP(DS)); 4467c478bd9Sstevel@tonic-gate ihandle = open_instance_chain(env, phandle, 1); 4477c478bd9Sstevel@tonic-gate ihandle->my_args = pop_a_duped_string(env, &len); 4487c478bd9Sstevel@tonic-gate ihandle->my_args_len = len; 4497c478bd9Sstevel@tonic-gate PUSH(DS, (fstack_t)ihandle); 4507c478bd9Sstevel@tonic-gate } 4517c478bd9Sstevel@tonic-gate 4527c478bd9Sstevel@tonic-gate void 4537c478bd9Sstevel@tonic-gate dollar_open_package(fcode_env_t *env) 4547c478bd9Sstevel@tonic-gate { 4557c478bd9Sstevel@tonic-gate fstack_t ok; 4567c478bd9Sstevel@tonic-gate 4577c478bd9Sstevel@tonic-gate CHECK_DEPTH(env, 4, "$open-package"); 4587c478bd9Sstevel@tonic-gate find_package(env); 4597c478bd9Sstevel@tonic-gate ok = POP(DS); 4607c478bd9Sstevel@tonic-gate if (ok) { 4617c478bd9Sstevel@tonic-gate open_package(env); 4627c478bd9Sstevel@tonic-gate } else { 463*25cf1a30Sjl139090 (void) POP(DS); 464*25cf1a30Sjl139090 (void) POP(DS); 4657c478bd9Sstevel@tonic-gate PUSH(DS, 0); 4667c478bd9Sstevel@tonic-gate } 4677c478bd9Sstevel@tonic-gate } 4687c478bd9Sstevel@tonic-gate 4697c478bd9Sstevel@tonic-gate void 4707c478bd9Sstevel@tonic-gate close_package(fcode_env_t *env) 4717c478bd9Sstevel@tonic-gate { 4727c478bd9Sstevel@tonic-gate instance_t *ihandle; 4737c478bd9Sstevel@tonic-gate 4747c478bd9Sstevel@tonic-gate CHECK_DEPTH(env, 1, "close-package"); 4757c478bd9Sstevel@tonic-gate ihandle = (instance_t *)POP(DS); 4767c478bd9Sstevel@tonic-gate close_instance_chain(env, ihandle, 1); 4777c478bd9Sstevel@tonic-gate } 4787c478bd9Sstevel@tonic-gate 4797c478bd9Sstevel@tonic-gate static void (*find_method_hook)(fcode_env_t *); 4807c478bd9Sstevel@tonic-gate 4817c478bd9Sstevel@tonic-gate void 4827c478bd9Sstevel@tonic-gate set_find_method_hook(fcode_env_t *env, void (*hook)(fcode_env_t *)) 4837c478bd9Sstevel@tonic-gate { 4847c478bd9Sstevel@tonic-gate find_method_hook = hook; 4857c478bd9Sstevel@tonic-gate } 4867c478bd9Sstevel@tonic-gate 4877c478bd9Sstevel@tonic-gate void 4887c478bd9Sstevel@tonic-gate find_method(fcode_env_t *env) 4897c478bd9Sstevel@tonic-gate { 4907c478bd9Sstevel@tonic-gate fstack_t d; 4917c478bd9Sstevel@tonic-gate device_t *device; 4927c478bd9Sstevel@tonic-gate acf_t acf = 0; 4937c478bd9Sstevel@tonic-gate 4947c478bd9Sstevel@tonic-gate CHECK_DEPTH(env, 3, "find-method"); 4957c478bd9Sstevel@tonic-gate if (find_method_hook) { 4967c478bd9Sstevel@tonic-gate (*find_method_hook)(env); 4977c478bd9Sstevel@tonic-gate if (TOS) /* Found it */ 4987c478bd9Sstevel@tonic-gate return; 4997c478bd9Sstevel@tonic-gate POP(DS); 5007c478bd9Sstevel@tonic-gate } 5017c478bd9Sstevel@tonic-gate 5027c478bd9Sstevel@tonic-gate d = POP(DS); 5037c478bd9Sstevel@tonic-gate CONVERT_PHANDLE(env, device, d); 5047c478bd9Sstevel@tonic-gate PUSH(DS, (fstack_t)&device->vocabulary); 5057c478bd9Sstevel@tonic-gate acf = voc_find(env); 5067c478bd9Sstevel@tonic-gate PUSH(DS, (fstack_t)acf); 5077c478bd9Sstevel@tonic-gate if (acf) { 5087c478bd9Sstevel@tonic-gate PUSH(DS, TRUE); 5097c478bd9Sstevel@tonic-gate } 5107c478bd9Sstevel@tonic-gate } 5117c478bd9Sstevel@tonic-gate 5127c478bd9Sstevel@tonic-gate /* 5137c478bd9Sstevel@tonic-gate * 'call-package' Fcode 5147c478bd9Sstevel@tonic-gate */ 5157c478bd9Sstevel@tonic-gate void 5167c478bd9Sstevel@tonic-gate call_package(fcode_env_t *env) 5177c478bd9Sstevel@tonic-gate { 5187c478bd9Sstevel@tonic-gate instance_t *ihandle, *saved_myself; 5197c478bd9Sstevel@tonic-gate 5207c478bd9Sstevel@tonic-gate CHECK_DEPTH(env, 2, "call-package"); 5217c478bd9Sstevel@tonic-gate ihandle = (instance_t *)POP(DS); 5227c478bd9Sstevel@tonic-gate saved_myself = MYSELF; 5237c478bd9Sstevel@tonic-gate MYSELF = ihandle; 5247c478bd9Sstevel@tonic-gate execute(env); 5257c478bd9Sstevel@tonic-gate MYSELF = saved_myself; 5267c478bd9Sstevel@tonic-gate } 5277c478bd9Sstevel@tonic-gate 5287c478bd9Sstevel@tonic-gate void 5297c478bd9Sstevel@tonic-gate ihandle_to_phandle(fcode_env_t *env) 5307c478bd9Sstevel@tonic-gate { 5317c478bd9Sstevel@tonic-gate instance_t *i; 5327c478bd9Sstevel@tonic-gate 5337c478bd9Sstevel@tonic-gate CHECK_DEPTH(env, 1, "ihandle>phandle"); 5347c478bd9Sstevel@tonic-gate i = (instance_t *)TOS; 5357c478bd9Sstevel@tonic-gate REVERT_PHANDLE(env, TOS, i->device); 5367c478bd9Sstevel@tonic-gate } 5377c478bd9Sstevel@tonic-gate 5387c478bd9Sstevel@tonic-gate char * 5397c478bd9Sstevel@tonic-gate get_package_name(fcode_env_t *env, device_t *d) 5407c478bd9Sstevel@tonic-gate { 5417c478bd9Sstevel@tonic-gate char *name; 5427c478bd9Sstevel@tonic-gate prop_t *prop; 5437c478bd9Sstevel@tonic-gate 5447c478bd9Sstevel@tonic-gate prop = lookup_package_property(env, "name", d); 5457c478bd9Sstevel@tonic-gate if (prop == NULL) { 5467c478bd9Sstevel@tonic-gate name = "<Unnamed>"; 5477c478bd9Sstevel@tonic-gate } else { 5487c478bd9Sstevel@tonic-gate name = (char *)prop->data; 5497c478bd9Sstevel@tonic-gate } 5507c478bd9Sstevel@tonic-gate return (name); 5517c478bd9Sstevel@tonic-gate } 5527c478bd9Sstevel@tonic-gate 5537c478bd9Sstevel@tonic-gate static char *package_search_path = "/packages:/openprom"; 5547c478bd9Sstevel@tonic-gate 5557c478bd9Sstevel@tonic-gate device_t * 5567c478bd9Sstevel@tonic-gate match_package_path(fcode_env_t *env, char *path) 5577c478bd9Sstevel@tonic-gate { 5587c478bd9Sstevel@tonic-gate device_t *d; 5597c478bd9Sstevel@tonic-gate char *name; 5607c478bd9Sstevel@tonic-gate int len; 5617c478bd9Sstevel@tonic-gate 5627c478bd9Sstevel@tonic-gate if (*path == '/') { 5637c478bd9Sstevel@tonic-gate d = env->root_node->child; 5647c478bd9Sstevel@tonic-gate path++; 5657c478bd9Sstevel@tonic-gate } else 5667c478bd9Sstevel@tonic-gate d = env->current_device; 5677c478bd9Sstevel@tonic-gate while (*path != '\0' && d != NULL) { 5687c478bd9Sstevel@tonic-gate name = get_package_name(env, d); 5697c478bd9Sstevel@tonic-gate len = strlen(name); 5707c478bd9Sstevel@tonic-gate if (strncmp(name, path, len) == 0) { 5717c478bd9Sstevel@tonic-gate path += len; 5727c478bd9Sstevel@tonic-gate if (*path == '\0') { 5737c478bd9Sstevel@tonic-gate return (d); 5747c478bd9Sstevel@tonic-gate } 5757c478bd9Sstevel@tonic-gate /* skip the '/' */ 5767c478bd9Sstevel@tonic-gate if (*path++ != '/') 5777c478bd9Sstevel@tonic-gate break; 5787c478bd9Sstevel@tonic-gate d = d->child; 5797c478bd9Sstevel@tonic-gate } else { 5807c478bd9Sstevel@tonic-gate d = d->peer; 5817c478bd9Sstevel@tonic-gate } 5827c478bd9Sstevel@tonic-gate } 5837c478bd9Sstevel@tonic-gate return (NULL); 5847c478bd9Sstevel@tonic-gate } 5857c478bd9Sstevel@tonic-gate 5867c478bd9Sstevel@tonic-gate device_t * 5877c478bd9Sstevel@tonic-gate locate_package(fcode_env_t *env, char *start) 5887c478bd9Sstevel@tonic-gate { 5897c478bd9Sstevel@tonic-gate device_t *d; 5907c478bd9Sstevel@tonic-gate char *p, *next_p; 5917c478bd9Sstevel@tonic-gate char *tpath, *fpath; 5927c478bd9Sstevel@tonic-gate 5937c478bd9Sstevel@tonic-gate if ((d = match_package_path(env, start)) != NULL) 5947c478bd9Sstevel@tonic-gate return (d); 5957c478bd9Sstevel@tonic-gate 5967c478bd9Sstevel@tonic-gate /* 5977c478bd9Sstevel@tonic-gate * ignore starting '/' 5987c478bd9Sstevel@tonic-gate */ 5997c478bd9Sstevel@tonic-gate if (*start == '/') 6007c478bd9Sstevel@tonic-gate *start++; 6017c478bd9Sstevel@tonic-gate 6027c478bd9Sstevel@tonic-gate fpath = STRDUP(package_search_path); 6037c478bd9Sstevel@tonic-gate for (p = fpath; p != NULL; p = next_p) { 6047c478bd9Sstevel@tonic-gate if ((next_p = strchr(p, ':')) != NULL) 6057c478bd9Sstevel@tonic-gate *next_p++ = '\0'; 6067c478bd9Sstevel@tonic-gate tpath = MALLOC(strlen(p) + strlen(start) + 2); 6077c478bd9Sstevel@tonic-gate sprintf(tpath, "%s/%s", p, start); 6087c478bd9Sstevel@tonic-gate if ((d = match_package_path(env, tpath)) != NULL) { 6097c478bd9Sstevel@tonic-gate FREE(fpath); 6107c478bd9Sstevel@tonic-gate FREE(tpath); 6117c478bd9Sstevel@tonic-gate return (d); 6127c478bd9Sstevel@tonic-gate } 6137c478bd9Sstevel@tonic-gate FREE(tpath); 6147c478bd9Sstevel@tonic-gate } 6157c478bd9Sstevel@tonic-gate FREE(fpath); 6167c478bd9Sstevel@tonic-gate return (NULL); 6177c478bd9Sstevel@tonic-gate } 6187c478bd9Sstevel@tonic-gate 6197c478bd9Sstevel@tonic-gate void 6207c478bd9Sstevel@tonic-gate find_package(fcode_env_t *env) 6217c478bd9Sstevel@tonic-gate { 6227c478bd9Sstevel@tonic-gate char *path; 6237c478bd9Sstevel@tonic-gate device_t *package; 6247c478bd9Sstevel@tonic-gate fstack_t ph = 0; 6257c478bd9Sstevel@tonic-gate 6267c478bd9Sstevel@tonic-gate CHECK_DEPTH(env, 2, "find-package"); 6277c478bd9Sstevel@tonic-gate if ((path = pop_a_duped_string(env, NULL)) != NULL) { 6287c478bd9Sstevel@tonic-gate if (strcmp(path, "/") == 0) 6297c478bd9Sstevel@tonic-gate package = env->root_node; 6307c478bd9Sstevel@tonic-gate else 6317c478bd9Sstevel@tonic-gate package = locate_package(env, path); 6327c478bd9Sstevel@tonic-gate FREE(path); 6337c478bd9Sstevel@tonic-gate REVERT_PHANDLE(env, ph, package); 6347c478bd9Sstevel@tonic-gate } 6357c478bd9Sstevel@tonic-gate PUSH(DS, ph); 6367c478bd9Sstevel@tonic-gate if (package) 6377c478bd9Sstevel@tonic-gate PUSH(DS, TRUE); 6387c478bd9Sstevel@tonic-gate } 6397c478bd9Sstevel@tonic-gate 6407c478bd9Sstevel@tonic-gate static void 6417c478bd9Sstevel@tonic-gate encode_unit_hack(fcode_env_t *env) 6427c478bd9Sstevel@tonic-gate { 6437c478bd9Sstevel@tonic-gate int hi, i; 6447c478bd9Sstevel@tonic-gate uint_t ncells = get_number_of_parent_address_cells(env); 6457c478bd9Sstevel@tonic-gate 6467c478bd9Sstevel@tonic-gate for (i = 0; i < ncells; i++) 6477c478bd9Sstevel@tonic-gate POP(DS); 6487c478bd9Sstevel@tonic-gate push_a_string(env, NULL); 6497c478bd9Sstevel@tonic-gate } 6507c478bd9Sstevel@tonic-gate 6517c478bd9Sstevel@tonic-gate void 6527c478bd9Sstevel@tonic-gate dollar_call_method(fcode_env_t *env) 6537c478bd9Sstevel@tonic-gate { 6547c478bd9Sstevel@tonic-gate instance_t *old_myself; 6557c478bd9Sstevel@tonic-gate instance_t *myself; 6567c478bd9Sstevel@tonic-gate device_t *device; 6577c478bd9Sstevel@tonic-gate char *method; 6587c478bd9Sstevel@tonic-gate 6597c478bd9Sstevel@tonic-gate CHECK_DEPTH(env, 3, "$call-method"); 6607c478bd9Sstevel@tonic-gate check_my_self(env, "$call-method"); 6617c478bd9Sstevel@tonic-gate old_myself = MYSELF; 6627c478bd9Sstevel@tonic-gate myself = (instance_t *)POP(DS); 6637c478bd9Sstevel@tonic-gate 6647c478bd9Sstevel@tonic-gate method = (char *)DS[-1]; 6657c478bd9Sstevel@tonic-gate debug_msg(DEBUG_CALL_METHOD, "$call_method %s\n", method); 6667c478bd9Sstevel@tonic-gate 6677c478bd9Sstevel@tonic-gate if (old_myself && !myself) { 6687c478bd9Sstevel@tonic-gate /* We hit the root of our tree */ 6697c478bd9Sstevel@tonic-gate device = old_myself->device; 6707c478bd9Sstevel@tonic-gate return; 6717c478bd9Sstevel@tonic-gate } 6727c478bd9Sstevel@tonic-gate 6737c478bd9Sstevel@tonic-gate MYSELF = myself; 6747c478bd9Sstevel@tonic-gate check_my_self(env, "$call-method"); 6757c478bd9Sstevel@tonic-gate device = MYSELF->device; 6767c478bd9Sstevel@tonic-gate do_push_package(env, device); 6777c478bd9Sstevel@tonic-gate PUSH(DS, (fstack_t)device); 6787c478bd9Sstevel@tonic-gate REVERT_PHANDLE(env, TOS, device); 6797c478bd9Sstevel@tonic-gate find_method(env); 6807c478bd9Sstevel@tonic-gate if (TOS) { 6817c478bd9Sstevel@tonic-gate (void) POP(DS); 6827c478bd9Sstevel@tonic-gate execute(env); 6837c478bd9Sstevel@tonic-gate } else if (strcmp(method, "encode-unit") == 0) { 6847c478bd9Sstevel@tonic-gate encode_unit_hack(env); 6857c478bd9Sstevel@tonic-gate } else { 6867c478bd9Sstevel@tonic-gate throw_from_fclib(env, 1, "Unimplemented package method: %s%s", 6877c478bd9Sstevel@tonic-gate get_path(env, device), method); 6887c478bd9Sstevel@tonic-gate } 6897c478bd9Sstevel@tonic-gate MYSELF = old_myself; 6907c478bd9Sstevel@tonic-gate do_push_package(env, MYSELF->device); 6917c478bd9Sstevel@tonic-gate } 6927c478bd9Sstevel@tonic-gate 6937c478bd9Sstevel@tonic-gate void 6947c478bd9Sstevel@tonic-gate dollar_call_parent(fcode_env_t *env) 6957c478bd9Sstevel@tonic-gate { 6967c478bd9Sstevel@tonic-gate CHECK_DEPTH(env, 2, "$call-parent"); 6977c478bd9Sstevel@tonic-gate 6987c478bd9Sstevel@tonic-gate check_my_self(env, "$call-parent"); 6997c478bd9Sstevel@tonic-gate 7007c478bd9Sstevel@tonic-gate PUSH(DS, (fstack_t)MYSELF->parent); 7017c478bd9Sstevel@tonic-gate dollar_call_method(env); 7027c478bd9Sstevel@tonic-gate } 7037c478bd9Sstevel@tonic-gate 7047c478bd9Sstevel@tonic-gate #ifdef DEBUG 7057c478bd9Sstevel@tonic-gate void 7067c478bd9Sstevel@tonic-gate current_device(fcode_env_t *env) 7077c478bd9Sstevel@tonic-gate { 7087c478bd9Sstevel@tonic-gate PUSH(DS, (fstack_t)&env->current_device); 7097c478bd9Sstevel@tonic-gate } 7107c478bd9Sstevel@tonic-gate 7117c478bd9Sstevel@tonic-gate char * 7127c478bd9Sstevel@tonic-gate get_path(fcode_env_t *env, device_t *d) 7137c478bd9Sstevel@tonic-gate { 7147c478bd9Sstevel@tonic-gate char *pre_path, *name, *path; 7157c478bd9Sstevel@tonic-gate int n; 7167c478bd9Sstevel@tonic-gate 7177c478bd9Sstevel@tonic-gate if (d->parent) 7187c478bd9Sstevel@tonic-gate pre_path = get_path(env, d->parent); 7197c478bd9Sstevel@tonic-gate else 7207c478bd9Sstevel@tonic-gate pre_path = STRDUP(""); 7217c478bd9Sstevel@tonic-gate 7227c478bd9Sstevel@tonic-gate name = get_package_name(env, d); 7237c478bd9Sstevel@tonic-gate n = strlen(pre_path) + strlen(name) + 1; 7247c478bd9Sstevel@tonic-gate path = MALLOC(n); 7257c478bd9Sstevel@tonic-gate strcpy(path, pre_path); 7267c478bd9Sstevel@tonic-gate strcat(path, name); 7277c478bd9Sstevel@tonic-gate if (d->child && d->parent) 7287c478bd9Sstevel@tonic-gate strcat(path, "/"); 7297c478bd9Sstevel@tonic-gate FREE(pre_path); 7307c478bd9Sstevel@tonic-gate return (path); 7317c478bd9Sstevel@tonic-gate } 7327c478bd9Sstevel@tonic-gate 7337c478bd9Sstevel@tonic-gate static void 7347c478bd9Sstevel@tonic-gate pwd_dollar(fcode_env_t *env) 7357c478bd9Sstevel@tonic-gate { 7367c478bd9Sstevel@tonic-gate if (env->current_device) 7377c478bd9Sstevel@tonic-gate push_a_string(env, get_path(env, env->current_device)); 7387c478bd9Sstevel@tonic-gate else 7397c478bd9Sstevel@tonic-gate push_a_string(env, NULL); 7407c478bd9Sstevel@tonic-gate } 7417c478bd9Sstevel@tonic-gate 7427c478bd9Sstevel@tonic-gate void 7437c478bd9Sstevel@tonic-gate pwd(fcode_env_t *env) 7447c478bd9Sstevel@tonic-gate { 7457c478bd9Sstevel@tonic-gate if (env->current_device) { 7467c478bd9Sstevel@tonic-gate log_message(MSG_INFO, "%s\n", 7477c478bd9Sstevel@tonic-gate get_path(env, env->current_device)); 7487c478bd9Sstevel@tonic-gate } else { 7497c478bd9Sstevel@tonic-gate log_message(MSG_INFO, "No device context\n"); 7507c478bd9Sstevel@tonic-gate } 7517c478bd9Sstevel@tonic-gate } 7527c478bd9Sstevel@tonic-gate 7537c478bd9Sstevel@tonic-gate void 7547c478bd9Sstevel@tonic-gate do_ls(fcode_env_t *env) 7557c478bd9Sstevel@tonic-gate { 7567c478bd9Sstevel@tonic-gate device_t *d; 7577c478bd9Sstevel@tonic-gate 7587c478bd9Sstevel@tonic-gate if (env->current_device == NULL) { 7597c478bd9Sstevel@tonic-gate log_message(MSG_INFO, "No device context\n"); 7607c478bd9Sstevel@tonic-gate return; 7617c478bd9Sstevel@tonic-gate } 7627c478bd9Sstevel@tonic-gate 7637c478bd9Sstevel@tonic-gate d = env->current_device->child; 7647c478bd9Sstevel@tonic-gate while (d) { 7657c478bd9Sstevel@tonic-gate char *name; 7667c478bd9Sstevel@tonic-gate fstack_t ph; 7677c478bd9Sstevel@tonic-gate name = get_package_name(env, d); 7687c478bd9Sstevel@tonic-gate REVERT_PHANDLE(env, ph, d); 7697c478bd9Sstevel@tonic-gate log_message(MSG_INFO, "%llx %s\n", (uint64_t)ph, name); 7707c478bd9Sstevel@tonic-gate d = d->peer; 7717c478bd9Sstevel@tonic-gate } 7727c478bd9Sstevel@tonic-gate } 7737c478bd9Sstevel@tonic-gate 7747c478bd9Sstevel@tonic-gate void 7757c478bd9Sstevel@tonic-gate paren_cd(fcode_env_t *env) 7767c478bd9Sstevel@tonic-gate { 7777c478bd9Sstevel@tonic-gate char *str; 7787c478bd9Sstevel@tonic-gate device_t *p; 7797c478bd9Sstevel@tonic-gate 7807c478bd9Sstevel@tonic-gate str = pop_a_string(env, NULL); 7817c478bd9Sstevel@tonic-gate if (strcmp(str, "/") == 0) { 7827c478bd9Sstevel@tonic-gate root_node(env); 7837c478bd9Sstevel@tonic-gate return; 7847c478bd9Sstevel@tonic-gate } 7857c478bd9Sstevel@tonic-gate 7867c478bd9Sstevel@tonic-gate if (env->current_device == NULL) { 7877c478bd9Sstevel@tonic-gate log_message(MSG_INFO, "No device context\n"); 7887c478bd9Sstevel@tonic-gate return; 7897c478bd9Sstevel@tonic-gate } 7907c478bd9Sstevel@tonic-gate 7917c478bd9Sstevel@tonic-gate if (strcmp(str, "..") == 0) 7927c478bd9Sstevel@tonic-gate p = env->current_device->parent; 7937c478bd9Sstevel@tonic-gate else { 7947c478bd9Sstevel@tonic-gate device_t *n = env->current_device->child; 7957c478bd9Sstevel@tonic-gate 7967c478bd9Sstevel@tonic-gate p = NULL; 7977c478bd9Sstevel@tonic-gate while (n) { 7987c478bd9Sstevel@tonic-gate char *name; 7997c478bd9Sstevel@tonic-gate 8007c478bd9Sstevel@tonic-gate name = get_package_name(env, n); 8017c478bd9Sstevel@tonic-gate if (strcmp(name, str) == 0) { 8027c478bd9Sstevel@tonic-gate p = n; 8037c478bd9Sstevel@tonic-gate break; 8047c478bd9Sstevel@tonic-gate } 8057c478bd9Sstevel@tonic-gate n = n->peer; 8067c478bd9Sstevel@tonic-gate } 8077c478bd9Sstevel@tonic-gate } 8087c478bd9Sstevel@tonic-gate 8097c478bd9Sstevel@tonic-gate if (p) { 8107c478bd9Sstevel@tonic-gate activate_device(env, p); 8117c478bd9Sstevel@tonic-gate } else { 8127c478bd9Sstevel@tonic-gate log_message(MSG_INFO, "No such node: %s\n", str); 8137c478bd9Sstevel@tonic-gate } 8147c478bd9Sstevel@tonic-gate } 8157c478bd9Sstevel@tonic-gate 8167c478bd9Sstevel@tonic-gate void 8177c478bd9Sstevel@tonic-gate do_cd(fcode_env_t *env) 8187c478bd9Sstevel@tonic-gate { 8197c478bd9Sstevel@tonic-gate parse_word(env); 8207c478bd9Sstevel@tonic-gate paren_cd(env); 8217c478bd9Sstevel@tonic-gate } 8227c478bd9Sstevel@tonic-gate 8237c478bd9Sstevel@tonic-gate void 8247c478bd9Sstevel@tonic-gate do_unselect_dev(fcode_env_t *env) 8257c478bd9Sstevel@tonic-gate { 8267c478bd9Sstevel@tonic-gate check_my_self(env, "unselect-dev"); 8277c478bd9Sstevel@tonic-gate PUSH(DS, (fstack_t)MYSELF); 8287c478bd9Sstevel@tonic-gate close_package(env); 8297c478bd9Sstevel@tonic-gate deactivate_device(env, NULL); 8307c478bd9Sstevel@tonic-gate } 8317c478bd9Sstevel@tonic-gate 8327c478bd9Sstevel@tonic-gate void 8337c478bd9Sstevel@tonic-gate do_select_dev(fcode_env_t *env) 8347c478bd9Sstevel@tonic-gate { 8357c478bd9Sstevel@tonic-gate PUSH(DS, 0); 8367c478bd9Sstevel@tonic-gate PUSH(DS, 0); 8377c478bd9Sstevel@tonic-gate two_swap(env); 8387c478bd9Sstevel@tonic-gate dollar_open_package(env); 8397c478bd9Sstevel@tonic-gate if (TOS) { 8407c478bd9Sstevel@tonic-gate MYSELF = (instance_t *)POP(DS); 8417c478bd9Sstevel@tonic-gate check_my_self(env, "select-dev"); 8427c478bd9Sstevel@tonic-gate activate_device(env, MYSELF->device); 8437c478bd9Sstevel@tonic-gate } else { 8447c478bd9Sstevel@tonic-gate drop(env); 8457c478bd9Sstevel@tonic-gate log_message(MSG_INFO, "Can't open package\n"); 8467c478bd9Sstevel@tonic-gate } 8477c478bd9Sstevel@tonic-gate } 8487c478bd9Sstevel@tonic-gate 8497c478bd9Sstevel@tonic-gate void 8507c478bd9Sstevel@tonic-gate device_end(fcode_env_t *env) 8517c478bd9Sstevel@tonic-gate { 8527c478bd9Sstevel@tonic-gate if (env->current_device) { 8537c478bd9Sstevel@tonic-gate deactivate_device(env, NULL); 8547c478bd9Sstevel@tonic-gate } 8557c478bd9Sstevel@tonic-gate } 8567c478bd9Sstevel@tonic-gate 8577c478bd9Sstevel@tonic-gate void 8587c478bd9Sstevel@tonic-gate end_package(fcode_env_t *env) 8597c478bd9Sstevel@tonic-gate { 8607c478bd9Sstevel@tonic-gate finish_device(env); 8617c478bd9Sstevel@tonic-gate close_instance_chain(env, MYSELF, 0); 8627c478bd9Sstevel@tonic-gate device_end(env); 8637c478bd9Sstevel@tonic-gate MYSELF = NULL; 8647c478bd9Sstevel@tonic-gate } 8657c478bd9Sstevel@tonic-gate 8667c478bd9Sstevel@tonic-gate void 8677c478bd9Sstevel@tonic-gate exec_parent_method(fcode_env_t *env) 8687c478bd9Sstevel@tonic-gate { 8697c478bd9Sstevel@tonic-gate instance_t *old_myself; 8707c478bd9Sstevel@tonic-gate instance_t *myself; 8717c478bd9Sstevel@tonic-gate device_t *device; 8727c478bd9Sstevel@tonic-gate char *method; 8737c478bd9Sstevel@tonic-gate fstack_t d; 8747c478bd9Sstevel@tonic-gate 8757c478bd9Sstevel@tonic-gate check_my_self(env, "exec-parent-method"); 8767c478bd9Sstevel@tonic-gate old_myself = MYSELF; 8777c478bd9Sstevel@tonic-gate MYSELF = MYSELF->parent; 8787c478bd9Sstevel@tonic-gate 8797c478bd9Sstevel@tonic-gate method = (char *)DS[-1]; 8807c478bd9Sstevel@tonic-gate debug_msg(DEBUG_FIND_FCODE, "exec_parent_method: '%s'\n", method); 8817c478bd9Sstevel@tonic-gate 8827c478bd9Sstevel@tonic-gate check_my_self(env, "exec-parent-method"); 8837c478bd9Sstevel@tonic-gate device = MYSELF->device; 8847c478bd9Sstevel@tonic-gate do_push_package(env, device); 8857c478bd9Sstevel@tonic-gate PUSH(DS, (fstack_t)device); 8867c478bd9Sstevel@tonic-gate REVERT_PHANDLE(env, TOS, device); 8877c478bd9Sstevel@tonic-gate find_method(env); 8887c478bd9Sstevel@tonic-gate d = POP(DS); 8897c478bd9Sstevel@tonic-gate if (d) { 8907c478bd9Sstevel@tonic-gate debug_msg(DEBUG_FIND_FCODE, "exec-parent-method: '%s'/%x" 8917c478bd9Sstevel@tonic-gate " execute\n", method, (int)TOS); 8927c478bd9Sstevel@tonic-gate execute(env); 8937c478bd9Sstevel@tonic-gate PUSH(DS, TRUE); 8947c478bd9Sstevel@tonic-gate } else { 8957c478bd9Sstevel@tonic-gate debug_msg(DEBUG_FIND_FCODE, "exec-parent-method: '%s'" 8967c478bd9Sstevel@tonic-gate " not found\n", method); 8977c478bd9Sstevel@tonic-gate PUSH(DS, FALSE); 8987c478bd9Sstevel@tonic-gate } 8997c478bd9Sstevel@tonic-gate MYSELF = old_myself; 9007c478bd9Sstevel@tonic-gate do_push_package(env, MYSELF->device); 9017c478bd9Sstevel@tonic-gate } 9027c478bd9Sstevel@tonic-gate 9037c478bd9Sstevel@tonic-gate void 9047c478bd9Sstevel@tonic-gate dump_device(fcode_env_t *env) 9057c478bd9Sstevel@tonic-gate { 9067c478bd9Sstevel@tonic-gate device_t *phandle; 9077c478bd9Sstevel@tonic-gate int i; 9087c478bd9Sstevel@tonic-gate 9097c478bd9Sstevel@tonic-gate CONVERT_PHANDLE(env, phandle, POP(DS)); 9107c478bd9Sstevel@tonic-gate log_message(MSG_DEBUG, "Node: %p\n", phandle); 9117c478bd9Sstevel@tonic-gate log_message(MSG_DEBUG, " Parent: (%8p) %p\n", 9127c478bd9Sstevel@tonic-gate &phandle->parent, phandle->parent); 9137c478bd9Sstevel@tonic-gate log_message(MSG_DEBUG, " Child: (%8p) %p\n", 9147c478bd9Sstevel@tonic-gate &phandle->child, phandle->child); 9157c478bd9Sstevel@tonic-gate log_message(MSG_DEBUG, " Peer: (%8p) %p\n", 9167c478bd9Sstevel@tonic-gate &phandle->peer, phandle->peer); 9177c478bd9Sstevel@tonic-gate log_message(MSG_DEBUG, " Private: (%8p) %p\n", 9187c478bd9Sstevel@tonic-gate &phandle->private, phandle->private); 9197c478bd9Sstevel@tonic-gate log_message(MSG_DEBUG, " Props: (%8p) %p\n", 9207c478bd9Sstevel@tonic-gate &phandle->properties, phandle->properties); 9217c478bd9Sstevel@tonic-gate log_message(MSG_DEBUG, " Voc: (%8p) %p\n", 9227c478bd9Sstevel@tonic-gate &phandle->vocabulary, phandle->vocabulary); 9237c478bd9Sstevel@tonic-gate log_message(MSG_DEBUG, " sizes: (%8p) %d %d\n", 9247c478bd9Sstevel@tonic-gate &phandle->data_size, 9257c478bd9Sstevel@tonic-gate phandle->data_size[INIT_DATA], 9267c478bd9Sstevel@tonic-gate phandle->data_size[UINIT_DATA]); 9277c478bd9Sstevel@tonic-gate log_message(MSG_DEBUG, " my_space: %x\n", phandle->my_space); 9287c478bd9Sstevel@tonic-gate log_message(MSG_DEBUG, " my_addr :"); 9297c478bd9Sstevel@tonic-gate for (i = 0; i < MAX_MY_ADDR; i++) 9307c478bd9Sstevel@tonic-gate log_message(MSG_DEBUG, " %x", (int)phandle->my_addr[i]); 9317c478bd9Sstevel@tonic-gate log_message(MSG_DEBUG, "\n"); 9327c478bd9Sstevel@tonic-gate log_message(MSG_DEBUG, " data: (%8p)\n", phandle->init_data); 9337c478bd9Sstevel@tonic-gate for (i = 0; i < phandle->data_size[INIT_DATA]; i++) { 9347c478bd9Sstevel@tonic-gate log_message(MSG_DEBUG, " %3d -> (%8p) %x\n", i, 9357c478bd9Sstevel@tonic-gate &phandle->init_data[i], phandle->init_data[i]); 9367c478bd9Sstevel@tonic-gate } 9377c478bd9Sstevel@tonic-gate } 9387c478bd9Sstevel@tonic-gate 9397c478bd9Sstevel@tonic-gate void 9407c478bd9Sstevel@tonic-gate dump_instance(fcode_env_t *env) 9417c478bd9Sstevel@tonic-gate { 9427c478bd9Sstevel@tonic-gate int i; 9437c478bd9Sstevel@tonic-gate instance_t *ihandle; 9447c478bd9Sstevel@tonic-gate 9457c478bd9Sstevel@tonic-gate ihandle = (instance_t *)POP(DS); 9467c478bd9Sstevel@tonic-gate log_message(MSG_DEBUG, "Ihandle: %p\n", ihandle); 9477c478bd9Sstevel@tonic-gate log_message(MSG_DEBUG, " Parent: (%8p) %p\n", 9487c478bd9Sstevel@tonic-gate &ihandle->parent, ihandle->parent); 9497c478bd9Sstevel@tonic-gate log_message(MSG_DEBUG, " Device: (%8p) %p\n", 9507c478bd9Sstevel@tonic-gate &ihandle->device, ihandle->device); 9517c478bd9Sstevel@tonic-gate log_message(MSG_DEBUG, " args: '%s'\n", 9527c478bd9Sstevel@tonic-gate ((ihandle->my_args) ? ihandle->my_args : "")); 9537c478bd9Sstevel@tonic-gate log_message(MSG_DEBUG, " my-space: %x\n", ihandle->my_space); 9547c478bd9Sstevel@tonic-gate log_message(MSG_DEBUG, " my_addr :"); 9557c478bd9Sstevel@tonic-gate for (i = 0; i < MAX_MY_ADDR; i++) 9567c478bd9Sstevel@tonic-gate log_message(MSG_DEBUG, " %x", (int)ihandle->my_addr[i]); 9577c478bd9Sstevel@tonic-gate log_message(MSG_DEBUG, "\n"); 9587c478bd9Sstevel@tonic-gate log_message(MSG_DEBUG, " sizes: %d %d\n", 9597c478bd9Sstevel@tonic-gate ihandle->device->data_size[INIT_DATA], 9607c478bd9Sstevel@tonic-gate ihandle->device->data_size[UINIT_DATA]); 9617c478bd9Sstevel@tonic-gate log_message(MSG_DEBUG, " data: (%8p) %x %x\n", 9627c478bd9Sstevel@tonic-gate ihandle->data, ihandle->data[0], ihandle->data[1]); 9637c478bd9Sstevel@tonic-gate if (ihandle->device->data_size[INIT_DATA]) { 9647c478bd9Sstevel@tonic-gate log_message(MSG_DEBUG, " Initialised:\n"); 9657c478bd9Sstevel@tonic-gate for (i = 0; i < ihandle->device->data_size[INIT_DATA]; i++) { 9667c478bd9Sstevel@tonic-gate log_message(MSG_DEBUG, " %3d -> (%8p) %x\n", i, 9677c478bd9Sstevel@tonic-gate &ihandle->data[INIT_DATA][i], 9687c478bd9Sstevel@tonic-gate ihandle->data[INIT_DATA][i]); 9697c478bd9Sstevel@tonic-gate } 9707c478bd9Sstevel@tonic-gate } 9717c478bd9Sstevel@tonic-gate if (ihandle->device->data_size[INIT_DATA]) { 9727c478bd9Sstevel@tonic-gate log_message(MSG_DEBUG, " UnInitialised:\n"); 9737c478bd9Sstevel@tonic-gate for (i = 0; i < ihandle->device->data_size[UINIT_DATA]; i++) { 9747c478bd9Sstevel@tonic-gate log_message(MSG_DEBUG, " %3d -> (%8p) %x\n", i, 9757c478bd9Sstevel@tonic-gate &ihandle->data[UINIT_DATA][i], 9767c478bd9Sstevel@tonic-gate ihandle->data[UINIT_DATA][i]); 9777c478bd9Sstevel@tonic-gate } 9787c478bd9Sstevel@tonic-gate } 9797c478bd9Sstevel@tonic-gate } 9807c478bd9Sstevel@tonic-gate 9817c478bd9Sstevel@tonic-gate #endif 9827c478bd9Sstevel@tonic-gate 9837c478bd9Sstevel@tonic-gate #pragma init(_init) 9847c478bd9Sstevel@tonic-gate 9857c478bd9Sstevel@tonic-gate #ifdef CONVERT_HANDLES 9867c478bd9Sstevel@tonic-gate static device_t * 9877c478bd9Sstevel@tonic-gate safe_convert_phandle(fcode_env_t *env, fstack_t d) 9887c478bd9Sstevel@tonic-gate { 9897c478bd9Sstevel@tonic-gate return ((device_t *)d); 9907c478bd9Sstevel@tonic-gate } 9917c478bd9Sstevel@tonic-gate 9927c478bd9Sstevel@tonic-gate static fstack_t 9937c478bd9Sstevel@tonic-gate safe_revert_phandle(fcode_env_t *env, device_t *d) 9947c478bd9Sstevel@tonic-gate { 9957c478bd9Sstevel@tonic-gate return ((fstack_t)d); 9967c478bd9Sstevel@tonic-gate } 9977c478bd9Sstevel@tonic-gate 9987c478bd9Sstevel@tonic-gate static void 9997c478bd9Sstevel@tonic-gate safe_allocate_phandle(fcode_env_t *env) 10007c478bd9Sstevel@tonic-gate { 10017c478bd9Sstevel@tonic-gate } 10027c478bd9Sstevel@tonic-gate 10037c478bd9Sstevel@tonic-gate #endif 10047c478bd9Sstevel@tonic-gate 10057c478bd9Sstevel@tonic-gate static void 10067c478bd9Sstevel@tonic-gate _init(void) 10077c478bd9Sstevel@tonic-gate { 10087c478bd9Sstevel@tonic-gate fcode_env_t *env = initial_env; 10097c478bd9Sstevel@tonic-gate char *name = "/"; 10107c478bd9Sstevel@tonic-gate device_t *d; 10117c478bd9Sstevel@tonic-gate 10127c478bd9Sstevel@tonic-gate ASSERT(env); 10137c478bd9Sstevel@tonic-gate NOTICE; 10147c478bd9Sstevel@tonic-gate 10157c478bd9Sstevel@tonic-gate #ifdef CONVERT_HANDLES 10167c478bd9Sstevel@tonic-gate env->convert_phandle = safe_convert_phandle; 10177c478bd9Sstevel@tonic-gate env->revert_phandle = safe_revert_phandle; 10187c478bd9Sstevel@tonic-gate env->allocate_phandle = safe_allocate_phandle; 10197c478bd9Sstevel@tonic-gate #endif 10207c478bd9Sstevel@tonic-gate 10217c478bd9Sstevel@tonic-gate /* build the root node */ 10227c478bd9Sstevel@tonic-gate d = create_phandle(env, NULL); 10237c478bd9Sstevel@tonic-gate env->current_device = d; 10247c478bd9Sstevel@tonic-gate env->root_node = d; 10257c478bd9Sstevel@tonic-gate push_a_string(env, name); 10267c478bd9Sstevel@tonic-gate device_name(env); 10277c478bd9Sstevel@tonic-gate env->current_device = NULL; 10287c478bd9Sstevel@tonic-gate 10297c478bd9Sstevel@tonic-gate create_my_self(env); 10307c478bd9Sstevel@tonic-gate create_my_space(env); 10317c478bd9Sstevel@tonic-gate 10327c478bd9Sstevel@tonic-gate P1275(0x102, 0, "my-address", my_address); 10337c478bd9Sstevel@tonic-gate /* Fcode 0x103 "my-space" is created using create_internal_value */ 10347c478bd9Sstevel@tonic-gate 10357c478bd9Sstevel@tonic-gate P1275(0x11f, 0, "new-device", new_device); 10367c478bd9Sstevel@tonic-gate 10377c478bd9Sstevel@tonic-gate P1275(0x127, 0, "finish-device", finish_device); 10387c478bd9Sstevel@tonic-gate 10397c478bd9Sstevel@tonic-gate FCODE(0x129, 0, "push-package", push_package); 10407c478bd9Sstevel@tonic-gate FCODE(0x12a, 0, "pop-package", pop_package); 10417c478bd9Sstevel@tonic-gate FCODE(0x12b, 0, "interpose", interpose); 10427c478bd9Sstevel@tonic-gate 10437c478bd9Sstevel@tonic-gate P1275(0x202, 0, "my-args", my_args); 10447c478bd9Sstevel@tonic-gate /* Fcode 0x203 "my-self" is created using create_internal_value */ 10457c478bd9Sstevel@tonic-gate P1275(0x204, 0, "find-package", find_package); 10467c478bd9Sstevel@tonic-gate P1275(0x205, 0, "open-package", open_package); 10477c478bd9Sstevel@tonic-gate P1275(0x206, 0, "close-package", close_package); 10487c478bd9Sstevel@tonic-gate P1275(0x207, 0, "find-method", find_method); 10497c478bd9Sstevel@tonic-gate P1275(0x208, 0, "call-package", call_package); 10507c478bd9Sstevel@tonic-gate P1275(0x209, 0, "$call-parent", dollar_call_parent); 10517c478bd9Sstevel@tonic-gate P1275(0x20a, 0, "my-parent", my_parent); 10527c478bd9Sstevel@tonic-gate P1275(0x20b, 0, "ihandle>phandle", ihandle_to_phandle); 10537c478bd9Sstevel@tonic-gate 10547c478bd9Sstevel@tonic-gate P1275(0x20d, 0, "my-unit", my_unit); 10557c478bd9Sstevel@tonic-gate P1275(0x20e, 0, "$call-method", dollar_call_method); 10567c478bd9Sstevel@tonic-gate P1275(0x20f, 0, "$open-package", dollar_open_package); 10577c478bd9Sstevel@tonic-gate 10587c478bd9Sstevel@tonic-gate P1275(0x23b, 0, "child", child_node); 10597c478bd9Sstevel@tonic-gate P1275(0x23c, 0, "peer", peer_node); 10607c478bd9Sstevel@tonic-gate 10617c478bd9Sstevel@tonic-gate P1275(0x23f, 0, "set-args", set_args); 10627c478bd9Sstevel@tonic-gate 10637c478bd9Sstevel@tonic-gate FORTH(IMMEDIATE, "root-node", root_node); 10647c478bd9Sstevel@tonic-gate FORTH(0, "current-device", current_device); 10657c478bd9Sstevel@tonic-gate FORTH(0, "pwd$", pwd_dollar); 10667c478bd9Sstevel@tonic-gate FORTH(IMMEDIATE, "pwd", pwd); 10677c478bd9Sstevel@tonic-gate FORTH(IMMEDIATE, "ls", do_ls); 10687c478bd9Sstevel@tonic-gate FORTH(IMMEDIATE, "(cd)", paren_cd); 10697c478bd9Sstevel@tonic-gate FORTH(IMMEDIATE, "cd", do_cd); 10707c478bd9Sstevel@tonic-gate FORTH(IMMEDIATE, "device-end", device_end); 10717c478bd9Sstevel@tonic-gate FORTH(0, "select-dev", do_select_dev); 10727c478bd9Sstevel@tonic-gate FORTH(0, "unselect-dev", do_unselect_dev); 10737c478bd9Sstevel@tonic-gate FORTH(0, "begin-package", begin_package); 10747c478bd9Sstevel@tonic-gate FORTH(0, "end-package", end_package); 10757c478bd9Sstevel@tonic-gate FORTH(IMMEDIATE, "dump-device", dump_device); 10767c478bd9Sstevel@tonic-gate FORTH(IMMEDIATE, "dump-instance", dump_instance); 10777c478bd9Sstevel@tonic-gate FORTH(0, "exec-parent-method", exec_parent_method); 10787c478bd9Sstevel@tonic-gate } 1079