X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=qemu%2Froms%2Fopenbios%2Finclude%2Fkernel%2Fstack.h;fp=qemu%2Froms%2Fopenbios%2Finclude%2Fkernel%2Fstack.h;h=5edfc5cf3489d1ec62a49a6067ecc5bd507e7754;hb=e44e3482bdb4d0ebde2d8b41830ac2cdb07948fb;hp=0000000000000000000000000000000000000000;hpb=9ca8dbcc65cfc63d6f5ef3312a33184e1d726e00;p=kvmfornfv.git 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