emul: espi: Add ACPI Shared Memory functions

Add the bare minimum to set and access the ACPI shared memory via the
eSPI emulator.

Signed-off-by: Yuval Peress <peress@chromium.org>
This commit is contained in:
Yuval Peress 2021-07-28 21:40:13 -06:00 committed by Anas Nashif
commit ab6e724ab4
9 changed files with 192 additions and 1 deletions

View file

@ -61,6 +61,17 @@ typedef int (*emul_espi_api_get_vw)(struct espi_emul *emul,
enum espi_vwire_signal vw,
uint8_t *level);
#ifdef CONFIG_ESPI_PERIPHERAL_ACPI_SHM_REGION
/**
* Get the ACPI shared memory address owned by the emulator.
*
* @param emul Emulator instance.
*
* @retval The address of the memory.
*/
typedef uintptr_t (*emul_espi_api_get_acpi_shm)(struct espi_emul *emul);
#endif
/**
* Find an emulator present on a eSPI bus
*
@ -88,11 +99,13 @@ typedef struct espi_emul *(*emul_find_emul)(const struct device *dev,
typedef int (*emul_trigger_event)(const struct device *dev,
struct espi_event *evt);
/** Definition of the eSPI device emulator API */
struct emul_espi_device_api {
emul_espi_api_set_vw set_vw;
emul_espi_api_get_vw get_vw;
#ifdef CONFIG_ESPI_PERIPHERAL_ACPI_SHM_REGION
emul_espi_api_get_acpi_shm get_acpi_shm;
#endif
};
/** Node in a linked list of emulators for eSPI devices */
@ -152,6 +165,18 @@ int emul_espi_host_send_vw(const struct device *espi_dev,
*/
int emul_espi_host_port80_write(const struct device *espi_dev, uint32_t data);
#ifdef CONFIG_ESPI_PERIPHERAL_ACPI_SHM_REGION
/**
* Get the host device's ACPI shared memory start address. The size of the region is
* CONFIG_EMUL_ESPI_HOST_ACPI_SHM_REGION_SIZE.
*
* @param espi_dev eSPI emulation controller device.
* @return Address of the start of the ACPI shared memory.
*/
uintptr_t emul_espi_host_get_acpi_shm(const struct device *espi_dev);
#endif
#ifdef __cplusplus
}
#endif