2 # Copyright (c) 2006 Martin Decky
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions
9 # - Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer.
11 # - Redistributions in binary form must reproduce the above copyright
12 # notice, this list of conditions and the following disclaimer in the
13 # documentation and/or other materials provided with the distribution.
14 # - The name of the author may not be used to endorse or promote products
15 # derived from this software without specific prior written permission.
17 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 .global jump_to_kernel
99 rlwinm. r7, r5, 32-3, 3, 31
111 # r7 = real_mode (pa)
112 # r8 = framebuffer (pa)
118 rlwinm r31, r31, 0, 17, 15
121 # set real_mode meeting point address
129 ori r30, r30, ~(msr_ir | msr_dr | msr_ee)@l
137 .section REALMODE, "ax"
146 # copy kernel to proper location
150 # r8 = framebuffer (pa)
153 li r31, PAGE_SIZE >> 2
192 # initially fill segment registers
198 li r30, 0 # ASID 0 (VSIDs 0 .. 7)
204 addis r31, r31, 0x1000 # move to next SR
210 lis r30, 0x4000 # priviledged access only
211 ori r30, r30, 8 # ASID 0 (VSIDs 8 .. 15)
217 addis r31, r31, 0x1000 # move to next SR
221 # invalidate block address translation registers
251 # create empty Page Hash Table
252 # on top of memory, size 64 KB
256 lwz r31, 0(r3) # r31 = memory size
259 ori r30, r30, 65536@l # r30 = 65536
261 subi r29, r30, 1 # r29 = 65535
264 andc r31, r31, r29 # pht = ALIGN_DOWN(memory_size - 65536, 65536)
269 srw r30, r30, r29 # r30 = 16384
292 # create BAT identity mapping
296 lwz r31, 0(r3) # r31 = memory size
300 blt no_bat # less than 128 KB -> no BAT
303 srw r31, r31, r29 # r31 = total >> 18
305 # create Block Length mask by replicating
306 # the leading logical one 14 times
313 srw r30, r31, r29 # r30 = mask >> 1
314 or r31, r31, r30 # mask = mask | r30
320 andi. r31, r31, 0x07ff # mask = mask & 0x07ff (BAT can map up to 256 MB)
323 slw r31, r31, r29 # mask = mask << 2
324 ori r31, r31, 0x0002 # mask = mask | 0x0002 (priviledged access only)
351 # pc = KERNEL_START_ADDR
353 # sprg0 = KA2PA(KERNEL_START_ADDR)
354 # sprg3 = physical memory size
357 lis r31, KERNEL_START_ADDR@ha
358 addi r31, r31, KERNEL_START_ADDR@l
362 subis r31, r31, 0x8000
371 ori r31, r31, (msr_ir | msr_dr)@l
383 .space (TRANS_SIZE * TRANS_ITEM_SIZE)