Skip to content

Commit fd5472b

Browse files
yliu80jren1
authored andcommitted
IOC mediator: DEBUG: add dummy channels
Add three PTY devices as dummy native channels. They are used for emulating native lifecycle channel, native signal channel and native OEM raw channel for IOC debugging. Signed-off-by: Liu Yuan <yuan1.liu@intel.com> Reviewed-by: Wang Yu <yu1.wang@intel.com> Reviewed-by: Liu Shuo <shuo.a.liu@intel.com> Reviewed-by: Zhao Yakui <yakui.zhao@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
1 parent 75b5e67 commit fd5472b

File tree

1 file changed

+64
-0
lines changed
  • devicemodel/hw/platform

1 file changed

+64
-0
lines changed

devicemodel/hw/platform/ioc.c

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,12 @@ do { if (ioc_debug && dbg_file) { fprintf(dbg_file, format, arg);\
106106
fflush(dbg_file); } } while (0)
107107
#define WPRINTF(format, arg...) printf(format, ##arg)
108108

109+
/*
110+
* For debugging only, to generate lifecycle, signal and oem-raw data
111+
* from PTY devices instead of native CBC cdevs.
112+
*/
113+
/* #define IOC_DUMMY */
114+
109115
/*
110116
* Type definition for thread function.
111117
*/
@@ -122,6 +128,16 @@ static char virtual_uart_path[32];
122128
*/
123129
static uint32_t ioc_boot_reason;
124130

131+
/*
132+
* Dummy pty slave fd is to maintain the pty active,
133+
* to avoid EIO error when close the slave pty.
134+
*/
135+
#ifdef IOC_DUMMY
136+
static int dummy0_sfd = -1;
137+
static int dummy1_sfd = -1;
138+
static int dummy2_sfd = -1;
139+
#endif
140+
125141
/*
126142
* IOC channels definition.
127143
*/
@@ -146,6 +162,11 @@ static struct ioc_ch_info ioc_ch_tbl[] = {
146162
{IOC_INIT_FD, IOC_NP_RAW10, IOC_NATIVE_RAW10, IOC_CH_ON},
147163
{IOC_INIT_FD, IOC_NP_RAW11, IOC_NATIVE_RAW11, IOC_CH_ON},
148164
{IOC_INIT_FD, IOC_DP_NONE, IOC_VIRTUAL_UART, IOC_CH_ON},
165+
#ifdef IOC_DUMMY
166+
{IOC_INIT_FD, IOC_NP_FLF, IOC_NATIVE_DUMMY0, IOC_CH_ON},
167+
{IOC_INIT_FD, IOC_NP_FSIG, IOC_NATIVE_DUMMY1, IOC_CH_ON},
168+
{IOC_INIT_FD, IOC_NP_FRAW, IOC_NATIVE_DUMMY2, IOC_CH_ON}
169+
#endif
149170
};
150171

151172
static struct cbc_signal cbc_tx_signal_table[] = {
@@ -713,6 +734,24 @@ ioc_ch_init(struct ioc_dev *ioc)
713734
case IOC_VIRTUAL_UART:
714735
fd = ioc_open_virtual_uart(virtual_uart_path);
715736
break;
737+
#ifdef IOC_DUMMY
738+
/*
739+
* TODO: check open if success for dummy fd
740+
*/
741+
case IOC_NATIVE_DUMMY0:
742+
fd = ioc_open_virtual_uart(chl->name);
743+
dummy0_sfd = open(chl->name, O_RDWR | O_NOCTTY |
744+
O_NONBLOCK);
745+
case IOC_NATIVE_DUMMY1:
746+
fd = ioc_open_virtual_uart(chl->name);
747+
dummy1_sfd = open(chl->name, O_RDWR | O_NOCTTY |
748+
O_NONBLOCK);
749+
case IOC_NATIVE_DUMMY2:
750+
fd = ioc_open_virtual_uart(chl->name);
751+
dummy2_sfd = open(chl->name, O_RDWR | O_NOCTTY |
752+
O_NONBLOCK);
753+
break;
754+
#endif
716755
default:
717756
fd = -1;
718757
break;
@@ -751,6 +790,12 @@ ioc_ch_deinit(void)
751790
close(chl->fd);
752791
chl->fd = IOC_INIT_FD;
753792
}
793+
794+
#ifdef IOC_DUMMY
795+
close(dummy0_sfd);
796+
close(dummy1_sfd);
797+
close(dummy2_sfd);
798+
#endif
754799
}
755800

756801
/*
@@ -890,7 +935,18 @@ ioc_process_tx(struct ioc_dev *ioc, enum ioc_ch_id id)
890935
req->srv_len = count;
891936
req->link_len = 0;
892937
req->rtype = CBC_REQ_T_PROT;
938+
#ifdef IOC_DUMMY
939+
if (id == IOC_NATIVE_DUMMY0)
940+
req->id = IOC_NATIVE_LFCC;
941+
else if (id == IOC_NATIVE_DUMMY1)
942+
req->id = IOC_NATIVE_SIGNAL;
943+
else if (id == IOC_NATIVE_DUMMY2)
944+
req->id = IOC_NATIVE_RAW11;
945+
else
946+
req->id = id;
947+
#else
893948
req->id = id;
949+
#endif
894950
cbc_request_enqueue(ioc, req, CBC_QUEUE_T_TX, false);
895951
return 0;
896952
}
@@ -906,6 +962,11 @@ ioc_dispatch(struct ioc_dev *ioc, struct ioc_ch_info *chl)
906962
case IOC_NATIVE_LFCC:
907963
case IOC_NATIVE_SIGNAL:
908964
case IOC_NATIVE_RAW0 ... IOC_NATIVE_RAW11:
965+
#ifdef IOC_DUMMY
966+
case IOC_NATIVE_DUMMY0:
967+
case IOC_NATIVE_DUMMY1:
968+
case IOC_NATIVE_DUMMY2:
969+
#endif
909970
ioc_process_tx(ioc, chl->id);
910971
break;
911972
case IOC_VIRTUAL_UART:
@@ -1158,6 +1219,9 @@ ioc_init(void)
11581219
if (ioc_is_platform_supported() != 0)
11591220
goto ioc_err;
11601221

1222+
/* Check IOC boot reason */
1223+
if (ioc_boot_reason == 0)
1224+
goto ioc_err;
11611225
ioc = (struct ioc_dev *)calloc(1, sizeof(struct ioc_dev));
11621226
if (!ioc)
11631227
goto ioc_err;

0 commit comments

Comments
 (0)