diff options
Diffstat (limited to 'qemu/roms/openbios/include/kernel')
-rw-r--r-- | qemu/roms/openbios/include/kernel/kernel.h | 58 | ||||
-rw-r--r-- | qemu/roms/openbios/include/kernel/stack.h | 117 |
2 files changed, 175 insertions, 0 deletions
diff --git a/qemu/roms/openbios/include/kernel/kernel.h b/qemu/roms/openbios/include/kernel/kernel.h new file mode 100644 index 000000000..c887e24b9 --- /dev/null +++ b/qemu/roms/openbios/include/kernel/kernel.h @@ -0,0 +1,58 @@ +/* + * Creation Date: <2003/12/19 00:20:11 samuel> + * Time-stamp: <2004/01/07 19:19:14 samuel> + * + * <kernel.h> + * + * + * + * Copyright (C) 2003, 2004 Samuel Rydh (samuel@ibrium.se) + * Stefan Reinauer (stepan@openbios.org) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 + * + */ + +#ifndef _H_KERNEL +#define _H_KERNEL + +#include "kernel/stack.h" +#include "asm/io.h" + +/* Interrupt status */ +#define FORTH_INTSTAT_CLR 0x0 +#define FORTH_INTSTAT_STOP 0x1 +#define FORTH_INTSTAT_DBG 0x2 + +extern volatile int interruptforth; +extern int enterforth( xt_t xt ); +extern void panic(const char *error) __attribute__ ((noreturn)); + +extern xt_t findword(const char *s1); +extern void modules_init( void ); +extern void init_trampoline(ucell *t); +extern void forth_init(void); + +/* arch kernel hooks */ +extern void exception(cell no); + +#ifdef FCOMPILER +extern void include_file( const char *str ); +extern void encode_file( const char *str ); +extern int get_inputbyte( void ); +extern void put_outputbyte( int c ); +#endif + +#ifndef BOOTSTRAP +#undef putchar +#undef getchar + +extern int putchar( int ch ); +extern int getchar( void ); +#endif + +extern int availchar( void ); + +#endif /* _H_KERNEL */ diff --git a/qemu/roms/openbios/include/kernel/stack.h b/qemu/roms/openbios/include/kernel/stack.h new file mode 100644 index 000000000..5edfc5cf3 --- /dev/null +++ b/qemu/roms/openbios/include/kernel/stack.h @@ -0,0 +1,117 @@ +/* stack.h + * tag: stack and stack access functions + * + * Copyright (C) 2003 Patrick Mauritz, Stefan Reinauer + * + * See the file "COPYING" for further information about + * the copyright and warranty status of this work. + */ + +#ifndef __STACK_H +#define __STACK_H + +#define dstacksize 512 +extern int dstackcnt; +extern cell dstack[dstacksize]; + +#define rstacksize 512 +extern int rstackcnt; +extern cell rstack[rstacksize]; + +extern int dbgrstackcnt; + +//typedef struct opaque_xt *xt_t; +//typedef struct opaque_ihandle *ihandle_t; +//typedef struct opaque_phandle *phandle_t; + +typedef ucell xt_t; +typedef ucell ihandle_t; +typedef ucell phandle_t; + + + +#ifdef NATIVE_BITWIDTH_EQUALS_HOST_BITWIDTH + +static inline ucell pointer2cell(const void* x) +{ + return (ucell)(uintptr_t)x; +} + +static inline void* cell2pointer(ucell x) +{ + return (void*)(uintptr_t)x; +} + +#endif + +static inline void PUSH(ucell value) { + dstack[++dstackcnt] = (value); +} +static inline void PUSH_xt( xt_t xt ) { PUSH( (ucell)xt ); } +static inline void PUSH_ih( ihandle_t ih ) { PUSH( (ucell)ih ); } +static inline void PUSH_ph( phandle_t ph ) { PUSH( (ucell)ph ); } + +static inline ucell POP(void) { + return (ucell) dstack[dstackcnt--]; +} +static inline xt_t POP_xt( void ) { return (xt_t)POP(); } +static inline ihandle_t POP_ih( void ) { return (ihandle_t)POP(); } +static inline phandle_t POP_ph( void ) { return (phandle_t)POP(); } + +static inline void DROP(void) { + dstackcnt--; +} + +static inline void DDROP(void) { + dstackcnt -= 2; +} + +static inline void DPUSH(ducell value) { +#ifdef NEED_FAKE_INT128_T + dstack[++dstackcnt] = (cell) value.lo; + dstack[++dstackcnt] = (cell) value.hi; +#else + dstack[++dstackcnt] = (cell) value; + dstack[++dstackcnt] = (cell) (value >> bitspercell); +#endif +} + +static inline ducell DPOP(void) { +#ifdef NEED_FAKE_INT128_T + ducell du; + du.hi = (ucell) dstack[dstackcnt--]; + du.lo = (ucell) dstack[dstackcnt--]; + return du; +#else + ducell du; + du = ((ducell)(ucell) dstack[dstackcnt--]) << bitspercell; + du |= (ucell) dstack[dstackcnt--]; + return du; +#endif +} + +static inline ucell GETTOS(void) { + return dstack[dstackcnt]; +} + +#define GETITEM(number) (dstack[dstackcnt - number]) +static inline void PUSHR(ucell value) { + rstack[++rstackcnt] = (value); +} + +static inline ucell POPR(void) { + return (ucell) rstack[rstackcnt--]; +} +static inline ucell GETTORS(void) { + return rstack[rstackcnt]; +} + + +#if defined(DEBUG_DSTACK) || defined(FCOMPILER) +void printdstack(void); +#endif +#if defined(DEBUG_RSTACK) || defined(FCOMPILER) +void printrstack(void); +#endif + +#endif |