DM: ioc code cleanup

- make ioc_init/ioc_deinit take struct vmctx as argument
- ioc_init return int instead of pointer to struct ioc_dev
- add ioc_dev in vmctx to track ioc_dev
- remove the atkbdc.h included in vmmapi.h

Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
Reviewed-by: Liu, Yuan1 <yuan1.liu@intel.com>
Reviewed-by: Jason Chen CJ <jason.cj.chen@intel.com>
Reviewed-by: Wang Yu <yu1.wang@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
Acked-by: Eddie Dong <Eddie.dong@intel.com>
This commit is contained in:
Yin Fengwei 2018-04-20 18:04:07 +08:00 committed by lijinxia
parent 68900064f4
commit bd86b66296
4 changed files with 18 additions and 8 deletions

View File

@ -781,7 +781,7 @@ main(int argc, char *argv[])
pci_irq_init(ctx);
atkbdc_init(ctx);
ioapic_init(ctx);
ioc_init();
ioc_init(ctx);
vrtc_init(ctx);
sci_init(ctx);

View File

@ -89,6 +89,7 @@
#include <sys/types.h>
#include "ioc.h"
#include "vmmapi.h"
/* For debugging log to a file */
static int ioc_debug;
@ -1051,8 +1052,8 @@ ioc_parse(const char *opts)
/*
* IOC mediator main entry.
*/
struct ioc_dev *
ioc_init(void)
int
ioc_init(struct vmctx *ctx)
{
int i;
struct ioc_dev *ioc;
@ -1161,7 +1162,9 @@ ioc_init(void)
(void *)ioc) < 0)
goto work_err;
return ioc;
ctx->ioc_dev = ioc;
return 0;
work_err:
pthread_mutex_destroy(&ioc->rx_mtx);
pthread_cond_destroy(&ioc->rx_cond);
@ -1179,15 +1182,17 @@ alloc_err:
ioc_err:
IOC_LOG_DEINIT;
DPRINTF("%s", "ioc mediator startup failed!!\r\n");
return NULL;
return -1;
}
/*
* Called by DM in main entry.
*/
void
ioc_deinit(struct ioc_dev *ioc)
ioc_deinit(struct vmctx *ctx)
{
struct ioc_dev *ioc = ctx->ioc_dev;
if (!ioc) {
DPRINTF("%s", "ioc deinit parameter is NULL\r\n");
return;
@ -1199,4 +1204,6 @@ ioc_deinit(struct ioc_dev *ioc)
free(ioc->pool);
free(ioc);
IOC_LOG_DEINIT;
ctx->ioc_dev = NULL;
}

View File

@ -710,9 +710,11 @@ struct ioc_dev {
/* Parse IOC parameters */
int ioc_parse(const char *opts);
struct vmctx;
/* IOC mediator common ops */
struct ioc_dev *ioc_init(void);
void ioc_deinit(struct ioc_dev *dev);
int ioc_init(struct vmctx *ctx);
void ioc_deinit(struct vmctx *ctx);
/* Build a cbc_request and send it to CBC protocol stack */
void ioc_build_request(struct ioc_dev *ioc, int32_t link_len, int32_t srv_len);

View File

@ -62,6 +62,7 @@ struct vmctx {
/* fields to track virtual devices */
void *atkbdc_base;
void *vrtc;
void *ioc_dev;
};
/*