Esempio n. 1
0
File: main.c Progetto: Hooman3/minix
/*===========================================================================*
 *				shutdown 				     *
 *===========================================================================*/
void minix_shutdown(minix_timer_t *tp)
{
/* This function is called from prepare_shutdown or stop_sequence to bring 
 * down MINIX.
 */
  int how;

#ifdef CONFIG_SMP
  /* 
   * FIXME
   *
   * we will need to stop timers on all cpus if SMP is enabled and put them in
   * such a state that we can perform the whole boot process once restarted from
   * monitor again
   */
  if (ncpus > 1)
	  smp_shutdown_aps();
#endif
  hw_intr_disable_all();
  stop_local_timer();

  how = tp ? tmr_arg(tp)->ta_int : 0;

  /* Show shutdown message */
  direct_cls();
  if((how & RB_POWERDOWN) == RB_POWERDOWN)
	direct_print("MINIX has halted and will now power off.\n");
  else if(how & RB_HALT)
	direct_print("MINIX has halted. "
		     "It is safe to turn off your computer.\n");
  else
	direct_print("MINIX will now reset.\n");
  arch_shutdown(how);
}
Esempio n. 2
0
/*===========================================================================*
 *				do_setalarm				     *
 *===========================================================================*/
int do_setalarm(struct proc * caller, message * m_ptr)
{
/* A process requests a synchronous alarm, or wants to cancel its alarm. */
  long exp_time;		/* expiration time for this alarm */
  int use_abs_time;		/* use absolute or relative time */
  timer_t *tp;			/* the process' timer structure */
  clock_t uptime;		/* placeholder for current uptime */

  /* Extract shared parameters from the request message. */
  exp_time = m_ptr->ALRM_EXP_TIME;	/* alarm's expiration time */
  use_abs_time = m_ptr->ALRM_ABS_TIME;	/* flag for absolute time */
  if (! (priv(caller)->s_flags & SYS_PROC)) return(EPERM);

  /* Get the timer structure and set the parameters for this alarm. */
  tp = &(priv(caller)->s_alarm_timer);
  tmr_arg(tp)->ta_int = caller->p_endpoint;
  tp->tmr_func = cause_alarm; 

  /* Return the ticks left on the previous alarm. */
  uptime = get_monotonic(); 
  if ((tp->tmr_exp_time != TMR_NEVER) && (uptime < tp->tmr_exp_time) ) {
      m_ptr->ALRM_TIME_LEFT = (tp->tmr_exp_time - uptime);
  } else {
      m_ptr->ALRM_TIME_LEFT = 0;
  }

  /* Finally, (re)set the timer depending on the expiration time. */
  if (exp_time == 0) {
      reset_timer(tp);
  } else {
      tp->tmr_exp_time = (use_abs_time) ? exp_time : exp_time + get_monotonic();
      set_timer(tp, tp->tmr_exp_time, tp->tmr_func);
  }
  return(OK);
}
Esempio n. 3
0
/*===========================================================================*
 *				cause_alarm				     *
 *===========================================================================*/
static void cause_alarm(timer_t *tp)
{
/* Routine called if a timer goes off and the process requested a synchronous
 * alarm. The process number is stored in timer argument 'ta_int'. Notify that
 * process with a notification message from CLOCK.
 */
  endpoint_t proc_nr_e = tmr_arg(tp)->ta_int;	/* get process number */
  mini_notify(proc_addr(CLOCK), proc_nr_e);	/* notify process */
}
Esempio n. 4
0
void nucleos_shutdown(timer_t *tp)
{
/* This function is called from prepare_shutdown or stop_sequence to bring
 * down Nucleos. How to shutdown is in the argument: RBT_HALT (return to the
 * monitor), RBT_MONITOR (execute given code), RBT_RESET (hard reset).
 */
	arch_stop_local_timer();
	intr_init(INTS_ORIG, 0);
	arch_shutdown(tp ? tmr_arg(tp)->ta_int : RBT_PANIC);
}
Esempio n. 5
0
/*===========================================================================*
 *				prepare_shutdown			     *
 *===========================================================================*/
void prepare_shutdown(const int how)
{
/* This function prepares to shutdown MINIX. */
  static timer_t shutdown_timer;

  /* Continue after 1 second, to give processes a chance to get scheduled to 
   * do shutdown work.  Set a watchog timer to call shutdown(). The timer 
   * argument passes the shutdown status. 
   */
  printf("MINIX will now be shut down ...\n");
  tmr_arg(&shutdown_timer)->ta_int = how;
  set_timer(&shutdown_timer, get_monotonic() + system_hz, minix_shutdown);
}
Esempio n. 6
0
void prepare_shutdown(int how)
{
	/* This function prepares to shutdown Nucleos. */
	static timer_t shutdown_timer;

	/* Continue after 1 second, to give processes a chance to get scheduled to
	 * do shutdown work.  Set a watchog timer to call shutdown(). The timer
	 * argument passes the shutdown status.
	 */
	printk("Nucleos will now be shut down ...\n");
	tmr_arg(&shutdown_timer)->ta_int = how;
	set_timer(&shutdown_timer, get_uptime() + system_hz, nucleos_shutdown);
}
Esempio n. 7
0
/*===========================================================================*
 *				select_timeout_check	  	     	     *
 *===========================================================================*/
