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_MODID_GET 0x02000031
51 #define SN_SAL_SYSCTL_GET 0x02000032
52 #define SN_SAL_SYSCTL_IOBRICK_MODULE_GET 0x02000033
53 #define SN_SAL_SYSCTL_IO_PORTSPEED_GET 0x02000035
54 #define SN_SAL_SYSCTL_SLAB_GET 0x02000036
55 #define SN_SAL_BUS_CONFIG 0x02000037
56 #define SN_SAL_SYS_SERIAL_GET 0x02000038
57 #define SN_SAL_PARTITION_SERIAL_GET 0x02000039
58 #define SN_SAL_SYSCTL_PARTITION_GET 0x0200003a
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_IOIF_GET_PCI_TOPOLOGY 0x02000062
84 * Service-specific constants
87 /* Console interrupt manipulation */
89 #define SAL_CONSOLE_INTR_OFF 0 /* turn the interrupt off */
90 #define SAL_CONSOLE_INTR_ON 1 /* turn the interrupt on */
91 #define SAL_CONSOLE_INTR_STATUS 2 /* retrieve the interrupt status */
92 /* interrupt specification & status return codes */
93 #define SAL_CONSOLE_INTR_XMIT 1 /* output interrupt */
94 #define SAL_CONSOLE_INTR_RECV 2 /* input interrupt */
96 /* interrupt handling */
97 #define SAL_INTR_ALLOC 1
98 #define SAL_INTR_FREE 2
101 * IRouter (i.e. generalized system controller) operations
103 #define SAL_IROUTER_OPEN 0 /* open a subchannel */
104 #define SAL_IROUTER_CLOSE 1 /* close a subchannel */
105 #define SAL_IROUTER_SEND 2 /* send part of an IRouter packet */
106 #define SAL_IROUTER_RECV 3 /* receive part of an IRouter packet */
107 #define SAL_IROUTER_INTR_STATUS 4 /* check the interrupt status for
110 #define SAL_IROUTER_INTR_ON 5 /* enable an interrupt */
111 #define SAL_IROUTER_INTR_OFF 6 /* disable an interrupt */
112 #define SAL_IROUTER_INIT 7 /* initialize IRouter driver */
114 /* IRouter interrupt mask bits */
115 #define SAL_IROUTER_INTR_XMIT SAL_CONSOLE_INTR_XMIT
116 #define SAL_IROUTER_INTR_RECV SAL_CONSOLE_INTR_RECV
119 * Error Handling Features
121 #define SAL_ERR_FEAT_MCA_SLV_TO_OS_INIT_SLV 0x1
122 #define SAL_ERR_FEAT_LOG_SBES 0x2
123 #define SAL_ERR_FEAT_MFR_OVERRIDE 0x4
124 #define SAL_ERR_FEAT_SBE_THRESHOLD 0xffff0000
129 #define SALRET_MORE_PASSES 1
131 #define SALRET_NOT_IMPLEMENTED (-1)
132 #define SALRET_INVALID_ARG (-2)
133 #define SALRET_ERROR (-3)
137 * sn_sal_rev_major - get the major SGI SAL revision number
139 * The SGI PROM stores its version in sal_[ab]_rev_(major|minor).
140 * This routine simply extracts the major value from the
141 * @ia64_sal_systab structure constructed by ia64_sal_init().
144 sn_sal_rev_major(void)
146 struct ia64_sal_systab
*systab
= efi
.sal_systab
;
148 return (int)systab
->sal_b_rev_major
;
152 * sn_sal_rev_minor - get the minor SGI SAL revision number
154 * The SGI PROM stores its version in sal_[ab]_rev_(major|minor).
155 * This routine simply extracts the minor value from the
156 * @ia64_sal_systab structure constructed by ia64_sal_init().
159 sn_sal_rev_minor(void)
161 struct ia64_sal_systab
*systab
= efi
.sal_systab
;
163 return (int)systab
->sal_b_rev_minor
;
167 * Specify the minimum PROM revsion required for this kernel.
168 * Note that they're stored in hex format...
170 #define SN_SAL_MIN_MAJOR 0x4 /* SN2 kernels need at least PROM 4.0 */
171 #define SN_SAL_MIN_MINOR 0x0
174 * Returns the master console nasid, if the call fails, return an illegal
178 ia64_sn_get_console_nasid(void)
180 struct ia64_sal_retval ret_stuff
;
182 ret_stuff
.status
= 0;
186 SAL_CALL(ret_stuff
, SN_SAL_GET_MASTER_NASID
, 0, 0, 0, 0, 0, 0, 0);
188 if (ret_stuff
.status
< 0)
189 return ret_stuff
.status
;
191 /* Master console nasid is in 'v0' */
196 * Returns the master baseio nasid, if the call fails, return an illegal
200 ia64_sn_get_master_baseio_nasid(void)
202 struct ia64_sal_retval ret_stuff
;
204 ret_stuff
.status
= 0;
208 SAL_CALL(ret_stuff
, SN_SAL_GET_MASTER_BASEIO_NASID
, 0, 0, 0, 0, 0, 0, 0);
210 if (ret_stuff
.status
< 0)
211 return ret_stuff
.status
;
213 /* Master baseio nasid is in 'v0' */
218 ia64_sn_get_klconfig_addr(nasid_t nasid
)
220 struct ia64_sal_retval ret_stuff
;
223 cnodeid
= nasid_to_cnodeid(nasid
);
224 ret_stuff
.status
= 0;
228 SAL_CALL(ret_stuff
, SN_SAL_GET_KLCONFIG_ADDR
, (u64
)nasid
, 0, 0, 0, 0, 0, 0);
231 * We should panic if a valid cnode nasid does not produce
232 * a klconfig address.
234 if (ret_stuff
.status
!= 0) {
235 panic("ia64_sn_get_klconfig_addr: Returned error %lx\n", ret_stuff
.status
);
237 return ret_stuff
.v0
? __va(ret_stuff
.v0
) : NULL
;
241 * Returns the next console character.
244 ia64_sn_console_getc(int *ch
)
246 struct ia64_sal_retval ret_stuff
;
248 ret_stuff
.status
= 0;
252 SAL_CALL_NOLOCK(ret_stuff
, SN_SAL_CONSOLE_GETC
, 0, 0, 0, 0, 0, 0, 0);
254 /* character is in 'v0' */
255 *ch
= (int)ret_stuff
.v0
;
257 return ret_stuff
.status
;
261 * Read a character from the SAL console device, after a previous interrupt
262 * or poll operation has given us to know that a character is available
266 ia64_sn_console_readc(void)
268 struct ia64_sal_retval ret_stuff
;
270 ret_stuff
.status
= 0;
274 SAL_CALL_NOLOCK(ret_stuff
, SN_SAL_CONSOLE_READC
, 0, 0, 0, 0, 0, 0, 0);
276 /* character is in 'v0' */
281 * Sends the given character to the console.
284 ia64_sn_console_putc(char ch
)
286 struct ia64_sal_retval ret_stuff
;
288 ret_stuff
.status
= 0;
292 SAL_CALL_NOLOCK(ret_stuff
, SN_SAL_CONSOLE_PUTC
, (uint64_t)ch
, 0, 0, 0, 0, 0, 0);
294 return ret_stuff
.status
;
298 * Sends the given buffer to the console.
301 ia64_sn_console_putb(const char *buf
, int len
)
303 struct ia64_sal_retval ret_stuff
;
305 ret_stuff
.status
= 0;
309 SAL_CALL_NOLOCK(ret_stuff
, SN_SAL_CONSOLE_PUTB
, (uint64_t)buf
, (uint64_t)len
, 0, 0, 0, 0, 0);
311 if ( ret_stuff
.status
== 0 ) {
318 * Print a platform error record
321 ia64_sn_plat_specific_err_print(int (*hook
)(const char*, ...), char *rec
)
323 struct ia64_sal_retval ret_stuff
;
325 ret_stuff
.status
= 0;
329 SAL_CALL_REENTRANT(ret_stuff
, SN_SAL_PRINT_ERROR
, (uint64_t)hook
, (uint64_t)rec
, 0, 0, 0, 0, 0);
331 return ret_stuff
.status
;
335 * Check for Platform errors
338 ia64_sn_plat_cpei_handler(void)
340 struct ia64_sal_retval ret_stuff
;
342 ret_stuff
.status
= 0;
346 SAL_CALL_NOLOCK(ret_stuff
, SN_SAL_LOG_CE
, 0, 0, 0, 0, 0, 0, 0);
348 return ret_stuff
.status
;
352 * Set Error Handling Features
355 ia64_sn_plat_set_error_handling_features(void)
357 struct ia64_sal_retval ret_stuff
;
359 ret_stuff
.status
= 0;
363 SAL_CALL_REENTRANT(ret_stuff
, SN_SAL_SET_ERROR_HANDLING_FEATURES
,
364 (SAL_ERR_FEAT_MCA_SLV_TO_OS_INIT_SLV
| SAL_ERR_FEAT_LOG_SBES
),
367 return ret_stuff
.status
;
371 * Checks for console input.
374 ia64_sn_console_check(int *result
)
376 struct ia64_sal_retval ret_stuff
;
378 ret_stuff
.status
= 0;
382 SAL_CALL_NOLOCK(ret_stuff
, SN_SAL_CONSOLE_POLL
, 0, 0, 0, 0, 0, 0, 0);
384 /* result is in 'v0' */
385 *result
= (int)ret_stuff
.v0
;
387 return ret_stuff
.status
;
391 * Checks console interrupt status
394 ia64_sn_console_intr_status(void)
396 struct ia64_sal_retval ret_stuff
;
398 ret_stuff
.status
= 0;
402 SAL_CALL_NOLOCK(ret_stuff
, SN_SAL_CONSOLE_INTR
,
403 0, SAL_CONSOLE_INTR_STATUS
,
406 if (ret_stuff
.status
== 0) {
414 * Enable an interrupt on the SAL console device.
417 ia64_sn_console_intr_enable(uint64_t intr
)
419 struct ia64_sal_retval ret_stuff
;
421 ret_stuff
.status
= 0;
425 SAL_CALL_NOLOCK(ret_stuff
, SN_SAL_CONSOLE_INTR
,
426 intr
, SAL_CONSOLE_INTR_ON
,
431 * Disable an interrupt on the SAL console device.
434 ia64_sn_console_intr_disable(uint64_t intr
)
436 struct ia64_sal_retval ret_stuff
;
438 ret_stuff
.status
= 0;
442 SAL_CALL_NOLOCK(ret_stuff
, SN_SAL_CONSOLE_INTR
,
443 intr
, SAL_CONSOLE_INTR_OFF
,
448 * Sends a character buffer to the console asynchronously.
451 ia64_sn_console_xmit_chars(char *buf
, int len
)
453 struct ia64_sal_retval ret_stuff
;
455 ret_stuff
.status
= 0;
459 SAL_CALL_NOLOCK(ret_stuff
, SN_SAL_CONSOLE_XMIT_CHARS
,
460 (uint64_t)buf
, (uint64_t)len
,
463 if (ret_stuff
.status
== 0) {
471 * Returns the iobrick module Id
474 ia64_sn_sysctl_iobrick_module_get(nasid_t nasid
, int *result
)
476 struct ia64_sal_retval ret_stuff
;
478 ret_stuff
.status
= 0;
482 SAL_CALL_NOLOCK(ret_stuff
, SN_SAL_SYSCTL_IOBRICK_MODULE_GET
, nasid
, 0, 0, 0, 0, 0, 0);
484 /* result is in 'v0' */
485 *result
= (int)ret_stuff
.v0
;
487 return ret_stuff
.status
;
491 * ia64_sn_pod_mode - call the SN_SAL_POD_MODE function
493 * SN_SAL_POD_MODE actually takes an argument, but it's always
494 * 0 when we call it from the kernel, so we don't have to expose
498 ia64_sn_pod_mode(void)
500 struct ia64_sal_retval isrv
;
501 SAL_CALL_REENTRANT(isrv
, SN_SAL_POD_MODE
, 0, 0, 0, 0, 0, 0, 0);
508 * ia64_sn_probe_mem - read from memory safely
509 * @addr: address to probe
510 * @size: number bytes to read (1,2,4,8)
511 * @data_ptr: address to store value read by probe (-1 returned if probe fails)
513 * Call into the SAL to do a memory read. If the read generates a machine
514 * check, this routine will recover gracefully and return -1 to the caller.
515 * @addr is usually a kernel virtual address in uncached space (i.e. the
516 * address starts with 0xc), but if called in physical mode, @addr should
517 * be a physical address.
520 * 0 - probe successful
521 * 1 - probe failed (generated MCA)
526 ia64_sn_probe_mem(long addr
, long size
, void *data_ptr
)
528 struct ia64_sal_retval isrv
;
530 SAL_CALL(isrv
, SN_SAL_PROBE
, addr
, size
, 0, 0, 0, 0, 0);
535 *((u8
*)data_ptr
) = (u8
)isrv
.v0
;
538 *((u16
*)data_ptr
) = (u16
)isrv
.v0
;
541 *((u32
*)data_ptr
) = (u32
)isrv
.v0
;
544 *((u64
*)data_ptr
) = (u64
)isrv
.v0
;
554 * Retrieve the system serial number as an ASCII string.
557 ia64_sn_sys_serial_get(char *buf
)
559 struct ia64_sal_retval ret_stuff
;
560 SAL_CALL_NOLOCK(ret_stuff
, SN_SAL_SYS_SERIAL_GET
, buf
, 0, 0, 0, 0, 0, 0);
561 return ret_stuff
.status
;
564 extern char sn_system_serial_number_string
[];
565 extern u64 sn_partition_serial_number
;
568 sn_system_serial_number(void) {
569 if (sn_system_serial_number_string
[0]) {
570 return(sn_system_serial_number_string
);
572 ia64_sn_sys_serial_get(sn_system_serial_number_string
);
573 return(sn_system_serial_number_string
);
579 * Returns a unique id number for this system and partition (suitable for
580 * use with license managers), based in part on the system serial number.
583 ia64_sn_partition_serial_get(void)
585 struct ia64_sal_retval ret_stuff
;
586 ia64_sal_oemcall_reentrant(&ret_stuff
, SN_SAL_PARTITION_SERIAL_GET
, 0,
588 if (ret_stuff
.status
!= 0)
594 sn_partition_serial_number_val(void) {
595 if (unlikely(sn_partition_serial_number
== 0)) {
596 sn_partition_serial_number
= ia64_sn_partition_serial_get();
598 return sn_partition_serial_number
;
602 * Returns the partition id of the nasid passed in as an argument,
603 * or INVALID_PARTID if the partition id cannot be retrieved.
605 static inline partid_t
606 ia64_sn_sysctl_partition_get(nasid_t nasid
)
608 struct ia64_sal_retval ret_stuff
;
609 ia64_sal_oemcall_nolock(&ret_stuff
, SN_SAL_SYSCTL_PARTITION_GET
, nasid
,
611 if (ret_stuff
.status
!= 0)
612 return INVALID_PARTID
;
613 return ((partid_t
)ret_stuff
.v0
);
617 * Returns the partition id of the current processor.
620 extern partid_t sn_partid
;
622 static inline partid_t
623 sn_local_partid(void) {
624 if (unlikely(sn_partid
< 0)) {
625 sn_partid
= ia64_sn_sysctl_partition_get(cpuid_to_nasid(smp_processor_id()));
631 * Returns the physical address of the partition's reserved page through
632 * an iterative number of calls.
634 * On first call, 'cookie' and 'len' should be set to 0, and 'addr'
635 * set to the nasid of the partition whose reserved page's address is
637 * On subsequent calls, pass the values, that were passed back on the
640 * While the return status equals SALRET_MORE_PASSES, keep calling
641 * this function after first copying 'len' bytes starting at 'addr'
642 * into 'buf'. Once the return status equals SALRET_OK, 'addr' will
643 * be the physical address of the partition's reserved page. If the
644 * return status equals neither of these, an error as occurred.
647 sn_partition_reserved_page_pa(u64 buf
, u64
*cookie
, u64
*addr
, u64
*len
)
649 struct ia64_sal_retval rv
;
650 ia64_sal_oemcall_reentrant(&rv
, SN_SAL_GET_PARTITION_ADDR
, *cookie
,
651 *addr
, buf
, *len
, 0, 0, 0);
659 * Register or unregister a physical address range being referenced across
660 * a partition boundary for which certain SAL errors should be scanned for,
661 * cleaned up and ignored. This is of value for kernel partitioning code only.
662 * Values for the operation argument:
663 * 1 = register this address range with SAL
664 * 0 = unregister this address range with SAL
666 * SAL maintains a reference count on an address range in case it is registered
669 * On success, returns the reference count of the address range after the SAL
670 * call has performed the current registration/unregistration. Returns a
671 * negative value if an error occurred.
674 sn_register_xp_addr_region(u64 paddr
, u64 len
, int operation
)
676 struct ia64_sal_retval ret_stuff
;
677 ia64_sal_oemcall(&ret_stuff
, SN_SAL_XP_ADDR_REGION
, paddr
, len
,
678 (u64
)operation
, 0, 0, 0, 0);
679 return ret_stuff
.status
;
683 * Register or unregister an instruction range for which SAL errors should
684 * be ignored. If an error occurs while in the registered range, SAL jumps
685 * to return_addr after ignoring the error. Values for the operation argument:
686 * 1 = register this instruction range with SAL
687 * 0 = unregister this instruction range with SAL
689 * Returns 0 on success, or a negative value if an error occurred.
692 sn_register_nofault_code(u64 start_addr
, u64 end_addr
, u64 return_addr
,
693 int virtual, int operation
)
695 struct ia64_sal_retval ret_stuff
;
698 call
= SN_SAL_NO_FAULT_ZONE_VIRTUAL
;
700 call
= SN_SAL_NO_FAULT_ZONE_PHYSICAL
;
702 ia64_sal_oemcall(&ret_stuff
, call
, start_addr
, end_addr
, return_addr
,
704 return ret_stuff
.status
;
708 * Change or query the coherence domain for this partition. Each cpu-based
709 * nasid is represented by a bit in an array of 64-bit words:
710 * 0 = not in this partition's coherency domain
711 * 1 = in this partition's coherency domain
713 * It is not possible for the local system's nasids to be removed from
714 * the coherency domain. Purpose of the domain arguments:
715 * new_domain = set the coherence domain to the given nasids
716 * old_domain = return the current coherence domain
718 * Returns 0 on success, or a negative value if an error occurred.
721 sn_change_coherence(u64
*new_domain
, u64
*old_domain
)
723 struct ia64_sal_retval ret_stuff
;
724 ia64_sal_oemcall(&ret_stuff
, SN_SAL_COHERENCE
, (u64
)new_domain
,
725 (u64
)old_domain
, 0, 0, 0, 0, 0);
726 return ret_stuff
.status
;
730 * Change memory access protections for a physical address range.
731 * nasid_array is not used on Altix, but may be in future architectures.
732 * Available memory protection access classes are defined after the function.
735 sn_change_memprotect(u64 paddr
, u64 len
, u64 perms
, u64
*nasid_array
)
737 struct ia64_sal_retval ret_stuff
;
739 unsigned long irq_flags
;
741 cnodeid
= nasid_to_cnodeid(get_node_number(paddr
));
742 // spin_lock(&NODEPDA(cnodeid)->bist_lock);
743 local_irq_save(irq_flags
);
744 ia64_sal_oemcall_nolock(&ret_stuff
, SN_SAL_MEMPROTECT
, paddr
, len
,
745 (u64
)nasid_array
, perms
, 0, 0, 0);
746 local_irq_restore(irq_flags
);
747 // spin_unlock(&NODEPDA(cnodeid)->bist_lock);
748 return ret_stuff
.status
;
750 #define SN_MEMPROT_ACCESS_CLASS_0 0x14a080
751 #define SN_MEMPROT_ACCESS_CLASS_1 0x2520c2
752 #define SN_MEMPROT_ACCESS_CLASS_2 0x14a1ca
753 #define SN_MEMPROT_ACCESS_CLASS_3 0x14a290
754 #define SN_MEMPROT_ACCESS_CLASS_6 0x084080
755 #define SN_MEMPROT_ACCESS_CLASS_7 0x021080
758 * Turns off system power.
761 ia64_sn_power_down(void)
763 struct ia64_sal_retval ret_stuff
;
764 SAL_CALL(ret_stuff
, SN_SAL_SYSTEM_POWER_DOWN
, 0, 0, 0, 0, 0, 0, 0);
770 * ia64_sn_fru_capture - tell the system controller to capture hw state
772 * This routine will call the SAL which will tell the system controller(s)
773 * to capture hw mmr information from each SHub in the system.
776 ia64_sn_fru_capture(void)
778 struct ia64_sal_retval isrv
;
779 SAL_CALL(isrv
, SN_SAL_SYSCTL_FRU_CAPTURE
, 0, 0, 0, 0, 0, 0, 0);
786 * Performs an operation on a PCI bus or slot -- power up, power down
790 ia64_sn_sysctl_iobrick_pci_op(nasid_t n
, u64 connection_type
,
794 struct ia64_sal_retval rv
= {0, 0, 0, 0};
796 SAL_CALL_NOLOCK(rv
, SN_SAL_SYSCTL_IOBRICK_PCI_OP
, connection_type
, n
, action
,
797 bus
, (u64
) slot
, 0, 0);
805 * Open a subchannel for sending arbitrary data to the system
806 * controller network via the system controller device associated with
807 * 'nasid'. Return the subchannel number or a negative error code.
810 ia64_sn_irtr_open(nasid_t nasid
)
812 struct ia64_sal_retval rv
;
813 SAL_CALL_REENTRANT(rv
, SN_SAL_IROUTER_OP
, SAL_IROUTER_OPEN
, nasid
,
819 * Close system controller subchannel 'subch' previously opened on 'nasid'.
822 ia64_sn_irtr_close(nasid_t nasid
, int subch
)
824 struct ia64_sal_retval rv
;
825 SAL_CALL_REENTRANT(rv
, SN_SAL_IROUTER_OP
, SAL_IROUTER_CLOSE
,
826 (u64
) nasid
, (u64
) subch
, 0, 0, 0, 0);
827 return (int) rv
.status
;
831 * Read data from system controller associated with 'nasid' on
832 * subchannel 'subch'. The buffer to be filled is pointed to by
833 * 'buf', and its capacity is in the integer pointed to by 'len'. The
834 * referent of 'len' is set to the number of bytes read by the SAL
835 * call. The return value is either SALRET_OK (for bytes read) or
836 * SALRET_ERROR (for error or "no data available").
839 ia64_sn_irtr_recv(nasid_t nasid
, int subch
, char *buf
, int *len
)
841 struct ia64_sal_retval rv
;
842 SAL_CALL_REENTRANT(rv
, SN_SAL_IROUTER_OP
, SAL_IROUTER_RECV
,
843 (u64
) nasid
, (u64
) subch
, (u64
) buf
, (u64
) len
,
845 return (int) rv
.status
;
849 * Write data to the system controller network via the system
850 * controller associated with 'nasid' on suchannel 'subch'. The
851 * buffer to be written out is pointed to by 'buf', and 'len' is the
852 * number of bytes to be written. The return value is either the
853 * number of bytes written (which could be zero) or a negative error
857 ia64_sn_irtr_send(nasid_t nasid
, int subch
, char *buf
, int len
)
859 struct ia64_sal_retval rv
;
860 SAL_CALL_REENTRANT(rv
, SN_SAL_IROUTER_OP
, SAL_IROUTER_SEND
,
861 (u64
) nasid
, (u64
) subch
, (u64
) buf
, (u64
) len
,
867 * Check whether any interrupts are pending for the system controller
868 * associated with 'nasid' and its subchannel 'subch'. The return
869 * value is a mask of pending interrupts (SAL_IROUTER_INTR_XMIT and/or
870 * SAL_IROUTER_INTR_RECV).
873 ia64_sn_irtr_intr(nasid_t nasid
, int subch
)
875 struct ia64_sal_retval rv
;
876 SAL_CALL_REENTRANT(rv
, SN_SAL_IROUTER_OP
, SAL_IROUTER_INTR_STATUS
,
877 (u64
) nasid
, (u64
) subch
, 0, 0, 0, 0);
882 * Enable the interrupt indicated by the intr parameter (either
883 * SAL_IROUTER_INTR_XMIT or SAL_IROUTER_INTR_RECV).
886 ia64_sn_irtr_intr_enable(nasid_t nasid
, int subch
, u64 intr
)
888 struct ia64_sal_retval rv
;
889 SAL_CALL_REENTRANT(rv
, SN_SAL_IROUTER_OP
, SAL_IROUTER_INTR_ON
,
890 (u64
) nasid
, (u64
) subch
, intr
, 0, 0, 0);
895 * Disable the interrupt indicated by the intr parameter (either
896 * SAL_IROUTER_INTR_XMIT or SAL_IROUTER_INTR_RECV).
899 ia64_sn_irtr_intr_disable(nasid_t nasid
, int subch
, u64 intr
)
901 struct ia64_sal_retval rv
;
902 SAL_CALL_REENTRANT(rv
, SN_SAL_IROUTER_OP
, SAL_IROUTER_INTR_OFF
,
903 (u64
) nasid
, (u64
) subch
, intr
, 0, 0, 0);
908 * Set up a node as the point of contact for system controller
909 * environmental event delivery.
912 ia64_sn_sysctl_event_init(nasid_t nasid
)
914 struct ia64_sal_retval rv
;
915 SAL_CALL_REENTRANT(rv
, SN_SAL_SYSCTL_EVENT
, (u64
) nasid
,
921 * ia64_sn_get_fit_compt - read a FIT entry from the PROM header
922 * @nasid: NASID of node to read
923 * @index: FIT entry index to be retrieved (0..n)
924 * @fitentry: 16 byte buffer where FIT entry will be stored.
925 * @banbuf: optional buffer for retrieving banner
926 * @banlen: length of banner buffer
928 * Access to the physical PROM chips needs to be serialized since reads and
929 * writes can't occur at the same time, so we need to call into the SAL when
930 * we want to look at the FIT entries on the chips.
934 * %SALRET_INVALID_ARG if index too big
935 * %SALRET_NOT_IMPLEMENTED if running on older PROM
936 * ??? if nasid invalid OR banner buffer not large enough
939 ia64_sn_get_fit_compt(u64 nasid
, u64 index
, void *fitentry
, void *banbuf
,
942 struct ia64_sal_retval rv
;
943 SAL_CALL_NOLOCK(rv
, SN_SAL_GET_FIT_COMPT
, nasid
, index
, fitentry
,
944 banbuf
, banlen
, 0, 0);
945 return (int) rv
.status
;
949 * Initialize the SAL components of the system controller
950 * communication driver; specifically pass in a sizable buffer that
951 * can be used for allocation of subchannel queues as new subchannels
952 * are opened. "buf" points to the buffer, and "len" specifies its
956 ia64_sn_irtr_init(nasid_t nasid
, void *buf
, int len
)
958 struct ia64_sal_retval rv
;
959 SAL_CALL_REENTRANT(rv
, SN_SAL_IROUTER_OP
, SAL_IROUTER_INIT
,
960 (u64
) nasid
, (u64
) buf
, (u64
) len
, 0, 0, 0);
961 return (int) rv
.status
;
965 * Returns the nasid, subnode & slice corresponding to a SAPIC ID
968 * arg0 - SN_SAL_GET_SAPIC_INFO
969 * arg1 - sapicid (lid >> 16)
976 ia64_sn_get_sapic_info(int sapicid
, int *nasid
, int *subnode
, int *slice
)
978 struct ia64_sal_retval ret_stuff
;
980 ret_stuff
.status
= 0;
984 SAL_CALL_NOLOCK(ret_stuff
, SN_SAL_GET_SAPIC_INFO
, sapicid
, 0, 0, 0, 0, 0, 0);
986 /***** BEGIN HACK - temp til old proms no longer supported ********/
987 if (ret_stuff
.status
== SALRET_NOT_IMPLEMENTED
) {
988 if (nasid
) *nasid
= sapicid
& 0xfff;
989 if (subnode
) *subnode
= (sapicid
>> 13) & 1;
990 if (slice
) *slice
= (sapicid
>> 12) & 3;
993 /***** END HACK *******/
995 if (ret_stuff
.status
< 0)
996 return ret_stuff
.status
;
998 if (nasid
) *nasid
= (int) ret_stuff
.v0
;
999 if (subnode
) *subnode
= (int) ret_stuff
.v1
;
1000 if (slice
) *slice
= (int) ret_stuff
.v2
;
1005 * Returns information about the HUB/SHUB.
1007 * arg0 - SN_SAL_GET_SN_INFO
1008 * arg1 - 0 (other values reserved for future use)
1011 * [7:0] - shub type (0=shub1, 1=shub2)
1012 * [15:8] - Log2 max number of nodes in entire system (includes
1013 * C-bricks, I-bricks, etc)
1014 * [23:16] - Log2 of nodes per sharing domain
1015 * [31:24] - partition ID
1016 * [39:32] - coherency_id
1017 * [47:40] - regionsize
1019 * [15:0] - nasid mask (ex., 0x7ff for 11 bit nasid)
1020 * [23:15] - bit position of low nasid bit
1023 ia64_sn_get_sn_info(int fc
, u8
*shubtype
, u16
*nasid_bitmask
, u8
*nasid_shift
,
1024 u8
*systemsize
, u8
*sharing_domain_size
, u8
*partid
, u8
*coher
, u8
*reg
)
1026 struct ia64_sal_retval ret_stuff
;
1028 ret_stuff
.status
= 0;
1032 SAL_CALL_NOLOCK(ret_stuff
, SN_SAL_GET_SN_INFO
, fc
, 0, 0, 0, 0, 0, 0);
1034 /***** BEGIN HACK - temp til old proms no longer supported ********/
1035 if (ret_stuff
.status
== SALRET_NOT_IMPLEMENTED
) {
1036 int nasid
= get_sapicid() & 0xfff;;
1037 #define SH_SHUB_ID_NODES_PER_BIT_MASK 0x001f000000000000UL
1038 #define SH_SHUB_ID_NODES_PER_BIT_SHFT 48
1039 if (shubtype
) *shubtype
= 0;
1040 if (nasid_bitmask
) *nasid_bitmask
= 0x7ff;
1041 if (nasid_shift
) *nasid_shift
= 38;
1042 if (systemsize
) *systemsize
= 11;
1043 if (sharing_domain_size
) *sharing_domain_size
= 9;
1044 if (partid
) *partid
= ia64_sn_sysctl_partition_get(nasid
);
1045 if (coher
) *coher
= nasid
>> 9;
1046 if (reg
) *reg
= (HUB_L((u64
*) LOCAL_MMR_ADDR(SH1_SHUB_ID
)) & SH_SHUB_ID_NODES_PER_BIT_MASK
) >>
1047 SH_SHUB_ID_NODES_PER_BIT_SHFT
;
1050 /***** END HACK *******/
1052 if (ret_stuff
.status
< 0)
1053 return ret_stuff
.status
;
1055 if (shubtype
) *shubtype
= ret_stuff
.v0
& 0xff;
1056 if (systemsize
) *systemsize
= (ret_stuff
.v0
>> 8) & 0xff;
1057 if (sharing_domain_size
) *sharing_domain_size
= (ret_stuff
.v0
>> 16) & 0xff;
1058 if (partid
) *partid
= (ret_stuff
.v0
>> 24) & 0xff;
1059 if (coher
) *coher
= (ret_stuff
.v0
>> 32) & 0xff;
1060 if (reg
) *reg
= (ret_stuff
.v0
>> 40) & 0xff;
1061 if (nasid_bitmask
) *nasid_bitmask
= (ret_stuff
.v1
& 0xffff);
1062 if (nasid_shift
) *nasid_shift
= (ret_stuff
.v1
>> 16) & 0xff;
1067 * This is the access point to the Altix PROM hardware performance
1068 * and status monitoring interface. For info on using this, see
1069 * include/asm-ia64/sn/sn2/sn_hwperf.h
1072 ia64_sn_hwperf_op(nasid_t nasid
, u64 opcode
, u64 a0
, u64 a1
, u64 a2
,
1073 u64 a3
, u64 a4
, int *v0
)
1075 struct ia64_sal_retval rv
;
1076 SAL_CALL_NOLOCK(rv
, SN_SAL_HWPERF_OP
, (u64
)nasid
,
1077 opcode
, a0
, a1
, a2
, a3
, a4
);
1080 return (int) rv
.status
;
1084 ia64_sn_ioif_get_pci_topology(u64 rack
, u64 bay
, u64 slot
, u64 slab
,
1087 struct ia64_sal_retval rv
;
1088 SAL_CALL_NOLOCK(rv
, SN_SAL_IOIF_GET_PCI_TOPOLOGY
,
1089 rack
, bay
, slot
, slab
, buf
, len
, 0);
1090 return (int) rv
.status
;
1094 * BTE error recovery is implemented in SAL
1097 ia64_sn_bte_recovery(nasid_t nasid
)
1099 struct ia64_sal_retval rv
;
1102 SAL_CALL_NOLOCK(rv
, SN_SAL_BTE_RECOVER
, 0, 0, 0, 0, 0, 0, 0);
1103 if (rv
.status
== SALRET_NOT_IMPLEMENTED
)
1105 return (int) rv
.status
;
1108 #endif /* _ASM_IA64_SN_SN_SAL_H */