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