sal.c revision 96442
1/*- 2 * Copyright (c) 2001 Doug Rabson 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 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * 26 * $FreeBSD: head/sys/ia64/ia64/sal.c 96442 2002-05-12 05:54:21Z marcel $ 27 */ 28 29#include <sys/param.h> 30#include <sys/systm.h> 31#include <sys/kernel.h> 32#include <sys/malloc.h> 33#include <vm/vm.h> 34#include <vm/vm_kern.h> 35#include <machine/md_var.h> 36#include <machine/sal.h> 37#include <machine/smp.h> 38 39/* 40 * IPIs are used more genericly than only 41 * for inter-processor interrupts. Don't 42 * make it a SMP specific thing... 43 */ 44int ipi_vector[IPI_COUNT]; 45 46static struct ia64_fdesc sal_fdesc; 47static sal_entry_t fake_sal; 48 49extern u_int64_t ia64_pal_entry; 50sal_entry_t *ia64_sal_entry = fake_sal; 51 52static struct ia64_sal_result 53fake_sal(u_int64_t a1, u_int64_t a2, u_int64_t a3, u_int64_t a4, 54 u_int64_t a5, u_int64_t a6, u_int64_t a7, u_int64_t a8) 55{ 56 struct ia64_sal_result res; 57 res.sal_status = -3; 58 res.sal_result[0] = 0; 59 res.sal_result[1] = 0; 60 res.sal_result[2] = 0; 61 return res; 62} 63 64static void 65setup_ipi_vectors(int ceil) 66{ 67 int ipi; 68 69 ipi_vector[IPI_MCA_RENDEZ] = ceil - 0x10; 70 ipi_vector[IPI_MCA_CMCV] = ceil - 0x30; 71 ipi_vector[IPI_TEST] = ceil - 0x30 + 1; 72 73 ipi = IPI_AST; /* First generic IPI. */ 74 ceil -= 0x20; /* First vector in group. */ 75 while (ipi < IPI_COUNT) 76 ipi_vector[ipi++] = ceil++; 77} 78 79void 80ia64_sal_init(struct sal_system_table *saltab) 81{ 82 static int sizes[6] = { 83 48, 32, 16, 32, 16, 16 84 }; 85 u_int8_t *p; 86 int i; 87 88 if (memcmp(saltab->sal_signature, "SST_", 4)) { 89 printf("Bad signature for SAL System Table\n"); 90 return; 91 } 92 93 p = (u_int8_t *) (saltab + 1); 94 for (i = 0; i < saltab->sal_entry_count; i++) { 95 switch (*p) { 96 case 0: { 97 struct sal_entrypoint_descriptor *dp; 98 99 dp = (struct sal_entrypoint_descriptor*)p; 100 ia64_pal_entry = IA64_PHYS_TO_RR7(dp->sale_pal_proc); 101 if (bootverbose) 102 printf("PAL Proc at 0x%lx\n", ia64_pal_entry); 103 sal_fdesc.func = IA64_PHYS_TO_RR7(dp->sale_sal_proc); 104 sal_fdesc.gp = IA64_PHYS_TO_RR7(dp->sale_sal_gp); 105 if (bootverbose) 106 printf("SAL Proc at 0x%lx, GP at 0x%lx\n", 107 sal_fdesc.func, sal_fdesc.gp); 108 ia64_sal_entry = (sal_entry_t *) &sal_fdesc; 109 break; 110 } 111 case 5: { 112 struct sal_ap_wakeup_descriptor *dp; 113#ifdef SMP 114 struct ia64_sal_result result; 115#endif 116 117 dp = (struct sal_ap_wakeup_descriptor*)p; 118 if (dp->sale_mechanism != 0) { 119 printf("SAL: unsupported AP wake-up mechanism " 120 "(%d)\n", dp->sale_mechanism); 121 break; 122 } 123 124 if (dp->sale_vector < 0x10 || dp->sale_vector > 0xff) { 125 printf("SAL: invalid AP wake-up vector " 126 "(0x%lx)\n", dp->sale_vector); 127 break; 128 } 129 130 /* 131 * SAL documents that the wake-up vector should be 132 * high (close to 255). The MCA rendezvous vector 133 * should be less than the wake-up vector, but still 134 * "high". We use the following priority assignment: 135 * Wake-up: priority of the sale_vector 136 * Rendezvous: priority-1 137 * Generic IPIs: priority-2 138 * Special IPIs: priority-3 139 * Consequently, the wake-up priority should be at 140 * least 4 (ie vector >= 0x40). 141 */ 142 if (dp->sale_vector < 0x40) { 143 printf("SAL: AP wake-up vector too low " 144 "(0x%lx)\n", dp->sale_vector); 145 break; 146 } 147 148 if (bootverbose) 149 printf("SAL: AP wake-up vector: 0x%x\n", 150 dp->sale_vector); 151 152 ipi_vector[IPI_AP_WAKEUP] = dp->sale_vector; 153 setup_ipi_vectors(dp->sale_vector & 0xf0); 154 155#ifdef SMP 156 result = ia64_sal_entry(SAL_SET_VECTORS, 157 SAL_OS_BOOT_RENDEZ, 158 ia64_tpa(FDESC_FUNC(os_boot_rendez)), 159 ia64_tpa(FDESC_GP(os_boot_rendez)), 160 0, 0, 0, 0); 161#endif 162 163 break; 164 } 165 } 166 p += sizes[*p]; 167 } 168 169 if (ipi_vector[IPI_AP_WAKEUP] == 0) 170 setup_ipi_vectors(0xf0); 171} 172