xref: /openbmc/linux/arch/ia64/include/asm/sn/sn_sal.h (revision 1164e757)
17f30491cSTony Luck #ifndef _ASM_IA64_SN_SN_SAL_H
27f30491cSTony Luck #define _ASM_IA64_SN_SN_SAL_H
37f30491cSTony Luck 
47f30491cSTony Luck /*
57f30491cSTony Luck  * System Abstraction Layer definitions for IA64
67f30491cSTony Luck  *
77f30491cSTony Luck  * This file is subject to the terms and conditions of the GNU General Public
87f30491cSTony Luck  * License.  See the file "COPYING" in the main directory of this archive
97f30491cSTony Luck  * for more details.
107f30491cSTony Luck  *
117f30491cSTony Luck  * Copyright (c) 2000-2006 Silicon Graphics, Inc.  All rights reserved.
127f30491cSTony Luck  */
137f30491cSTony Luck 
14cf07cb1fSChristoph Hellwig #include <linux/types.h>
157f30491cSTony Luck #include <asm/sal.h>
167f30491cSTony Luck 
177f30491cSTony Luck // SGI Specific Calls
187f30491cSTony Luck #define  SN_SAL_GET_PARTITION_ADDR		   0x02000009
197f30491cSTony Luck #define  SN_SAL_MEMPROTECT                         0x0200003e
207f30491cSTony Luck 
217576f684SRuss Anderson #define  SN_SAL_WATCHLIST_ALLOC			   0x02000070
227576f684SRuss Anderson #define  SN_SAL_WATCHLIST_FREE			   0x02000071
237f30491cSTony Luck 
247f30491cSTony Luck /*
257f30491cSTony Luck  * SAL Error Codes
267f30491cSTony Luck  */
277f30491cSTony Luck #define SALRET_MORE_PASSES	1
287f30491cSTony Luck #define SALRET_OK		0
297f30491cSTony Luck #define SALRET_NOT_IMPLEMENTED	(-1)
307f30491cSTony Luck #define SALRET_INVALID_ARG	(-2)
317f30491cSTony Luck #define SALRET_ERROR		(-3)
327f30491cSTony Luck 
337f30491cSTony Luck /*
347f30491cSTony Luck  * Returns the physical address of the partition's reserved page through
357f30491cSTony Luck  * an iterative number of calls.
367f30491cSTony Luck  *
377f30491cSTony Luck  * On first call, 'cookie' and 'len' should be set to 0, and 'addr'
387f30491cSTony Luck  * set to the nasid of the partition whose reserved page's address is
397f30491cSTony Luck  * being sought.
407f30491cSTony Luck  * On subsequent calls, pass the values, that were passed back on the
417f30491cSTony Luck  * previous call.
427f30491cSTony Luck  *
437f30491cSTony Luck  * While the return status equals SALRET_MORE_PASSES, keep calling
447f30491cSTony Luck  * this function after first copying 'len' bytes starting at 'addr'
457f30491cSTony Luck  * into 'buf'. Once the return status equals SALRET_OK, 'addr' will
467f30491cSTony Luck  * be the physical address of the partition's reserved page. If the
477f30491cSTony Luck  * return status equals neither of these, an error as occurred.
487f30491cSTony Luck  */
497f30491cSTony Luck static inline s64
sn_partition_reserved_page_pa(u64 buf,u64 * cookie,u64 * addr,u64 * len)507f30491cSTony Luck sn_partition_reserved_page_pa(u64 buf, u64 *cookie, u64 *addr, u64 *len)
517f30491cSTony Luck {
527f30491cSTony Luck 	struct ia64_sal_retval rv;
537f30491cSTony Luck 	ia64_sal_oemcall_reentrant(&rv, SN_SAL_GET_PARTITION_ADDR, *cookie,
547f30491cSTony Luck 				   *addr, buf, *len, 0, 0, 0);
557f30491cSTony Luck 	*cookie = rv.v0;
567f30491cSTony Luck 	*addr = rv.v1;
577f30491cSTony Luck 	*len = rv.v2;
587f30491cSTony Luck 	return rv.status;
597f30491cSTony Luck }
607f30491cSTony Luck 
617f30491cSTony Luck /*
627f30491cSTony Luck  * Change memory access protections for a physical address range.
637f30491cSTony Luck  * nasid_array is not used on Altix, but may be in future architectures.
647f30491cSTony Luck  * Available memory protection access classes are defined after the function.
657f30491cSTony Luck  */
667f30491cSTony Luck static inline int
sn_change_memprotect(u64 paddr,u64 len,u64 perms,u64 * nasid_array)677f30491cSTony Luck sn_change_memprotect(u64 paddr, u64 len, u64 perms, u64 *nasid_array)
687f30491cSTony Luck {
697f30491cSTony Luck 	struct ia64_sal_retval ret_stuff;
707f30491cSTony Luck 
717f30491cSTony Luck 	ia64_sal_oemcall_nolock(&ret_stuff, SN_SAL_MEMPROTECT, paddr, len,
727f30491cSTony Luck 				(u64)nasid_array, perms, 0, 0, 0);
737f30491cSTony Luck 	return ret_stuff.status;
747f30491cSTony Luck }
757f30491cSTony Luck #define SN_MEMPROT_ACCESS_CLASS_0		0x14a080
767f30491cSTony Luck #define SN_MEMPROT_ACCESS_CLASS_1		0x2520c2
777f30491cSTony Luck #define SN_MEMPROT_ACCESS_CLASS_2		0x14a1ca
787f30491cSTony Luck #define SN_MEMPROT_ACCESS_CLASS_3		0x14a290
797f30491cSTony Luck #define SN_MEMPROT_ACCESS_CLASS_6		0x084080
807f30491cSTony Luck #define SN_MEMPROT_ACCESS_CLASS_7		0x021080
817f30491cSTony Luck 
827576f684SRuss Anderson union sn_watchlist_u {
837576f684SRuss Anderson 	u64     val;
847576f684SRuss Anderson 	struct {
857576f684SRuss Anderson 		u64	blade	: 16,
867576f684SRuss Anderson 			size	: 32,
877576f684SRuss Anderson 			filler	: 16;
887576f684SRuss Anderson 	};
897576f684SRuss Anderson };
907576f684SRuss Anderson 
917576f684SRuss Anderson static inline int
sn_mq_watchlist_alloc(int blade,void * mq,unsigned int mq_size,unsigned long * intr_mmr_offset)927576f684SRuss Anderson sn_mq_watchlist_alloc(int blade, void *mq, unsigned int mq_size,
937576f684SRuss Anderson 				unsigned long *intr_mmr_offset)
947576f684SRuss Anderson {
957576f684SRuss Anderson 	struct ia64_sal_retval rv;
967576f684SRuss Anderson 	unsigned long addr;
977576f684SRuss Anderson 	union sn_watchlist_u size_blade;
987576f684SRuss Anderson 	int watchlist;
997576f684SRuss Anderson 
1007576f684SRuss Anderson 	addr = (unsigned long)mq;
1017576f684SRuss Anderson 	size_blade.size = mq_size;
1027576f684SRuss Anderson 	size_blade.blade = blade;
1037576f684SRuss Anderson 
1047576f684SRuss Anderson 	/*
1057576f684SRuss Anderson 	 * bios returns watchlist number or negative error number.
1067576f684SRuss Anderson 	 */
1077576f684SRuss Anderson 	ia64_sal_oemcall_nolock(&rv, SN_SAL_WATCHLIST_ALLOC, addr,
1087576f684SRuss Anderson 			size_blade.val, (u64)intr_mmr_offset,
1097576f684SRuss Anderson 			(u64)&watchlist, 0, 0, 0);
1107576f684SRuss Anderson 	if (rv.status < 0)
1117576f684SRuss Anderson 		return rv.status;
1127576f684SRuss Anderson 
1137576f684SRuss Anderson 	return watchlist;
1147576f684SRuss Anderson }
1157576f684SRuss Anderson 
1167576f684SRuss Anderson static inline int
sn_mq_watchlist_free(int blade,int watchlist_num)1177576f684SRuss Anderson sn_mq_watchlist_free(int blade, int watchlist_num)
1187576f684SRuss Anderson {
1197576f684SRuss Anderson 	struct ia64_sal_retval rv;
1207576f684SRuss Anderson 	ia64_sal_oemcall_nolock(&rv, SN_SAL_WATCHLIST_FREE, blade,
1217576f684SRuss Anderson 			watchlist_num, 0, 0, 0, 0, 0);
1227576f684SRuss Anderson 	return rv.status;
1237576f684SRuss Anderson }
1247f30491cSTony Luck #endif /* _ASM_IA64_SN_SN_SAL_H */
125