vof.h 2.1 KB

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