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 27119880Sobrien#include <sys/cdefs.h> 28119880Sobrien__FBSDID("$FreeBSD$"); 29119880Sobrien 3083364Sdfr#include <stand.h> 3183364Sdfr#include "libski.h" 3283364Sdfr 33110211Smarcel/* 34110211Smarcel * Ugh... Work around a bug in the Linux version of ski for SSC_GET_RTC. The 35110211Smarcel * PSR.dt register is not preserved properly and causes further memory 36110211Smarcel * references to be done without translation. All we need to do is preserve 37110211Smarcel * PSR.dt across the SSC call. We do this by saving and restoring psr.l 38110211Smarcel * completely. 39110211Smarcel */ 4083364Sdfru_int64_t 4183364Sdfrssc(u_int64_t in0, u_int64_t in1, u_int64_t in2, u_int64_t in3, int which) 4283364Sdfr{ 43110211Smarcel register u_int64_t psr; 4483364Sdfr register u_int64_t ret0 __asm("r8"); 4583364Sdfr 46110211Smarcel __asm __volatile("mov %0=psr;;" : "=r"(psr)); 4783364Sdfr __asm __volatile("mov r15=%1\n\t" 48110211Smarcel "break 0x80000;;" 4983364Sdfr : "=r"(ret0) 5083364Sdfr : "r"(which), "r"(in0), "r"(in1), "r"(in2), "r"(in3)); 51110211Smarcel __asm __volatile("mov psr.l=%0;; srlz.d" :: "r"(psr)); 5283364Sdfr return ret0; 5383364Sdfr} 54