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)
26 #include <allocator.h>
30 #define LAST_ELEMENT(x) x[sizeof x / sizeof x[0] - 1]
32 /* Hack to get around static inline issues */
33 #include "../lib/libhvcall/libhvcall.h"
36 extern char _start_OF[];
38 unsigned long fdt_start;
39 unsigned long romfs_base;
40 unsigned long epapr_magic;
41 unsigned long epapr_ima_size; // ePAPR initially mapped area size
42 unsigned char hash_table[HASHSIZE*CELLSIZE];
47 long engine(int mode, long param_1, long param_2)
50 // mode = ENGINE_MODE_PARAM_1 | MODE_PARAM_2
51 // (param_1 = error, param_2 = reason)
54 // mode = ENGINE_MODE_PARAM_1 | ENGINE_MODE_NOP
57 // mode = ENGINE_MODE_NOP | ENGINE_MODE_POP
60 // mode = ENGINE_MODE_PARAM_1 | MODE_PARAM_2 | ENGINE_MODE_EVAL
61 // (param_1 = strlen(string), param_2 = string)
65 static cell handler_stack[160];
66 static cell c_return[2];
72 static int init_engine = 0;
73 if (init_engine == 0) {
74 // one-time initialisation
76 LAST_ELEMENT(xt_FORTH_X2d_WORDLIST).a = xt_LASTWORD;
79 dp = the_data_stack - 1;
80 rp = handler_stack - 1;
82 // return-address for "evaluate" personality
84 c_return[1].a = &dummy;
87 if (mode & ENGINE_MODE_PARAM_2) {
90 if (mode & ENGINE_MODE_PARAM_1) {
94 if (mode & ENGINE_MODE_NOP ) {
98 if (mode & ENGINE_MODE_EVAL) {
100 ip = xt_EVALUATE + 2 + ((10 + CELLSIZE - 1) / CELLSIZE);
106 #include "board.code"
107 #include ISTR(TARG,code)
110 // Only reached in case of non-exception call
111 over: if (mode & ENGINE_MODE_POP) {