ssc.c revision 110211
183364Sdfr/*- 283364Sdfr * Copyright (c) 2001 Doug Rabson 383364Sdfr * All rights reserved. 483364Sdfr * 583364Sdfr * Redistribution and use in source and binary forms, with or without 683364Sdfr * modification, are permitted provided that the following conditions 783364Sdfr * are met: 883364Sdfr * 1. Redistributions of source code must retain the above copyright 983364Sdfr * notice, this list of conditions and the following disclaimer. 1083364Sdfr * 2. Redistributions in binary form must reproduce the above copyright 1183364Sdfr * notice, this list of conditions and the following disclaimer in the 1283364Sdfr * documentation and/or other materials provided with the distribution. 1383364Sdfr * 1483364Sdfr * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1583364Sdfr * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1683364Sdfr * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1783364Sdfr * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 1883364Sdfr * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 1983364Sdfr * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2083364Sdfr * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2183364Sdfr * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2283364Sdfr * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2383364Sdfr * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2483364Sdfr * SUCH DAMAGE. 2583364Sdfr * 2683364Sdfr * $FreeBSD: head/sys/boot/ia64/ski/ssc.c 110211 2003-02-01 22:50:09Z marcel $ 2783364Sdfr */ 2883364Sdfr 2983364Sdfr#include <stand.h> 3083364Sdfr#include "libski.h" 3183364Sdfr 32110211Smarcel/* 33110211Smarcel * Ugh... Work around a bug in the Linux version of ski for SSC_GET_RTC. The 34110211Smarcel * PSR.dt register is not preserved properly and causes further memory 35110211Smarcel * references to be done without translation. All we need to do is preserve 36110211Smarcel * PSR.dt across the SSC call. We do this by saving and restoring psr.l 37110211Smarcel * completely. 38110211Smarcel */ 3983364Sdfru_int64_t 4083364Sdfrssc(u_int64_t in0, u_int64_t in1, u_int64_t in2, u_int64_t in3, int which) 4183364Sdfr{ 42110211Smarcel register u_int64_t psr; 4383364Sdfr register u_int64_t ret0 __asm("r8"); 4483364Sdfr 45110211Smarcel __asm __volatile("mov %0=psr;;" : "=r"(psr)); 4683364Sdfr __asm __volatile("mov r15=%1\n\t" 47110211Smarcel "break 0x80000;;" 4883364Sdfr : "=r"(ret0) 4983364Sdfr : "r"(which), "r"(in0), "r"(in1), "r"(in2), "r"(in3)); 50110211Smarcel __asm __volatile("mov psr.l=%0;; srlz.d" :: "r"(psr)); 5183364Sdfr return ret0; 5283364Sdfr} 53