mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-21 13:08:42 +00:00
dm: completely remove enable_bar()/disable_bar() functions
Following up ond648df766c
, surgically remove all the functions related to enable_bar()/disable_bar() that got introduced in8787b65fde
. Tracked-On: #2902 Signed-off-by: Peter Fang <peter.fang@intel.com> Reviewed-by: Shuo A Liu <shuo.a.liu@intel.com>
This commit is contained in:
parent
a718fbe860
commit
4c38ff00c6
@ -26,7 +26,6 @@
|
|||||||
* $FreeBSD$
|
* $FreeBSD$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
@ -45,7 +44,6 @@ static struct {
|
|||||||
int flags;
|
int flags;
|
||||||
inout_func_t handler;
|
inout_func_t handler;
|
||||||
void *arg;
|
void *arg;
|
||||||
bool enabled;
|
|
||||||
} inout_handlers[MAX_IOPORTS];
|
} inout_handlers[MAX_IOPORTS];
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -115,11 +113,6 @@ emulate_inout(struct vmctx *ctx, int *pvcpu, struct pio_request *pio_request)
|
|||||||
if (!(flags & IOPORT_F_OUT))
|
if (!(flags & IOPORT_F_OUT))
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inout_handlers[port].enabled == false) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
retval = handler(ctx, *pvcpu, in, port, bytes,
|
retval = handler(ctx, *pvcpu, in, port, bytes,
|
||||||
(uint32_t *)&(pio_request->value), arg);
|
(uint32_t *)&(pio_request->value), arg);
|
||||||
return retval;
|
return retval;
|
||||||
@ -148,42 +141,6 @@ init_inout(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
|
||||||
disable_inout(struct inout_port *iop)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
if (!VERIFY_IOPORT(iop->port, iop->size)) {
|
|
||||||
printf("invalid input: port:0x%x, size:%d",
|
|
||||||
iop->port, iop->size);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = iop->port; i < iop->port + iop->size; i++) {
|
|
||||||
inout_handlers[i].enabled = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
enable_inout(struct inout_port *iop)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
if (!VERIFY_IOPORT(iop->port, iop->size)) {
|
|
||||||
printf("invalid input: port:0x%x, size:%d",
|
|
||||||
iop->port, iop->size);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = iop->port; i < iop->port + iop->size; i++) {
|
|
||||||
inout_handlers[i].enabled = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
register_inout(struct inout_port *iop)
|
register_inout(struct inout_port *iop)
|
||||||
{
|
{
|
||||||
@ -211,7 +168,6 @@ register_inout(struct inout_port *iop)
|
|||||||
inout_handlers[i].flags = iop->flags;
|
inout_handlers[i].flags = iop->flags;
|
||||||
inout_handlers[i].handler = iop->handler;
|
inout_handlers[i].handler = iop->handler;
|
||||||
inout_handlers[i].arg = iop->arg;
|
inout_handlers[i].arg = iop->arg;
|
||||||
inout_handlers[i].enabled = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -33,7 +33,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdbool.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
@ -51,7 +50,6 @@ struct mmio_rb_range {
|
|||||||
struct mem_range mr_param;
|
struct mem_range mr_param;
|
||||||
uint64_t mr_base;
|
uint64_t mr_base;
|
||||||
uint64_t mr_end;
|
uint64_t mr_end;
|
||||||
bool enabled;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static RB_HEAD(mmio_rb_tree, mmio_rb_range) mmio_rb_root, mmio_rb_fallback;
|
static RB_HEAD(mmio_rb_tree, mmio_rb_range) mmio_rb_root, mmio_rb_fallback;
|
||||||
@ -168,25 +166,18 @@ emulate_mem(struct vmctx *ctx, struct mmio_request *mmio_req)
|
|||||||
if (mmio_hint && paddr >= mmio_hint->mr_base &&
|
if (mmio_hint && paddr >= mmio_hint->mr_base &&
|
||||||
paddr <= mmio_hint->mr_end)
|
paddr <= mmio_hint->mr_end)
|
||||||
entry = mmio_hint;
|
entry = mmio_hint;
|
||||||
|
else if (mmio_rb_lookup(&mmio_rb_root, paddr, &entry) == 0)
|
||||||
if (entry == NULL) {
|
/* Update the per-VM cache */
|
||||||
if (mmio_rb_lookup(&mmio_rb_root, paddr, &entry) == 0)
|
|
||||||
/* Update the per-VMU cache */
|
|
||||||
mmio_hint = entry;
|
mmio_hint = entry;
|
||||||
else if (mmio_rb_lookup(&mmio_rb_fallback, paddr, &entry)) {
|
else if (mmio_rb_lookup(&mmio_rb_fallback, paddr, &entry)) {
|
||||||
pthread_rwlock_unlock(&mmio_rwlock);
|
pthread_rwlock_unlock(&mmio_rwlock);
|
||||||
return -ESRCH;
|
return -ESRCH;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
pthread_rwlock_unlock(&mmio_rwlock);
|
||||||
|
|
||||||
assert(entry != NULL);
|
assert(entry != NULL);
|
||||||
|
|
||||||
if (entry->enabled == false) {
|
|
||||||
pthread_rwlock_unlock(&mmio_rwlock);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
pthread_rwlock_unlock(&mmio_rwlock);
|
|
||||||
|
|
||||||
if (mmio_req->direction == REQUEST_READ)
|
if (mmio_req->direction == REQUEST_READ)
|
||||||
err = mem_read(ctx, 0, paddr, (uint64_t *)&mmio_req->value,
|
err = mem_read(ctx, 0, paddr, (uint64_t *)&mmio_req->value,
|
||||||
size, &entry->mr_param);
|
size, &entry->mr_param);
|
||||||
@ -197,68 +188,6 @@ emulate_mem(struct vmctx *ctx, struct mmio_request *mmio_req)
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
|
||||||
disable_mem(struct mem_range *memp)
|
|
||||||
{
|
|
||||||
uint64_t paddr = memp->base;
|
|
||||||
struct mmio_rb_range *entry = NULL;
|
|
||||||
|
|
||||||
pthread_rwlock_rdlock(&mmio_rwlock);
|
|
||||||
/*
|
|
||||||
* First check the per-VM cache
|
|
||||||
*/
|
|
||||||
if (mmio_hint && paddr >= mmio_hint->mr_base &&
|
|
||||||
paddr <= mmio_hint->mr_end)
|
|
||||||
entry = mmio_hint;
|
|
||||||
|
|
||||||
if (entry == NULL) {
|
|
||||||
if (mmio_rb_lookup(&mmio_rb_root, paddr, &entry) == 0)
|
|
||||||
/* Update the per-VMU cache */
|
|
||||||
mmio_hint = entry;
|
|
||||||
else if (mmio_rb_lookup(&mmio_rb_fallback, paddr, &entry)) {
|
|
||||||
pthread_rwlock_unlock(&mmio_rwlock);
|
|
||||||
return -ESRCH;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
assert(entry != NULL);
|
|
||||||
entry->enabled = false;
|
|
||||||
pthread_rwlock_unlock(&mmio_rwlock);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
enable_mem(struct mem_range *memp)
|
|
||||||
{
|
|
||||||
uint64_t paddr = memp->base;
|
|
||||||
struct mmio_rb_range *entry = NULL;
|
|
||||||
|
|
||||||
pthread_rwlock_rdlock(&mmio_rwlock);
|
|
||||||
/*
|
|
||||||
* First check the per-VM cache
|
|
||||||
*/
|
|
||||||
if (mmio_hint && paddr >= mmio_hint->mr_base &&
|
|
||||||
paddr <= mmio_hint->mr_end)
|
|
||||||
entry = mmio_hint;
|
|
||||||
|
|
||||||
if (entry == NULL) {
|
|
||||||
if (mmio_rb_lookup(&mmio_rb_root, paddr, &entry) == 0)
|
|
||||||
/* Update the per-VMU cache */
|
|
||||||
mmio_hint = entry;
|
|
||||||
else if (mmio_rb_lookup(&mmio_rb_fallback, paddr, &entry)) {
|
|
||||||
pthread_rwlock_unlock(&mmio_rwlock);
|
|
||||||
return -ESRCH;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
assert(entry != NULL);
|
|
||||||
entry->enabled = true;
|
|
||||||
pthread_rwlock_unlock(&mmio_rwlock);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
register_mem_int(struct mmio_rb_tree *rbt, struct mem_range *memp)
|
register_mem_int(struct mmio_rb_tree *rbt, struct mem_range *memp)
|
||||||
{
|
{
|
||||||
@ -273,7 +202,6 @@ register_mem_int(struct mmio_rb_tree *rbt, struct mem_range *memp)
|
|||||||
mrp->mr_param = *memp;
|
mrp->mr_param = *memp;
|
||||||
mrp->mr_base = memp->base;
|
mrp->mr_base = memp->base;
|
||||||
mrp->mr_end = memp->base + memp->size - 1;
|
mrp->mr_end = memp->base + memp->size - 1;
|
||||||
mrp->enabled = true;
|
|
||||||
pthread_rwlock_wrlock(&mmio_rwlock);
|
pthread_rwlock_wrlock(&mmio_rwlock);
|
||||||
if (mmio_rb_lookup(rbt, memp->base, &entry) != 0)
|
if (mmio_rb_lookup(rbt, memp->base, &entry) != 0)
|
||||||
err = mmio_rb_add(rbt, mrp);
|
err = mmio_rb_add(rbt, mrp);
|
||||||
|
@ -74,7 +74,5 @@ void init_inout(void);
|
|||||||
int emulate_inout(struct vmctx *ctx, int *pvcpu, struct pio_request *req);
|
int emulate_inout(struct vmctx *ctx, int *pvcpu, struct pio_request *req);
|
||||||
int register_inout(struct inout_port *iop);
|
int register_inout(struct inout_port *iop);
|
||||||
int unregister_inout(struct inout_port *iop);
|
int unregister_inout(struct inout_port *iop);
|
||||||
int enable_inout(struct inout_port *iop);
|
|
||||||
int disable_inout(struct inout_port *iop);
|
|
||||||
|
|
||||||
#endif /* _INOUT_H_ */
|
#endif /* _INOUT_H_ */
|
||||||
|
@ -42,16 +42,13 @@ struct mem_range {
|
|||||||
long arg2;
|
long arg2;
|
||||||
uint64_t base;
|
uint64_t base;
|
||||||
uint64_t size;
|
uint64_t size;
|
||||||
bool enabled;
|
|
||||||
};
|
};
|
||||||
#define MEM_F_READ 0x1
|
#define MEM_F_READ 0x1
|
||||||
#define MEM_F_WRITE 0x2
|
#define MEM_F_WRITE 0x2
|
||||||
#define MEM_F_RW 0x3
|
#define MEM_F_RW (MEM_F_READ | MEM_F_WRITE)
|
||||||
#define MEM_F_IMMUTABLE 0x4 /* mem_range cannot be unregistered */
|
#define MEM_F_IMMUTABLE 0x4 /* mem_range cannot be unregistered */
|
||||||
|
|
||||||
int emulate_mem(struct vmctx *ctx, struct mmio_request *mmio_req);
|
int emulate_mem(struct vmctx *ctx, struct mmio_request *mmio_req);
|
||||||
int disable_mem(struct mem_range *memp);
|
|
||||||
int enable_mem(struct mem_range *memp);
|
|
||||||
int register_mem(struct mem_range *memp);
|
int register_mem(struct mem_range *memp);
|
||||||
int register_mem_fallback(struct mem_range *memp);
|
int register_mem_fallback(struct mem_range *memp);
|
||||||
int unregister_mem(struct mem_range *memp);
|
int unregister_mem(struct mem_range *memp);
|
||||||
|
Loading…
Reference in New Issue
Block a user