Loading...
1/* SPDX-License-Identifier: GPL-2.0-or-later */
2/*
3 * Copyright (c) 2016 IBM Corporation.
4 */
5
6#include "ppc_asm.h"
7#include "../include/asm/opal-api.h"
8
9 .text
10
11 .globl opal_kentry
12opal_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 LOAD_REG_ADDR(r11, opal)
20 ld r8,0(r11)
21 ld r9,8(r11)
22 bctr
23
24#define OPAL_CALL(name, token) \
25 .globl name; \
26name: \
27 li r0, token; \
28 b opal_call;
29
30opal_call:
31 mflr r11
32 std r11,16(r1)
33 mfcr r12
34 stw r12,8(r1)
35 mr r13,r2
36
37 /* Set opal return address */
38 LOAD_REG_ADDR(r11, opal_return)
39 mtlr r11
40 mfmsr r12
41
42 /* switch to BE when we enter OPAL */
43 li r11,MSR_LE
44 andc r12,r12,r11
45 mtspr SPRN_HSRR1,r12
46
47 /* load the opal call entry point and base */
48 LOAD_REG_ADDR(r11, opal)
49 ld r12,8(r11)
50 ld r2,0(r11)
51 mtspr SPRN_HSRR0,r12
52 hrfid
53
54opal_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
62
63OPAL_CALL(opal_console_write, OPAL_CONSOLE_WRITE);
64OPAL_CALL(opal_console_read, OPAL_CONSOLE_READ);
65OPAL_CALL(opal_console_write_buffer_space, OPAL_CONSOLE_WRITE_BUFFER_SPACE);
66OPAL_CALL(opal_poll_events, OPAL_POLL_EVENTS);
67OPAL_CALL(opal_console_flush, OPAL_CONSOLE_FLUSH);
1/*
2 * Copyright (c) 2016 IBM Corporation.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version.
8 */
9
10#include "ppc_asm.h"
11#include "../include/asm/opal-api.h"
12
13 .text
14
15 .globl opal_kentry
16opal_kentry:
17 /* r3 is the fdt ptr */
18 mtctr r4
19 li r4, 0
20 li r5, 0
21 li r6, 0
22 li r7, 0
23 ld r11,opal@got(r2)
24 ld r8,0(r11)
25 ld r9,8(r11)
26 bctr
27
28#define OPAL_CALL(name, token) \
29 .globl name; \
30name: \
31 li r0, token; \
32 b opal_call;
33
34opal_call:
35 mflr r11
36 std r11,16(r1)
37 mfcr r12
38 stw r12,8(r1)
39 mr r13,r2
40
41 /* Set opal return address */
42 ld r11,opal_return@got(r2)
43 mtlr r11
44 mfmsr r12
45
46 /* switch to BE when we enter OPAL */
47 li r11,MSR_LE
48 andc r12,r12,r11
49 mtspr SPRN_HSRR1,r12
50
51 /* load the opal call entry point and base */
52 ld r11,opal@got(r2)
53 ld r12,8(r11)
54 ld r2,0(r11)
55 mtspr SPRN_HSRR0,r12
56 hrfid
57
58opal_return:
59 FIXUP_ENDIAN
60 mr r2,r13;
61 lwz r11,8(r1);
62 ld r12,16(r1)
63 mtcr r11;
64 mtlr r12
65 blr
66
67OPAL_CALL(opal_console_write, OPAL_CONSOLE_WRITE);
68OPAL_CALL(opal_console_read, OPAL_CONSOLE_READ);
69OPAL_CALL(opal_console_write_buffer_space, OPAL_CONSOLE_WRITE_BUFFER_SPACE);
70OPAL_CALL(opal_poll_events, OPAL_POLL_EVENTS);
71OPAL_CALL(opal_console_flush, OPAL_CONSOLE_FLUSH);