sal_stub.c revision 110211
1110211Smarcel/*
2110211Smarcel * Copyright (c) 2003 Marcel Moolenaar
3110211Smarcel * All rights reserved.
4110211Smarcel *
5110211Smarcel * Redistribution and use in source and binary forms, with or without
6110211Smarcel * modification, are permitted provided that the following conditions
7110211Smarcel * are met:
8110211Smarcel *
9110211Smarcel * 1. Redistributions of source code must retain the above copyright
10110211Smarcel *    notice, this list of conditions and the following disclaimer.
11110211Smarcel * 2. Redistributions in binary form must reproduce the above copyright
12110211Smarcel *    notice, this list of conditions and the following disclaimer in the
13110211Smarcel *    documentation and/or other materials provided with the distribution.
14110211Smarcel *
15110211Smarcel * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16110211Smarcel * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17110211Smarcel * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18110211Smarcel * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19110211Smarcel * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20110211Smarcel * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21110211Smarcel * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22110211Smarcel * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23110211Smarcel * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24110211Smarcel * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25110211Smarcel *
26110211Smarcel * $FreeBSD: head/sys/boot/ia64/ski/sal_stub.c 110211 2003-02-01 22:50:09Z marcel $
27110211Smarcel */
28110211Smarcel
29110211Smarcel#include <sys/types.h>
30110211Smarcel#include <machine/md_var.h>
31110211Smarcel#include <machine/sal.h>
32110211Smarcel#include <stand.h>
33110211Smarcel#include "libski.h"
34110211Smarcel
35110211Smarcelextern void PalProc(void);
36110211Smarcelstatic sal_entry_t SalProc;
37110211Smarcel
38110211Smarcelstruct {
39110211Smarcel	struct sal_system_table header;
40110211Smarcel	struct sal_entrypoint_descriptor entry;
41110211Smarcel	struct sal_ap_wakeup_descriptor wakeup;
42110211Smarcel} sal_systab = {
43110211Smarcel	/* Header. */
44110211Smarcel	{
45110211Smarcel		SAL_SIGNATURE,
46110211Smarcel		sizeof(sal_systab),
47110211Smarcel		{ 00, 03 },		/* Revision 3.0. */
48110211Smarcel		2,			/* Number of decsriptors. */
49110211Smarcel		0,			/* XXX checksum. */
50110211Smarcel		{ 0 },
51110211Smarcel		{ 00, 00 },		/* XXX SAL_A version. */
52110211Smarcel		{ 00, 00 },		/* XXX SAL_B version. */
53110211Smarcel		"FreeBSD",
54110211Smarcel		"Ski loader",
55110211Smarcel		{ 0 }
56110211Smarcel	},
57110211Smarcel	/* Entrypoint. */
58110211Smarcel	{
59110211Smarcel		0,			/* Type=entrypoint descr. */
60110211Smarcel		{ 0 },
61110211Smarcel		0,			/* XXX PalProc. */
62110211Smarcel		0,			/* XXX SalProc. */
63110211Smarcel		0,			/* XXX SalProc GP. */
64110211Smarcel		{ 0 }
65110211Smarcel	},
66110211Smarcel	/* AP wakeup. */
67110211Smarcel	{
68110211Smarcel		5,			/* Type=AP wakeup descr. */
69110211Smarcel		0,			/* External interrupt. */
70110211Smarcel		{ 0 },
71110211Smarcel		255			/* Wakeup vector. */
72110211Smarcel	}
73110211Smarcel};
74110211Smarcel
75110211Smarcelstatic inline void
76110211Smarcelputs(const char *s)
77110211Smarcel{
78110211Smarcel	s = (const char *)((7UL << 61) | (u_long)s);
79110211Smarcel	while (*s)
80110211Smarcel		ski_cons_putchar(*s++);
81110211Smarcel}
82110211Smarcel
83110211Smarcelstatic struct ia64_sal_result
84110211SmarcelSalProc(u_int64_t a1, u_int64_t a2, u_int64_t a3, u_int64_t a4, u_int64_t a5,
85110211Smarcel    u_int64_t a6, u_int64_t a7, u_int64_t a8)
86110211Smarcel{
87110211Smarcel	struct ia64_sal_result res;
88110211Smarcel
89110211Smarcel	res.sal_status = -3;
90110211Smarcel	res.sal_result[0] = 0;
91110211Smarcel	res.sal_result[1] = 0;
92110211Smarcel	res.sal_result[2] = 0;
93110211Smarcel
94110211Smarcel	if (a1 == SAL_FREQ_BASE) {
95110211Smarcel		res.sal_status = 0;
96110211Smarcel		res.sal_result[0] = 133338184;
97110211Smarcel	} else if (a1 == SAL_SET_VECTORS) {
98110211Smarcel		/* XXX unofficial SSC function. */
99110211Smarcel		ssc(a2, a3, a4, a5, SSC_SAL_SET_VECTORS);
100110211Smarcel	} else if (a1 != SAL_GET_STATE_INFO_SIZE) {
101110211Smarcel		puts("SAL: unimplemented function called\n");
102110211Smarcel	}
103110211Smarcel
104110211Smarcel	return (res);
105110211Smarcel}
106110211Smarcel
107110211Smarcelvoid
108110211Smarcelsal_stub_init(void)
109110211Smarcel{
110110211Smarcel	struct ia64_fdesc *fd;
111110211Smarcel
112110211Smarcel	fd = (void*)PalProc;
113110211Smarcel	sal_systab.entry.sale_pal_proc = fd->func;
114110211Smarcel	fd = (void*)SalProc;
115110211Smarcel	sal_systab.entry.sale_sal_proc = fd->func;
116110211Smarcel	sal_systab.entry.sale_sal_gp = fd->gp;
117110211Smarcel}
118