ppc64: Don't set Kp bit on SLB
[openbios.git] / include / kernel / stack.h
blob5edfc5cf3489d1ec62a49a6067ecc5bd507e7754
1 /* stack.h
2 * tag: stack and stack access functions
4 * Copyright (C) 2003 Patrick Mauritz, Stefan Reinauer
6 * See the file "COPYING" for further information about
7 * the copyright and warranty status of this work.
8 */
10 #ifndef __STACK_H
11 #define __STACK_H
13 #define dstacksize 512
14 extern int dstackcnt;
15 extern cell dstack[dstacksize];
17 #define rstacksize 512
18 extern int rstackcnt;
19 extern cell rstack[rstacksize];
21 extern int dbgrstackcnt;
23 //typedef struct opaque_xt *xt_t;
24 //typedef struct opaque_ihandle *ihandle_t;
25 //typedef struct opaque_phandle *phandle_t;
27 typedef ucell xt_t;
28 typedef ucell ihandle_t;
29 typedef ucell phandle_t;
33 #ifdef NATIVE_BITWIDTH_EQUALS_HOST_BITWIDTH
35 static inline ucell pointer2cell(const void* x)
37 return (ucell)(uintptr_t)x;
40 static inline void* cell2pointer(ucell x)
42 return (void*)(uintptr_t)x;
45 #endif
47 static inline void PUSH(ucell value) {
48 dstack[++dstackcnt] = (value);
50 static inline void PUSH_xt( xt_t xt ) { PUSH( (ucell)xt ); }
51 static inline void PUSH_ih( ihandle_t ih ) { PUSH( (ucell)ih ); }
52 static inline void PUSH_ph( phandle_t ph ) { PUSH( (ucell)ph ); }
54 static inline ucell POP(void) {
55 return (ucell) dstack[dstackcnt--];
57 static inline xt_t POP_xt( void ) { return (xt_t)POP(); }
58 static inline ihandle_t POP_ih( void ) { return (ihandle_t)POP(); }
59 static inline phandle_t POP_ph( void ) { return (phandle_t)POP(); }
61 static inline void DROP(void) {
62 dstackcnt--;
65 static inline void DDROP(void) {
66 dstackcnt -= 2;
69 static inline void DPUSH(ducell value) {
70 #ifdef NEED_FAKE_INT128_T
71 dstack[++dstackcnt] = (cell) value.lo;
72 dstack[++dstackcnt] = (cell) value.hi;
73 #else
74 dstack[++dstackcnt] = (cell) value;
75 dstack[++dstackcnt] = (cell) (value >> bitspercell);
76 #endif
79 static inline ducell DPOP(void) {
80 #ifdef NEED_FAKE_INT128_T
81 ducell du;
82 du.hi = (ucell) dstack[dstackcnt--];
83 du.lo = (ucell) dstack[dstackcnt--];
84 return du;
85 #else
86 ducell du;
87 du = ((ducell)(ucell) dstack[dstackcnt--]) << bitspercell;
88 du |= (ucell) dstack[dstackcnt--];
89 return du;
90 #endif
93 static inline ucell GETTOS(void) {
94 return dstack[dstackcnt];
97 #define GETITEM(number) (dstack[dstackcnt - number])
98 static inline void PUSHR(ucell value) {
99 rstack[++rstackcnt] = (value);
102 static inline ucell POPR(void) {
103 return (ucell) rstack[rstackcnt--];
105 static inline ucell GETTORS(void) {
106 return rstack[rstackcnt];
110 #if defined(DEBUG_DSTACK) || defined(FCOMPILER)
111 void printdstack(void);
112 #endif
113 #if defined(DEBUG_RSTACK) || defined(FCOMPILER)
114 void printrstack(void);
115 #endif
117 #endif