xref: /openbmc/qemu/include/hw/ppc/vof.h (revision 2f44bea9)
1 /*
2  * Virtual Open Firmware
3  *
4  * SPDX-License-Identifier: GPL-2.0-or-later
5  */
6 #ifndef HW_VOF_H
7 #define HW_VOF_H
8 
9 typedef struct Vof {
10     uint64_t top_addr; /* copied from rma_size */
11     GArray *claimed; /* array of SpaprOfClaimed */
12     uint64_t claimed_base;
13     GHashTable *of_instances; /* ihandle -> SpaprOfInstance */
14     uint32_t of_instance_last;
15     char *bootargs;
16     long fw_size;
17 } Vof;
18 
19 int vof_client_call(MachineState *ms, Vof *vof, void *fdt,
20                     target_ulong args_real);
21 uint64_t vof_claim(Vof *vof, uint64_t virt, uint64_t size, uint64_t align);
22 void vof_init(Vof *vof, uint64_t top_addr, Error **errp);
23 void vof_cleanup(Vof *vof);
24 void vof_build_dt(void *fdt, Vof *vof);
25 uint32_t vof_client_open_store(void *fdt, Vof *vof, const char *nodename,
26                                const char *prop, const char *path);
27 
28 #define TYPE_VOF_MACHINE_IF "vof-machine-if"
29 
30 typedef struct VofMachineIfClass VofMachineIfClass;
31 DECLARE_CLASS_CHECKERS(VofMachineIfClass, VOF_MACHINE, TYPE_VOF_MACHINE_IF)
32 
33 struct VofMachineIfClass {
34     InterfaceClass parent;
35     target_ulong (*client_architecture_support)(MachineState *ms, CPUState *cs,
36                                                 target_ulong vec);
37     void (*quiesce)(MachineState *ms);
38     bool (*setprop)(MachineState *ms, const char *path, const char *propname,
39                     void *val, int vallen);
40 };
41 
42 /*
43  * Initial stack size is from
44  * https://www.devicetree.org/open-firmware/bindings/ppc/release/ppc-2_1.html#REF27292
45  *
46  * "Client programs shall be invoked with a valid stack pointer (r1) with
47  * at least 32K bytes of memory available for stack growth".
48  */
49 #define VOF_STACK_SIZE       0x8000
50 
51 #define VOF_MEM_READ(pa, buf, size) \
52     address_space_read(&address_space_memory, \
53     (pa), MEMTXATTRS_UNSPECIFIED, (buf), (size))
54 #define VOF_MEM_WRITE(pa, buf, size) \
55     address_space_write(&address_space_memory, \
56     (pa), MEMTXATTRS_UNSPECIFIED, (buf), (size))
57 
58 #define PROM_ERROR          (~0U)
59 
60 #endif /* HW_VOF_H */
61