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