1219841Smarcel/*- 2219841Smarcel * Copyright (c) 2011 Marcel Moolenaar 3219841Smarcel * All rights reserved. 4219841Smarcel * 5219841Smarcel * Redistribution and use in source and binary forms, with or without 6219841Smarcel * modification, are permitted provided that the following conditions 7219841Smarcel * are met: 8219841Smarcel * 9219841Smarcel * 1. Redistributions of source code must retain the above copyright 10219841Smarcel * notice, this list of conditions and the following disclaimer. 11219841Smarcel * 2. Redistributions in binary form must reproduce the above copyright 12219841Smarcel * notice, this list of conditions and the following disclaimer in the 13219841Smarcel * documentation and/or other materials provided with the distribution. 14219841Smarcel * 15219841Smarcel * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16219841Smarcel * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17219841Smarcel * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18219841Smarcel * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19219841Smarcel * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20219841Smarcel * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21219841Smarcel * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22219841Smarcel * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23219841Smarcel * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24219841Smarcel * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25219841Smarcel * 26219841Smarcel * $FreeBSD$ 27219841Smarcel */ 28219841Smarcel 29219841Smarcel#include <machine/asm.h> 30219841Smarcel#include <machine/ia64_cpu.h> 31219841Smarcel 32219841Smarcel .text 33219841Smarcel 34219841Smarcel/* 35219841Smarcel * u_long ia64_efi_physical(ia64_efi_f, u_long, u_long, u_long, u_long) 36219841Smarcel * 37219841Smarcel * loc0 = ar.pfs 38219841Smarcel * loc1 = rp 39219841Smarcel * loc2 = psr 40219841Smarcel * loc3 = sp 41219841Smarcel * loc4 = bsp 42219841Smarcel * loc5 = gp 43219841Smarcel */ 44219841SmarcelENTRY(ia64_efi_physical, 5) 45219841Smarcel .prologue 46219841Smarcel .regstk 5,6,4,0 47219841Smarcel .save ar.pfs,loc0 48219841Smarcel alloc loc0=ar.pfs,5,6,4,0 49219841Smarcel ;; 50219841Smarcel .save rp,loc1 51219841Smarcel mov loc1=rp 52219841Smarcel ;; 53219841Smarcel .body 54219841Smarcel mov loc2=psr // save psr 55219841Smarcel movl r16=IA64_PSR_I | IA64_PSR_IT | IA64_PSR_DT | \ 56219841Smarcel IA64_PSR_RT | IA64_PSR_DFL | IA64_PSR_DFH 57219841Smarcel ;; 58219841Smarcel andcm r14=loc2,r16 59219841Smarcel movl r15=IA64_PSR_BN 60219841Smarcel ;; 61219841Smarcel rsm psr.i 62219841Smarcel mov r17=ar.rsc 63219841Smarcel or r16=r14,r15 // new psr 64219841Smarcel ;; 65219841Smarcel mov ar.rsc=0 66219841Smarcel or loc2=loc2,r15 67219841Smarcel ;; 68219841Smarcel flushrs 69219841Smarcel mov loc3=sp // save sp 70219841Smarcel ;; 71219841Smarcel mov loc4=ar.bsp // save ar.bsp 72219841Smarcel mov r18=ar.rnat 73219841Smarcel ;; 74219841Smarcel tpa r19=loc4 // new bspstore 75219841Smarcel mov loc5=gp 76219841Smarcel ;; 77219841Smarcel tpa r20=loc3 // new sp 78219841Smarcel ld8 r21=[in0],8 79219841Smarcel ;; 80219841Smarcel1: 81219841Smarcel mov r14=ip 82219841Smarcel ;; 83219841Smarcel ld8 r22=[in0] 84219841Smarcel add r15=2f-1b,r14 85219841Smarcel ;; 86219841Smarcel tpa r14=r15 87219841Smarcel ;; 88219841Smarcel rsm psr.ic 89219841Smarcel ;; 90219841Smarcel srlz.i 91219841Smarcel ;; 92219841Smarcel mov cr.iip=r14 93219841Smarcel mov cr.ifs=r0 94219841Smarcel mov cr.ipsr=r16 95219841Smarcel ;; 96219841Smarcel rfi 97219841Smarcel2: 98219841Smarcel mov ar.bspstore=r19 99219841Smarcel mov sp=r20 100219841Smarcel ;; 101219841Smarcel mov ar.rnat=r18 102219841Smarcel mov ar.rsc=r17 103219841Smarcel ;; 104219841Smarcel mov b6=r21 105219841Smarcel mov gp=r22 106219841Smarcel mov out0=in1 107219841Smarcel mov out1=in2 108219841Smarcel mov out2=in3 109219841Smarcel mov out3=in4 110219841Smarcel ;; 111219841Smarcel br.call.sptk.many rp=b6 112219841Smarcel mov gp=loc5 113219841Smarcel ;; 114219841Smarcel rsm psr.i | psr.ic 115219841Smarcel mov r16=ar.rsc 116219841Smarcel ;; 117219841Smarcel srlz.i 118219841Smarcel mov ar.rsc=0 119219841Smarcel ;; 120219841Smarcel flushrs 121219841Smarcel ;; 122219841Smarcel mov r17=ar.rnat 123219841Smarcel movl r18=3f 124219841Smarcel ;; 125219841Smarcel mov cr.iip=r18 126219841Smarcel mov cr.ifs=r0 127219841Smarcel mov cr.ipsr=loc2 128219841Smarcel ;; 129219841Smarcel rfi 130219841Smarcel3: 131219841Smarcel mov ar.bspstore=loc4 132219841Smarcel mov sp=loc3 133219841Smarcel ;; 134219841Smarcel mov ar.rnat=r17 135219841Smarcel mov ar.rsc=r16 136219841Smarcel ;; 137219841Smarcel mov rp=loc1 138219841Smarcel mov ar.pfs=loc0 139219841Smarcel ;; 140219841Smarcel br.ret.sptk.many rp 141219841SmarcelEND(ia64_efi_physical) 142219841Smarcel 143219841Smarcel 144219841Smarcel/* 145219841Smarcel * ia64_pal_ret ia64_pal_physical(ia64_fw_f, u_long, u_long, u_long, u_long) 146219841Smarcel * 147219841Smarcel * loc0 = ar.pfs 148219841Smarcel * loc1 = rp 149219841Smarcel * loc2 = psr 150219841Smarcel * loc3 = sp 151219841Smarcel * loc4 = bsp 152219841Smarcel * loc5 = gp 153219841Smarcel */ 154219841SmarcelENTRY(ia64_pal_physical, 5) 155219841Smarcel .prologue 156219841Smarcel .regstk 5,6,4,0 157219841Smarcel .save ar.pfs,loc0 158219841Smarcel alloc loc0=ar.pfs,5,6,4,0 159219841Smarcel ;; 160219841Smarcel .save rp,loc1 161219841Smarcel mov loc1=rp 162219841Smarcel ;; 163219841Smarcel .body 164219841Smarcel mov loc2=psr // save psr 165219841Smarcel movl r16=IA64_PSR_I | IA64_PSR_IT | IA64_PSR_DT | \ 166219841Smarcel IA64_PSR_RT | IA64_PSR_DFL | IA64_PSR_DFH 167219841Smarcel ;; 168219841Smarcel andcm r14=loc2,r16 169219841Smarcel movl r15=IA64_PSR_BN 170219841Smarcel ;; 171219841Smarcel rsm psr.i 172219841Smarcel mov r17=ar.rsc 173219841Smarcel or r16=r14,r15 // new psr 174219841Smarcel ;; 175219841Smarcel mov ar.rsc=0 176219841Smarcel or loc2=loc2,r15 177219841Smarcel ;; 178219841Smarcel flushrs 179219841Smarcel mov loc3=sp // save sp 180219841Smarcel ;; 181219841Smarcel mov loc4=ar.bsp // save ar.bsp 182219841Smarcel mov r18=ar.rnat 183219841Smarcel ;; 184219841Smarcel mov loc5=gp 185219841Smarcel movl r14=kstack 186219841Smarcel ;; 187219841Smarcel tpa r19=r14 // new bspstore 188219841Smarcel movl r15=kstack_top 189219841Smarcel ;; 190219841Smarcel tpa r20=r15 // new sp 191219841Smarcel movl r21=ia64_pal_entry 192219841Smarcel ;; 193219841Smarcel1: 194219841Smarcel mov r14=ip 195219841Smarcel ld8 r22=[r21] 196219841Smarcel ;; 197219841Smarcel tpa r21=r22 198219841Smarcel add r15=2f-1b,r14 199219841Smarcel ;; 200219841Smarcel tpa r14=r15 201219841Smarcel ;; 202219841Smarcel rsm psr.ic 203219841Smarcel ;; 204219841Smarcel srlz.i 205219841Smarcel ;; 206219841Smarcel mov cr.iip=r14 207219841Smarcel mov cr.ifs=r0 208219841Smarcel mov cr.ipsr=r16 209219841Smarcel ;; 210219841Smarcel rfi 211219841Smarcel2: 212219841Smarcel mov ar.bspstore=r19 213219841Smarcel add sp=-16,r20 214219841Smarcel ;; 215219841Smarcel mov ar.rnat=r18 216219841Smarcel mov ar.rsc=r17 217219841Smarcel ;; 218219841Smarcel mov b6=r21 219219841Smarcel mov out0=in0 220219841Smarcel mov out1=in1 221219841Smarcel mov out2=in2 222219841Smarcel mov out3=in3 223219841Smarcel // PAL static calls 224219841Smarcel mov r28=in0 225219841Smarcel mov r29=in1 226219841Smarcel mov r30=in2 227219841Smarcel mov r31=in3 228219841Smarcel br.call.sptk.many rp=b6 229219841Smarcel mov gp=loc5 230219841Smarcel ;; 231219841Smarcel rsm psr.i | psr.ic 232219841Smarcel mov r16=ar.rsc 233219841Smarcel ;; 234219841Smarcel srlz.i 235219841Smarcel mov ar.rsc=0 236219841Smarcel ;; 237219841Smarcel flushrs 238219841Smarcel ;; 239219841Smarcel mov r17=ar.rnat 240219841Smarcel movl r18=3f 241219841Smarcel ;; 242219841Smarcel mov cr.iip=r18 243219841Smarcel mov cr.ifs=r0 244219841Smarcel mov cr.ipsr=loc2 245219841Smarcel ;; 246219841Smarcel rfi 247219841Smarcel3: 248219841Smarcel mov ar.bspstore=loc4 249219841Smarcel mov sp=loc3 250219841Smarcel ;; 251219841Smarcel mov ar.rnat=r17 252219841Smarcel mov ar.rsc=r16 253219841Smarcel ;; 254219841Smarcel mov rp=loc1 255219841Smarcel mov ar.pfs=loc0 256219841Smarcel ;; 257219841Smarcel br.ret.sptk.many rp 258219841SmarcelEND(ia64_pal_physical) 259