Print this page
XXXX introduce drv_sectohz


 452 
 453                 tod_ops.tod_set_watchdog_timer = rmc_set_watchdog_timer;
 454                 tod_ops.tod_clear_watchdog_timer = rmc_clear_watchdog_timer;
 455 
 456                 /*
 457                  * Now is a good time to activate hardware watchdog
 458                  * (if one exists).
 459                  */
 460                 mutex_enter(&tod_lock);
 461                 if (watchdog_enable && tod_ops.tod_set_watchdog_timer != NULL)
 462                         err = tod_ops.tod_set_watchdog_timer(0);
 463                 mutex_exit(&tod_lock);
 464                 if (err != 0)
 465                         printf("Hardware watchdog enabled\n");
 466 
 467                 /*
 468                  * Set time interval and start timesync routine.
 469                  * Also just this once set the Solaris clock
 470                  * to the RMC clock.
 471                  */
 472                 timesync_interval = drv_usectohz(5*60 * MICROSEC);
 473                 plat_timesync((void *) &attaching);
 474 
 475                 return (DDI_SUCCESS);
 476         case DDI_RESUME:
 477                 return (DDI_SUCCESS);
 478         default:
 479                 return (DDI_FAILURE);
 480         }
 481 }
 482 
 483 
 484 static int
 485 rmclomv_detach(dev_info_t *dip, ddi_detach_cmd_t cmd)
 486 {
 487         timeout_id_t    tid;
 488         int             instance;
 489         int             err;
 490 
 491         switch (cmd) {
 492         case DDI_DETACH:


2982 
2983                         /* rmclomv_checkrmc_lock is held at this point! */
2984                         CALLB_CPR_EXIT(&cprinfo);
2985 
2986                         thread_exit();
2987                         /* NOTREACHED */
2988                 }
2989 
2990                 rmclomv_checkrmc_sig = RMCLOMV_CHECKRMC_WAIT;
2991 
2992                 /*
2993                  * If the RMC is not responding, rmclomv_do_cmd() takes a
2994                  * long time and eventually times out. We conclude that the
2995                  * RMC is broken if it doesn't respond to a number of polls
2996                  * made 60 secs apart. So that the rmclomv_do_cmd() time-out
2997                  * period isn't added to our 60 second timer, make the
2998                  * timeout() call before calling rmclomv_do_cmd().
2999                  */
3000                 if (timer_id == 0) {
3001                         timer_id = timeout(rmclomv_checkrmc_wakeup, NULL,
3002                             60 * drv_usectohz(1000000));
3003                 }
3004 
3005                 mutex_exit(&rmclomv_checkrmc_lock);
3006 
3007                 err = rmclomv_do_cmd(DP_GET_SYSINFO, DP_GET_SYSINFO_R,
3008                     sizeof (sysinfo), NULL, (intptr_t)&sysinfo);
3009                 if (err == 0) {
3010                         mutex_enter(&rmclomv_state_lock);
3011                         state = rmclomv_rmc_state;
3012                         /* successful poll, reset fail count */
3013                         rmclomv_rmcfailcount = 0;
3014                         mutex_exit(&rmclomv_state_lock);
3015 
3016                         if (state != RMCLOMV_RMCSTATE_OK) {
3017                                 rmclomv_refresh_wakeup();
3018                         }
3019                 }
3020                 if ((err != 0) &&
3021                     (rmclomv_rmc_error != RMCLOMV_RMCSTATE_DOWNLOAD)) {
3022                         /*




 452 
 453                 tod_ops.tod_set_watchdog_timer = rmc_set_watchdog_timer;
 454                 tod_ops.tod_clear_watchdog_timer = rmc_clear_watchdog_timer;
 455 
 456                 /*
 457                  * Now is a good time to activate hardware watchdog
 458                  * (if one exists).
 459                  */
 460                 mutex_enter(&tod_lock);
 461                 if (watchdog_enable && tod_ops.tod_set_watchdog_timer != NULL)
 462                         err = tod_ops.tod_set_watchdog_timer(0);
 463                 mutex_exit(&tod_lock);
 464                 if (err != 0)
 465                         printf("Hardware watchdog enabled\n");
 466 
 467                 /*
 468                  * Set time interval and start timesync routine.
 469                  * Also just this once set the Solaris clock
 470                  * to the RMC clock.
 471                  */
 472                 timesync_interval = drv_sectohz(5 * 60);
 473                 plat_timesync((void *) &attaching);
 474 
 475                 return (DDI_SUCCESS);
 476         case DDI_RESUME:
 477                 return (DDI_SUCCESS);
 478         default:
 479                 return (DDI_FAILURE);
 480         }
 481 }
 482 
 483 
 484 static int
 485 rmclomv_detach(dev_info_t *dip, ddi_detach_cmd_t cmd)
 486 {
 487         timeout_id_t    tid;
 488         int             instance;
 489         int             err;
 490 
 491         switch (cmd) {
 492         case DDI_DETACH:


2982 
2983                         /* rmclomv_checkrmc_lock is held at this point! */
2984                         CALLB_CPR_EXIT(&cprinfo);
2985 
2986                         thread_exit();
2987                         /* NOTREACHED */
2988                 }
2989 
2990                 rmclomv_checkrmc_sig = RMCLOMV_CHECKRMC_WAIT;
2991 
2992                 /*
2993                  * If the RMC is not responding, rmclomv_do_cmd() takes a
2994                  * long time and eventually times out. We conclude that the
2995                  * RMC is broken if it doesn't respond to a number of polls
2996                  * made 60 secs apart. So that the rmclomv_do_cmd() time-out
2997                  * period isn't added to our 60 second timer, make the
2998                  * timeout() call before calling rmclomv_do_cmd().
2999                  */
3000                 if (timer_id == 0) {
3001                         timer_id = timeout(rmclomv_checkrmc_wakeup, NULL,
3002                             drv_sectohz(60));
3003                 }
3004 
3005                 mutex_exit(&rmclomv_checkrmc_lock);
3006 
3007                 err = rmclomv_do_cmd(DP_GET_SYSINFO, DP_GET_SYSINFO_R,
3008                     sizeof (sysinfo), NULL, (intptr_t)&sysinfo);
3009                 if (err == 0) {
3010                         mutex_enter(&rmclomv_state_lock);
3011                         state = rmclomv_rmc_state;
3012                         /* successful poll, reset fail count */
3013                         rmclomv_rmcfailcount = 0;
3014                         mutex_exit(&rmclomv_state_lock);
3015 
3016                         if (state != RMCLOMV_RMCSTATE_OK) {
3017                                 rmclomv_refresh_wakeup();
3018                         }
3019                 }
3020                 if ((err != 0) &&
3021                     (rmclomv_rmc_error != RMCLOMV_RMCSTATE_DOWNLOAD)) {
3022                         /*