Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2)  * This file is subject to the terms and conditions of the GNU General Public
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * License.  See the file "COPYING" in the main directory of this archive
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  * for more details.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  * (C) Copyright 2020 Hewlett Packard Enterprise Development LP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  * Copyright (C) 2004-2008 Silicon Graphics, Inc. All rights reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11)  * External Cross Partition (XP) structures and defines.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #ifndef _DRIVERS_MISC_SGIXP_XP_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #define _DRIVERS_MISC_SGIXP_XP_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include <linux/mutex.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #if defined CONFIG_X86_UV || defined CONFIG_IA64_SGI_UV
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #include <asm/uv/uv.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) #ifdef USE_DBUG_ON
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) #define DBUG_ON(condition)	BUG_ON(condition)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) #define DBUG_ON(condition)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30)  * Define the maximum number of partitions the system can possibly support.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31)  * It is based on the maximum number of hardware partitionable regions. The
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32)  * term 'region' in this context refers to the minimum number of nodes that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33)  * can comprise an access protection grouping. The access protection is in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34)  * regards to memory, IPI and IOI.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36)  * The maximum number of hardware partitionable regions is equal to the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37)  * maximum number of nodes in the entire system divided by the minimum number
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38)  * of nodes that comprise an access protection grouping.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) #define XP_MAX_NPARTITIONS_SN2	64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) #define XP_MAX_NPARTITIONS_UV	256
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44)  * XPC establishes channel connections between the local partition and any
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45)  * other partition that is currently up. Over these channels, kernel-level
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46)  * `users' can communicate with their counterparts on the other partitions.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48)  * If the need for additional channels arises, one can simply increase
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49)  * XPC_MAX_NCHANNELS accordingly. If the day should come where that number
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50)  * exceeds the absolute MAXIMUM number of channels possible (eight), then one
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51)  * will need to make changes to the XPC code to accommodate for this.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53)  * The absolute maximum number of channels possible is limited to eight for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54)  * performance reasons on sn2 hardware. The internal cross partition structures
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55)  * require sixteen bytes per channel, and eight allows all of this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56)  * interface-shared info to fit in one 128-byte cacheline.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) #define XPC_MEM_CHANNEL		0	/* memory channel number */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) #define	XPC_NET_CHANNEL		1	/* network channel number */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) #define XPC_MAX_NCHANNELS	2	/* max #of channels allowed */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) #if XPC_MAX_NCHANNELS > 8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) #error	XPC_MAX_NCHANNELS exceeds absolute MAXIMUM possible.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68)  * Define macro, XPC_MSG_SIZE(), is provided for the user
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69)  * that wants to fit as many msg entries as possible in a given memory size
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70)  * (e.g. a memory page).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) #define XPC_MSG_MAX_SIZE	128
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) #define XPC_MSG_HDR_MAX_SIZE	16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) #define XPC_MSG_PAYLOAD_MAX_SIZE (XPC_MSG_MAX_SIZE - XPC_MSG_HDR_MAX_SIZE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) #define XPC_MSG_SIZE(_payload_size) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 				ALIGN(XPC_MSG_HDR_MAX_SIZE + (_payload_size), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 				      is_uv_system() ? 64 : 128)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82)  * Define the return values and values passed to user's callout functions.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83)  * (It is important to add new value codes at the end just preceding
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84)  * xpUnknownReason, which must have the highest numerical value.)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) enum xp_retval {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	xpSuccess = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	xpNotConnected,		/*  1: channel is not connected */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	xpConnected,		/*  2: channel connected (opened) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	xpRETIRED1,		/*  3: (formerly xpDisconnected) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	xpMsgReceived,		/*  4: message received */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	xpMsgDelivered,		/*  5: message delivered and acknowledged */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	xpRETIRED2,		/*  6: (formerly xpTransferFailed) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	xpNoWait,		/*  7: operation would require wait */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	xpRetry,		/*  8: retry operation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	xpTimeout,		/*  9: timeout in xpc_allocate_msg_wait() */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	xpInterrupted,		/* 10: interrupted wait */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	xpUnequalMsgSizes,	/* 11: message size disparity between sides */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	xpInvalidAddress,	/* 12: invalid address */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	xpNoMemory,		/* 13: no memory available for XPC structures */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	xpLackOfResources,	/* 14: insufficient resources for operation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	xpUnregistered,		/* 15: channel is not registered */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	xpAlreadyRegistered,	/* 16: channel is already registered */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	xpPartitionDown,	/* 17: remote partition is down */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	xpNotLoaded,		/* 18: XPC module is not loaded */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	xpUnloading,		/* 19: this side is unloading XPC module */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	xpBadMagic,		/* 20: XPC MAGIC string not found */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	xpReactivating,		/* 21: remote partition was reactivated */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 	xpUnregistering,	/* 22: this side is unregistering channel */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	xpOtherUnregistering,	/* 23: other side is unregistering channel */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	xpCloneKThread,		/* 24: cloning kernel thread */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	xpCloneKThreadFailed,	/* 25: cloning kernel thread failed */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 	xpNoHeartbeat,		/* 26: remote partition has no heartbeat */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 	xpPioReadError,		/* 27: PIO read error */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 	xpPhysAddrRegFailed,	/* 28: registration of phys addr range failed */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	xpRETIRED3,		/* 29: (formerly xpBteDirectoryError) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	xpRETIRED4,		/* 30: (formerly xpBtePoisonError) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	xpRETIRED5,		/* 31: (formerly xpBteWriteError) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	xpRETIRED6,		/* 32: (formerly xpBteAccessError) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	xpRETIRED7,		/* 33: (formerly xpBtePWriteError) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	xpRETIRED8,		/* 34: (formerly xpBtePReadError) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 	xpRETIRED9,		/* 35: (formerly xpBteTimeOutError) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 	xpRETIRED10,		/* 36: (formerly xpBteXtalkError) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 	xpRETIRED11,		/* 37: (formerly xpBteNotAvailable) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 	xpRETIRED12,		/* 38: (formerly xpBteUnmappedError) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 	xpBadVersion,		/* 39: bad version number */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 	xpVarsNotSet,		/* 40: the XPC variables are not set up */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 	xpNoRsvdPageAddr,	/* 41: unable to get rsvd page's phys addr */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 	xpInvalidPartid,	/* 42: invalid partition ID */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 	xpLocalPartid,		/* 43: local partition ID */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	xpOtherGoingDown,	/* 44: other side going down, reason unknown */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 	xpSystemGoingDown,	/* 45: system is going down, reason unknown */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	xpSystemHalt,		/* 46: system is being halted */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 	xpSystemReboot,		/* 47: system is being rebooted */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 	xpSystemPoweroff,	/* 48: system is being powered off */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 	xpDisconnecting,	/* 49: channel disconnecting (closing) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	xpOpenCloseError,	/* 50: channel open/close protocol error */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 	xpDisconnected,		/* 51: channel disconnected (closed) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 	xpBteCopyError,		/* 52: bte_copy() returned error */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 	xpSalError,		/* 53: sn SAL error */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 	xpRsvdPageNotSet,	/* 54: the reserved page is not set up */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 	xpPayloadTooBig,	/* 55: payload too large for message slot */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 	xpUnsupported,		/* 56: unsupported functionality or resource */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 	xpNeedMoreInfo,		/* 57: more info is needed by SAL */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 	xpGruCopyError,		/* 58: gru_copy_gru() returned error */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 	xpGruSendMqError,	/* 59: gru send message queue related error */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 	xpBadChannelNumber,	/* 60: invalid channel number */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 	xpBadMsgType,		/* 61: invalid message type */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 	xpBiosError,		/* 62: BIOS error */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 	xpUnknownReason		/* 63: unknown reason - must be last in enum */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178)  * Define the callout function type used by XPC to update the user on
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179)  * connection activity and state changes via the user function registered
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180)  * by xpc_connect().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182)  * Arguments:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184)  *	reason - reason code.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185)  *	partid - partition ID associated with condition.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186)  *	ch_number - channel # associated with condition.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187)  *	data - pointer to optional data.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188)  *	key - pointer to optional user-defined value provided as the "key"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189)  *	      argument to xpc_connect().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191)  * A reason code of xpConnected indicates that a connection has been
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192)  * established to the specified partition on the specified channel. The data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193)  * argument indicates the max number of entries allowed in the message queue.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195)  * A reason code of xpMsgReceived indicates that a XPC message arrived from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196)  * the specified partition on the specified channel. The data argument
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197)  * specifies the address of the message's payload. The user must call
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198)  * xpc_received() when finished with the payload.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200)  * All other reason codes indicate failure. The data argmument is NULL.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201)  * When a failure reason code is received, one can assume that the channel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202)  * is not connected.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) typedef void (*xpc_channel_func) (enum xp_retval reason, short partid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 				  int ch_number, void *data, void *key);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208)  * Define the callout function type used by XPC to notify the user of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209)  * messages received and delivered via the user function registered by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210)  * xpc_send_notify().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212)  * Arguments:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214)  *	reason - reason code.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215)  *	partid - partition ID associated with condition.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216)  *	ch_number - channel # associated with condition.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217)  *	key - pointer to optional user-defined value provided as the "key"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218)  *	      argument to xpc_send_notify().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220)  * A reason code of xpMsgDelivered indicates that the message was delivered
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221)  * to the intended recipient and that they have acknowledged its receipt by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222)  * calling xpc_received().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224)  * All other reason codes indicate failure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226)  * NOTE: The user defined function must be callable by an interrupt handler
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227)  *       and thus cannot block.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) typedef void (*xpc_notify_func) (enum xp_retval reason, short partid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 				 int ch_number, void *key);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233)  * The following is a registration entry. There is a global array of these,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234)  * one per channel. It is used to record the connection registration made
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235)  * by the users of XPC. As long as a registration entry exists, for any
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236)  * partition that comes up, XPC will attempt to establish a connection on
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237)  * that channel. Notification that a connection has been made will occur via
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238)  * the xpc_channel_func function.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240)  * The 'func' field points to the function to call when aynchronous
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241)  * notification is required for such events as: a connection established/lost,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242)  * or an incoming message received, or an error condition encountered. A
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243)  * non-NULL 'func' field indicates that there is an active registration for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244)  * the channel.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) struct xpc_registration {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 	struct mutex mutex;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 	xpc_channel_func func;	/* function to call */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 	void *key;		/* pointer to user's key */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 	u16 nentries;		/* #of msg entries in local msg queue */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 	u16 entry_size;		/* message queue's message entry size */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 	u32 assigned_limit;	/* limit on #of assigned kthreads */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 	u32 idle_limit;		/* limit on #of idle kthreads */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) } ____cacheline_aligned;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) #define XPC_CHANNEL_REGISTERED(_c)	(xpc_registrations[_c].func != NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) /* the following are valid xpc_send() or xpc_send_notify() flags */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) #define XPC_WAIT	0	/* wait flag */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) #define XPC_NOWAIT	1	/* no wait flag */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) struct xpc_interface {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 	void (*connect) (int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 	void (*disconnect) (int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 	enum xp_retval (*send) (short, int, u32, void *, u16);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 	enum xp_retval (*send_notify) (short, int, u32, void *, u16,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 					xpc_notify_func, void *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 	void (*received) (short, int, void *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 	enum xp_retval (*partid_to_nasids) (short, void *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) extern struct xpc_interface xpc_interface;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) extern void xpc_set_interface(void (*)(int),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 			      void (*)(int),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 			      enum xp_retval (*)(short, int, u32, void *, u16),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 			      enum xp_retval (*)(short, int, u32, void *, u16,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 						 xpc_notify_func, void *),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 			      void (*)(short, int, void *),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 			      enum xp_retval (*)(short, void *));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) extern void xpc_clear_interface(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) extern enum xp_retval xpc_connect(int, xpc_channel_func, void *, u16,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 				   u16, u32, u32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) extern void xpc_disconnect(int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) static inline enum xp_retval
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) xpc_send(short partid, int ch_number, u32 flags, void *payload,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 	 u16 payload_size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 	if (!xpc_interface.send)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 		return xpNotLoaded;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 	return xpc_interface.send(partid, ch_number, flags, payload,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 				  payload_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) static inline enum xp_retval
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) xpc_send_notify(short partid, int ch_number, u32 flags, void *payload,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 		u16 payload_size, xpc_notify_func func, void *key)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 	if (!xpc_interface.send_notify)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 		return xpNotLoaded;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 	return xpc_interface.send_notify(partid, ch_number, flags, payload,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 					 payload_size, func, key);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) static inline void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) xpc_received(short partid, int ch_number, void *payload)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) 	if (xpc_interface.received)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) 		xpc_interface.received(partid, ch_number, payload);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) static inline enum xp_retval
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) xpc_partid_to_nasids(short partid, void *nasids)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) 	if (!xpc_interface.partid_to_nasids)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) 		return xpNotLoaded;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) 	return xpc_interface.partid_to_nasids(partid, nasids);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) extern short xp_max_npartitions;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) extern short xp_partition_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) extern u8 xp_region_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) extern unsigned long (*xp_pa) (void *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) extern unsigned long (*xp_socket_pa) (unsigned long);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) extern enum xp_retval (*xp_remote_memcpy) (unsigned long, const unsigned long,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) 		       size_t);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) extern int (*xp_cpu_to_nasid) (int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) extern enum xp_retval (*xp_expand_memprotect) (unsigned long, unsigned long);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) extern enum xp_retval (*xp_restrict_memprotect) (unsigned long, unsigned long);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) extern u64 xp_nofault_PIOR_target;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) extern int xp_nofault_PIOR(void *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) extern int xp_error_PIOR(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) extern struct device *xp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) extern enum xp_retval xp_init_uv(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) extern void xp_exit_uv(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) #endif /* _DRIVERS_MISC_SGIXP_XP_H */