@@ -106,6 +106,12 @@ do { if (ioc_debug && dbg_file) { fprintf(dbg_file, format, arg);\
106
106
fflush(dbg_file); } } while (0)
107
107
#define WPRINTF (format , arg ...) printf(format, ##arg)
108
108
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
+
109
115
/*
110
116
* Type definition for thread function.
111
117
*/
@@ -122,6 +128,16 @@ static char virtual_uart_path[32];
122
128
*/
123
129
static uint32_t ioc_boot_reason ;
124
130
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
+
125
141
/*
126
142
* IOC channels definition.
127
143
*/
@@ -146,6 +162,11 @@ static struct ioc_ch_info ioc_ch_tbl[] = {
146
162
{IOC_INIT_FD , IOC_NP_RAW10 , IOC_NATIVE_RAW10 , IOC_CH_ON },
147
163
{IOC_INIT_FD , IOC_NP_RAW11 , IOC_NATIVE_RAW11 , IOC_CH_ON },
148
164
{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
149
170
};
150
171
151
172
static struct cbc_signal cbc_tx_signal_table [] = {
@@ -713,6 +734,24 @@ ioc_ch_init(struct ioc_dev *ioc)
713
734
case IOC_VIRTUAL_UART :
714
735
fd = ioc_open_virtual_uart (virtual_uart_path );
715
736
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
716
755
default :
717
756
fd = -1 ;
718
757
break ;
@@ -751,6 +790,12 @@ ioc_ch_deinit(void)
751
790
close (chl -> fd );
752
791
chl -> fd = IOC_INIT_FD ;
753
792
}
793
+
794
+ #ifdef IOC_DUMMY
795
+ close (dummy0_sfd );
796
+ close (dummy1_sfd );
797
+ close (dummy2_sfd );
798
+ #endif
754
799
}
755
800
756
801
/*
@@ -890,7 +935,18 @@ ioc_process_tx(struct ioc_dev *ioc, enum ioc_ch_id id)
890
935
req -> srv_len = count ;
891
936
req -> link_len = 0 ;
892
937
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
893
948
req -> id = id ;
949
+ #endif
894
950
cbc_request_enqueue (ioc , req , CBC_QUEUE_T_TX , false);
895
951
return 0 ;
896
952
}
@@ -906,6 +962,11 @@ ioc_dispatch(struct ioc_dev *ioc, struct ioc_ch_info *chl)
906
962
case IOC_NATIVE_LFCC :
907
963
case IOC_NATIVE_SIGNAL :
908
964
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
909
970
ioc_process_tx (ioc , chl -> id );
910
971
break ;
911
972
case IOC_VIRTUAL_UART :
@@ -1158,6 +1219,9 @@ ioc_init(void)
1158
1219
if (ioc_is_platform_supported () != 0 )
1159
1220
goto ioc_err ;
1160
1221
1222
+ /* Check IOC boot reason */
1223
+ if (ioc_boot_reason == 0 )
1224
+ goto ioc_err ;
1161
1225
ioc = (struct ioc_dev * )calloc (1 , sizeof (struct ioc_dev ));
1162
1226
if (!ioc )
1163
1227
goto ioc_err ;
0 commit comments