1 #ifndef L4_PPC32_OF_H__
2 #define L4_PPC32_OF_H__
19 prom_args(const char *s, int na, int nr) : service(s), nargs(na), nret(nr) {}
22 typedef int (*prom_entry)(struct prom_args *);
24 //int prom_call(const char *service, int nargs, int nret, ...) const;
31 typedef void *ihandle_t;
32 typedef void *phandle_t;
41 unsigned prom_call(const char *service, int nargs, int nret, ...) const
43 struct prom_args args = prom_args(service, nargs, nret);
47 for(int i = 0; i < nargs; i++)
48 args.args[i] = va_arg(list, void*);
51 for(int i = 0; i < nret; i++)
52 args.args[nargs + i] = 0;
54 if(_prom()(&args) < 0)
57 return (nret > 0) ? (unsigned long)args.args[nargs] : 0;
61 int prom_getprop(phandle_t node, const char *pname, void *value,
64 return prom_call("getprop", 4, 1, node, pname, (unsigned long)value,
68 int prom_next_node(phandle_t *nodep)
72 if ((node = *nodep) != 0
73 && (*nodep = (phandle_t)prom_call("child", 1, 1, node)) != 0)
75 if ((*nodep = (phandle_t)prom_call("peer", 1, 1, node)) != 0)
78 if ((node = (phandle_t)prom_call("parent", 1, 1, node)) == 0)
80 if ((*nodep = (phandle_t)prom_call("peer", 1, 1, node)) != 0)
86 static inline bool handle_valid(T p)
88 return ((unsigned long)p != 0 && (unsigned long)p != PROM_ERROR);
91 static prom_entry _prom(unsigned long prom = 0)
93 static prom_entry local_prom;
96 local_prom = reinterpret_cast<prom_entry>(prom);
104 static void set_prom(unsigned long prom)
109 static unsigned long get_prom()
111 return reinterpret_cast<unsigned long>(_prom());
117 #endif /* L4_PPC32_OF_H__*/