source: trunk/packages/xen-3.1/xen-3.1/extras/mini-os/arch/ia64/sal.c @ 34

Last change on this file since 34 was 34, checked in by hartmans, 18 years ago

Add xen and xen-common

File size: 3.2 KB
Line 
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 */
29
30#include "os.h"
31#include "lib.h"
32#include "console.h"
33#include "page.h"
34
35
36static struct ia64_fdesc sal_fdesc;
37uint64_t ia64_pal_entry;        /* PAL_PROC entrypoint */
38
39
40struct ia64_sal_result
41ia64_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}
46
47static struct ia64_sal_result
48fake_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}
58
59/*
60 * Currently only the SAL_DESC_ENTRYPOINT is checked to get
61 * the entry points the pal and sal functions.
62 */
63void
64ia64_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;
69
70        PRINT_BV("Reading SALtable:\n");
71        ia64_sal_entry = fake_sal;
72
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;
84
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}
103
Note: See TracBrowser for help on using the repository browser.