Merge tag 'sched-urgent-2020-12-27' of git://git.kernel.org/pub/scm/linux/kernel...
[linux/fpc-iii.git] / arch / powerpc / boot / opal-calls.S
blobad0e15d930c4e759fcb87e1db2887071a143d6c4
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3  * Copyright (c) 2016 IBM Corporation.
4  */
6 #include "ppc_asm.h"
7 #include "../include/asm/opal-api.h"
9         .text
11         .globl opal_kentry
12 opal_kentry:
13         /* r3 is the fdt ptr */
14         mtctr r4
15         li      r4, 0
16         li      r5, 0
17         li      r6, 0
18         li      r7, 0
19         ld      r11,opal@got(r2)
20         ld      r8,0(r11)
21         ld      r9,8(r11)
22         bctr
24 #define OPAL_CALL(name, token)                          \
25         .globl name;                                    \
26 name:                                                   \
27         li      r0, token;                              \
28         b       opal_call;
30 opal_call:
31         mflr    r11
32         std     r11,16(r1)
33         mfcr    r12
34         stw     r12,8(r1)
35         mr      r13,r2
37         /* Set opal return address */
38         ld      r11,opal_return@got(r2)
39         mtlr    r11
40         mfmsr   r12
42         /* switch to BE when we enter OPAL */
43         li      r11,MSR_LE
44         andc    r12,r12,r11
45         mtspr   SPRN_HSRR1,r12
47         /* load the opal call entry point and base */
48         ld      r11,opal@got(r2)
49         ld      r12,8(r11)
50         ld      r2,0(r11)
51         mtspr   SPRN_HSRR0,r12
52         hrfid
54 opal_return:
55         FIXUP_ENDIAN
56         mr      r2,r13;
57         lwz     r11,8(r1);
58         ld      r12,16(r1)
59         mtcr    r11;
60         mtlr    r12
61         blr
63 OPAL_CALL(opal_console_write,                   OPAL_CONSOLE_WRITE);
64 OPAL_CALL(opal_console_read,                    OPAL_CONSOLE_READ);
65 OPAL_CALL(opal_console_write_buffer_space,      OPAL_CONSOLE_WRITE_BUFFER_SPACE);
66 OPAL_CALL(opal_poll_events,                     OPAL_POLL_EVENTS);
67 OPAL_CALL(opal_console_flush,                   OPAL_CONSOLE_FLUSH);