sal_stub.c revision 110211
1/* 2 * Copyright (c) 2003 Marcel Moolenaar 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * 26 * $FreeBSD: head/sys/boot/ia64/ski/sal_stub.c 110211 2003-02-01 22:50:09Z marcel $ 27 */ 28 29#include <sys/types.h> 30#include <machine/md_var.h> 31#include <machine/sal.h> 32#include <stand.h> 33#include "libski.h" 34 35extern void PalProc(void); 36static sal_entry_t SalProc; 37 38struct { 39 struct sal_system_table header; 40 struct sal_entrypoint_descriptor entry; 41 struct sal_ap_wakeup_descriptor wakeup; 42} sal_systab = { 43 /* Header. */ 44 { 45 SAL_SIGNATURE, 46 sizeof(sal_systab), 47 { 00, 03 }, /* Revision 3.0. */ 48 2, /* Number of decsriptors. */ 49 0, /* XXX checksum. */ 50 { 0 }, 51 { 00, 00 }, /* XXX SAL_A version. */ 52 { 00, 00 }, /* XXX SAL_B version. */ 53 "FreeBSD", 54 "Ski loader", 55 { 0 } 56 }, 57 /* Entrypoint. */ 58 { 59 0, /* Type=entrypoint descr. */ 60 { 0 }, 61 0, /* XXX PalProc. */ 62 0, /* XXX SalProc. */ 63 0, /* XXX SalProc GP. */ 64 { 0 } 65 }, 66 /* AP wakeup. */ 67 { 68 5, /* Type=AP wakeup descr. */ 69 0, /* External interrupt. */ 70 { 0 }, 71 255 /* Wakeup vector. */ 72 } 73}; 74 75static inline void 76puts(const char *s) 77{ 78 s = (const char *)((7UL << 61) | (u_long)s); 79 while (*s) 80 ski_cons_putchar(*s++); 81} 82 83static struct ia64_sal_result 84SalProc(u_int64_t a1, u_int64_t a2, u_int64_t a3, u_int64_t a4, u_int64_t a5, 85 u_int64_t a6, u_int64_t a7, u_int64_t a8) 86{ 87 struct ia64_sal_result res; 88 89 res.sal_status = -3; 90 res.sal_result[0] = 0; 91 res.sal_result[1] = 0; 92 res.sal_result[2] = 0; 93 94 if (a1 == SAL_FREQ_BASE) { 95 res.sal_status = 0; 96 res.sal_result[0] = 133338184; 97 } else if (a1 == SAL_SET_VECTORS) { 98 /* XXX unofficial SSC function. */ 99 ssc(a2, a3, a4, a5, SSC_SAL_SET_VECTORS); 100 } else if (a1 != SAL_GET_STATE_INFO_SIZE) { 101 puts("SAL: unimplemented function called\n"); 102 } 103 104 return (res); 105} 106 107void 108sal_stub_init(void) 109{ 110 struct ia64_fdesc *fd; 111 112 fd = (void*)PalProc; 113 sal_systab.entry.sale_pal_proc = fd->func; 114 fd = (void*)SalProc; 115 sal_systab.entry.sale_sal_proc = fd->func; 116 sal_systab.entry.sale_sal_gp = fd->gp; 117} 118