1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* 23*7c478bd9Sstevel@tonic-gate * Copyright (c) 1999 by Sun Microsystems, Inc. 24*7c478bd9Sstevel@tonic-gate * All rights reserved. 25*7c478bd9Sstevel@tonic-gate */ 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 28*7c478bd9Sstevel@tonic-gate 29*7c478bd9Sstevel@tonic-gate #include <stdio.h> 30*7c478bd9Sstevel@tonic-gate 31*7c478bd9Sstevel@tonic-gate #include <fcode/private.h> 32*7c478bd9Sstevel@tonic-gate #include <fcode/log.h> 33*7c478bd9Sstevel@tonic-gate 34*7c478bd9Sstevel@tonic-gate void 35*7c478bd9Sstevel@tonic-gate do_run(fcode_env_t *env, int next) 36*7c478bd9Sstevel@tonic-gate { 37*7c478bd9Sstevel@tonic-gate token_t target, indirect; 38*7c478bd9Sstevel@tonic-gate void (*fn)(fcode_env_t *env); 39*7c478bd9Sstevel@tonic-gate int debug_state = current_debug_state(env); 40*7c478bd9Sstevel@tonic-gate extern void do_memory_watch(fcode_env_t *env); 41*7c478bd9Sstevel@tonic-gate 42*7c478bd9Sstevel@tonic-gate for (; ; ) { 43*7c478bd9Sstevel@tonic-gate if (next) { 44*7c478bd9Sstevel@tonic-gate DEBUGF(NEXT_VITALS, output_vitals(env); 45*7c478bd9Sstevel@tonic-gate log_message(MSG_FC_DEBUG, "\n")); 46*7c478bd9Sstevel@tonic-gate CHECK_INTERRUPT; 47*7c478bd9Sstevel@tonic-gate if (IP == NULL) 48*7c478bd9Sstevel@tonic-gate break; 49*7c478bd9Sstevel@tonic-gate WA = (token_t *) *IP; 50*7c478bd9Sstevel@tonic-gate IP++; 51*7c478bd9Sstevel@tonic-gate } 52*7c478bd9Sstevel@tonic-gate check_for_debug_entry(env); 53*7c478bd9Sstevel@tonic-gate indirect = *WA; 54*7c478bd9Sstevel@tonic-gate if (indirect & 1) { 55*7c478bd9Sstevel@tonic-gate target = indirect & ~1; 56*7c478bd9Sstevel@tonic-gate target = *((token_t *)target); 57*7c478bd9Sstevel@tonic-gate } else 58*7c478bd9Sstevel@tonic-gate target = indirect; 59*7c478bd9Sstevel@tonic-gate fn = (void (*)(fcode_env_t *)) target; 60*7c478bd9Sstevel@tonic-gate if (do_exec_debug(env, (void *)fn)) 61*7c478bd9Sstevel@tonic-gate break; 62*7c478bd9Sstevel@tonic-gate if (indirect & 1) { 63*7c478bd9Sstevel@tonic-gate PUSH(DS, (fstack_t) (WA+1)); 64*7c478bd9Sstevel@tonic-gate WA = (token_t *) target; 65*7c478bd9Sstevel@tonic-gate } 66*7c478bd9Sstevel@tonic-gate WA++; 67*7c478bd9Sstevel@tonic-gate fn(env); 68*7c478bd9Sstevel@tonic-gate check_vitals(env); 69*7c478bd9Sstevel@tonic-gate check_for_debug_exit(env); 70*7c478bd9Sstevel@tonic-gate do_memory_watch(env); 71*7c478bd9Sstevel@tonic-gate next = 1; 72*7c478bd9Sstevel@tonic-gate } 73*7c478bd9Sstevel@tonic-gate clear_debug_state(env, debug_state); 74*7c478bd9Sstevel@tonic-gate } 75*7c478bd9Sstevel@tonic-gate 76*7c478bd9Sstevel@tonic-gate void 77*7c478bd9Sstevel@tonic-gate do_semi(fcode_env_t *env) 78*7c478bd9Sstevel@tonic-gate { 79*7c478bd9Sstevel@tonic-gate CHECK_RETURN_DEPTH(env, 1, ";"); 80*7c478bd9Sstevel@tonic-gate check_semi_debug_exit(env); 81*7c478bd9Sstevel@tonic-gate IP = (token_t *) POP(RS); 82*7c478bd9Sstevel@tonic-gate } 83*7c478bd9Sstevel@tonic-gate 84*7c478bd9Sstevel@tonic-gate void 85*7c478bd9Sstevel@tonic-gate do_colon(fcode_env_t *env) 86*7c478bd9Sstevel@tonic-gate { 87*7c478bd9Sstevel@tonic-gate PUSH(RS, (fstack_t) IP); 88*7c478bd9Sstevel@tonic-gate IP = WA; 89*7c478bd9Sstevel@tonic-gate } 90*7c478bd9Sstevel@tonic-gate 91*7c478bd9Sstevel@tonic-gate void 92*7c478bd9Sstevel@tonic-gate do_alias(fcode_env_t *env) 93*7c478bd9Sstevel@tonic-gate { 94*7c478bd9Sstevel@tonic-gate token_t *ip; 95*7c478bd9Sstevel@tonic-gate 96*7c478bd9Sstevel@tonic-gate ip = IP; 97*7c478bd9Sstevel@tonic-gate IP = 0; 98*7c478bd9Sstevel@tonic-gate WA = (token_t *) *WA; 99*7c478bd9Sstevel@tonic-gate do_run(env, 0); 100*7c478bd9Sstevel@tonic-gate IP = ip; 101*7c478bd9Sstevel@tonic-gate } 102*7c478bd9Sstevel@tonic-gate 103*7c478bd9Sstevel@tonic-gate void 104*7c478bd9Sstevel@tonic-gate execute(fcode_env_t *env) 105*7c478bd9Sstevel@tonic-gate { 106*7c478bd9Sstevel@tonic-gate token_t *ip, *wa; 107*7c478bd9Sstevel@tonic-gate 108*7c478bd9Sstevel@tonic-gate /* 109*7c478bd9Sstevel@tonic-gate * In order to ensure that only this token executes we 110*7c478bd9Sstevel@tonic-gate * force IP to zero after stashing it, then when the stack 111*7c478bd9Sstevel@tonic-gate * unwinds (do_run returns) we can restore the old value. 112*7c478bd9Sstevel@tonic-gate */ 113*7c478bd9Sstevel@tonic-gate CHECK_DEPTH(env, 1, "execute"); 114*7c478bd9Sstevel@tonic-gate ip = IP; 115*7c478bd9Sstevel@tonic-gate wa = WA; 116*7c478bd9Sstevel@tonic-gate IP = 0; 117*7c478bd9Sstevel@tonic-gate WA = (token_t *) POP(DS); 118*7c478bd9Sstevel@tonic-gate do_run(env, 0); 119*7c478bd9Sstevel@tonic-gate IP = ip; 120*7c478bd9Sstevel@tonic-gate WA = wa; 121*7c478bd9Sstevel@tonic-gate } 122