2 * Copyright (C) 2012 Margarida Gouveia
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
15 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
18 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
20 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
21 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
22 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 #include <machine/bat.h>
30 * When we are invoked from Wii loaders, the state of the MMU and the BAT
31 * mappings can vary. In this file we try to reset the MMU to a state
32 * that lets us boot FreeBSD.
34 * N.B.: keep the BAT0 in sync with mmu_oea.c and never touch BAT1 later.
36 * This file is being included from aim/locore32.S.
39 #define MMU_REALMODE() \
41 rlwinm %r12, %r12, 0, ~(PSL_DR|PSL_IR);\
46 clrlwi %r11, %r11, 3; /* XXX why? */ \
47 addi %r11, %r11, 2f - 1b; \
49 mtsrr1 %r12; /* Disables the MMU */ \
54 #define MMU_VIRTUALMODE() \
58 addi %r11, %r11, 4f - 3b; \
60 ori %r12, %r12, PSL_DR|PSL_IR; \
62 mtsrr1 %r12; /* Enables the MMU */ \
69 /* Reset standard BATs */
88 /* Reset high BATs. IBAT[4-7][UL] + DBAT[4-7][UL] */
107 * We need to setup BAT0 as in mmu_oea.c.
109 li %r11, BATU(0x00000000, BAT_BL_256M, BAT_Vs)
110 li %r12, BATL(0x00000000, BAT_M, BAT_PP_RW)
118 * We use BAT1 to be able to write I/O memory, including the
119 * framebuffer registers.
121 /* BATU(0x0c000000, BAT_BL_32M, BAT_Vs) */
123 ori %r11, %r11, BAT_BL_32M|BAT_Vs
124 /* BATL(0x0c000000, BAT_I|BAT_G, BAT_PP_RW) */
126 ori %r12, %r12, BAT_I|BAT_G|BAT_PP_RW