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