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