void select_timeout_check(timer_t *timer)
{
  int s;
  struct selectentry *se;

  s = tmr_arg(timer)->ta_int;
  if (s < 0 || s >= MAXSELECTS) return;	/* Entry does not exist */

  se = &selecttab[s];
  if (se->requestor == NULL) return;
  fp = se->requestor;
  if (se->expiry <= 0) return;	/* Strange, did we even ask for a timeout? */
  se->expiry = 0;
  if (is_deferred(se)) return;	/* Wait for initial replies to DEV_SELECT */
  select_return(se);
}
Esempio n. 8
0
/*===========================================================================*
 *                              set_timer                                    *
 *===========================================================================*/
void set_timer(timer_t *tp, int ticks, tmr_func_t watchdog, int arg)
{
        int r;
        clock_t now, prev_time = 0, next_time;

        if ((r = getuptime(&now)) != OK)
                panic("set_timer: couldn't get uptime");

        /* Set timer argument and add timer to the list. */
        tmr_arg(tp)->ta_int = arg;
        prev_time = tmrs_settimer(&timers, tp, now+ticks, watchdog, &next_time);

        /* Reschedule our synchronous alarm if necessary. */
        if (expiring == 0 && (! prev_time || prev_time > next_time)) {
                if (sys_setalarm(next_time, 1) != OK)
                        panic("set_timer: couldn't set alarm");
        }
}
Esempio n. 9
0
/*===========================================================================*
 *				shutdown 				     *
 *===========================================================================*/
void minix_shutdown(timer_t *tp)
{
/* This function is called from prepare_shutdown or stop_sequence to bring 
 * down MINIX. How to shutdown is in the argument: RBT_HALT (return to the
 * monitor), RBT_RESET (hard reset). 
 */
  int how;

#ifdef CONFIG_SMP
  /* 
   * FIXME
   *
   * we will need to stop timers on all cpus if SMP is enabled and put them in
   * such a state that we can perform the whole boot process once restarted from
   * monitor again
   */
  if (ncpus > 1)
	  smp_shutdown_aps();
#endif
  hw_intr_disable_all();
  stop_local_timer();

  how = tp ? tmr_arg(tp)->ta_int : RBT_PANIC;

  /* Show shutdown message */
  direct_cls();
  switch(how) {
  case RBT_HALT:
	direct_print("MINIX has halted. "
		     "It is safe to turn off your computer.\n");
	break;
  case RBT_POWEROFF:
	direct_print("MINIX has halted and will now power off.\n");
	break;
  case RBT_DEFAULT:
  case RBT_REBOOT:
  case RBT_RESET:
  default:
	direct_print("MINIX will now reset.\n");
	break;
  }
  arch_shutdown(how);
}
Esempio n. 10
0
/*===========================================================================*
 *				pm_set_timer				     *
 *===========================================================================*/
PUBLIC void pm_set_timer(timer_t *tp, int ticks, tmr_func_t watchdog, int arg)
{
	int r;
	clock_t now, prev_time = 0, next_time;

	if ((r = getuptime(&now)) != OK)
		panic(__FILE__, "PM couldn't get uptime", NO_NUM);

	/* Set timer argument and add timer to the list. */
	tmr_arg(tp)->ta_int = arg;
	prev_time = tmrs_settimer(&pm_timers,tp,now+ticks,watchdog,&next_time);

	/* Reschedule our synchronous alarm if necessary. */
	if (! prev_time || prev_time > next_time) {
		if (sys_setalarm(next_time, 1) != OK)
			panic(__FILE__, "PM set timer couldn't set alarm.", NO_NUM);
	}

	return;
}
Esempio n. 11
0
/*===========================================================================*
 *				shutdown 				     *
 *===========================================================================*/
void minix_shutdown(timer_t *tp)
{
/* This function is called from prepare_shutdown or stop_sequence to bring 
 * down MINIX. How to shutdown is in the argument: RBT_HALT (return to the
 * monitor), RBT_MONITOR (execute given code), RBT_RESET (hard reset). 
 */
#ifdef CONFIG_SMP
  /* 
   * FIXME
   *
   * we will need to stop timers on all cpus if SMP is enabled and put them in
   * such a state that we can perform the whole boot process once restarted from
   * monitor again
   */
  if (ncpus > 1)
	  smp_shutdown_aps();
#endif
  hw_intr_disable_all();
  stop_local_timer();
  arch_shutdown(tp ? tmr_arg(tp)->ta_int : RBT_PANIC);
}