debuggers.hg

view extras/mini-os/arch/ia64/sal.c @ 0:7d21f7218375

Exact replica of unstable on 051908 + README-this
author Mukesh Rathor
date Mon May 19 15:34:57 2008 -0700 (2008-05-19)
parents
children 46f8fc57b1a4
line source
1 /*
2 * Done by Dietmar Hahn <dietmar.hahn@fujitsu-siemens.com>
3 * Mostly taken from FreeBSD.
4 *
5 ****************************************************************************
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 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 *
28 */
30 #include "os.h"
31 #include "lib.h"
32 #include "console.h"
33 #include "page.h"
36 static struct ia64_fdesc sal_fdesc;
37 uint64_t ia64_pal_entry; /* PAL_PROC entrypoint */
40 struct ia64_sal_result
41 ia64_sal_call(uint64_t a1, uint64_t a2, uint64_t a3, uint64_t a4,
42 uint64_t a5, uint64_t a6, uint64_t a7, uint64_t a8)
43 {
44 return ia64_sal_entry(a1, a2, a3, a4, a5, a6, a7, a8);
45 }
47 static struct ia64_sal_result
48 fake_sal(uint64_t a1, uint64_t a2, uint64_t a3, uint64_t a4,
49 uint64_t a5, uint64_t a6, uint64_t a7, uint64_t a8)
50 {
51 struct ia64_sal_result res;
52 res.sal_status = -3;
53 res.sal_result[0] = 0;
54 res.sal_result[1] = 0;
55 res.sal_result[2] = 0;
56 return res;
57 }
59 /*
60 * Currently only the SAL_DESC_ENTRYPOINT is checked to get
61 * the entry points the pal and sal functions.
62 */
63 void
64 ia64_sal_init(struct sal_system_table *saltab)
65 {
66 static int sizes[6] = { 48, 32, 16, 32, 16, 16 };
67 uint8_t *p;
68 int i;
70 PRINT_BV("Reading SALtable:\n");
71 ia64_sal_entry = fake_sal;
73 if (memcmp((void*)(uint64_t)(saltab->sal_signature), SAL_SIGNATURE, 4))
74 {
75 printk("Bad signature for SAL System Table\n");
76 return;
77 }
78 p = (uint8_t *) (saltab + 1);
79 for (i = 0; i < SWAP(saltab->sal_entry_count); i++) {
80 switch (SWAP(*p)) {
81 case SAL_DESC_ENTRYPOINT: // 0
82 {
83 struct sal_entrypoint_descriptor *dp;
85 dp = (struct sal_entrypoint_descriptor*)p;
86 ia64_pal_entry =
87 IA64_PHYS_TO_RR7(SWAP(dp->sale_pal_proc));
88 PRINT_BV(" PAL Proc at 0x%lx\n", ia64_pal_entry);
89 sal_fdesc.func =
90 IA64_PHYS_TO_RR7(SWAP(dp->sale_sal_proc));
91 sal_fdesc.gp = IA64_PHYS_TO_RR7(SWAP(dp->sale_sal_gp));
92 PRINT_BV(" SAL Proc at 0x%lx, GP at 0x%lx\n",
93 sal_fdesc.func, sal_fdesc.gp);
94 ia64_sal_entry = (sal_entry_t *) &sal_fdesc;
95 break;
96 }
97 default:
98 break;
99 }
100 p += sizes[*p];
101 }
102 }