Skip to content

Commit edc5846

Browse files
fyin1jren1
authored andcommitted
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>
1 parent 4fcdebc commit edc5846

File tree

4 files changed

+18
-8
lines changed

4 files changed

+18
-8
lines changed

devicemodel/core/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -781,7 +781,7 @@ main(int argc, char *argv[])
781781
pci_irq_init(ctx);
782782
atkbdc_init(ctx);
783783
ioapic_init(ctx);
784-
ioc_init();
784+
ioc_init(ctx);
785785

786786
vrtc_init(ctx);
787787
sci_init(ctx);

devicemodel/hw/platform/ioc.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@
8989
#include <sys/types.h>
9090

9191
#include "ioc.h"
92+
#include "vmmapi.h"
9293

9394
/* For debugging log to a file */
9495
static int ioc_debug;
@@ -1051,8 +1052,8 @@ ioc_parse(const char *opts)
10511052
/*
10521053
* IOC mediator main entry.
10531054
*/
1054-
struct ioc_dev *
1055-
ioc_init(void)
1055+
int
1056+
ioc_init(struct vmctx *ctx)
10561057
{
10571058
int i;
10581059
struct ioc_dev *ioc;
@@ -1161,7 +1162,9 @@ ioc_init(void)
11611162
(void *)ioc) < 0)
11621163
goto work_err;
11631164

1164-
return ioc;
1165+
ctx->ioc_dev = ioc;
1166+
return 0;
1167+
11651168
work_err:
11661169
pthread_mutex_destroy(&ioc->rx_mtx);
11671170
pthread_cond_destroy(&ioc->rx_cond);
@@ -1179,15 +1182,17 @@ ioc_init(void)
11791182
ioc_err:
11801183
IOC_LOG_DEINIT;
11811184
DPRINTF("%s", "ioc mediator startup failed!!\r\n");
1182-
return NULL;
1185+
return -1;
11831186
}
11841187

11851188
/*
11861189
* Called by DM in main entry.
11871190
*/
11881191
void
1189-
ioc_deinit(struct ioc_dev *ioc)
1192+
ioc_deinit(struct vmctx *ctx)
11901193
{
1194+
struct ioc_dev *ioc = ctx->ioc_dev;
1195+
11911196
if (!ioc) {
11921197
DPRINTF("%s", "ioc deinit parameter is NULL\r\n");
11931198
return;
@@ -1199,4 +1204,6 @@ ioc_deinit(struct ioc_dev *ioc)
11991204
free(ioc->pool);
12001205
free(ioc);
12011206
IOC_LOG_DEINIT;
1207+
1208+
ctx->ioc_dev = NULL;
12021209
}

devicemodel/include/ioc.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -710,9 +710,11 @@ struct ioc_dev {
710710
/* Parse IOC parameters */
711711
int ioc_parse(const char *opts);
712712

713+
struct vmctx;
714+
713715
/* IOC mediator common ops */
714-
struct ioc_dev *ioc_init(void);
715-
void ioc_deinit(struct ioc_dev *dev);
716+
int ioc_init(struct vmctx *ctx);
717+
void ioc_deinit(struct vmctx *ctx);
716718

717719
/* Build a cbc_request and send it to CBC protocol stack */
718720
void ioc_build_request(struct ioc_dev *ioc, int32_t link_len, int32_t srv_len);

devicemodel/include/vmmapi.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ struct vmctx {
6262
/* fields to track virtual devices */
6363
void *atkbdc_base;
6464
void *vrtc;
65+
void *ioc_dev;
6566
};
6667

6768
/*

0 commit comments

Comments
 (0)