summaryrefslogtreecommitdiffstats
path: root/sys/boot/ia64/libski/sal_stub.c
blob: b5661a395b118835899c25399290144fc1fc3466 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/*
 * Copyright (c) 2003 Marcel Moolenaar
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");

#include <sys/types.h>
#include <machine/md_var.h>
#include <machine/sal.h>
#include <stand.h>
#include "libski.h"

extern void PalProc(void);
static sal_entry_t SalProc;

struct {
	struct sal_system_table header;
	struct sal_entrypoint_descriptor entry;
	struct sal_ap_wakeup_descriptor wakeup;
} sal_systab = {
	/* Header. */
	{
		SAL_SIGNATURE,
		sizeof(sal_systab),
		{ 00, 03 },		/* Revision 3.0. */
		2,			/* Number of decsriptors. */
		0,			/* XXX checksum. */
		{ 0 },
		{ 00, 00 },		/* XXX SAL_A version. */
		{ 00, 00 },		/* XXX SAL_B version. */
		"FreeBSD",
		"Ski loader",
		{ 0 }
	},
	/* Entrypoint. */
	{
		0,			/* Type=entrypoint descr. */
		{ 0 },
		0,			/* XXX PalProc. */
		0,			/* XXX SalProc. */
		0,			/* XXX SalProc GP. */
		{ 0 }
	},
	/* AP wakeup. */
	{
		5,			/* Type=AP wakeup descr. */
		0,			/* External interrupt. */
		{ 0 },
		255			/* Wakeup vector. */
	}
};

static inline void
puts(const char *s)
{
	s = (const char *)((7UL << 61) | (u_long)s);
	while (*s)
		ski_cons_putchar(*s++);
}

static struct ia64_sal_result
SalProc(u_int64_t a1, u_int64_t a2, u_int64_t a3, u_int64_t a4, u_int64_t a5,
    u_int64_t a6, u_int64_t a7, u_int64_t a8)
{
	struct ia64_sal_result res;

	res.sal_status = -3;
	res.sal_result[0] = 0;
	res.sal_result[1] = 0;
	res.sal_result[2] = 0;

	if (a1 == SAL_FREQ_BASE) {
		res.sal_status = 0;
		res.sal_result[0] = 133338184;
	} else if (a1 == SAL_SET_VECTORS) {
		/* XXX unofficial SSC function. */
		ssc(a2, a3, a4, a5, SSC_SAL_SET_VECTORS);
	} else if (a1 != SAL_GET_STATE_INFO_SIZE) {
		puts("SAL: unimplemented function called\n");
	}

	return (res);
}

void
sal_stub_init(void)
{
	struct ia64_fdesc *fd;

	fd = (void*)PalProc;
	sal_systab.entry.sale_pal_proc = fd->func;
	fd = (void*)SalProc;
	sal_systab.entry.sale_sal_proc = fd->func;
	sal_systab.entry.sale_sal_gp = fd->gp;
}
OpenPOWER on IntegriCloud