^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0-only */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * PS3 bootwrapper entry.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Copyright (C) 2007 Sony Computer Entertainment Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Copyright 2007 Sony Corp.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include "ppc_asm.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) .machine "ppc64"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) .text
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) * __system_reset_overlay - The PS3 first stage entry.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) * The bootwraper build script copies the 512 bytes at symbol
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) * __system_reset_overlay to offset 0x100 of the rom image. This symbol
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) * must occupy 512 or less bytes.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) * The PS3 has a single processor with two threads.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) .globl __system_reset_overlay
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) __system_reset_overlay:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) /* Switch to 32-bit mode. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) mfmsr r9
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) clrldi r9,r9,1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) mtmsrd r9
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) nop
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) /* Get thread number in r3 and branch. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) mfspr r3, 0x88
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) cntlzw. r3, r3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) beq 1f
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) /* Secondary goes to __secondary_hold in kernel. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) li r4, 0x60
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) mtctr r4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) bctr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) 1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) /* Primary delays then goes to _zimage_start in wrapper. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) or 31, 31, 31 /* db16cyc */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) or 31, 31, 31 /* db16cyc */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) lis r4, _zimage_start@ha
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) addi r4, r4, _zimage_start@l
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) mtctr r4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) bctr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) . = __system_reset_overlay + 512
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) * __system_reset_kernel - Place holder for the kernel reset vector.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) * The bootwrapper build script copies 512 bytes from offset 0x100
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) * of the rom image to the symbol __system_reset_kernel. At runtime
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) * the bootwrapper program copies the 512 bytes at __system_reset_kernel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) * to ram address 0x100. This symbol must occupy 512 bytes.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) .globl __system_reset_kernel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) __system_reset_kernel:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) . = __system_reset_kernel + 512