Add several methods for rebooting a processor.
Detect a rerun of POST under coreboot and attempt to reboot the
processor.
#define PORT_FD_DIR 0x03f7
#define PORT_SERIAL1 0x03f8
#define PORT_PCI_CMD 0x0cf8
+#define PORT_PCI_REBOOT 0x0cf9
#define PORT_PCI_DATA 0x0cfc
#define PORT_BIOS_DEBUG 0x0402
#define PORT_QEMU_CFG_CTL 0x0510
}
return -1;
}
+
+void
+pci_reboot(void)
+{
+ u8 v = inb(PORT_PCI_REBOOT) & ~6;
+ outb(v|2, PORT_PCI_REBOOT); /* Request hard reset */
+ udelay(50);
+ outb(v|6, PORT_PCI_REBOOT); /* Actually do the reset */
+ udelay(50);
+}
int pci_init_device(const struct pci_device_id *table, u16 bdf, void *arg);
int pci_find_init_device(const struct pci_device_id *ids, void *arg);
+void pci_reboot(void);
// pirtable.c
void create_pirtable(void);
memmap_finalize();
}
+// Attempt to invoke a hard-reboot.
+static void
+tryReboot(void)
+{
+ dprintf(1, "Attempting a hard reboot\n");
+
+ // Try keyboard controller reboot.
+ i8042_reboot();
+
+ // Try PCI 0xcf9 reboot
+ pci_reboot();
+
+ // Try triple fault
+ asm volatile("int3");
+
+ panic("Could not reboot");
+}
+
+static int HaveRunPost;
+
// 32-bit entry point.
void VISIBLE32FLAT
_start(void)
debug_serial_setup();
dprintf(1, "Start bios (version %s)\n", VERSION);
+ if (CONFIG_COREBOOT && HaveRunPost)
+ // This is a soft reboot - invoke a hard reboot.
+ tryReboot();
+
// Allow writes to modify bios area (0xf0000)
make_bios_writable();
+ if (CONFIG_COREBOOT)
+ HaveRunPost = 1;
+
// Perform main setup code.
post();
return -1;
}
-int
+static int
i8042_flush(void)
{
dprintf(7, "i8042_flush\n");
return 0;
}
-int
+static int
i8042_command(int command, u8 *param)
{
dprintf(7, "i8042_command cmd=%x\n", command);
return i8042_command(I8042_CMD_AUX_SEND, &c);
}
+void
+i8042_reboot(void)
+{
+ int i;
+ for (i=0; i<10; i++) {
+ i8042_wait_write();
+ udelay(50);
+ outb(0xfe, PORT_PS2_STATUS); /* pulse reset low */
+ udelay(50);
+ }
+}
+
/****************************************************************
* Device commands.
#define I8042_CTR_XLATE 0x40
// functions
-int i8042_flush(void);
-int i8042_command(int command, u8 *param);
+void i8042_reboot(void);
int ps2_kbd_command(int command, u8 *param);
int ps2_mouse_command(int command, u8 *param);
void ps2port_setup(void);