17a8d25c0SNathan Whitehorn/*- 27a8d25c0SNathan Whitehorn * Copyright (C) 2010 Andreas Tobler 37a8d25c0SNathan Whitehorn * All rights reserved. 47a8d25c0SNathan Whitehorn * 57a8d25c0SNathan Whitehorn * Redistribution and use in source and binary forms, with or without 67a8d25c0SNathan Whitehorn * modification, are permitted provided that the following conditions 77a8d25c0SNathan Whitehorn * are met: 87a8d25c0SNathan Whitehorn * 1. Redistributions of source code must retain the above copyright 97a8d25c0SNathan Whitehorn * notice, this list of conditions and the following disclaimer. 107a8d25c0SNathan Whitehorn * 2. Redistributions in binary form must reproduce the above copyright 117a8d25c0SNathan Whitehorn * notice, this list of conditions and the following disclaimer in the 127a8d25c0SNathan Whitehorn * documentation and/or other materials provided with the distribution. 137a8d25c0SNathan Whitehorn * 147a8d25c0SNathan Whitehorn * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 157a8d25c0SNathan Whitehorn * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 167a8d25c0SNathan Whitehorn * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 177a8d25c0SNathan Whitehorn * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 187a8d25c0SNathan Whitehorn * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 197a8d25c0SNathan Whitehorn * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 207a8d25c0SNathan Whitehorn * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 217a8d25c0SNathan Whitehorn * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 227a8d25c0SNathan Whitehorn * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 237a8d25c0SNathan Whitehorn * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 247a8d25c0SNathan Whitehorn */ 257a8d25c0SNathan Whitehorn#include <machine/asm.h> 267a8d25c0SNathan Whitehorn 277a8d25c0SNathan Whitehorn/* Hypervisor entry call. */ 287a8d25c0SNathan Whitehorn#define hc .long 0x44000022 297a8d25c0SNathan Whitehorn 307a8d25c0SNathan Whitehorn/* 317a8d25c0SNathan Whitehorn * Simple HV calls take the same arguments, with the same ABI, as this 327a8d25c0SNathan Whitehorn * C function 337a8d25c0SNathan Whitehorn */ 347a8d25c0SNathan WhitehornASENTRY(phyp_hcall) 357a8d25c0SNathan Whitehorn mflr %r0 367a8d25c0SNathan Whitehorn std %r0,16(%r1) 37ba5189f7SJustin Hibbits#if defined(_CALL_ELF) && _CALL_ELF == 2 38ba5189f7SJustin Hibbits ld %r11,96(%r1) /* Last couple args into volatile regs*/ 39ba5189f7SJustin Hibbits ld %r12,104(%r1) 40ba5189f7SJustin Hibbits#else 410ef68558SNathan Whitehorn ld %r11,112(%r1) /* Last couple args into volatile regs*/ 420ef68558SNathan Whitehorn ld %r12,120(%r1) 43ba5189f7SJustin Hibbits#endif 447a8d25c0SNathan Whitehorn hc /* invoke the hypervisor */ 457a8d25c0SNathan Whitehorn ld %r0,16(%r1) 467a8d25c0SNathan Whitehorn mtlr %r0 477a8d25c0SNathan Whitehorn blr /* return r3 = status */ 4878599c32SConrad MeyerASEND(phyp_hcall) 497a8d25c0SNathan Whitehorn 507a8d25c0SNathan Whitehorn/* 517a8d25c0SNathan Whitehorn * PFT HV calls take a special ABI (see PAPR 14.5.4.1) 527a8d25c0SNathan Whitehorn * 537a8d25c0SNathan Whitehorn * r3-r7 arguments passed unchanged, r8-r10 are addresses of return values 547a8d25c0SNathan Whitehorn * HV takes the same r3-r7, but returns values in r3, r4-r6 557a8d25c0SNathan Whitehorn */ 567a8d25c0SNathan WhitehornASENTRY(phyp_pft_hcall) 577a8d25c0SNathan Whitehorn mflr %r0 587a8d25c0SNathan Whitehorn std %r0,16(%r1) 597a8d25c0SNathan Whitehorn stdu %r1,-80(%r1) 607a8d25c0SNathan Whitehorn std %r8,48(%r1) /* save arguments */ 617a8d25c0SNathan Whitehorn std %r9,56(%r1) 627a8d25c0SNathan Whitehorn std %r10,64(%r1) 637a8d25c0SNathan Whitehorn hc /* invoke the hypervisor */ 647a8d25c0SNathan Whitehorn ld %r11,48(%r1) /* store results */ 657a8d25c0SNathan Whitehorn std %r4,0(%r11) 667a8d25c0SNathan Whitehorn ld %r11,56(%r1) 677a8d25c0SNathan Whitehorn std %r5,0(%r11) 687a8d25c0SNathan Whitehorn ld %r11,64(%r1) 697a8d25c0SNathan Whitehorn std %r6,0(%r11) 707a8d25c0SNathan Whitehorn ld %r1,0(%r1) /* exit */ 717a8d25c0SNathan Whitehorn ld %r0,16(%r1) 727a8d25c0SNathan Whitehorn mtlr %r0 737a8d25c0SNathan Whitehorn blr /* return r3 = status */ 7478599c32SConrad MeyerASEND(phyp_pft_hcall) 75