2021-05-01 10:05:21 +00:00
|
|
|
/* SPDX-License-Identifier: MIT */
|
|
|
|
|
|
|
|
#ifndef HV_H
|
|
|
|
#define HV_H
|
|
|
|
|
2021-05-14 20:47:43 +00:00
|
|
|
#include "iodev.h"
|
2021-05-01 10:05:21 +00:00
|
|
|
#include "types.h"
|
2021-05-15 14:55:34 +00:00
|
|
|
#include "uartproxy.h"
|
2021-05-01 10:05:21 +00:00
|
|
|
|
2021-05-04 18:29:11 +00:00
|
|
|
typedef bool(hv_hook_t)(u64 addr, u64 *val, bool write, int width);
|
|
|
|
|
2021-05-27 12:17:01 +00:00
|
|
|
#define MMIO_EVT_WIDTH GENMASK(4, 0)
|
|
|
|
#define MMIO_EVT_WRITE BIT(5)
|
|
|
|
#define MMIO_EVT_MULTI BIT(6)
|
2021-05-15 13:03:29 +00:00
|
|
|
|
|
|
|
struct hv_evt_mmiotrace {
|
|
|
|
u32 flags;
|
|
|
|
u32 reserved;
|
|
|
|
u64 pc;
|
|
|
|
u64 addr;
|
|
|
|
u64 data;
|
|
|
|
};
|
|
|
|
|
2021-06-05 20:05:17 +00:00
|
|
|
struct hv_evt_irqtrace {
|
|
|
|
u32 flags;
|
|
|
|
u16 type;
|
|
|
|
u16 num;
|
|
|
|
};
|
|
|
|
|
2021-05-15 14:55:34 +00:00
|
|
|
struct hv_vm_proxy_hook_data {
|
|
|
|
u32 flags;
|
|
|
|
u32 id;
|
|
|
|
u64 addr;
|
2021-05-27 12:17:01 +00:00
|
|
|
u64 data[2];
|
2021-05-15 14:55:34 +00:00
|
|
|
};
|
|
|
|
|
2021-05-25 10:53:41 +00:00
|
|
|
typedef enum _hv_entry_type {
|
2021-05-15 14:55:34 +00:00
|
|
|
HV_HOOK_VM = 1,
|
2021-05-25 11:04:20 +00:00
|
|
|
HV_VTIMER,
|
2021-05-25 11:07:02 +00:00
|
|
|
HV_USER_INTERRUPT,
|
2021-05-27 12:16:17 +00:00
|
|
|
HV_WDT_BARK,
|
2021-05-25 10:53:41 +00:00
|
|
|
} hv_entry_type;
|
2021-05-15 14:55:34 +00:00
|
|
|
|
2021-05-04 06:38:17 +00:00
|
|
|
/* VM */
|
|
|
|
void hv_pt_init(void);
|
2021-05-01 10:05:21 +00:00
|
|
|
int hv_map(u64 from, u64 to, u64 size, u64 incr);
|
|
|
|
int hv_unmap(u64 from, u64 size);
|
|
|
|
int hv_map_hw(u64 from, u64 to, u64 size);
|
|
|
|
int hv_map_sw(u64 from, u64 to, u64 size);
|
2021-05-04 18:29:11 +00:00
|
|
|
int hv_map_hook(u64 from, hv_hook_t *hook, u64 size);
|
2021-05-04 18:27:19 +00:00
|
|
|
u64 hv_translate(u64 addr, bool s1only, bool w);
|
2021-05-04 18:29:11 +00:00
|
|
|
u64 hv_pt_walk(u64 addr);
|
|
|
|
bool hv_handle_dabort(u64 *regs);
|
2021-06-05 20:05:17 +00:00
|
|
|
bool hv_pa_write(u64 addr, u64 *val, int width);
|
|
|
|
bool hv_pa_read(u64 addr, u64 *val, int width);
|
|
|
|
bool hv_pa_rw(u64 addr, u64 *val, bool write, int width);
|
|
|
|
|
|
|
|
/* AIC events through tracing the MMIO event address */
|
|
|
|
bool hv_trace_irq(u32 type, u32 num, u32 count, u32 flags);
|
2021-05-04 06:38:17 +00:00
|
|
|
|
2021-05-04 18:30:07 +00:00
|
|
|
/* Virtual peripherals */
|
2021-08-23 08:02:28 +00:00
|
|
|
void hv_vuart_poll(void);
|
|
|
|
void hv_map_vuart(u64 base, int irq, iodev_id_t iodev);
|
2021-05-04 18:30:07 +00:00
|
|
|
|
2021-05-15 14:55:34 +00:00
|
|
|
/* Exceptions */
|
|
|
|
void hv_exc_proxy(u64 *regs, uartproxy_boot_reason_t reason, uartproxy_exc_code_t type,
|
|
|
|
void *extra);
|
|
|
|
|
2021-05-27 12:16:17 +00:00
|
|
|
/* WDT */
|
|
|
|
void hv_wdt_pet(void);
|
|
|
|
void hv_wdt_suspend(void);
|
|
|
|
void hv_wdt_resume(void);
|
|
|
|
void hv_wdt_init(void);
|
2021-09-15 13:08:35 +00:00
|
|
|
void hv_wdt_start(int cpu);
|
2021-05-27 12:16:17 +00:00
|
|
|
void hv_wdt_stop(void);
|
|
|
|
void hv_wdt_breadcrumb(char c);
|
|
|
|
|
2021-05-27 12:11:49 +00:00
|
|
|
/* Utilities */
|
2021-05-25 11:05:10 +00:00
|
|
|
void hv_write_hcr(u64 val);
|
2021-05-27 12:11:49 +00:00
|
|
|
u64 hv_get_spsr(void);
|
|
|
|
void hv_set_spsr(u64 val);
|
|
|
|
u64 hv_get_esr(void);
|
|
|
|
u64 hv_get_far(void);
|
|
|
|
u64 hv_get_elr(void);
|
2021-05-29 18:29:52 +00:00
|
|
|
u64 hv_get_afsr1(void);
|
2021-05-27 12:11:49 +00:00
|
|
|
void hv_set_elr(u64 val);
|
2021-05-25 11:05:10 +00:00
|
|
|
|
2021-05-04 06:38:17 +00:00
|
|
|
/* HV main */
|
|
|
|
void hv_init(void);
|
2021-05-01 10:05:21 +00:00
|
|
|
void hv_start(void *entry, u64 regs[4]);
|
2021-05-25 11:04:20 +00:00
|
|
|
void hv_arm_tick(void);
|
2021-05-27 16:24:29 +00:00
|
|
|
void hv_tick(u64 *regs);
|
2021-05-01 10:05:21 +00:00
|
|
|
|
|
|
|
#endif
|