blob: 38bb2032e28d89bb4e801eed13c3fc71ad97b16f [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001#define _GNU_SOURCE /**/
2
3#include <string.h>
4#include <stdio.h>
5#include <stdarg.h>
6#include <stdlib.h>
7#include <time.h>
8#include <syslog.h>
9#include <unistd.h>
10#include <errno.h>
11#include <signal.h>
12#include <netdb.h>
13#include <sys/types.h>
14#include <sys/ioctl.h>
15#include <sys/socket.h>
16#include <sys/time.h>
17#include <sys/uio.h>
18#include <sys/stat.h>
19#include <fcntl.h>
20#include <sys/sysctl.h>
21#include <net/if.h>
22#include <poll.h>
23#include <stddef.h>
24#include <linux/if_packet.h>
25#include <netinet/ether.h>
26#include <netinet/if_ether.h>
27#include <arpa/inet.h>
28#include <pthread.h>
29#include <zte_mdl.h>
30
xf.libe704612024-05-28 19:09:12 -070031#define PROC_CMDLINE_NO_CONSOLE (0)
32#define PROC_CMDLINE_CONSOLE (1)
33#define STDOUT_BUFFER_SIZE (256)
34#define STDOUT_PATH_DEVNULL "/dev/null"
35
lh9ed821d2023-04-07 01:36:19 -070036void nvserver_entry(void)
37{
38 nvserver_main(0,NULL);
39 return;
40}
41
42void at_ctl_entry(char *arg)
43{
44 //printf("at_ctl_entry boot:%s\n", arg);
45 char *argv[2];
46 argv[0] = NULL;
47 argv[1] = arg;
48
49 at_ctl_main(2, argv);
50 return;
51}
52
53void rtc_service_entry(char *arg)
54{
55 rtc_service_main(0,NULL);
56 return;
57}
58
59void zte_mainctrl_entry(char *arg)
60{
61 zte_mainctrl_main(0,NULL);
62 return;
63}
64
65void zte_hotplug_entry(char *arg)
66{
67 zte_hotplug_main(0,NULL);
68 return;
69}
70
71void zte_audio_res_ctrl_entry(char *arg)
72{
73 zte_audio_res_ctrl_main(0,NULL);
74 return;
75}
76
77void zte_drv_serial_ctrl_entry(char *arg)
78{
79 zte_drv_serial_ctrl_main();
80 return;
81}
82
83void zte_drv_usb_ctrl_entry(char *arg)
84{
85 zte_drv_usb_ctrl_main(0,NULL);
86 return;
87}
88
89void sntp_entry(char *arg)
90{
91 sntp_main(0,NULL);
92 return;
93}
xf.li6c8fc1e2023-08-12 00:11:09 -070094void wlan_entry(char *arg)
95{
jb.qi5532c6f2024-02-29 23:55:54 -080096#if (defined _USE_VEHICLE_DC_REF)&&(defined _USE_VEHICLE_DC_REF_MMC0) //jb.qi add for wifi config on 20240301
xf.li6c8fc1e2023-08-12 00:11:09 -070097 wlan_main(0,NULL);
jb.qi5532c6f2024-02-29 23:55:54 -080098#endif
xf.li6c8fc1e2023-08-12 00:11:09 -070099 return;
100}
lh9ed821d2023-04-07 01:36:19 -0700101void fota_dm_entry(char *arg)
102{
103 fota_dm_main(0,NULL);
104 //return; //kw 3
105}
106
xf.libe704612024-05-28 19:09:12 -0700107void rediect_stdout(void)
108{
109 int fd = 0;
110 FILE *file = NULL;
111 int console = PROC_CMDLINE_NO_CONSOLE;
112 char buffer[STDOUT_BUFFER_SIZE] = {0};
113
114 file = fopen("/proc/cmdline", "r");
115 if (file == NULL) {
116 printf("rediect_stdout: cmdline file read error\n");
117 return;
118 }
119
120 while (fgets(buffer, sizeof(buffer), file) != NULL)
121 {
122 if(strstr(buffer, "console"))
123 {
124 console = PROC_CMDLINE_CONSOLE;
125 break;
126 }
127 }
128
129 if((console == PROC_CMDLINE_NO_CONSOLE)
130 && ((fd = open(STDOUT_PATH_DEVNULL, O_RDWR, 0)) > 0))
131 {
132 (void)dup2(fd, STDIN_FILENO);
133 (void)dup2(fd, STDOUT_FILENO);
134 (void)dup2(fd, STDERR_FILENO);
135
136 setvbuf(stdout, NULL, _IOLBF, 0);
137 if (fd > STDERR_FILENO)
138 (void)close(fd);
139 }
140 fclose(file);
141}
142
lh9ed821d2023-04-07 01:36:19 -0700143int main(int argc, char *argv[])
144{
145 /* nvserver */
xf.lif2330622024-05-15 18:17:18 -0700146 pthread_t nvserver_thread_tid;
147
xf.libe704612024-05-28 19:09:12 -0700148 rediect_stdout();
xf.lif2330622024-05-15 18:17:18 -0700149 pthread_create(&nvserver_thread_tid, NULL, (void *)nvserver_entry, NULL);
150
lh9ed821d2023-04-07 01:36:19 -0700151 /* zte_drv_serial_ctrl */
152 pthread_t zte_drv_serial_ctrl_thread_tid;
153 pthread_create(&zte_drv_serial_ctrl_thread_tid, NULL, (void *)zte_drv_serial_ctrl_entry, NULL);
154 /* zte_drv_usb_ctrl */
155 pthread_t zte_drv_usb_ctrl_thread_tid;
156 pthread_create(&zte_drv_usb_ctrl_thread_tid, NULL, (void *)zte_drv_usb_ctrl_entry, NULL);
157
158 if (0 != strcmp(argv[2], "amt")) { //³äµç»òÕý³£¿ª»úģʽ
159 /* zte_hotplug */
160 pthread_t zte_hotplug_thread_tid;
161 pthread_create(&zte_hotplug_thread_tid, NULL, (void *)zte_hotplug_entry, NULL);
162
163#if(PRODUCT_TYPE != PRODUCT_TH)
164 /* at_ctl */
165 pthread_t at_ctl_thread_tid;
166 pthread_create(&at_ctl_thread_tid, NULL, (void *)at_ctl_entry, argv[1]);
167 /* rtc_service */
168 pthread_t rtc_service_thread_tid;
169 pthread_create(&rtc_service_thread_tid, NULL, (void *)rtc_service_entry, NULL);
170 /* zte_mainctrl */
171 pthread_t zte_mainctrl_thread_tid;
172 pthread_create(&zte_mainctrl_thread_tid, NULL, (void *)zte_mainctrl_entry, NULL);
173#endif
174
xf.li6c8fc1e2023-08-12 00:11:09 -0700175#ifdef _USE_VEHICLE_DC_REF
176 /* wifi_manager */
177 pthread_t wlan_thread_tid;
178 pthread_create(&wlan_thread_tid, NULL, (void *)wlan_entry, NULL);
179#endif
180
lh9ed821d2023-04-07 01:36:19 -0700181 /* zte_audio_res_ctrl */
182 pthread_t zte_audio_res_ctrl_thread_tid;
183 pthread_create(&zte_audio_res_ctrl_thread_tid, NULL, (void *)zte_audio_res_ctrl_entry, NULL);
184
185 /* sntp */
186 //pthread_t sntp_thread_tid;
187 //pthread_create(&sntp_thread_tid, NULL, (void *)sntp_entry, NULL);
188 /* zte_fota */
189 pthread_t fota_dm_thread_tid;
190 pthread_create(&fota_dm_thread_tid, NULL, (void *)fota_dm_entry, NULL);
191
192 }
193 while(1)
194 {
195 sleep(20);
xf.libdd93d52023-05-12 07:10:14 -0700196 //printf("app test -1 \n");
lh9ed821d2023-04-07 01:36:19 -0700197 }
198
199 return 0;
200}
201