10 typedef unsigned long prom_arg_t
;
12 #define ADDR(x) (uint32_t)(x)
14 static int prom_handle(struct prom_args
*pargs
)
17 uint32_t rtassize
= 0;
20 if (strcmp("call-method", (void *)(unsigned long)pargs
->service
)) {
24 if (strcmp("instantiate-rtas", (void *)(unsigned long)pargs
->args
[0])) {
28 rtas
= ci_finddevice("/rtas");
29 /* rtas-size is set by QEMU depending of FWNMI support */
30 ci_getprop(rtas
, "rtas-size", &rtassize
, sizeof(rtassize
));
31 if (rtassize
< hv_rtas_size
) {
35 rtasbase
= (void *)(unsigned long) pargs
->args
[2];
37 memcpy(rtasbase
, hv_rtas
, hv_rtas_size
);
38 pargs
->args
[pargs
->nargs
] = 0;
39 pargs
->args
[pargs
->nargs
+ 1] = pargs
->args
[2];
44 void prom_entry(uint32_t args
)
46 if (prom_handle((void *)(unsigned long) args
)) {
51 static int call_ci(const char *service
, int nargs
, int nret
, ...)
54 struct prom_args args
;
57 args
.service
= ADDR(service
);
62 for (i
= 0; i
< nargs
; i
++) {
63 args
.args
[i
] = va_arg(list
, prom_arg_t
);
67 for (i
= 0; i
< nret
; i
++) {
68 args
.args
[nargs
+ i
] = 0;
71 if (ci_entry((uint32_t)(&args
)) < 0) {
75 return (nret
> 0) ? args
.args
[nargs
] : 0;
78 void ci_panic(const char *str
)
80 call_ci("exit", 0, 0);
83 phandle
ci_finddevice(const char *path
)
85 return call_ci("finddevice", 1, 1, path
);
88 uint32_t ci_getprop(phandle ph
, const char *propname
, void *prop
, int len
)
90 return call_ci("getprop", 4, 1, ph
, propname
, prop
, len
);