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