grub2/0397-grub-core-kern-mips-loongson-init.c-Support-halt-for.patch
Peter Jones f74b50e380 Rebase to upstream, fix a pile of bugs. The usual.
Signed-off-by: Peter Jones <pjones@redhat.com>
2013-06-12 15:37:08 -04:00

79 lines
2.1 KiB
Diff

From 405b6d1cdc0d3fba50b0ba846c811a6ec1939ff3 Mon Sep 17 00:00:00 2001
From: Vladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Date: Tue, 30 Apr 2013 17:37:37 +0200
Subject: [PATCH 397/482] * grub-core/kern/mips/loongson/init.c: Support
halt for loongson 2E.
---
ChangeLog | 4 ++++
grub-core/kern/mips/loongson/init.c | 33 +++++++++++++++++++++++++++++++++
2 files changed, 37 insertions(+)
diff --git a/ChangeLog b/ChangeLog
index b0ae4ee..6b5feff 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
2013-04-30 Vladimir Serbinenko <phcoder@gmail.com>
+ * grub-core/kern/mips/loongson/init.c: Support halt for loongson 2E.
+
+2013-04-30 Vladimir Serbinenko <phcoder@gmail.com>
+
* grub-core/partmap/amiga.c: Fix size of checksummed block.
2013-04-29 Vladimir Serbinenko <phcoder@gmail.com>
diff --git a/grub-core/kern/mips/loongson/init.c b/grub-core/kern/mips/loongson/init.c
index 52cbfd4..3ed1ded 100644
--- a/grub-core/kern/mips/loongson/init.c
+++ b/grub-core/kern/mips/loongson/init.c
@@ -221,12 +221,45 @@ grub_machine_fini (void)
{
}
+static int
+halt_via (grub_pci_device_t dev, grub_pci_id_t pciid,
+ void *data __attribute__ ((unused)))
+{
+ grub_uint16_t pm;
+ grub_pci_address_t addr;
+
+ if (pciid != 0x30571106)
+ return 0;
+
+ addr = grub_pci_make_address (dev, 0x40);
+ pm = grub_pci_read (addr) & ~1;
+
+ if (pm == 0)
+ {
+ grub_pci_write (addr, 0x1801);
+ pm = 0x1800;
+ }
+
+ addr = grub_pci_make_address (dev, 0x80);
+ grub_pci_write_byte (addr, 0xff);
+
+ addr = grub_pci_make_address (dev, GRUB_PCI_REG_COMMAND);
+ grub_pci_write_word (addr, grub_pci_read_word (addr) | GRUB_PCI_COMMAND_IO_ENABLED);
+
+ /* FIXME: This one is derived from qemu. Check on real hardware. */
+ grub_outw (0x2000, pm + 4 + GRUB_MACHINE_PCI_IO_BASE);
+ grub_millisleep (5000);
+
+ return 0;
+}
+
void
grub_halt (void)
{
switch (grub_arch_machine)
{
case GRUB_ARCH_MACHINE_FULOONG2E:
+ grub_pci_iterate (halt_via, NULL);
break;
case GRUB_ARCH_MACHINE_FULOONG2F:
{
--
1.8.2.1