1 #ifndef _ASM_IA64_SN_SN_SAL_H
2 #define _ASM_IA64_SN_SN_SAL_H
5 * System Abstraction Layer definitions for IA64
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
11 * Copyright (c) 2000-2005 Silicon Graphics, Inc. All rights reserved.
15 #include <linux/config.h>
17 #include <asm/sn/sn_cpuid.h>
18 #include <asm/sn/arch.h>
19 #include <asm/sn/geo.h>
20 #include <asm/sn/nodepda.h>
21 #include <asm/sn/shub_mmr.h>
24 #define SN_SAL_POD_MODE 0x02000001
25 #define SN_SAL_SYSTEM_RESET 0x02000002
26 #define SN_SAL_PROBE 0x02000003
27 #define SN_SAL_GET_MASTER_NASID 0x02000004
28 #define SN_SAL_GET_KLCONFIG_ADDR 0x02000005
29 #define SN_SAL_LOG_CE 0x02000006
30 #define SN_SAL_REGISTER_CE 0x02000007
31 #define SN_SAL_GET_PARTITION_ADDR 0x02000009
32 #define SN_SAL_XP_ADDR_REGION 0x0200000f
33 #define SN_SAL_NO_FAULT_ZONE_VIRTUAL 0x02000010
34 #define SN_SAL_NO_FAULT_ZONE_PHYSICAL 0x02000011
35 #define SN_SAL_PRINT_ERROR 0x02000012
36 #define SN_SAL_SET_ERROR_HANDLING_FEATURES 0x0200001a // reentrant
37 #define SN_SAL_GET_FIT_COMPT 0x0200001b // reentrant
38 #define SN_SAL_GET_SAPIC_INFO 0x0200001d
39 #define SN_SAL_GET_SN_INFO 0x0200001e
40 #define SN_SAL_CONSOLE_PUTC 0x02000021
41 #define SN_SAL_CONSOLE_GETC 0x02000022
42 #define SN_SAL_CONSOLE_PUTS 0x02000023
43 #define SN_SAL_CONSOLE_GETS 0x02000024
44 #define SN_SAL_CONSOLE_GETS_TIMEOUT 0x02000025
45 #define SN_SAL_CONSOLE_POLL 0x02000026
46 #define SN_SAL_CONSOLE_INTR 0x02000027
47 #define SN_SAL_CONSOLE_PUTB 0x02000028
48 #define SN_SAL_CONSOLE_XMIT_CHARS 0x0200002a
49 #define SN_SAL_CONSOLE_READC 0x0200002b
50 #define SN_SAL_SYSCTL_OP 0x02000030
51 #define SN_SAL_SYSCTL_MODID_GET 0x02000031
52 #define SN_SAL_SYSCTL_GET 0x02000032
53 #define SN_SAL_SYSCTL_IOBRICK_MODULE_GET 0x02000033
54 #define SN_SAL_SYSCTL_IO_PORTSPEED_GET 0x02000035
55 #define SN_SAL_SYSCTL_SLAB_GET 0x02000036
56 #define SN_SAL_BUS_CONFIG 0x02000037
57 #define SN_SAL_SYS_SERIAL_GET 0x02000038
58 #define SN_SAL_PARTITION_SERIAL_GET 0x02000039
59 #define SN_SAL_SYSTEM_POWER_DOWN 0x0200003b
60 #define SN_SAL_GET_MASTER_BASEIO_NASID 0x0200003c
61 #define SN_SAL_COHERENCE 0x0200003d
62 #define SN_SAL_MEMPROTECT 0x0200003e
63 #define SN_SAL_SYSCTL_FRU_CAPTURE 0x0200003f
65 #define SN_SAL_SYSCTL_IOBRICK_PCI_OP 0x02000042 // reentrant
66 #define SN_SAL_IROUTER_OP 0x02000043
67 #define SN_SAL_SYSCTL_EVENT 0x02000044
68 #define SN_SAL_IOIF_INTERRUPT 0x0200004a
69 #define SN_SAL_HWPERF_OP 0x02000050 // lock
70 #define SN_SAL_IOIF_ERROR_INTERRUPT 0x02000051
72 #define SN_SAL_IOIF_SLOT_ENABLE 0x02000053
73 #define SN_SAL_IOIF_SLOT_DISABLE 0x02000054
74 #define SN_SAL_IOIF_GET_HUBDEV_INFO 0x02000055
75 #define SN_SAL_IOIF_GET_PCIBUS_INFO 0x02000056
76 #define SN_SAL_IOIF_GET_PCIDEV_INFO 0x02000057
77 #define SN_SAL_IOIF_GET_WIDGET_DMAFLUSH_LIST 0x02000058
79 #define SN_SAL_HUB_ERROR_INTERRUPT 0x02000060
80 #define SN_SAL_BTE_RECOVER 0x02000061
81 #define SN_SAL_RESERVED_DO_NOT_USE 0x02000062
82 #define SN_SAL_IOIF_GET_PCI_TOPOLOGY 0x02000064
84 #define SN_SAL_GET_PROM_FEATURE_SET 0x02000065
85 #define SN_SAL_SET_OS_FEATURE_SET 0x02000066
88 * Service-specific constants
91 /* Console interrupt manipulation */
93 #define SAL_CONSOLE_INTR_OFF 0 /* turn the interrupt off */
94 #define SAL_CONSOLE_INTR_ON 1 /* turn the interrupt on */
95 #define SAL_CONSOLE_INTR_STATUS 2 /* retrieve the interrupt status */
96 /* interrupt specification & status return codes */
97 #define SAL_CONSOLE_INTR_XMIT 1 /* output interrupt */
98 #define SAL_CONSOLE_INTR_RECV 2 /* input interrupt */
100 /* interrupt handling */
101 #define SAL_INTR_ALLOC 1
102 #define SAL_INTR_FREE 2
105 * operations available on the generic SN_SAL_SYSCTL_OP
108 #define SAL_SYSCTL_OP_IOBOARD 0x0001 /* retrieve board type */
109 #define SAL_SYSCTL_OP_TIO_JLCK_RST 0x0002 /* issue TIO clock reset */
112 * IRouter (i.e. generalized system controller) operations
114 #define SAL_IROUTER_OPEN 0 /* open a subchannel */
115 #define SAL_IROUTER_CLOSE 1 /* close a subchannel */
116 #define SAL_IROUTER_SEND 2 /* send part of an IRouter packet */
117 #define SAL_IROUTER_RECV 3 /* receive part of an IRouter packet */
118 #define SAL_IROUTER_INTR_STATUS 4 /* check the interrupt status for
121 #define SAL_IROUTER_INTR_ON 5 /* enable an interrupt */
122 #define SAL_IROUTER_INTR_OFF 6 /* disable an interrupt */
123 #define SAL_IROUTER_INIT 7 /* initialize IRouter driver */
125 /* IRouter interrupt mask bits */
126 #define SAL_IROUTER_INTR_XMIT SAL_CONSOLE_INTR_XMIT
127 #define SAL_IROUTER_INTR_RECV SAL_CONSOLE_INTR_RECV
130 * Error Handling Features
132 #define SAL_ERR_FEAT_MCA_SLV_TO_OS_INIT_SLV 0x1 // obsolete
133 #define SAL_ERR_FEAT_LOG_SBES 0x2 // obsolete
134 #define SAL_ERR_FEAT_MFR_OVERRIDE 0x4
135 #define SAL_ERR_FEAT_SBE_THRESHOLD 0xffff0000
140 #define SALRET_MORE_PASSES 1
142 #define SALRET_NOT_IMPLEMENTED (-1)
143 #define SALRET_INVALID_ARG (-2)
144 #define SALRET_ERROR (-3)
146 #define SN_SAL_FAKE_PROM 0x02009999
149 * sn_sal_revision - get the SGI SAL revision number
151 * The SGI PROM stores its version in the sal_[ab]_rev_(major|minor).
152 * This routine simply extracts the major and minor values and
153 * presents them in a u32 format.
155 * For example, version 4.05 would be represented at 0x0405.
160 struct ia64_sal_systab *systab = efi.sal_systab;
162 return (u32)(systab->sal_b_rev_major << 8 | systab->sal_b_rev_minor);
166 * Returns the master console nasid, if the call fails, return an illegal
170 ia64_sn_get_console_nasid(void)
172 struct ia64_sal_retval ret_stuff;
174 ret_stuff.status = 0;
178 SAL_CALL(ret_stuff, SN_SAL_GET_MASTER_NASID, 0, 0, 0, 0, 0, 0, 0);
180 if (ret_stuff.status < 0)
181 return ret_stuff.status;
183 /* Master console nasid is in 'v0' */
188 * Returns the master baseio nasid, if the call fails, return an illegal
192 ia64_sn_get_master_baseio_nasid(void)
194 struct ia64_sal_retval ret_stuff;
196 ret_stuff.status = 0;
200 SAL_CALL(ret_stuff, SN_SAL_GET_MASTER_BASEIO_NASID, 0, 0, 0, 0, 0, 0, 0);
202 if (ret_stuff.status < 0)
203 return ret_stuff.status;
205 /* Master baseio nasid is in 'v0' */
210 ia64_sn_get_klconfig_addr(nasid_t nasid)
212 struct ia64_sal_retval ret_stuff;
215 cnodeid = nasid_to_cnodeid(nasid);
216 ret_stuff.status = 0;
220 SAL_CALL(ret_stuff, SN_SAL_GET_KLCONFIG_ADDR, (u64)nasid, 0, 0, 0, 0, 0, 0);
223 * We should panic if a valid cnode nasid does not produce
224 * a klconfig address.
226 if (ret_stuff.status != 0) {
227 panic("ia64_sn_get_klconfig_addr: Returned error %lx\n", ret_stuff.status);
229 return ret_stuff.v0 ? __va(ret_stuff.v0) : NULL;
233 * Returns the next console character.
236 ia64_sn_console_getc(int *ch)
238 struct ia64_sal_retval ret_stuff;
240 ret_stuff.status = 0;
244 SAL_CALL_NOLOCK(ret_stuff, SN_SAL_CONSOLE_GETC, 0, 0, 0, 0, 0, 0, 0);
246 /* character is in 'v0' */
247 *ch = (int)ret_stuff.v0;
249 return ret_stuff.status;
253 * Read a character from the SAL console device, after a previous interrupt
254 * or poll operation has given us to know that a character is available
258 ia64_sn_console_readc(void)
260 struct ia64_sal_retval ret_stuff;
262 ret_stuff.status = 0;
266 SAL_CALL_NOLOCK(ret_stuff, SN_SAL_CONSOLE_READC, 0, 0, 0, 0, 0, 0, 0);
268 /* character is in 'v0' */
273 * Sends the given character to the console.
276 ia64_sn_console_putc(char ch)
278 struct ia64_sal_retval ret_stuff;
280 ret_stuff.status = 0;
284 SAL_CALL_NOLOCK(ret_stuff, SN_SAL_CONSOLE_PUTC, (uint64_t)ch, 0, 0, 0, 0, 0, 0);
286 return ret_stuff.status;
290 * Sends the given buffer to the console.
293 ia64_sn_console_putb(const char *buf, int len)
295 struct ia64_sal_retval ret_stuff;
297 ret_stuff.status = 0;
301 SAL_CALL_NOLOCK(ret_stuff, SN_SAL_CONSOLE_PUTB, (uint64_t)buf, (uint64_t)len, 0, 0, 0, 0, 0);
303 if ( ret_stuff.status == 0 ) {
310 * Print a platform error record
313 ia64_sn_plat_specific_err_print(int (*hook)(const char*, ...), char *rec)
315 struct ia64_sal_retval ret_stuff;
317 ret_stuff.status = 0;
321 SAL_CALL_REENTRANT(ret_stuff, SN_SAL_PRINT_ERROR, (uint64_t)hook, (uint64_t)rec, 0, 0, 0, 0, 0);
323 return ret_stuff.status;
327 * Check for Platform errors
330 ia64_sn_plat_cpei_handler(void)
332 struct ia64_sal_retval ret_stuff;
334 ret_stuff.status = 0;
338 SAL_CALL_NOLOCK(ret_stuff, SN_SAL_LOG_CE, 0, 0, 0, 0, 0, 0, 0);
340 return ret_stuff.status;
344 * Set Error Handling Features (Obsolete)
347 ia64_sn_plat_set_error_handling_features(void)
349 struct ia64_sal_retval ret_stuff;
351 ret_stuff.status = 0;
355 SAL_CALL_REENTRANT(ret_stuff, SN_SAL_SET_ERROR_HANDLING_FEATURES,
356 (SAL_ERR_FEAT_MCA_SLV_TO_OS_INIT_SLV | SAL_ERR_FEAT_LOG_SBES),
359 return ret_stuff.status;
363 * Checks for console input.
366 ia64_sn_console_check(int *result)
368 struct ia64_sal_retval ret_stuff;
370 ret_stuff.status = 0;
374 SAL_CALL_NOLOCK(ret_stuff, SN_SAL_CONSOLE_POLL, 0, 0, 0, 0, 0, 0, 0);
376 /* result is in 'v0' */
377 *result = (int)ret_stuff.v0;
379 return ret_stuff.status;
383 * Checks console interrupt status
386 ia64_sn_console_intr_status(void)
388 struct ia64_sal_retval ret_stuff;
390 ret_stuff.status = 0;
394 SAL_CALL_NOLOCK(ret_stuff, SN_SAL_CONSOLE_INTR,
395 0, SAL_CONSOLE_INTR_STATUS,
398 if (ret_stuff.status == 0) {
406 * Enable an interrupt on the SAL console device.
409 ia64_sn_console_intr_enable(uint64_t intr)
411 struct ia64_sal_retval ret_stuff;
413 ret_stuff.status = 0;
417 SAL_CALL_NOLOCK(ret_stuff, SN_SAL_CONSOLE_INTR,
418 intr, SAL_CONSOLE_INTR_ON,
423 * Disable an interrupt on the SAL console device.
426 ia64_sn_console_intr_disable(uint64_t intr)
428 struct ia64_sal_retval ret_stuff;
430 ret_stuff.status = 0;
434 SAL_CALL_NOLOCK(ret_stuff, SN_SAL_CONSOLE_INTR,
435 intr, SAL_CONSOLE_INTR_OFF,
440 * Sends a character buffer to the console asynchronously.
443 ia64_sn_console_xmit_chars(char *buf, int len)
445 struct ia64_sal_retval ret_stuff;
447 ret_stuff.status = 0;
451 SAL_CALL_NOLOCK(ret_stuff, SN_SAL_CONSOLE_XMIT_CHARS,
452 (uint64_t)buf, (uint64_t)len,
455 if (ret_stuff.status == 0) {
463 * Returns the iobrick module Id
466 ia64_sn_sysctl_iobrick_module_get(nasid_t nasid, int *result)
468 struct ia64_sal_retval ret_stuff;
470 ret_stuff.status = 0;
474 SAL_CALL_NOLOCK(ret_stuff, SN_SAL_SYSCTL_IOBRICK_MODULE_GET, nasid, 0, 0, 0, 0, 0, 0);
476 /* result is in 'v0' */
477 *result = (int)ret_stuff.v0;
479 return ret_stuff.status;
483 * ia64_sn_pod_mode - call the SN_SAL_POD_MODE function
485 * SN_SAL_POD_MODE actually takes an argument, but it's always
486 * 0 when we call it from the kernel, so we don't have to expose
490 ia64_sn_pod_mode(void)
492 struct ia64_sal_retval isrv;
493 SAL_CALL_REENTRANT(isrv, SN_SAL_POD_MODE, 0, 0, 0, 0, 0, 0, 0);
500 * ia64_sn_probe_mem - read from memory safely
501 * @addr: address to probe
502 * @size: number bytes to read (1,2,4,8)
503 * @data_ptr: address to store value read by probe (-1 returned if probe fails)
505 * Call into the SAL to do a memory read. If the read generates a machine
506 * check, this routine will recover gracefully and return -1 to the caller.
507 * @addr is usually a kernel virtual address in uncached space (i.e. the
508 * address starts with 0xc), but if called in physical mode, @addr should
509 * be a physical address.
512 * 0 - probe successful
513 * 1 - probe failed (generated MCA)
518 ia64_sn_probe_mem(long addr, long size, void *data_ptr)
520 struct ia64_sal_retval isrv;
522 SAL_CALL(isrv, SN_SAL_PROBE, addr, size, 0, 0, 0, 0, 0);
527 *((u8*)data_ptr) = (u8)isrv.v0;
530 *((u16*)data_ptr) = (u16)isrv.v0;
533 *((u32*)data_ptr) = (u32)isrv.v0;
536 *((u64*)data_ptr) = (u64)isrv.v0;
546 * Retrieve the system serial number as an ASCII string.
549 ia64_sn_sys_serial_get(char *buf)
551 struct ia64_sal_retval ret_stuff;
552 SAL_CALL_NOLOCK(ret_stuff, SN_SAL_SYS_SERIAL_GET, buf, 0, 0, 0, 0, 0, 0);
553 return ret_stuff.status;
556 extern char sn_system_serial_number_string[];
557 extern u64 sn_partition_serial_number;
560 sn_system_serial_number(void) {
561 if (sn_system_serial_number_string[0]) {
562 return(sn_system_serial_number_string);
564 ia64_sn_sys_serial_get(sn_system_serial_number_string);
565 return(sn_system_serial_number_string);
571 * Returns a unique id number for this system and partition (suitable for
572 * use with license managers), based in part on the system serial number.
575 ia64_sn_partition_serial_get(void)
577 struct ia64_sal_retval ret_stuff;
578 ia64_sal_oemcall_reentrant(&ret_stuff, SN_SAL_PARTITION_SERIAL_GET, 0,
580 if (ret_stuff.status != 0)
586 sn_partition_serial_number_val(void) {
587 if (unlikely(sn_partition_serial_number == 0)) {
588 sn_partition_serial_number = ia64_sn_partition_serial_get();
590 return sn_partition_serial_number;
594 * Returns the physical address of the partition's reserved page through
595 * an iterative number of calls.
597 * On first call, 'cookie' and 'len' should be set to 0, and 'addr'
598 * set to the nasid of the partition whose reserved page's address is
600 * On subsequent calls, pass the values, that were passed back on the
603 * While the return status equals SALRET_MORE_PASSES, keep calling
604 * this function after first copying 'len' bytes starting at 'addr'
605 * into 'buf'. Once the return status equals SALRET_OK, 'addr' will
606 * be the physical address of the partition's reserved page. If the
607 * return status equals neither of these, an error as occurred.
610 sn_partition_reserved_page_pa(u64 buf, u64 *cookie, u64 *addr, u64 *len)
612 struct ia64_sal_retval rv;
613 ia64_sal_oemcall_reentrant(&rv, SN_SAL_GET_PARTITION_ADDR, *cookie,
614 *addr, buf, *len, 0, 0, 0);
622 * Register or unregister a physical address range being referenced across
623 * a partition boundary for which certain SAL errors should be scanned for,
624 * cleaned up and ignored. This is of value for kernel partitioning code only.
625 * Values for the operation argument:
626 * 1 = register this address range with SAL
627 * 0 = unregister this address range with SAL
629 * SAL maintains a reference count on an address range in case it is registered
632 * On success, returns the reference count of the address range after the SAL
633 * call has performed the current registration/unregistration. Returns a
634 * negative value if an error occurred.
637 sn_register_xp_addr_region(u64 paddr, u64 len, int operation)
639 struct ia64_sal_retval ret_stuff;
640 ia64_sal_oemcall(&ret_stuff, SN_SAL_XP_ADDR_REGION, paddr, len,
641 (u64)operation, 0, 0, 0, 0);
642 return ret_stuff.status;
646 * Register or unregister an instruction range for which SAL errors should
647 * be ignored. If an error occurs while in the registered range, SAL jumps
648 * to return_addr after ignoring the error. Values for the operation argument:
649 * 1 = register this instruction range with SAL
650 * 0 = unregister this instruction range with SAL
652 * Returns 0 on success, or a negative value if an error occurred.
655 sn_register_nofault_code(u64 start_addr, u64 end_addr, u64 return_addr,
656 int virtual, int operation)
658 struct ia64_sal_retval ret_stuff;
661 call = SN_SAL_NO_FAULT_ZONE_VIRTUAL;
663 call = SN_SAL_NO_FAULT_ZONE_PHYSICAL;
665 ia64_sal_oemcall(&ret_stuff, call, start_addr, end_addr, return_addr,
667 return ret_stuff.status;
671 * Change or query the coherence domain for this partition. Each cpu-based
672 * nasid is represented by a bit in an array of 64-bit words:
673 * 0 = not in this partition's coherency domain
674 * 1 = in this partition's coherency domain
676 * It is not possible for the local system's nasids to be removed from
677 * the coherency domain. Purpose of the domain arguments:
678 * new_domain = set the coherence domain to the given nasids
679 * old_domain = return the current coherence domain
681 * Returns 0 on success, or a negative value if an error occurred.
684 sn_change_coherence(u64 *new_domain, u64 *old_domain)
686 struct ia64_sal_retval ret_stuff;
687 ia64_sal_oemcall(&ret_stuff, SN_SAL_COHERENCE, (u64)new_domain,
688 (u64)old_domain, 0, 0, 0, 0, 0);
689 return ret_stuff.status;
693 * Change memory access protections for a physical address range.
694 * nasid_array is not used on Altix, but may be in future architectures.
695 * Available memory protection access classes are defined after the function.
698 sn_change_memprotect(u64 paddr, u64 len, u64 perms, u64 *nasid_array)
700 struct ia64_sal_retval ret_stuff;
702 unsigned long irq_flags;
704 cnodeid = nasid_to_cnodeid(get_node_number(paddr));
705 // spin_lock(&NODEPDA(cnodeid)->bist_lock);
706 local_irq_save(irq_flags);
707 ia64_sal_oemcall_nolock(&ret_stuff, SN_SAL_MEMPROTECT, paddr, len,
708 (u64)nasid_array, perms, 0, 0, 0);
709 local_irq_restore(irq_flags);
710 // spin_unlock(&NODEPDA(cnodeid)->bist_lock);
711 return ret_stuff.status;
713 #define SN_MEMPROT_ACCESS_CLASS_0 0x14a080
714 #define SN_MEMPROT_ACCESS_CLASS_1 0x2520c2
715 #define SN_MEMPROT_ACCESS_CLASS_2 0x14a1ca
716 #define SN_MEMPROT_ACCESS_CLASS_3 0x14a290
717 #define SN_MEMPROT_ACCESS_CLASS_6 0x084080
718 #define SN_MEMPROT_ACCESS_CLASS_7 0x021080
721 * Turns off system power.
724 ia64_sn_power_down(void)
726 struct ia64_sal_retval ret_stuff;
727 SAL_CALL(ret_stuff, SN_SAL_SYSTEM_POWER_DOWN, 0, 0, 0, 0, 0, 0, 0);
734 * ia64_sn_fru_capture - tell the system controller to capture hw state
736 * This routine will call the SAL which will tell the system controller(s)
737 * to capture hw mmr information from each SHub in the system.
740 ia64_sn_fru_capture(void)
742 struct ia64_sal_retval isrv;
743 SAL_CALL(isrv, SN_SAL_SYSCTL_FRU_CAPTURE, 0, 0, 0, 0, 0, 0, 0);
750 * Performs an operation on a PCI bus or slot -- power up, power down
754 ia64_sn_sysctl_iobrick_pci_op(nasid_t n, u64 connection_type,
758 struct ia64_sal_retval rv = {0, 0, 0, 0};
760 SAL_CALL_NOLOCK(rv, SN_SAL_SYSCTL_IOBRICK_PCI_OP, connection_type, n, action,
761 bus, (u64) slot, 0, 0);
769 * Open a subchannel for sending arbitrary data to the system
770 * controller network via the system controller device associated with
771 * 'nasid'. Return the subchannel number or a negative error code.
774 ia64_sn_irtr_open(nasid_t nasid)
776 struct ia64_sal_retval rv;
777 SAL_CALL_REENTRANT(rv, SN_SAL_IROUTER_OP, SAL_IROUTER_OPEN, nasid,
783 * Close system controller subchannel 'subch' previously opened on 'nasid'.
786 ia64_sn_irtr_close(nasid_t nasid, int subch)
788 struct ia64_sal_retval rv;
789 SAL_CALL_REENTRANT(rv, SN_SAL_IROUTER_OP, SAL_IROUTER_CLOSE,
790 (u64) nasid, (u64) subch, 0, 0, 0, 0);
791 return (int) rv.status;
795 * Read data from system controller associated with 'nasid' on
796 * subchannel 'subch'. The buffer to be filled is pointed to by
797 * 'buf', and its capacity is in the integer pointed to by 'len'. The
798 * referent of 'len' is set to the number of bytes read by the SAL
799 * call. The return value is either SALRET_OK (for bytes read) or
800 * SALRET_ERROR (for error or "no data available").
803 ia64_sn_irtr_recv(nasid_t nasid, int subch, char *buf, int *len)
805 struct ia64_sal_retval rv;
806 SAL_CALL_REENTRANT(rv, SN_SAL_IROUTER_OP, SAL_IROUTER_RECV,
807 (u64) nasid, (u64) subch, (u64) buf, (u64) len,
809 return (int) rv.status;
813 * Write data to the system controller network via the system
814 * controller associated with 'nasid' on suchannel 'subch'. The
815 * buffer to be written out is pointed to by 'buf', and 'len' is the
816 * number of bytes to be written. The return value is either the
817 * number of bytes written (which could be zero) or a negative error
821 ia64_sn_irtr_send(nasid_t nasid, int subch, char *buf, int len)
823 struct ia64_sal_retval rv;
824 SAL_CALL_REENTRANT(rv, SN_SAL_IROUTER_OP, SAL_IROUTER_SEND,
825 (u64) nasid, (u64) subch, (u64) buf, (u64) len,
831 * Check whether any interrupts are pending for the system controller
832 * associated with 'nasid' and its subchannel 'subch'. The return
833 * value is a mask of pending interrupts (SAL_IROUTER_INTR_XMIT and/or
834 * SAL_IROUTER_INTR_RECV).
837 ia64_sn_irtr_intr(nasid_t nasid, int subch)
839 struct ia64_sal_retval rv;
840 SAL_CALL_REENTRANT(rv, SN_SAL_IROUTER_OP, SAL_IROUTER_INTR_STATUS,
841 (u64) nasid, (u64) subch, 0, 0, 0, 0);
846 * Enable the interrupt indicated by the intr parameter (either
847 * SAL_IROUTER_INTR_XMIT or SAL_IROUTER_INTR_RECV).
850 ia64_sn_irtr_intr_enable(nasid_t nasid, int subch, u64 intr)
852 struct ia64_sal_retval rv;
853 SAL_CALL_REENTRANT(rv, SN_SAL_IROUTER_OP, SAL_IROUTER_INTR_ON,
854 (u64) nasid, (u64) subch, intr, 0, 0, 0);
859 * Disable the interrupt indicated by the intr parameter (either
860 * SAL_IROUTER_INTR_XMIT or SAL_IROUTER_INTR_RECV).
863 ia64_sn_irtr_intr_disable(nasid_t nasid, int subch, u64 intr)
865 struct ia64_sal_retval rv;
866 SAL_CALL_REENTRANT(rv, SN_SAL_IROUTER_OP, SAL_IROUTER_INTR_OFF,
867 (u64) nasid, (u64) subch, intr, 0, 0, 0);
872 * Set up a node as the point of contact for system controller
873 * environmental event delivery.
876 ia64_sn_sysctl_event_init(nasid_t nasid)
878 struct ia64_sal_retval rv;
879 SAL_CALL_REENTRANT(rv, SN_SAL_SYSCTL_EVENT, (u64) nasid,
885 * Ask the system controller on the specified nasid to reset
886 * the CX corelet clock. Only valid on TIO nodes.
889 ia64_sn_sysctl_tio_clock_reset(nasid_t nasid)
891 struct ia64_sal_retval rv;
892 SAL_CALL_REENTRANT(rv, SN_SAL_SYSCTL_OP, SAL_SYSCTL_OP_TIO_JLCK_RST,
893 nasid, 0, 0, 0, 0, 0);
895 return (int)rv.status;
903 * Get the associated ioboard type for a given nasid.
906 ia64_sn_sysctl_ioboard_get(nasid_t nasid)
908 struct ia64_sal_retval rv;
909 SAL_CALL_REENTRANT(rv, SN_SAL_SYSCTL_OP, SAL_SYSCTL_OP_IOBOARD,
910 nasid, 0, 0, 0, 0, 0);
920 * ia64_sn_get_fit_compt - read a FIT entry from the PROM header
921 * @nasid: NASID of node to read
922 * @index: FIT entry index to be retrieved (0..n)
923 * @fitentry: 16 byte buffer where FIT entry will be stored.
924 * @banbuf: optional buffer for retrieving banner
925 * @banlen: length of banner buffer
927 * Access to the physical PROM chips needs to be serialized since reads and
928 * writes can't occur at the same time, so we need to call into the SAL when
929 * we want to look at the FIT entries on the chips.
933 * %SALRET_INVALID_ARG if index too big
934 * %SALRET_NOT_IMPLEMENTED if running on older PROM
935 * ??? if nasid invalid OR banner buffer not large enough
938 ia64_sn_get_fit_compt(u64 nasid, u64 index, void *fitentry, void *banbuf,
941 struct ia64_sal_retval rv;
942 SAL_CALL_NOLOCK(rv, SN_SAL_GET_FIT_COMPT, nasid, index, fitentry,
943 banbuf, banlen, 0, 0);
944 return (int) rv.status;
948 * Initialize the SAL components of the system controller
949 * communication driver; specifically pass in a sizable buffer that
950 * can be used for allocation of subchannel queues as new subchannels
951 * are opened. "buf" points to the buffer, and "len" specifies its
955 ia64_sn_irtr_init(nasid_t nasid, void *buf, int len)
957 struct ia64_sal_retval rv;
958 SAL_CALL_REENTRANT(rv, SN_SAL_IROUTER_OP, SAL_IROUTER_INIT,
959 (u64) nasid, (u64) buf, (u64) len, 0, 0, 0);
960 return (int) rv.status;
964 * Returns the nasid, subnode & slice corresponding to a SAPIC ID
967 * arg0 - SN_SAL_GET_SAPIC_INFO
968 * arg1 - sapicid (lid >> 16)
975 ia64_sn_get_sapic_info(int sapicid, int *nasid, int *subnode, int *slice)
977 struct ia64_sal_retval ret_stuff;
979 ret_stuff.status = 0;
983 SAL_CALL_NOLOCK(ret_stuff, SN_SAL_GET_SAPIC_INFO, sapicid, 0, 0, 0, 0, 0, 0);
985 /***** BEGIN HACK - temp til old proms no longer supported ********/
986 if (ret_stuff.status == SALRET_NOT_IMPLEMENTED) {
987 if (nasid) *nasid = sapicid & 0xfff;
988 if (subnode) *subnode = (sapicid >> 13) & 1;
989 if (slice) *slice = (sapicid >> 12) & 3;
992 /***** END HACK *******/
994 if (ret_stuff.status < 0)
995 return ret_stuff.status;
997 if (nasid) *nasid = (int) ret_stuff.v0;
998 if (subnode) *subnode = (int) ret_stuff.v1;
999 if (slice) *slice = (int) ret_stuff.v2;
1004 * Returns information about the HUB/SHUB.
1006 * arg0 - SN_SAL_GET_SN_INFO
1007 * arg1 - 0 (other values reserved for future use)
1010 * [7:0] - shub type (0=shub1, 1=shub2)
1011 * [15:8] - Log2 max number of nodes in entire system (includes
1012 * C-bricks, I-bricks, etc)
1013 * [23:16] - Log2 of nodes per sharing domain
1014 * [31:24] - partition ID
1015 * [39:32] - coherency_id
1016 * [47:40] - regionsize
1018 * [15:0] - nasid mask (ex., 0x7ff for 11 bit nasid)
1019 * [23:15] - bit position of low nasid bit
1022 ia64_sn_get_sn_info(int fc, u8 *shubtype, u16 *nasid_bitmask, u8 *nasid_shift,
1023 u8 *systemsize, u8 *sharing_domain_size, u8 *partid, u8 *coher, u8 *reg)
1025 struct ia64_sal_retval ret_stuff;
1027 ret_stuff.status = 0;
1031 SAL_CALL_NOLOCK(ret_stuff, SN_SAL_GET_SN_INFO, fc, 0, 0, 0, 0, 0, 0);
1033 if (ret_stuff.status < 0)
1034 return ret_stuff.status;
1036 if (shubtype) *shubtype = ret_stuff.v0 & 0xff;
1037 if (systemsize) *systemsize = (ret_stuff.v0 >> 8) & 0xff;
1038 if (sharing_domain_size) *sharing_domain_size = (ret_stuff.v0 >> 16) & 0xff;
1039 if (partid) *partid = (ret_stuff.v0 >> 24) & 0xff;
1040 if (coher) *coher = (ret_stuff.v0 >> 32) & 0xff;
1041 if (reg) *reg = (ret_stuff.v0 >> 40) & 0xff;
1042 if (nasid_bitmask) *nasid_bitmask = (ret_stuff.v1 & 0xffff);
1043 if (nasid_shift) *nasid_shift = (ret_stuff.v1 >> 16) & 0xff;
1048 * This is the access point to the Altix PROM hardware performance
1049 * and status monitoring interface. For info on using this, see
1050 * include/asm-ia64/sn/sn2/sn_hwperf.h
1053 ia64_sn_hwperf_op(nasid_t nasid, u64 opcode, u64 a0, u64 a1, u64 a2,
1054 u64 a3, u64 a4, int *v0)
1056 struct ia64_sal_retval rv;
1057 SAL_CALL_NOLOCK(rv, SN_SAL_HWPERF_OP, (u64)nasid,
1058 opcode, a0, a1, a2, a3, a4);
1061 return (int) rv.status;
1065 ia64_sn_ioif_get_pci_topology(u64 buf, u64 len)
1067 struct ia64_sal_retval rv;
1068 SAL_CALL_NOLOCK(rv, SN_SAL_IOIF_GET_PCI_TOPOLOGY, buf, len, 0, 0, 0, 0, 0);
1069 return (int) rv.status;
1073 * BTE error recovery is implemented in SAL
1076 ia64_sn_bte_recovery(nasid_t nasid)
1078 struct ia64_sal_retval rv;
1081 SAL_CALL_NOLOCK(rv, SN_SAL_BTE_RECOVER, 0, 0, 0, 0, 0, 0, 0);
1082 if (rv.status == SALRET_NOT_IMPLEMENTED)
1084 return (int) rv.status;
1088 ia64_sn_is_fake_prom(void)
1090 struct ia64_sal_retval rv;
1091 SAL_CALL_NOLOCK(rv, SN_SAL_FAKE_PROM, 0, 0, 0, 0, 0, 0, 0);
1092 return (rv.status == 0);
1096 ia64_sn_get_prom_feature_set(int set, unsigned long *feature_set)
1098 struct ia64_sal_retval rv;
1100 SAL_CALL_NOLOCK(rv, SN_SAL_GET_PROM_FEATURE_SET, set, 0, 0, 0, 0, 0, 0);
1103 *feature_set = rv.v0;
1108 ia64_sn_set_os_feature(int feature)
1110 struct ia64_sal_retval rv;
1112 SAL_CALL_NOLOCK(rv, SN_SAL_SET_OS_FEATURE_SET, feature, 0, 0, 0, 0, 0, 0);
1116 #endif /* _ASM_IA64_SN_SN_SAL_H */