1#ifndef _ASM_IA64_SN_SN_SAL_H
2#define _ASM_IA64_SN_SN_SAL_H
3
4/*
5 * System Abstraction Layer definitions for IA64
6 *
7 * This file is subject to the terms and conditions of the GNU General Public
8 * License.  See the file "COPYING" in the main directory of this archive
9 * for more details.
10 *
11 * Copyright (c) 2000-2002 Silicon Graphics, Inc.  All rights reserved.
12 */
13
14
15#include <asm/sal.h>
16#include <asm/sn/sn_cpuid.h>
17
18
19// SGI Specific Calls
20#define  SN_SAL_POD_MODE                           0x02000001
21#define  SN_SAL_SYSTEM_RESET                       0x02000002
22#define  SN_SAL_PROBE                              0x02000003
23#define  SN_SAL_GET_CONSOLE_NASID                  0x02000004
24#define	 SN_SAL_GET_KLCONFIG_ADDR		   0x02000005
25#define  SN_SAL_LOG_CE				   0x02000006
26#define  SN_SAL_REGISTER_CE			   0x02000007
27#define  SN_SAL_CONSOLE_PUTC                       0x02000021
28#define  SN_SAL_CONSOLE_GETC                       0x02000022
29#define  SN_SAL_CONSOLE_PUTS                       0x02000023
30#define  SN_SAL_CONSOLE_GETS                       0x02000024
31#define  SN_SAL_CONSOLE_GETS_TIMEOUT               0x02000025
32#define  SN_SAL_CONSOLE_POLL                       0x02000026
33#define  SN_SAL_CONSOLE_INTR                       0x02000027
34
35/*
36 * Service-specific constants
37 */
38#define SAL_CONSOLE_INTR_IN     0       /* manipulate input interrupts */
39#define SAL_CONSOLE_INTR_OUT    1       /* manipulate output low-water
40                                         * interrupts
41                                         */
42#define SAL_CONSOLE_INTR_OFF    0       /* turn the interrupt off */
43#define SAL_CONSOLE_INTR_ON     1       /* turn the interrupt on */
44
45
46
47
48u64 ia64_sn_probe_io_slot(long paddr, long size, void *data_ptr);
49
50/*
51 * Returns the master console nasid, if the call fails, return an illegal
52 * value.
53 */
54static inline u64
55ia64_sn_get_console_nasid(void)
56{
57	struct ia64_sal_retval ret_stuff;
58
59	ret_stuff.status = (uint64_t)0;
60	ret_stuff.v0 = (uint64_t)0;
61	ret_stuff.v1 = (uint64_t)0;
62	ret_stuff.v2 = (uint64_t)0;
63	SAL_CALL(ret_stuff, SN_SAL_GET_CONSOLE_NASID, 0, 0, 0, 0, 0, 0, 0);
64
65	if (ret_stuff.status < 0)
66		return ret_stuff.status;
67
68	/* Master console nasid is in 'v0' */
69	return ret_stuff.v0;
70}
71
72static inline u64
73ia64_sn_get_klconfig_addr(nasid_t nasid)
74{
75	struct ia64_sal_retval ret_stuff;
76	extern u64 klgraph_addr[];
77	int cnodeid;
78
79	cnodeid = nasid_to_cnodeid(nasid);
80	if (klgraph_addr[cnodeid] == 0) {
81		ret_stuff.status = (uint64_t)0;
82		ret_stuff.v0 = (uint64_t)0;
83		ret_stuff.v1 = (uint64_t)0;
84		ret_stuff.v2 = (uint64_t)0;
85		SAL_CALL(ret_stuff, SN_SAL_GET_KLCONFIG_ADDR, (u64)nasid, 0, 0, 0, 0, 0, 0);
86
87		/*
88	 	* We should panic if a valid cnode nasid does not produce
89	 	* a klconfig address.
90	 	*/
91		if (ret_stuff.status != 0) {
92			panic("ia64_sn_get_klconfig_addr: Returned error %lx\n", ret_stuff.status);
93		}
94
95		klgraph_addr[cnodeid] = ret_stuff.v0;
96	}
97	return(klgraph_addr[cnodeid]);
98}
99
100/*
101 * Returns the next console character.
102 */
103static inline u64
104ia64_sn_console_getc(int *ch)
105{
106	struct ia64_sal_retval ret_stuff;
107
108	ret_stuff.status = (uint64_t)0;
109	ret_stuff.v0 = (uint64_t)0;
110	ret_stuff.v1 = (uint64_t)0;
111	ret_stuff.v2 = (uint64_t)0;
112	SAL_CALL(ret_stuff, SN_SAL_CONSOLE_GETC, 0, 0, 0, 0, 0, 0, 0);
113
114	/* character is in 'v0' */
115	*ch = (int)ret_stuff.v0;
116
117	return ret_stuff.status;
118}
119
120/*
121 * Sends the given character to the console.
122 */
123static inline u64
124ia64_sn_console_putc(char ch)
125{
126	struct ia64_sal_retval ret_stuff;
127
128	ret_stuff.status = (uint64_t)0;
129	ret_stuff.v0 = (uint64_t)0;
130	ret_stuff.v1 = (uint64_t)0;
131	ret_stuff.v2 = (uint64_t)0;
132	SAL_CALL(ret_stuff, SN_SAL_CONSOLE_PUTC, (uint64_t)ch, 0, 0, 0, 0, 0, 0);
133
134	return ret_stuff.status;
135}
136
137/*
138 * Checks for console input.
139 */
140static inline u64
141ia64_sn_console_check(int *result)
142{
143	struct ia64_sal_retval ret_stuff;
144
145	ret_stuff.status = (uint64_t)0;
146	ret_stuff.v0 = (uint64_t)0;
147	ret_stuff.v1 = (uint64_t)0;
148	ret_stuff.v2 = (uint64_t)0;
149	SAL_CALL(ret_stuff, SN_SAL_CONSOLE_POLL, 0, 0, 0, 0, 0, 0, 0);
150
151	/* result is in 'v0' */
152	*result = (int)ret_stuff.v0;
153
154	return ret_stuff.status;
155}
156
157#endif /* _ASM_IA64_SN_SN_SAL_H */
158