sal.c revision 84121
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 84121 2001-09-29 11:00:24Z dfr $
27 */
28
29#include <sys/param.h>
30#include <sys/systm.h>
31#include <machine/sal.h>
32
33struct ia64_fdesc {
34	u_int64_t	func;
35	u_int64_t	gp;
36};
37
38static struct ia64_fdesc sal_fdesc;
39static sal_entry_t	fake_sal;
40
41extern u_int64_t	ia64_pal_entry;
42sal_entry_t		*ia64_sal_entry = fake_sal;
43
44static struct ia64_sal_result
45fake_sal(u_int64_t a1, u_int64_t a2, u_int64_t a3, u_int64_t a4,
46	 u_int64_t a5, u_int64_t a6, u_int64_t a7, u_int64_t a8)
47{
48	struct ia64_sal_result res;
49	res.sal_status = -3;
50	res.sal_result[0] = 0;
51	res.sal_result[1] = 0;
52	res.sal_result[2] = 0;
53	return res;
54}
55
56void
57ia64_sal_init(struct sal_system_table *saltab)
58{
59	static int sizes[6] = {
60		48, 32, 16, 32, 16, 16
61	};
62	u_int8_t *p;
63	int i;
64
65	if (memcmp(saltab->sal_signature, "SST_", 4)) {
66		printf("Bad signature for SAL System Table\n");
67		return;
68	}
69
70	p = (u_int8_t *) (saltab + 1);
71	for (i = 0; i < saltab->sal_entry_count; i++) {
72		if (*p == 0) {
73			struct sal_entrypoint_descriptor *dp;
74			dp = (struct sal_entrypoint_descriptor *) p;
75			ia64_pal_entry = IA64_PHYS_TO_RR7(dp->sale_pal_proc);
76			if (bootverbose)
77				printf("PAL Proc at 0x%lx\n", ia64_pal_entry);
78			sal_fdesc.func = IA64_PHYS_TO_RR7(dp->sale_sal_proc);
79			sal_fdesc.gp = IA64_PHYS_TO_RR7(dp->sale_sal_gp);
80			if (bootverbose)
81				printf("SAL Proc at 0x%lx, GP at 0x%lx\n",
82				       sal_fdesc.func, sal_fdesc.gp);
83			ia64_sal_entry = (sal_entry_t *) &sal_fdesc;
84			return;
85		}
86		p += sizes[*p];
87	}
88}
89
90