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