Oliver O'Halloran | 656ad58 | 2016-07-01 00:34:37 +1000 | [diff] [blame] | 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 | #define OPAL_CALL(name, token) \ |
| 16 | .globl name; \ |
| 17 | name: \ |
| 18 | li r0, token; \ |
| 19 | b opal_call; |
| 20 | |
| 21 | opal_call: |
| 22 | mflr r11 |
| 23 | std r11,16(r1) |
| 24 | mfcr r12 |
| 25 | stw r12,8(r1) |
| 26 | mr r13,r2 |
| 27 | |
| 28 | /* Set opal return address */ |
| 29 | ld r11,opal_return@got(r2) |
| 30 | mtlr r11 |
| 31 | mfmsr r12 |
| 32 | |
| 33 | /* switch to BE when we enter OPAL */ |
| 34 | li r11,MSR_LE |
| 35 | andc r12,r12,r11 |
| 36 | mtspr SPRN_HSRR1,r12 |
| 37 | |
| 38 | /* load the opal call entry point and base */ |
| 39 | ld r11,opal@got(r2) |
| 40 | ld r12,8(r11) |
| 41 | ld r2,0(r11) |
| 42 | mtspr SPRN_HSRR0,r12 |
| 43 | hrfid |
| 44 | |
| 45 | opal_return: |
| 46 | FIXUP_ENDIAN |
| 47 | mr r2,r13; |
| 48 | lwz r11,8(r1); |
| 49 | ld r12,16(r1) |
| 50 | mtcr r11; |
| 51 | mtlr r12 |
| 52 | blr |
| 53 | |
| 54 | OPAL_CALL(opal_console_write, OPAL_CONSOLE_WRITE); |
| 55 | OPAL_CALL(opal_console_read, OPAL_CONSOLE_READ); |
| 56 | OPAL_CALL(opal_console_write_buffer_space, OPAL_CONSOLE_WRITE_BUFFER_SPACE); |
| 57 | OPAL_CALL(opal_poll_events, OPAL_POLL_EVENTS); |
| 58 | OPAL_CALL(opal_console_flush, OPAL_CONSOLE_FLUSH); |