1139738Simp/*- 2110211Smarcel * Copyright (c) 2003 Marcel Moolenaar 3110211Smarcel * All rights reserved. 4110211Smarcel * 5110211Smarcel * Redistribution and use in source and binary forms, with or without 6110211Smarcel * modification, are permitted provided that the following conditions 7110211Smarcel * are met: 8110211Smarcel * 9110211Smarcel * 1. Redistributions of source code must retain the above copyright 10110211Smarcel * notice, this list of conditions and the following disclaimer. 11110211Smarcel * 2. Redistributions in binary form must reproduce the above copyright 12110211Smarcel * notice, this list of conditions and the following disclaimer in the 13110211Smarcel * documentation and/or other materials provided with the distribution. 14110211Smarcel * 15110211Smarcel * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16110211Smarcel * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17110211Smarcel * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18110211Smarcel * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19110211Smarcel * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20110211Smarcel * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21110211Smarcel * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22110211Smarcel * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23110211Smarcel * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24110211Smarcel * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25110211Smarcel */ 26110211Smarcel 27119880Sobrien#include <sys/cdefs.h> 28119880Sobrien__FBSDID("$FreeBSD$"); 29119880Sobrien 30110211Smarcel#include <sys/types.h> 31110211Smarcel#include <machine/md_var.h> 32110211Smarcel#include <machine/sal.h> 33110211Smarcel#include <stand.h> 34110211Smarcel#include "libski.h" 35110211Smarcel 36110211Smarcelextern void PalProc(void); 37110211Smarcelstatic sal_entry_t SalProc; 38110211Smarcel 39110211Smarcelstruct { 40110211Smarcel struct sal_system_table header; 41110211Smarcel struct sal_entrypoint_descriptor entry; 42110211Smarcel struct sal_ap_wakeup_descriptor wakeup; 43110211Smarcel} sal_systab = { 44110211Smarcel /* Header. */ 45110211Smarcel { 46110211Smarcel SAL_SIGNATURE, 47110211Smarcel sizeof(sal_systab), 48110211Smarcel { 00, 03 }, /* Revision 3.0. */ 49110211Smarcel 2, /* Number of decsriptors. */ 50110211Smarcel 0, /* XXX checksum. */ 51110211Smarcel { 0 }, 52110211Smarcel { 00, 00 }, /* XXX SAL_A version. */ 53110211Smarcel { 00, 00 }, /* XXX SAL_B version. */ 54110211Smarcel "FreeBSD", 55110211Smarcel "Ski loader", 56110211Smarcel { 0 } 57110211Smarcel }, 58110211Smarcel /* Entrypoint. */ 59110211Smarcel { 60110211Smarcel 0, /* Type=entrypoint descr. */ 61110211Smarcel { 0 }, 62110211Smarcel 0, /* XXX PalProc. */ 63110211Smarcel 0, /* XXX SalProc. */ 64110211Smarcel 0, /* XXX SalProc GP. */ 65110211Smarcel { 0 } 66110211Smarcel }, 67110211Smarcel /* AP wakeup. */ 68110211Smarcel { 69110211Smarcel 5, /* Type=AP wakeup descr. */ 70110211Smarcel 0, /* External interrupt. */ 71110211Smarcel { 0 }, 72110211Smarcel 255 /* Wakeup vector. */ 73110211Smarcel } 74110211Smarcel}; 75110211Smarcel 76110211Smarcelstatic inline void 77110211Smarcelputs(const char *s) 78110211Smarcel{ 79110211Smarcel s = (const char *)((7UL << 61) | (u_long)s); 80110211Smarcel while (*s) 81110211Smarcel ski_cons_putchar(*s++); 82110211Smarcel} 83110211Smarcel 84110211Smarcelstatic struct ia64_sal_result 85110211SmarcelSalProc(u_int64_t a1, u_int64_t a2, u_int64_t a3, u_int64_t a4, u_int64_t a5, 86110211Smarcel u_int64_t a6, u_int64_t a7, u_int64_t a8) 87110211Smarcel{ 88110211Smarcel struct ia64_sal_result res; 89110211Smarcel 90110211Smarcel res.sal_status = -3; 91110211Smarcel res.sal_result[0] = 0; 92110211Smarcel res.sal_result[1] = 0; 93110211Smarcel res.sal_result[2] = 0; 94110211Smarcel 95110211Smarcel if (a1 == SAL_FREQ_BASE) { 96110211Smarcel res.sal_status = 0; 97110211Smarcel res.sal_result[0] = 133338184; 98110211Smarcel } else if (a1 == SAL_SET_VECTORS) { 99110211Smarcel /* XXX unofficial SSC function. */ 100110211Smarcel ssc(a2, a3, a4, a5, SSC_SAL_SET_VECTORS); 101110211Smarcel } else if (a1 != SAL_GET_STATE_INFO_SIZE) { 102110211Smarcel puts("SAL: unimplemented function called\n"); 103110211Smarcel } 104110211Smarcel 105110211Smarcel return (res); 106110211Smarcel} 107110211Smarcel 108110211Smarcelvoid 109110211Smarcelsal_stub_init(void) 110110211Smarcel{ 111110211Smarcel struct ia64_fdesc *fd; 112110211Smarcel 113110211Smarcel fd = (void*)PalProc; 114110211Smarcel sal_systab.entry.sale_pal_proc = fd->func; 115110211Smarcel fd = (void*)SalProc; 116110211Smarcel sal_systab.entry.sale_sal_proc = fd->func; 117110211Smarcel sal_systab.entry.sale_sal_gp = fd->gp; 118110211Smarcel} 119