linux/arch/powerpc/boot/opal-calls.S
<<
>>
Prefs
   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        ld      r11,opal@got(r2)
  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        ld      r11,opal_return@got(r2)
  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        ld      r11,opal@got(r2)
  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);
  68