1/* 2 * Copyright 2014, NICTA 3 * 4 * This software may be distributed and modified according to the terms of 5 * the BSD 2-Clause license. Note that NO WARRANTY is provided. 6 * See "LICENSE_BSD2.txt" for details. 7 * 8 * @TAG(NICTA_BSD) 9 */ 10 11struct s { 12 unsigned long x; 13}; 14 15struct word_struct { 16 unsigned long words[2]; 17}; 18 19struct sc { 20 struct s cap; 21 struct word_struct ws; 22}; 23 24static inline unsigned __attribute__((__const__)) 25 bb(struct word_struct word_struct) { 26 return (word_struct.words[0] & 0xfffffff8) << 0; 27 } 28 29static inline struct s __attribute__((__const__)) 30 cncn(void) { 31 struct s x; 32 x.x = 0; 33 return x; 34 } 35 36static inline unsigned __attribute__((__const__)) 37 aa(struct word_struct word_struct) { 38 return (word_struct.words[1] & 0xfffffff8) << 0; 39 } 40 41static inline void 42ff(struct word_struct *mdb_node_ptr, unsigned v) { 43 mdb_node_ptr->words[1] &= ~0xfffffff8; 44 mdb_node_ptr->words[1] |= (v >> 0) & 0xfffffff8; 45} 46 47static inline struct word_struct __attribute__((__const__)) 48 cc(struct word_struct word_struct, unsigned v) { 49 word_struct.words[0] &= ~0xfffffff8; 50 word_struct.words[0] |= (v >> 0) & 0xfffffff8; 51 return word_struct; 52 } 53 54static inline void 55ee(struct word_struct *mdb_node_ptr, unsigned v) { 56 mdb_node_ptr->words[0] &= ~0xfffffff8; 57 mdb_node_ptr->words[0] |= (v >> 0) & 0xfffffff8; 58} 59 60static inline struct word_struct 61mk_word_struct(unsigned long a, unsigned long b, unsigned long c, unsigned long d) { 62 struct word_struct w; 63 64 w.words[0] = 0; 65 w.words[1] = 0; 66 w.words[1] |= (a & 0xfffffff8); 67 w.words[1] |= (b & 0x1) << 1; 68 w.words[1] |= (c & 0x1); 69 w.words[0] |= (d & 0xfffffff8); 70 71 return w; 72} 73 74 75void 76do_call(struct s newCap, struct sc *s, struct sc *d) { 77 struct word_struct the_ws; 78 unsigned pp, np; 79 ; ; 80 the_ws = s->ws; 81 d->cap = newCap; 82 s->cap = cncn(); 83 d->ws = the_ws; 84 s->ws = mk_word_struct(0, 0, 0, 0); 85 86 pp = bb(the_ws); 87 if(pp) 88 ff(&((struct sc *)(pp))->ws, ((unsigned int)d)); 89 90 np = aa(the_ws); 91 if(np) 92 ee(&((struct sc *)(np))->ws, ((unsigned int)d)); 93} 94 95 96