xref: /onnv-gate/usr/src/uts/sun4v/sys/error.h (revision 11759:8960658e7f30)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
51991Sheppo  * Common Development and Distribution License (the "License").
61991Sheppo  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
22*11759SAnthony.Yznaga@Sun.COM  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
230Sstevel@tonic-gate  * Use is subject to license terms.
240Sstevel@tonic-gate  */
250Sstevel@tonic-gate 
260Sstevel@tonic-gate #ifndef	_ERROR_H
270Sstevel@tonic-gate #define	_ERROR_H
280Sstevel@tonic-gate 
290Sstevel@tonic-gate #ifdef __cplusplus
300Sstevel@tonic-gate extern "C" {
310Sstevel@tonic-gate #endif
320Sstevel@tonic-gate 
330Sstevel@tonic-gate /*
340Sstevel@tonic-gate  * Resumable and Non-resumable queues
350Sstevel@tonic-gate  */
361991Sheppo #define	CPU_RQ_ENTRIES		64
372531Snarayan #define	MAX_CPU_RQ_ENTRIES	128
382531Snarayan 
392531Snarayan #define	CPU_NRQ_ENTRIES		4
402531Snarayan #define	MAX_CPU_NRQ_ENTRIES	4
412531Snarayan 
420Sstevel@tonic-gate #define	Q_ENTRY_SIZE		64
432531Snarayan 
440Sstevel@tonic-gate #define	CPU_RQ_SIZE		(CPU_RQ_ENTRIES * Q_ENTRY_SIZE)
450Sstevel@tonic-gate #define	CPU_NRQ_SIZE		(CPU_NRQ_ENTRIES * Q_ENTRY_SIZE)
460Sstevel@tonic-gate 
470Sstevel@tonic-gate /*
480Sstevel@tonic-gate  * Sun4v Error Report error Descriptor describes the type of the error
490Sstevel@tonic-gate  */
500Sstevel@tonic-gate #define	ERRH_DESC_UNDEFINED	0	/* Undefined */
510Sstevel@tonic-gate #define	ERRH_DESC_UCOR_RE	1	/* Uncorrected resumable error */
520Sstevel@tonic-gate #define	ERRH_DESC_PR_NRE	2	/* Precise non-resumable error */
530Sstevel@tonic-gate #define	ERRH_DESC_DEF_NRE	3	/* Deferred non-resumalbe error */
54541Srf157361 #define	ERRH_DESC_WARN_RE	4	/* Power-off for vBSC HostShutdown() */
553313Siskreen #define	ERRH_DESC_USER_DCORE	5	/* User initiated panic */
5611304SJanie.Lu@Sun.COM #define	ERRH_DESC_SP		6	/* SP state change */
570Sstevel@tonic-gate 
580Sstevel@tonic-gate /*
590Sstevel@tonic-gate  * Sun4v Error Report Error Attributes specifies the attributes of the error
600Sstevel@tonic-gate  */
610Sstevel@tonic-gate #define	ERRH_ATTR_CPU		0x00000001
620Sstevel@tonic-gate #define	ERRH_ATTR_MEM		0x00000002
630Sstevel@tonic-gate #define	ERRH_ATTR_PIO		0x00000004
640Sstevel@tonic-gate #define	ERRH_ATTR_IRF		0x00000008	/* Integer register file */
650Sstevel@tonic-gate /* Floating-point register file */
660Sstevel@tonic-gate #define	ERRH_ATTR_FRF		0x00000010
673156Sgirish #define	ERRH_ATTR_SHUT		0x00000020	/* Shutdown request */
683156Sgirish #define	ERRH_ATTR_ASR		0x00000040	/* Sun4v ASR */
693156Sgirish #define	ERRH_ATTR_ASI		0x00000080	/* Sun4v ASI */
703156Sgirish #define	ERRH_ATTR_PREG		0x00000100	/* Sun4v Privileged Register */
710Sstevel@tonic-gate #define	ERRH_ATTR_RQF		0x80000000	/* Resumablee Queue Full */
720Sstevel@tonic-gate 
730Sstevel@tonic-gate /*
7411304SJanie.Lu@Sun.COM  * For Execution mode
750Sstevel@tonic-gate  */
760Sstevel@tonic-gate #define	ERRH_MODE_MASK		0x03000000
770Sstevel@tonic-gate #define	ERRH_MODE_SHIFT		24
780Sstevel@tonic-gate #define	ERRH_MODE_UNKNOWN	0
790Sstevel@tonic-gate #define	ERRH_MODE_USER		1
800Sstevel@tonic-gate #define	ERRH_MODE_PRIV		2
810Sstevel@tonic-gate 
821457Swh94709 /*
8311304SJanie.Lu@Sun.COM  * For SP (Service Processor) state change
8411304SJanie.Lu@Sun.COM  */
85*11759SAnthony.Yznaga@Sun.COM #define	ERRH_SP_MASK		0x00000600
8611304SJanie.Lu@Sun.COM #define	ERRH_SP_SHIFT		9
87*11759SAnthony.Yznaga@Sun.COM #define	ERRH_SP_FAULTED		0	/* Physically present but faulted SP */
8811304SJanie.Lu@Sun.COM #define	ERRH_SP_AVAILABLE	1
89*11759SAnthony.Yznaga@Sun.COM #define	ERRH_SP_NOT_PRESENT	2	/* SP is not physically present */
9011304SJanie.Lu@Sun.COM 
9111304SJanie.Lu@Sun.COM /*
923156Sgirish  * ASR register number
933156Sgirish  */
943156Sgirish #define	ASR_REG_VALID		0x8000	/* Valid bit for register field */
953156Sgirish #define	ASR_REG_TICK		0x17	/* Tick Compare Register */
963156Sgirish 
973156Sgirish /*
981457Swh94709  * For the second argument passed to process_nonresumable_error(), it is
991457Swh94709  * an uint64_t. The upper 32 bits are reserved for various flags, the
1001457Swh94709  * lower 32 bits are used to pass the "current tl-1". Right now only bit
1011457Swh94709  * 32 in the upper 32 bits is being used as user's fill/spill flag.
1021457Swh94709  * If bit 32 is set, it means the first error in the error
1031457Swh94709  * queue happened in user fill/spill trap and it needs to be handled
1041457Swh94709  * differently.
1051457Swh94709  *
1061457Swh94709  * -Argument 2 of process_nonresumable_error()
1071457Swh94709  *    ----------------------------------------------
1081457Swh94709  *    |  reserved        |x|  current_tl - 1       |
1091457Swh94709  *    ----------------------------------------------
1101457Swh94709  *    63                 32 31                     0
1111457Swh94709  * x - bit 32, user fill/spill trap flag
1121457Swh94709  */
1131457Swh94709 #define	ERRH_U_SPILL_FILL		0x100000000
1141457Swh94709 #define	ERRH_U_SPILL_FILL_SHIFT		32
1151457Swh94709 #define	ERRH_TL_MASK			0xffffffff
1161457Swh94709 
1170Sstevel@tonic-gate #ifndef	_ASM
1180Sstevel@tonic-gate /*
1190Sstevel@tonic-gate  * For debug print out
1200Sstevel@tonic-gate  */
1210Sstevel@tonic-gate #define	ER_SZ_IN_EXT_WORD	(Q_ENTRY_SIZE / sizeof (uint64_t))
1220Sstevel@tonic-gate 
1230Sstevel@tonic-gate /*
1240Sstevel@tonic-gate  * Sun4v Error Report record
1250Sstevel@tonic-gate  */
1260Sstevel@tonic-gate typedef	struct {
1270Sstevel@tonic-gate 	uint64_t	ehdl;		/* Unique error handle */
1280Sstevel@tonic-gate 	uint64_t	stick;		/* Value of the %STICK register */
1290Sstevel@tonic-gate 	uint32_t	desc;		/* Error Descriptor */
1300Sstevel@tonic-gate 	uint32_t	attr;		/* error attributes bit field */
13110271SJason.Beloro@Sun.COM 	uint64_t	ra;		/* Real address */
1320Sstevel@tonic-gate 	uint32_t	sz;		/* Size of affected mem region */
1330Sstevel@tonic-gate 	uint16_t	cpuid;		/* Virtual ID of the affected CPU */
1343156Sgirish 	uint16_t	secs;		/* Seconds */
1353156Sgirish 	uint8_t		asi;		/* ASI */
1363156Sgirish 	uint8_t		rsvd;		/* Padding for ASI */
1373156Sgirish 	uint16_t	reg;		/* Value of the ASR register number */
1380Sstevel@tonic-gate } errh_er_t;
1390Sstevel@tonic-gate 
1400Sstevel@tonic-gate typedef struct errh_async_flt {
1410Sstevel@tonic-gate 	struct async_flt 	cmn_asyncflt;	/* common fault structure */
1420Sstevel@tonic-gate 	errh_er_t		errh_er;	/* sun4v er record */
1430Sstevel@tonic-gate } errh_async_flt_t;
1440Sstevel@tonic-gate 
1450Sstevel@tonic-gate /*
1460Sstevel@tonic-gate  * Global functions
1470Sstevel@tonic-gate  */
1480Sstevel@tonic-gate void mem_scrub(uint64_t, uint64_t);
1490Sstevel@tonic-gate void errh_cpu_run_bus_error_handlers(struct async_flt *, int);
1500Sstevel@tonic-gate void error_init(void);
1510Sstevel@tonic-gate void cpu_async_log_err(void *);
1520Sstevel@tonic-gate void cpu_ce_log_err(struct async_flt *);
1530Sstevel@tonic-gate void cpu_ue_log_err(struct async_flt *);
1543199Sep32863 uint64_t mem_sync(caddr_t, size_t);
1550Sstevel@tonic-gate 
1560Sstevel@tonic-gate #endif	/* _ASM */
1570Sstevel@tonic-gate 
1580Sstevel@tonic-gate #ifdef __cplusplus
1590Sstevel@tonic-gate }
1600Sstevel@tonic-gate #endif
1610Sstevel@tonic-gate 
1620Sstevel@tonic-gate #endif /* _ERROR_H */
163