ssc.c revision 119880
1218885Sdim/*- 2218885Sdim * Copyright (c) 2001 Doug Rabson 3218885Sdim * All rights reserved. 4218885Sdim * 5218885Sdim * Redistribution and use in source and binary forms, with or without 6218885Sdim * modification, are permitted provided that the following conditions 7218885Sdim * are met: 8218885Sdim * 1. Redistributions of source code must retain the above copyright 9218885Sdim * notice, this list of conditions and the following disclaimer. 10218885Sdim * 2. Redistributions in binary form must reproduce the above copyright 11218885Sdim * notice, this list of conditions and the following disclaimer in the 12218885Sdim * documentation and/or other materials provided with the distribution. 13218885Sdim * 14218885Sdim * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15218885Sdim * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16218885Sdim * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17249423Sdim * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18218885Sdim * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19249423Sdim * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20218885Sdim * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21239462Sdim * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22249423Sdim * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23249423Sdim * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24249423Sdim * SUCH DAMAGE. 25218885Sdim */ 26218885Sdim 27218885Sdim#include <sys/cdefs.h> 28218885Sdim__FBSDID("$FreeBSD: head/sys/boot/ia64/ski/ssc.c 119880 2003-09-08 09:11:32Z obrien $"); 29218885Sdim 30218885Sdim#include <stand.h> 31223017Sdim#include "libski.h" 32249423Sdim 33249423Sdim/* 34249423Sdim * Ugh... Work around a bug in the Linux version of ski for SSC_GET_RTC. The 35249423Sdim * PSR.dt register is not preserved properly and causes further memory 36249423Sdim * references to be done without translation. All we need to do is preserve 37249423Sdim * PSR.dt across the SSC call. We do this by saving and restoring psr.l 38218885Sdim * completely. 39249423Sdim */ 40249423Sdimu_int64_t 41249423Sdimssc(u_int64_t in0, u_int64_t in1, u_int64_t in2, u_int64_t in3, int which) 42249423Sdim{ 43249423Sdim register u_int64_t psr; 44249423Sdim register u_int64_t ret0 __asm("r8"); 45249423Sdim 46249423Sdim __asm __volatile("mov %0=psr;;" : "=r"(psr)); 47249423Sdim __asm __volatile("mov r15=%1\n\t" 48249423Sdim "break 0x80000;;" 49249423Sdim : "=r"(ret0) 50249423Sdim : "r"(which), "r"(in0), "r"(in1), "r"(in2), "r"(in3)); 51249423Sdim __asm __volatile("mov psr.l=%0;; srlz.d" :: "r"(psr)); 52218885Sdim return ret0; 53} 54