Ejemplo n.º 1
0
/* Powers down the machine we're running on,
   as long as we're running on Bochs or QEMU. */
void
shutdown_power_off (void)
{
  const char s[] = "Shutdown";
  const char *p;

#ifdef FILESYS
  filesys_done ();
#endif

  print_stats ();

  printf ("Powering off...\n");
  serial_flush ();

  /* ACPI Shutdown sequence supported by Bochs and QEMU
     http://forum.osdev.org/viewtopic.php?t=16990  */
  outw( 0xB004, 0x0 | 0x2000 );

  /* This is a special power-off sequence supported by Bochs and
     QEMU, but not by physical hardware. */
  for (p = s; *p != '\0'; p++)
    outb (0x8900, *p);

  /* This will power off a VMware VM if "gui.exitOnCLIHLT = TRUE"
     is set in its configuration file.  (The "pintos" script does
     that automatically.)  */
  asm volatile ("cli; hlt" : : : "memory");

  /* None of those worked. */
  printf ("still running...\n");
  for (;;);
}
Ejemplo n.º 2
0
/* Reboots the machine via the keyboard controller. */
void
shutdown_reboot (void)
{
  printf ("Rebooting...\n");
  
#ifdef FILESYS
  enum intr_level old_level = intr_enable ();
  filesys_done ();
  intr_set_level (old_level);
#endif

    /* See [kbd] for details on how to program the keyboard
     * controller. */
  for (;;)
    {
      int i;

      /* Poll keyboard controller's status byte until
       * 'input buffer empty' is reported. */
      for (i = 0; i < 0x10000; i++)
        {
          if ((inb (CONTROL_REG) & 0x02) == 0)
            break;
          timer_udelay (2);
        }

      timer_udelay (50);

      /* Pulse bit 0 of the output port P2 of the keyboard controller.
       * This will reset the CPU. */
      outb (CONTROL_REG, 0xfe);
      timer_udelay (50);
    }
}
Ejemplo n.º 3
0
/* Powers down the machine we're running on,
   as long as we're running on Bochs or QEMU. */
void
shutdown_power_off (void)
{
  switch (shutdown_power_off_recursion ++)
    {
      case 0:
#ifdef FILESYS
        {
          enum intr_level old_level = intr_enable ();
          filesys_done ();
          intr_set_level (old_level);
        }
#endif
      case 1:
        print_stats ();
        printf ("Powering off...\n");
        serial_flush ();
        break;
        
      default:
        shutdown_power_off_recursion = 2;
    }

  for (;;)
    {
      /* This is a special power-off sequence supported by Bochs and
         QEMU, but not by physical hardware. */
      const char *p;
      for (p = "Shutdown"; *p; ++p)
        outb (0x8900, *p);

      /* This will power off a VMware VM if "gui.exitOnCLIHLT = TRUE"
         is set in its configuration file.  (The "pintos" script does
         that automatically.)  */
      asm volatile ("cli; hlt");
      printf ("still running...\n");
    }
}
Ejemplo n.º 4
0
/* Powers down the machine we're running on,
   as long as we're running on Bochs or QEMU. */
void
shutdown_power_off (void)
{
  const char s[] = "Shutdown";
  const char *p;

  
#ifdef FILESYS
  printf("Closing filesystem\n");
  filesys_done ();
  	 printf("Printing Files in root directory\n");
	 void * LIST;
	 fsutil_ls(LIST);
	 printf("Printed Files in root directory\n");
	 printf("Setting *inode NULL\n");
  printf("Closed filesystem\n");
#endif

  print_stats ();

  printf ("Powering off...\n");
  serial_flush ();

  /* This is a special power-off sequence supported by Bochs and
     QEMU, but not by physical hardware. */
  for (p = s; *p != '\0'; p++)
    outb (0x8900, *p);

  /* This will power off a VMware VM if "gui.exitOnCLIHLT = TRUE"
     is set in its configuration file.  (The "pintos" script does
     that automatically.)  */
  asm volatile ("cli; hlt" : : : "memory");

  /* None of those worked. */
  printf ("still running...\n");
  for (;;);
}