From: Albert Herranz <albert_herranz@yahoo.es>
To: linuxppc-dev@lists.ozlabs.org
Cc: Albert Herranz <albert_herranz@yahoo.es>
Subject: [RFC PATCH 05/19] powerpc: wii: bootwrapper bits
Date: Sun, 22 Nov 2009 23:01:36 +0100 [thread overview]
Message-ID: <1258927311-4340-6-git-send-email-albert_herranz@yahoo.es> (raw)
In-Reply-To: <1258927311-4340-5-git-send-email-albert_herranz@yahoo.es>
Add support for the Nintendo Wii video game console to the powerpc
bootwrapper.
dtbImage.wii is a wrapped image that contains a flat device tree,
an entry point compatible with the Homebrew Channel and BootMii,
and an optional initrd.
Signed-off-by: Albert Herranz <albert_herranz@yahoo.es>
---
arch/powerpc/boot/Makefile | 3 +-
arch/powerpc/boot/wii.c | 173 ++++++++++++++++++++++++++++++++++++++++++++
arch/powerpc/boot/wrapper | 3 +
3 files changed, 178 insertions(+), 1 deletions(-)
create mode 100644 arch/powerpc/boot/wii.c
diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
index b2f06b0..fbaf101 100644
--- a/arch/powerpc/boot/Makefile
+++ b/arch/powerpc/boot/Makefile
@@ -77,7 +77,7 @@ src-plat := of.c cuboot-52xx.c cuboot-824x.c cuboot-83xx.c cuboot-85xx.c holly.c
cuboot-warp.c cuboot-85xx-cpm2.c cuboot-yosemite.c simpleboot.c \
virtex405-head.S virtex.c redboot-83xx.c cuboot-sam440ep.c \
cuboot-acadia.c cuboot-amigaone.c cuboot-kilauea.c \
- gamecube.c
+ gamecube.c wii.c
src-boot := $(src-wlib) $(src-plat) empty.c
src-boot := $(addprefix $(obj)/, $(src-boot))
@@ -256,6 +256,7 @@ image-$(CONFIG_STORCENTER) += cuImage.storcenter
image-$(CONFIG_MPC7448HPC2) += cuImage.mpc7448hpc2
image-$(CONFIG_PPC_C2K) += cuImage.c2k
image-$(CONFIG_GAMECUBE) += dtbImage.gamecube
+image-$(CONFIG_WII) += dtbImage.wii
# Board port in arch/powerpc/platform/amigaone/Kconfig
image-$(CONFIG_AMIGAONE) += cuImage.amigaone
diff --git a/arch/powerpc/boot/wii.c b/arch/powerpc/boot/wii.c
new file mode 100644
index 0000000..65b73a1
--- /dev/null
+++ b/arch/powerpc/boot/wii.c
@@ -0,0 +1,173 @@
+/*
+ * arch/powerpc/boot/wii.c
+ *
+ * Nintendo Wii bootwrapper support
+ * Copyright (C) 2008-2009 The GameCube Linux Team
+ * Copyright (C) 2008,2009 Albert Herranz
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ */
+
+#include <stddef.h>
+#include "stdio.h"
+#include "types.h"
+#include "io.h"
+#include "ops.h"
+
+#include "ugecon.h"
+
+
+BSS_STACK(8192);
+
+/*
+ * We enter with an unknown cache, high BATs and MMU status.
+ *
+ * We enable the MMU with an identity mapped memory scheme as expected
+ * by the start code.
+ *
+ */
+asm ("\n\
+.text\n\
+.globl _zimage_start\n\
+_zimage_start:\n\
+\n\
+ mfmsr 9\n\
+ andi. 0, 9, (1<<4)|(1<<5) /* MSR_DR|MSR_IR */\n\
+ bcl 20, 31, 1f\n\
+1: \n\
+ mflr 8\n\
+ clrlwi 8, 8, 3 /* convert to a real address */\n\
+ addi 8, 8, _mmu_off - 1b\n\
+ andc 9, 9, 0\n\
+ mtspr 0x01a, 8 /* SRR0 */\n\
+ mtspr 0x01b, 9 /* SRR1 */\n\
+ sync\n\
+ rfi\n\
+_mmu_off: \n\
+ /* MMU disabled */\n\
+\n\
+ /* Setup BATs */\n\
+ isync\n\
+ li 8, 0\n\
+ mtspr 0x210, 8 /* IBAT0U */\n\
+ mtspr 0x211, 8 /* IBAT0L */\n\
+ mtspr 0x212, 8 /* IBAT1U */\n\
+ mtspr 0x213, 8 /* IBAT1L */\n\
+ mtspr 0x214, 8 /* IBAT2U */\n\
+ mtspr 0x215, 8 /* IBAT2L */\n\
+ mtspr 0x216, 8 /* IBAT3U */\n\
+ mtspr 0x217, 8 /* IBAT3L */\n\
+ mtspr 0x218, 8 /* DBAT0U */\n\
+ mtspr 0x219, 8 /* DBAT0L */\n\
+ mtspr 0x21a, 8 /* DBAT1U */\n\
+ mtspr 0x21b, 8 /* DBAT1L */\n\
+ mtspr 0x21c, 8 /* DBAT2U */\n\
+ mtspr 0x21d, 8 /* DBAT2L */\n\
+ mtspr 0x21e, 8 /* DBAT3U */\n\
+ mtspr 0x21f, 8 /* DBAT3L */\n\
+\n\
+ mtspr 0x230, 8 /* IBAT4U */\n\
+ mtspr 0x231, 8 /* IBAT4L */\n\
+ mtspr 0x232, 8 /* IBAT5U */\n\
+ mtspr 0x233, 8 /* IBAT5L */\n\
+ mtspr 0x234, 8 /* IBAT6U */\n\
+ mtspr 0x235, 8 /* IBAT6L */\n\
+ mtspr 0x236, 8 /* IBAT7U */\n\
+ mtspr 0x237, 8 /* IBAT7L */\n\
+ mtspr 0x238, 8 /* DBAT4U */\n\
+ mtspr 0x239, 8 /* DBAT4L */\n\
+ mtspr 0x23a, 8 /* DBAT5U */\n\
+ mtspr 0x23b, 8 /* DBAT5L */\n\
+ mtspr 0x23c, 8 /* DBAT6U */\n\
+ mtspr 0x23d, 8 /* DBAT6L */\n\
+ mtspr 0x23e, 8 /* DBAT7U */\n\
+ mtspr 0x23f, 8 /* DBAT7L */\n\
+\n\
+ isync\n\
+ li 8, 0x01ff /* first 16MiB */\n\
+ li 9, 0x0002 /* rw */\n\
+ mtspr 0x210, 8 /* IBAT0U */\n\
+ mtspr 0x211, 9 /* IBAT0L */\n\
+ mtspr 0x218, 8 /* DBAT0U */\n\
+ mtspr 0x219, 9 /* DBAT0L */\n\
+\n\
+ lis 8, 0xcc00 /* I/O mem */\n\
+ ori 8, 8, 0x3ff /* 32MiB */\n\
+ lis 9, 0x0c00\n\
+ ori 9, 9, 0x002a /* uncached, guarded, rw */\n\
+ mtspr 0x21a, 8 /* DBAT1U */\n\
+ mtspr 0x21b, 9 /* DBAT1L */\n\
+\n\
+ lis 8, 0x0100 /* next 8MiB */\n\
+ ori 8, 8, 0x00ff /* 8MiB */\n\
+ lis 9, 0x0100 /* next 8MiB */\n\
+ ori 9, 9, 0x0002 /* rw */\n\
+ mtspr 0x214, 8 /* IBAT2U */\n\
+ mtspr 0x215, 9 /* IBAT2L */\n\
+ mtspr 0x21c, 8 /* DBAT2U */\n\
+ mtspr 0x21d, 9 /* DBAT2L */\n\
+\n\
+ lis 8, 0x1000 /* MEM2 */\n\
+ ori 8, 8, 0x07ff /* 64MiB */\n\
+ lis 9, 0x1000\n\
+ ori 9, 9, 0x0002 /* rw */\n\
+ mtspr 0x216, 8 /* IBAT3U */\n\
+ mtspr 0x217, 9 /* IBAT3L */\n\
+ mtspr 0x21e, 8 /* DBAT3U */\n\
+ mtspr 0x21f, 9 /* DBAT3L */\n\
+\n\
+ sync\n\
+ isync\n\
+\n\
+ /* enable high BATs */\n\
+ lis 8, 0x8200\n\
+ mtspr 0x3f3, 8 /* HID4 */\n\
+\n\
+ /* enable caches */\n\
+ mfspr 8, 0x3f0\n\
+ ori 8, 8, 0xc000\n\
+ mtspr 0x3f0, 8 /* HID0 */\n\
+ isync\n\
+\n\
+ li 3, 0\n\
+ li 4, 0\n\
+ li 5, 0\n\
+\n\
+ bcl 20, 31, 1f\n\
+1: \n\
+ mflr 8\n\
+ addi 8, 8, _mmu_on - 1b\n\
+ mfmsr 9\n\
+ ori 9, 9, (1<<4)|(1<<5) /* MSR_DR|MSR_IR */\n\
+ mtspr 0x01a, 8 /* SRR0 */\n\
+ mtspr 0x01b, 9 /* SRR1 */\n\
+ sync\n\
+ rfi\n\
+_mmu_on: \n\
+ /* turn on the front blue led (aka: yay! we got here!) */\n\
+ lis 8, 0xcd00\n\
+ ori 8, 8, 0x00c0\n\
+ lwz 9, 0(8)\n\
+ ori 9, 9, 0x20\n\
+ stw 9, 0(8)\n\
+ b _zimage_start_lib\n\
+");
+
+/*
+ *
+ */
+void platform_init(unsigned long r3, unsigned long r4, unsigned long r5)
+{
+ u32 heapsize = 24*1024*1024 - (u32)_end;
+
+ simple_alloc_init(_end, heapsize, 32, 64);
+ fdt_init(_dtb_start);
+
+ if (!ug_grab_io_base() && ug_is_adapter_present())
+ console_ops.write = ug_console_write;
+}
+
diff --git a/arch/powerpc/boot/wrapper b/arch/powerpc/boot/wrapper
index ac9e9a5..0e9ce10 100755
--- a/arch/powerpc/boot/wrapper
+++ b/arch/powerpc/boot/wrapper
@@ -230,6 +230,9 @@ xpedite52*)
link_address='0x1400000'
platformo=$object/cuboot-85xx.o
;;
+wii|gamecube)
+ link_address='0x600000'
+ ;;
esac
vmz="$tmpdir/`basename \"$kernel\"`.$ext"
--
1.6.3.3
next prev parent reply other threads:[~2009-11-22 22:02 UTC|newest]
Thread overview: 181+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-22 22:01 [RFC PATCH 00/19] powerpc: nintendo gamecube and wii support Albert Herranz
2009-11-22 22:01 ` [RFC PATCH 01/19] powerpc: gamecube/wii: usbgecko bootwrapper console support Albert Herranz
2009-11-22 22:01 ` [RFC PATCH 02/19] powerpc: gamecube: device tree Albert Herranz
2009-11-22 22:01 ` [RFC PATCH 03/19] powerpc: gamecube: bootwrapper bits Albert Herranz
2009-11-22 22:01 ` [RFC PATCH 04/19] powerpc: wii: device tree Albert Herranz
2009-11-22 22:01 ` Albert Herranz [this message]
2009-11-22 22:01 ` [RFC PATCH 06/19] powerpc: gamecube/wii: introduce GAMECUBE_COMMON Albert Herranz
2009-11-22 22:01 ` [RFC PATCH 07/19] powerpc: gamecube/wii: declare as non-coherent platforms Albert Herranz
2009-11-22 22:01 ` [RFC PATCH 08/19] powerpc: gamecube/wii: do not include PCI support Albert Herranz
2009-11-22 22:01 ` [RFC PATCH 09/19] powerpc: gamecube/wii: udbg support for usbgecko Albert Herranz
2009-11-22 22:01 ` [RFC PATCH 10/19] powerpc: gamecube/wii: early debugging using usbgecko Albert Herranz
2009-11-22 22:01 ` [RFC PATCH 11/19] powerpc: gamecube/wii: flipper interrupt controller support Albert Herranz
2009-11-22 22:01 ` [RFC PATCH 12/19] powerpc: gamecube: platform support Albert Herranz
2009-11-22 22:01 ` [RFC PATCH 13/19] powerpc: gamecube: default config Albert Herranz
2009-11-22 22:01 ` [RFC PATCH 14/19] powerpc: allow ioremap within reserved fake ram regions Albert Herranz
2009-11-22 22:01 ` [RFC PATCH 15/19] powerpc: broadway processor support Albert Herranz
2009-11-22 22:01 ` [RFC PATCH 16/19] powerpc: wii: hollywood interrupt controller support Albert Herranz
2009-11-22 22:01 ` [RFC PATCH 17/19] powerpc: wii: bootmii starlet 'mini' firmware support Albert Herranz
2009-11-22 22:01 ` [RFC PATCH 18/19] powerpc: wii: platform support Albert Herranz
2009-11-22 22:01 ` [RFC PATCH 19/19] powerpc: wii: default config Albert Herranz
2009-11-22 23:45 ` [RFC PATCH 18/19] powerpc: wii: platform support Grant Likely
2009-11-23 20:21 ` Albert Herranz
2009-11-24 22:24 ` Segher Boessenkool
2009-11-25 17:58 ` Albert Herranz
2009-11-26 22:05 ` Segher Boessenkool
2009-11-22 22:48 ` [RFC PATCH 17/19] powerpc: wii: bootmii starlet 'mini' firmware support Arnd Bergmann
2009-11-23 19:21 ` Albert Herranz
2009-11-24 22:13 ` Segher Boessenkool
2009-11-25 17:47 ` Albert Herranz
2009-11-26 22:00 ` Segher Boessenkool
2009-11-22 23:40 ` [RFC PATCH 16/19] powerpc: wii: hollywood interrupt controller support Grant Likely
2009-11-23 20:18 ` Albert Herranz
2009-11-24 21:54 ` Segher Boessenkool
2009-11-25 17:27 ` Albert Herranz
2009-11-26 5:23 ` Benjamin Herrenschmidt
2009-11-26 15:42 ` Albert Herranz
2009-11-26 21:13 ` Benjamin Herrenschmidt
2009-11-26 23:03 ` Segher Boessenkool
2009-11-22 23:38 ` [RFC PATCH 15/19] powerpc: broadway processor support Grant Likely
2009-11-23 20:16 ` Albert Herranz
2009-11-22 23:36 ` [RFC PATCH 14/19] powerpc: allow ioremap within reserved fake ram regions Grant Likely
2009-11-23 20:16 ` Albert Herranz
2009-11-23 20:41 ` Grant Likely
2009-11-23 23:45 ` Michael Ellerman
2009-11-24 17:09 ` Albert Herranz
2009-11-25 0:38 ` Michael Ellerman
2009-11-26 5:22 ` Benjamin Herrenschmidt
2009-11-26 15:35 ` Albert Herranz
2009-11-26 21:13 ` Benjamin Herrenschmidt
2009-11-22 23:34 ` [RFC PATCH 12/19] powerpc: gamecube: platform support Grant Likely
2009-11-23 20:02 ` Albert Herranz
2009-11-24 21:39 ` Segher Boessenkool
2009-11-25 17:24 ` Albert Herranz
2009-11-26 21:53 ` Segher Boessenkool
2009-11-26 22:07 ` Albert Herranz
2009-11-27 0:09 ` Segher Boessenkool
2009-11-27 21:35 ` Benjamin Herrenschmidt
2009-11-28 3:56 ` Grant Likely
2009-11-28 3:56 ` Grant Likely
2009-11-22 23:28 ` [RFC PATCH 11/19] powerpc: gamecube/wii: flipper interrupt controller support Grant Likely
2009-11-23 19:59 ` Albert Herranz
2009-11-26 5:18 ` Benjamin Herrenschmidt
2009-11-26 15:33 ` Albert Herranz
2009-11-26 21:12 ` Benjamin Herrenschmidt
2009-11-26 23:00 ` Segher Boessenkool
2009-11-26 23:38 ` Benjamin Herrenschmidt
2009-11-24 21:30 ` Segher Boessenkool
2009-11-25 17:13 ` Albert Herranz
2009-11-26 21:52 ` Segher Boessenkool
2009-11-26 22:05 ` Albert Herranz
2009-11-27 0:06 ` Segher Boessenkool
2009-11-27 12:17 ` Segher Boessenkool
2009-11-27 17:27 ` Albert Herranz
2009-11-27 21:34 ` Benjamin Herrenschmidt
2009-11-28 2:04 ` Segher Boessenkool
2009-11-28 2:26 ` Benjamin Herrenschmidt
2009-11-26 5:18 ` Benjamin Herrenschmidt
2009-11-26 15:30 ` Albert Herranz
2009-11-26 21:10 ` Benjamin Herrenschmidt
2009-11-22 22:27 ` [RFC PATCH 10/19] powerpc: gamecube/wii: early debugging using usbgecko Arnd Bergmann
2009-11-23 19:10 ` Albert Herranz
2009-11-23 22:13 ` Arnd Bergmann
2009-11-26 5:14 ` Benjamin Herrenschmidt
2009-11-26 22:54 ` Segher Boessenkool
2009-11-26 23:27 ` Benjamin Herrenschmidt
2009-11-24 0:54 ` Segher Boessenkool
2009-11-24 18:19 ` Albert Herranz
2009-11-22 23:22 ` [RFC PATCH 09/19] powerpc: gamecube/wii: udbg support for usbgecko Grant Likely
2009-11-24 0:49 ` Segher Boessenkool
2009-11-24 18:08 ` Albert Herranz
2009-11-24 21:19 ` Segher Boessenkool
2009-11-25 17:07 ` Albert Herranz
2009-11-26 5:12 ` Benjamin Herrenschmidt
2009-11-26 15:28 ` Albert Herranz
2009-11-26 21:02 ` Benjamin Herrenschmidt
2009-11-26 23:12 ` Segher Boessenkool
2009-11-22 23:21 ` [RFC PATCH 08/19] powerpc: gamecube/wii: do not include PCI support Grant Likely
2009-11-26 5:10 ` Benjamin Herrenschmidt
2009-11-22 22:20 ` [RFC PATCH 07/19] powerpc: gamecube/wii: declare as non-coherent platforms Arnd Bergmann
2009-11-23 19:06 ` Albert Herranz
2009-11-26 5:09 ` Benjamin Herrenschmidt
2009-11-22 23:20 ` [RFC PATCH 06/19] powerpc: gamecube/wii: introduce GAMECUBE_COMMON Grant Likely
2009-11-23 19:56 ` Albert Herranz
2009-11-24 0:35 ` Segher Boessenkool
2009-11-24 18:03 ` Albert Herranz
2009-11-24 21:15 ` Segher Boessenkool
2009-11-24 22:33 ` Arnd Bergmann
2009-11-25 17:06 ` Albert Herranz
2009-11-26 5:08 ` Benjamin Herrenschmidt
2009-11-26 15:22 ` Albert Herranz
2009-11-27 12:12 ` Segher Boessenkool
2009-11-22 23:19 ` [RFC PATCH 05/19] powerpc: wii: bootwrapper bits Grant Likely
2009-11-24 0:33 ` Segher Boessenkool
2009-11-24 17:56 ` Albert Herranz
2009-11-24 21:13 ` Segher Boessenkool
2009-11-22 23:18 ` [RFC PATCH 04/19] powerpc: wii: device tree Grant Likely
2009-11-23 19:54 ` Albert Herranz
2009-11-23 20:36 ` Grant Likely
2009-11-23 21:55 ` Albert Herranz
2009-11-25 16:57 ` Segher Boessenkool
2009-11-25 18:09 ` Albert Herranz
2009-11-25 17:49 ` Segher Boessenkool
2009-11-25 18:34 ` Albert Herranz
2009-11-26 4:58 ` Benjamin Herrenschmidt
2009-11-26 15:19 ` Albert Herranz
2009-11-26 4:51 ` Benjamin Herrenschmidt
2009-11-26 15:18 ` Albert Herranz
2009-11-26 21:01 ` Benjamin Herrenschmidt
2009-11-26 21:38 ` Albert Herranz
2009-11-26 22:37 ` Benjamin Herrenschmidt
2009-11-27 0:16 ` Segher Boessenkool
2009-11-27 0:15 ` Benjamin Herrenschmidt
2009-11-26 23:25 ` Segher Boessenkool
2009-11-26 22:50 ` Segher Boessenkool
2009-11-26 23:02 ` Albert Herranz
2009-11-26 4:45 ` Benjamin Herrenschmidt
2009-11-26 15:09 ` Albert Herranz
2009-11-26 20:48 ` Benjamin Herrenschmidt
2009-11-26 21:20 ` Albert Herranz
2009-11-26 23:17 ` Segher Boessenkool
2009-11-26 22:45 ` Segher Boessenkool
2009-11-22 23:11 ` [RFC PATCH 03/19] powerpc: gamecube: bootwrapper bits Grant Likely
2009-11-24 0:08 ` Segher Boessenkool
2009-11-24 17:38 ` Albert Herranz
2009-11-24 21:00 ` Segher Boessenkool
2009-11-24 23:45 ` Albert Herranz
2009-11-25 16:53 ` Segher Boessenkool
2009-11-26 4:36 ` Benjamin Herrenschmidt
2009-11-26 8:17 ` Gabriel Paubert
2009-11-26 8:46 ` Benjamin Herrenschmidt
2009-11-26 23:06 ` Segher Boessenkool
2009-11-26 4:35 ` Benjamin Herrenschmidt
2009-11-26 22:23 ` Segher Boessenkool
2009-11-22 23:02 ` [RFC PATCH 02/19] powerpc: gamecube: device tree Grant Likely
2009-11-23 19:44 ` Albert Herranz
2009-11-23 20:19 ` Grant Likely
2009-11-23 20:25 ` Albert Herranz
2009-11-24 22:53 ` Segher Boessenkool
2009-11-26 4:23 ` Benjamin Herrenschmidt
2009-11-27 12:09 ` Segher Boessenkool
2009-11-24 22:36 ` Segher Boessenkool
2009-11-26 4:23 ` Benjamin Herrenschmidt
2009-11-26 22:15 ` Segher Boessenkool
2009-11-26 22:38 ` Benjamin Herrenschmidt
2009-11-27 0:18 ` Segher Boessenkool
2009-11-26 4:21 ` Benjamin Herrenschmidt
2009-11-26 4:38 ` Grant Likely
2009-11-26 5:29 ` Benjamin Herrenschmidt
2009-11-26 5:51 ` Grant Likely
2009-11-26 22:30 ` Segher Boessenkool
2009-11-25 18:00 ` Segher Boessenkool
2009-11-25 18:43 ` Albert Herranz
2009-11-27 12:07 ` Segher Boessenkool
2009-11-26 4:27 ` Benjamin Herrenschmidt
2009-11-26 22:19 ` Segher Boessenkool
2009-11-22 22:50 ` [RFC PATCH 01/19] powerpc: gamecube/wii: usbgecko bootwrapper console support Grant Likely
2009-11-26 4:12 ` Benjamin Herrenschmidt
2009-11-22 22:48 ` [RFC PATCH 00/19] powerpc: nintendo gamecube and wii support Grant Likely
2009-11-22 22:49 ` Arnd Bergmann
2009-11-23 19:22 ` Albert Herranz
2009-11-23 5:13 ` Wolfram Sang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1258927311-4340-6-git-send-email-albert_herranz@yahoo.es \
--to=albert_herranz@yahoo.es \
--cc=linuxppc-dev@lists.ozlabs.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).