From af1a266670d040d2f4083ff309d732d648afba2a Mon Sep 17 00:00:00 2001
From: Angelos Mouzakitis <a.mouzakitis@virtualopensystems.com>
Date: Tue, 10 Oct 2023 14:33:42 +0000
Subject: Add submodule dependency files

Change-Id: Iaf8d18082d3991dec7c0ebbea540f092188eb4ec
---
 roms/openbios/arch/ppc/kernel.c | 99 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 99 insertions(+)
 create mode 100644 roms/openbios/arch/ppc/kernel.c

(limited to 'roms/openbios/arch/ppc/kernel.c')

diff --git a/roms/openbios/arch/ppc/kernel.c b/roms/openbios/arch/ppc/kernel.c
new file mode 100644
index 000000000..28f2965bb
--- /dev/null
+++ b/roms/openbios/arch/ppc/kernel.c
@@ -0,0 +1,99 @@
+/*
+ *   Creation Date: <2003/10/25 14:07:17 samuel>
+ *   Time-stamp: <2004/08/28 17:48:19 stepan>
+ *
+ *	<kernel.c>
+ *
+ *   Copyright (C) 2003, 2004 Samuel Rydh (samuel@ibrium.se)
+ *   Copyright (C) 2003, 2004 Stefan Reinauer
+ *
+ *   Based upon unix.c (from OpenBIOS):
+ *
+ *   Copyright (C) 2003 Patrick Mauritz, Stefan Reinauer
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   version 2
+ *
+ */
+
+#include "config.h"
+#include "dict.h"
+#include "libopenbios/bindings.h"
+#include "kernel/stack.h"
+#include "kernel/kernel.h"
+#include "libc/string.h"
+#include "kernel.h"
+
+#define MEMORY_SIZE	(256*1024)	/* 256K ram for hosted system */
+#define DICTIONARY_SIZE	(512*1024)	/* 512K for the dictionary   */
+
+static ucell 		*memory;
+
+/************************************************************************/
+/*	F U N C T I O N S						*/
+/************************************************************************/
+
+int
+forth_segv_handler( char *segv_addr )
+{
+	ucell addr = 0xdeadbeef;
+
+	if( PC >= (ucell) dict && PC <= (ucell) dict + dicthead )
+		addr = *(ucell *) PC;
+
+	printk("panic: segmentation violation at %x\n", (int)segv_addr);
+	printk("dict=0x%x here=0x%x(dict+0x%x) pc=0x%x(dict+0x%x)\n",
+	       (int)dict, (int)(dict + dicthead), dicthead,
+	       PC, PC - (ucell) dict);
+	printk("dstackcnt=%d rstackcnt=%d instruction=%x\n",
+	       dstackcnt, rstackcnt, addr);
+
+#ifdef DEBUG_DSTACK
+	printdstack();
+#endif
+#ifdef DEBUG_RSTACK
+	printrstack();
+#endif
+	return -1;
+}
+
+/*
+ * allocate memory and prepare engine for memory management.
+ */
+
+static void
+init_memory( void )
+{
+	memory = malloc(MEMORY_SIZE);
+	if( !memory )
+		panic("panic: not enough memory on host system.\n");
+
+	/* we push start and end of memory to the stack
+	 * so that it can be used by the forth word QUIT
+	 * to initialize the memory allocator
+	 */
+
+	PUSH( (ucell)memory );
+	PUSH( (ucell)memory + MEMORY_SIZE );
+}
+
+int
+initialize_forth( void )
+{
+	dict = malloc(DICTIONARY_SIZE);
+	load_dictionary( forth_dictionary, sizeof(forth_dictionary) );
+	forth_init();
+
+	PUSH_xt( bind_noname_func(arch_of_init) );
+	fword("PREPOST-initializer");
+
+	PC = (ucell)findword("initialize-of");
+	if( PC ) {
+		init_memory();
+		enterforth((xt_t)PC);
+		free( memory );
+	}
+	free( dict );
+	return 0;
+}
-- 
cgit