@@ -40,6 +40,7 @@ static pthread_mutex_t work_mutex = PTHREAD_MUTEX_INITIALIZER;
40
40
41
41
static pthread_mutex_t acrnd_stop_mutex = PTHREAD_MUTEX_INITIALIZER ;
42
42
static unsigned int acrnd_stop_timeout ;
43
+ static unsigned char platform_has_hw_ioc ;
43
44
44
45
static int sigterm = 0 ; /* Exit acrnd when recevied SIGTERM and stop all vms */
45
46
#define VMS_STOP_TIMEOUT 20 /* Wait VMS_STOP_TIMEOUT sec to stop all vms */
@@ -246,7 +247,7 @@ static int active_all_vms(void)
246
247
struct vmmngr_struct * vm ;
247
248
int ret = 0 ;
248
249
pid_t pid ;
249
- unsigned reason ;
250
+ unsigned reason = 0 ;
250
251
251
252
vmmngr_update ();
252
253
@@ -258,7 +259,9 @@ static int active_all_vms(void)
258
259
acrnd_run_vm (vm -> name );
259
260
break ;
260
261
case VM_SUSPENDED :
261
- reason = get_sos_wakeup_reason ();
262
+ if (platform_has_hw_ioc ) {
263
+ reason = get_sos_wakeup_reason ();
264
+ }
262
265
ret += resume_vm (vm -> name , reason );
263
266
break ;
264
267
default :
@@ -304,6 +307,8 @@ static int wakeup_suspended_vms(unsigned wakeup_reason)
304
307
#define SOS_LCS_SOCK "sos-lcs"
305
308
#define DEFAULT_TIMEOUT 2U
306
309
#define ACRND_NAME "acrnd"
310
+ #define HW_IOC_PATH "/dev/cbc-early-signals"
311
+
307
312
static int acrnd_fd = -1 ;
308
313
309
314
unsigned get_sos_wakeup_reason (void )
@@ -579,14 +584,16 @@ void handle_acrnd_resume(struct mngr_msg *msg, int client_fd, void *param)
579
584
{
580
585
struct mngr_msg ack ;
581
586
struct stat st ;
582
- int wakeup_reason ;
587
+ int wakeup_reason = 0 ;
583
588
584
589
ack .msgid = msg -> msgid ;
585
590
ack .timestamp = msg -> timestamp ;
586
591
ack .data .err = -1 ;
587
592
588
593
/* acrnd get wakeup_reason from sos lcs */
589
- wakeup_reason = get_sos_wakeup_reason ();
594
+ if (platform_has_hw_ioc ) {
595
+ wakeup_reason = get_sos_wakeup_reason ();
596
+ }
590
597
591
598
if (wakeup_reason & CBC_WK_RSN_RTC ) {
592
599
printf ("Resumed UOS, by RTC timer, reason(%x)!\n" , wakeup_reason );
@@ -629,11 +636,13 @@ static void handle_on_exit(void)
629
636
630
637
int init_vm (void )
631
638
{
632
- unsigned int wakeup_reason ;
639
+ unsigned int wakeup_reason = 0 ;
633
640
int ret ;
634
641
635
642
/* init all UOSs, according wakeup_reason */
636
- wakeup_reason = get_sos_wakeup_reason ();
643
+ if (platform_has_hw_ioc ) {
644
+ wakeup_reason = get_sos_wakeup_reason ();
645
+ }
637
646
638
647
if (wakeup_reason & CBC_WK_RSN_RTC ) {
639
648
printf ("Loading timer list to set vms wakeup time\n" );
@@ -672,7 +681,13 @@ int main(int argc, char *argv[])
672
681
printf ("Ingrone unknown opt: %c\n" , opt );
673
682
}
674
683
}
675
-
684
+
685
+ if (!access (HW_IOC_PATH , F_OK )) {
686
+ platform_has_hw_ioc = 1 ;
687
+ } else {
688
+ platform_has_hw_ioc = 0 ;
689
+ }
690
+
676
691
/* create listening thread */
677
692
acrnd_fd = mngr_open_un (ACRND_NAME , MNGR_SERVER );
678
693
if (acrnd_fd < 0 ) {
0 commit comments