2 * Copyright (C) 2015 Nathan Whitehorn
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/asm.h>
30 #include "opt_platform.h"
32 GLOBAL(opal_entrypoint)
39 TOC_ENTRY(opal_entrypoint)
46 * r4-r10 opal arguments
49 /* Save call stuff on stack */
56 /* Load OPAL entry information */
58 addis %r3,%r2,TOC_REF(opal_entrypoint)@ha
59 ld %r3,TOC_REF(opal_entrypoint)@l(%r3)
63 /* Save MSR in non-volatile scratch register and turn off translation */
67 /* Load last bits from the TOC */
68 addis %r3,%r2,TOC_REF(opal_msr)@ha
69 ld %r3,TOC_REF(opal_msr)@l(%r3)
71 addis %r2,%r2,TOC_REF(opal_data)@ha
72 ld %r2,TOC_REF(opal_data)@l(%r2)
76 #if defined(__LITTLE_ENDIAN__) && defined(QEMU)
77 /* QEMU hack: qemu does not emulate mtmsrd correctly! */
78 ori %r3,%r3,1 /* Leave PSR_LE set */
82 #if defined(__LITTLE_ENDIAN__) && defined(QEMU)
83 /* Clean up from qemu hack */
87 #ifdef __LITTLE_ENDIAN__
91 /* Shift registers over */
100 #ifdef __LITTLE_ENDIAN__
101 /* We need to rfid to switch endian. */
107 addi %r11, %r11, (2f-1b)
112 RETURN_TO_NATIVE_ENDIAN
123 /* Restore call stuff from stack */