1 /******************************************************************************
2 * Copyright (c) 2004, 2008 IBM Corporation
4 * This program and the accompanying materials
5 * are made available under the terms of the BSD License
6 * which accompanies this distribution, and is available at
7 * http://www.opensource.org/licenses/bsd-license.php
10 * IBM Corporation - initial implementation
11 *****************************************************************************/
13 // Copyright 2002,2003,2004 Segher Boessenkool <segher@kernel.crashing.org>
18 #define ISTR(x,y) XSTR(x.y)
27 #include <allocator.h>
31 #define LAST_ELEMENT(x) x[sizeof x / sizeof x[0] - 1]
33 /* Hack to get around static inline issues */
34 #include "../lib/libhvcall/libhvcall.h"
37 extern char _start_OF[];
39 unsigned long fdt_start;
40 unsigned long romfs_base;
41 unsigned long epapr_magic;
42 unsigned long epapr_ima_size; // ePAPR initially mapped area size
43 unsigned char hash_table[HASHSIZE*CELLSIZE];
47 static int did_stackwarning;
48 extern char the_system_stack[];
51 long engine(int mode, long param_1, long param_2)
54 // mode = ENGINE_MODE_PARAM_1 | MODE_PARAM_2
55 // (param_1 = error, param_2 = reason)
58 // mode = ENGINE_MODE_PARAM_1 | ENGINE_MODE_NOP
61 // mode = ENGINE_MODE_NOP | ENGINE_MODE_POP
64 // mode = ENGINE_MODE_PARAM_1 | MODE_PARAM_2 | ENGINE_MODE_EVAL
65 // (param_1 = strlen(string), param_2 = string)
69 static cell handler_stack[160];
70 static cell c_return[2];
76 static int init_engine = 0;
77 if (init_engine == 0) {
78 // one-time initialisation
80 LAST_ELEMENT(xt_FORTH_X2d_WORDLIST).a = xt_LASTWORD;
83 dp = the_data_stack - 1;
84 rp = handler_stack - 1;
86 // return-address for "evaluate" personality
88 c_return[1].a = &dummy;
91 if ((char *)&ip < the_system_stack && !did_stackwarning) {
92 puts("ERROR: stack overflow in engine()!");
96 if (mode & ENGINE_MODE_PARAM_2) {
99 if (mode & ENGINE_MODE_PARAM_1) {
103 if (mode & ENGINE_MODE_NOP ) {
107 if (mode & ENGINE_MODE_EVAL) {
108 (++rp)->a = c_return;
109 ip = xt_EVALUATE + 2 + ((10 + CELLSIZE - 1) / CELLSIZE);
115 #include "board.code"
116 #include ISTR(TARG,code)
119 // Only reached in case of non-exception call
120 over: if (mode & ENGINE_MODE_POP) {