Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /*
0003  * Copyright (c) 2016 IBM Corporation.
0004  */
0005 
0006 #include "ppc_asm.h"
0007 #include "../include/asm/opal-api.h"
0008 
0009     .text
0010 
0011     .globl opal_kentry
0012 opal_kentry:
0013     /* r3 is the fdt ptr */
0014     mtctr r4
0015     li  r4, 0
0016     li  r5, 0
0017     li  r6, 0
0018     li  r7, 0
0019     ld  r11,opal@got(r2)
0020     ld  r8,0(r11)
0021     ld  r9,8(r11)
0022     bctr
0023 
0024 #define OPAL_CALL(name, token)              \
0025     .globl name;                    \
0026 name:                           \
0027     li  r0, token;              \
0028     b   opal_call;
0029 
0030 opal_call:
0031     mflr    r11
0032     std r11,16(r1)
0033     mfcr    r12
0034     stw r12,8(r1)
0035     mr  r13,r2
0036 
0037     /* Set opal return address */
0038     ld  r11,opal_return@got(r2)
0039     mtlr    r11
0040     mfmsr   r12
0041 
0042     /* switch to BE when we enter OPAL */
0043     li  r11,MSR_LE
0044     andc    r12,r12,r11
0045     mtspr   SPRN_HSRR1,r12
0046 
0047     /* load the opal call entry point and base */
0048     ld  r11,opal@got(r2)
0049     ld  r12,8(r11)
0050     ld  r2,0(r11)
0051     mtspr   SPRN_HSRR0,r12
0052     hrfid
0053 
0054 opal_return:
0055     FIXUP_ENDIAN
0056     mr  r2,r13;
0057     lwz r11,8(r1);
0058     ld  r12,16(r1)
0059     mtcr    r11;
0060     mtlr    r12
0061     blr
0062 
0063 OPAL_CALL(opal_console_write,           OPAL_CONSOLE_WRITE);
0064 OPAL_CALL(opal_console_read,            OPAL_CONSOLE_READ);
0065 OPAL_CALL(opal_console_write_buffer_space,  OPAL_CONSOLE_WRITE_BUFFER_SPACE);
0066 OPAL_CALL(opal_poll_events,         OPAL_POLL_EVENTS);
0067 OPAL_CALL(opal_console_flush,           OPAL_CONSOLE_FLUSH);