1/* 2 * Entry point and assembler functions for ppc64 tests. 3 * 4 * Copyright (C) 2016, Red Hat Inc, Andrew Jones <drjones@redhat.com> 5 * 6 * This work is licensed under the terms of the GNU LGPL, version 2. 7 */ 8#define __ASSEMBLY__ 9#include <asm/hcall.h> 10#include <asm/ppc_asm.h> 11#include <asm/rtas.h> 12 13.section .init 14 15/* 16 * start is the entry point. r3 points to the DTB 17 */ 18.globl start 19start: 20 FIXUP_ENDIAN 21 /* 22 * We were loaded at QEMU's kernel load address, but we're not 23 * allowed to link there due to how QEMU deals with linker VMAs, 24 * so we just linked at zero. This means the first thing to do is 25 * to find our stack and toc, and then do a relocate. 26 */ 27 bl 0f 280: mflr r31 29 subi r31, r31, 0b - start /* QEMU's kernel load address */ 30 ld r1, (p_stack - start)(r31) 31 ld r2, (p_toc - start)(r31) 32 add r1, r1, r31 33 add r2, r2, r31 34 35 /* save DTB pointer */ 36 std r3, 56(r1) 37 38 /* 39 * Call relocate. relocate is C code, but careful to not use 40 * any global references, as they may use absolute addresses, 41 * which are, obviously, not yet relocated. 42 */ 43 mr r3, r31 44 ld r4, (p_dyn - start)(r31) 45 add r4, r4, r31 46 bl relocate 47 48 /* patch sc1 if needed */ 49 bl hcall_have_broken_sc1 50 cmpwi r3, 0 51 beq 1f 52 LOAD_REG_ADDR(r3, hcall) 53 LOAD_REG_IMMEDIATE(r4, SC1_REPLACEMENT) 54 stw r4, 0(r3) 55 56 /* complete setup */ 571: ld r3, 56(r1) 58 bl setup 59 60 /* run the test */ 61 LOAD_REG_ADDR(r5, __argc) 62 LOAD_REG_ADDR(r4, __argv) 63 lwz r3, 0(r5) 64 bl main 65 bl exit 66 b halt 67 68.align 3 69p_stack: .llong stackptr 70p_toc: .llong tocptr 71p_dyn: .llong dynamic_start 72 73.text 74.align 3 75 76.globl hcall 77hcall: 78 sc 1 79 blr 80 81.globl halt 82halt: 831: b 1b 84 85.globl enter_rtas 86enter_rtas: 87 mflr r0 88 std r0, 16(r1) 89 90 LOAD_REG_ADDR(r10, rtas_return_loc) 91 mtlr r10 92 LOAD_REG_ADDR(r11, rtas_entry) 93 ld r10, 0(r11) 94 95 mfmsr r11 96 LOAD_REG_IMMEDIATE(r9, RTAS_MSR_MASK) 97 and r11, r11, r9 98 mtsrr0 r10 99 mtsrr1 r11 100 rfid 101 b . 102 103rtas_return_loc: 104 FIXUP_ENDIAN 105 ld r0, 16(r1) 106 mtlr r0 107 blr 108