mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-09-24 02:08:04 +00:00
hv:Replace dynamic memory with static for port io
-- Add emulated port io index -- Add emulated pio array in vm structure -- Remove port list in vm structure -- Remove free_io_emulation_resource/register_io_handler/ create_io_handler APIs v2-->v3: -- not add 'is_emulated', check len == 0U -- Check if io_read/io_write handler is NULL before calling -- Replace ENUM with MACRO for emulated pio index to avoid MISRA-C violations v1-->v2: -- Remove EMUL_PIO_NUM in Kconfig, add emulated pio index for PIC/PCI/UART/RTC/PM Tracked-On: #861 Signed-off-by: Mingqiang Chi <mingqiang.chi@intel.com> Reviewed-by: Jason Chen CJ <jason.cj.chen@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
@@ -103,15 +103,7 @@ struct vm_arch {
|
||||
void *tmp_pg_array; /* Page array for tmp guest paging struct */
|
||||
struct acrn_vioapic vioapic; /* Virtual IOAPIC base address */
|
||||
struct acrn_vpic vpic; /* Virtual PIC */
|
||||
/**
|
||||
* A link to the IO handler of this VM.
|
||||
* We only register io handle to this link
|
||||
* when create VM on sequences and ungister it when
|
||||
* destory VM. So there no need lock to prevent preempt.
|
||||
* Besides, there only a few io handlers now, we don't
|
||||
* need binary search temporary.
|
||||
*/
|
||||
struct vm_io_handler *io_handler;
|
||||
struct vm_io_handler_desc emul_pio[EMUL_PIO_IDX_MAX];
|
||||
|
||||
/* reference to virtual platform to come here (as needed) */
|
||||
} __aligned(CPU_PAGE_SIZE);
|
||||
|
@@ -9,6 +9,19 @@
|
||||
|
||||
#include <types.h>
|
||||
|
||||
/* Define emulated port IO index */
|
||||
#define PIC_MASTER_PIO_IDX 0U
|
||||
#define PIC_SLAVE_PIO_IDX (PIC_MASTER_PIO_IDX + 1U)
|
||||
#define PIC_ELC_PIO_IDX (PIC_SLAVE_PIO_IDX + 1U)
|
||||
#define PCI_PIO_IDX (PIC_ELC_PIO_IDX + 1U)
|
||||
#define UART_PIO_IDX (PCI_PIO_IDX + 1U)
|
||||
#define PM1A_EVT_PIO_IDX (UART_PIO_IDX + 1U)
|
||||
#define PM1A_CNT_PIO_IDX (PM1A_EVT_PIO_IDX + 1U)
|
||||
#define PM1B_EVT_PIO_IDX (PM1A_CNT_PIO_IDX + 1U)
|
||||
#define PM1B_CNT_PIO_IDX (PM1B_EVT_PIO_IDX + 1U)
|
||||
#define RTC_PIO_IDX (PM1B_CNT_PIO_IDX + 1U)
|
||||
#define EMUL_PIO_IDX_MAX (RTC_PIO_IDX + 1U)
|
||||
|
||||
/* Write 1 byte to specified I/O port */
|
||||
static inline void pio_write8(uint8_t value, uint16_t port)
|
||||
{
|
||||
|
@@ -47,7 +47,7 @@ struct vm_io_range {
|
||||
uint32_t flags; /**< IO port attributes */
|
||||
};
|
||||
|
||||
struct vm_io_handler;
|
||||
struct vm_io_handler_desc;
|
||||
struct acrn_vm;
|
||||
struct acrn_vcpu;
|
||||
|
||||
@@ -108,10 +108,6 @@ struct vm_io_handler_desc {
|
||||
io_write_fn_t io_write;
|
||||
};
|
||||
|
||||
struct vm_io_handler {
|
||||
struct vm_io_handler *next;
|
||||
struct vm_io_handler_desc desc;
|
||||
};
|
||||
|
||||
#define IO_ATTR_R 0U
|
||||
#define IO_ATTR_RW 1U
|
||||
@@ -187,13 +183,6 @@ int32_t pio_instr_vmexit_handler(struct acrn_vcpu *vcpu);
|
||||
*/
|
||||
void setup_io_bitmap(struct acrn_vm *vm);
|
||||
|
||||
/**
|
||||
* @brief Free I/O bitmaps and port I/O handlers of \p vm
|
||||
*
|
||||
* @param vm The VM whose I/O bitmaps and handlers are to be freed
|
||||
*/
|
||||
void free_io_emulation_resource(struct acrn_vm *vm);
|
||||
|
||||
/**
|
||||
* @brief Allow a VM to access a port I/O range
|
||||
*
|
||||
@@ -210,14 +199,15 @@ void allow_guest_pio_access(struct acrn_vm *vm, uint16_t port_address,
|
||||
/**
|
||||
* @brief Register a port I/O handler
|
||||
*
|
||||
* @param vm The VM to which the port I/O handlers are registered
|
||||
* @param range The port I/O range that the given handlers can emulate
|
||||
* @param vm The VM to which the port I/O handlers are registered
|
||||
* @param pio_idx The emulated port io index
|
||||
* @param range The emulated port io range
|
||||
* @param io_read_fn_ptr The handler for emulating reads from the given range
|
||||
* @param io_write_fn_ptr The handler for emulating writes to the given range
|
||||
* @pre pio_idx < EMUL_PIO_IDX_MAX
|
||||
*/
|
||||
void register_io_emulation_handler(struct acrn_vm *vm, const struct vm_io_range *range,
|
||||
io_read_fn_t io_read_fn_ptr,
|
||||
io_write_fn_t io_write_fn_ptr);
|
||||
void register_io_emulation_handler(struct acrn_vm *vm, uint32_t pio_idx,
|
||||
const struct vm_io_range *range, io_read_fn_t io_read_fn_ptr, io_write_fn_t io_write_fn_ptr);
|
||||
|
||||
/**
|
||||
* @brief Register a MMIO handler
|
||||
|
Reference in New Issue
Block a user