/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* bos720 src/bos/kernel/sys/ras_error.h 1.13                             */
/*                                                                        */
/* Licensed Materials - Property of IBM                                   */
/*                                                                        */
/* Restricted Materials of IBM                                            */
/*                                                                        */
/* COPYRIGHT International Business Machines Corp. 2005,2007              */
/* All Rights Reserved                                                    */
/*                                                                        */
/* US Government Users Restricted Rights - Use, duplication or            */
/* disclosure restricted by GSA ADP Schedule Contract with IBM Corp.      */
/*                                                                        */
/* IBM_PROLOG_END_TAG                                                     */
/* @(#)39       1.13  src/bos/kernel/sys/ras_error.h, syserrchk, bos720 4/10/07 17:52:04 */

#ifndef _H_RAS_ERROR
#define _H_RAS_ERROR

/*
 * COMPONENT_NAME: (sysras) RAS Component Infrastructure
 *
 * FUNCTIONS: 
 *
 * ORIGINS: 27
 */

/* 
 * This header file contains definitions used by kernel components and
 * kernel extensions that have adopted RAS error-checking.
 */

/*
 * Error-checking levels
 */
enum {
	ERRCHECK_LEVEL_0 = 0, 
	ERRCHECK_LEVEL_1, 
	ERRCHECK_LEVEL_2,
	ERRCHECK_LEVEL_3,
	ERRCHECK_LEVEL_4,
	ERRCHECK_LEVEL_5,
	ERRCHECK_LEVEL_6,
	ERRCHECK_LEVEL_7,
	ERRCHECK_LEVEL_8,
	ERRCHECK_LEVEL_9
} errchk_level_t;

/*
 * Symbolic error-checking levels
 */
#define ERRCHECK_MINIMAL	ERRCHECK_LEVEL_1
#define ERRCHECK_NORMAL		ERRCHECK_LEVEL_3
#define ERRCHECK_DETAIL		ERRCHECK_LEVEL_7
#define ERRCHECK_MAXIMAL	ERRCHECK_LEVEL_9

/* Default error-checking level */
#ifdef DEBUG
#define ERRCHECK_DEFAULT	ERRCHECK_DETAIL
#else
#define ERRCHECK_DEFAULT	ERRCHECK_NORMAL
#endif

/*
 * Scrub levels
 */
enum {
	SCRUB_LEVEL_0 = 0, 
	SCRUB_LEVEL_1, 
	SCRUB_LEVEL_2,
	SCRUB_LEVEL_3,
	SCRUB_LEVEL_4,
	SCRUB_LEVEL_5,
	SCRUB_LEVEL_6,
	SCRUB_LEVEL_7,
	SCRUB_LEVEL_8,
	SCRUB_LEVEL_9
} scrub_level_t;

/*
 * Symbolic scrub levels
 */
#define SCRUB_MINIMAL	SCRUB_LEVEL_1
#define SCRUB_NORMAL	SCRUB_LEVEL_3
#define SCRUB_DETAIL	SCRUB_LEVEL_7

/*
 * Error-checking commands for krascntl() system call.
 */

#define RE_CHKON		1
#define RE_CHKOFF		2
#define RE_ERRLEVEL		3
#define RE_SCRUBON		4
#define RE_SCRUBOFF		5
#define RE_SCRUBLEVEL		6
#define RE_LOWSEVDISP		7
#define RE_MEDSEVDISP		8
#define RE_DOSCRUB		9
#define RE_SCRUBLISTTABLES	10
#define RE_SCRUBACTIVETABLES	11

#define RE_SCRUBAWARE		13
#define RE_SCRUBPREEMPT		14
#define RE_SCRUBUSAGE		15
#define RE_SCRUBUSAGE_START	16
#define RE_SCRUBUSAGE_END	17

#define RE_PASSTHROUGH		4094
#define RE_NOCMD		4095	/* Maximum possible command number */

#define  RASE_CHKON		RASC_COMMAND(RASD_ERROR, RE_CHKON)
#define  RASE_CHKOFF		RASC_COMMAND(RASD_ERROR, RE_CHKOFF)
#define  RASE_ERRLEVEL		RASC_COMMAND(RASD_ERROR, RE_ERRLEVEL)
#define  RASE_SCRUBON		RASC_COMMAND(RASD_ERROR, RE_SCRUBON)
#define  RASE_SCRUBOFF		RASC_COMMAND(RASD_ERROR, RE_SCRUBOFF)
#define  RASE_SCRUBLEVEL	RASC_COMMAND(RASD_ERROR, RE_SCRUBLEVEL)
#define  RASE_LOWSEVDISP	RASC_COMMAND(RASD_ERROR, RE_LOWSEVDISP)
#define  RASE_MEDSEVDISP	RASC_COMMAND(RASD_ERROR, RE_MEDSEVDISP)
#define  RASE_DOSCRUB		RASC_COMMAND(RASD_ERROR, RE_DOSCRUB)
#define  RASE_SCRUBLISTTABLES	RASC_COMMAND(RASD_ERROR, RE_SCRUBLISTTABLES)
#define  RASE_SCRUBACTIVETABLES	RASC_COMMAND(RASD_ERROR, RE_SCRUBACTIVETABLES)
#define  RASE_PASSTHROUGH	RASC_COMMAND(RASD_ERROR, RE_PASSTHROUGH)

/* Special commands to (1) use buffer for multiple RAS attributes;
 * (2) delete persistent attribute customizations;
 * (3) query persistent customizations.
 */
#define  RASE_MULTI  (RASC_COMMAND(RASD_ERROR, RE_NOCMD)| RAS_BUFFER)
#define  RASE_DELETE (RASC_COMMAND(RASD_ERROR, RE_NOCMD)| RAS_DELETE)
#define  RASE_QUERY  (RASC_COMMAND(RASD_ERROR, RE_NOCMD)| RAS_QUERY)

/* 
 * Global persistence commands for krascntl().
 */
#define  RASE_ERRCHK_DISABLE	RASC_COMMAND(RASD_ERROR, 0x12)
#define  RASE_ERRCHK_ENABLE	RASC_COMMAND(RASD_ERROR, 0x13)

#ifdef _KERNEL
/*
 * Commands available to ras_control() for modifying error-checking
 * attribute values. These are typically used by a component's callback
 * routine.
 */

#define  RASE_SET_CHKON	    RASC_COMMAND(RASD_ERROR, (NOCALLBACK|RE_CHKON ))
#define  RASE_SET_CHKOFF    RASC_COMMAND(RASD_ERROR, (NOCALLBACK|RE_CHKOFF))
#define  RASE_SET_ERRLEVEL  RASC_COMMAND(RASD_ERROR, (NOCALLBACK|RE_ERRLEVEL))
#define  RASE_SET_SCRUBON   RASC_COMMAND(RASD_ERROR, (NOCALLBACK|RE_SCRUBON ))
#define  RASE_SET_SCRUBOFF  RASC_COMMAND(RASD_ERROR, (NOCALLBACK|RE_SCRUBOFF))
#define  RASE_SET_SCRUBLVL  RASC_COMMAND(RASD_ERROR, (NOCALLBACK|RE_SCRUBLEVEL))
#define  RASE_SET_LOWDISP   RASC_COMMAND(RASD_ERROR, (NOCALLBACK|RE_LOWSEVDISP))
#define  RASE_SET_MEDDISP   RASC_COMMAND(RASD_ERROR, (NOCALLBACK|RE_MEDSEVDISP))
#define  RASE_SET_SCRUB_AWARE	\
	RASC_COMMAND(RASD_ERROR, (NOCALLBACK|RE_SCRUBAWARE))
#define  RASE_SET_SCRUB_PREEMPT	\
	RASC_COMMAND(RASD_ERROR, (NOCALLBACK|RE_SCRUBPREEMPT))
#define  RASE_SET_SCRUB_USAGE	\
	RASC_COMMAND(RASD_ERROR, (NOCALLBACK|RE_SCRUBUSAGE))
#define  RASE_SET_SCRUB_USAGE_START	\
	RASC_COMMAND(RASD_ERROR, (NOCALLBACK|RE_SCRUBUSAGE_START))
#define  RASE_SET_SCRUB_USAGE_END	\
	RASC_COMMAND(RASD_ERROR, (NOCALLBACK|RE_SCRUBUSAGE_END))

#endif /* _KERNEL */

/*
 * Error-checking-domain-specific information that is part of ras_stat_t.
 * This structure must not be larger than ras_stat_domain_t.
 */
typedef struct rasp_error_stat
{
	unsigned short	rst_flags;
	short		rst_errchk_lvl;
	short		rst_errlowsevdisp;
	short		rst_errmedsevdisp;
	int		rst_errchk_reserved[30];
} rstat_error_t;

/*
 * Error-checking-domain-specific information for persistent customizations.
 */
typedef struct rasp_perror_stat
{
    char	rst_flags;
    signed char	rst_on_off;
    short	rst_length;	/* Length of structure for extensibility */
    short	rst_errchk_lvl;
    short	rst_errlowsevdisp;
    short	rst_errmedsevdisp;
} rpstat_error_t;

/*
 * rst_flags values:
 */
#define		RTE_ERRCHK_ENABLED	0x0001

/* The following flags are internal only. */
#ifdef _KERNSYS
#define		RTE_SCRUB_ENABLED	0x0002
#define		RTE_CUSTOMIZED		0x0004
#define		RTE_ERRCHK_TURNING_ON	0x0008

/*
  Set of flags passed to user space by rasp_error_stat.
 */
#define		RTE_ERRCHK_USERFLAGS	(RTE_ERRCHK_ENABLED)

#endif /* _KERNSYS */

#ifdef _KERNEL
/*
 * RAS Services Macros:
 */
#define ERR_LEVEL(__comp_rasbp)				\
	(long)(((const rasr_block_t *)(__comp_rasbp))->rrb_errchecklevel)

#define ERR_DISP(__comp_rasbp, __err_sev)		\
	(((__err_sev) == LOW_SEVERITY)?			\
		(((const rasr_block_t *)(__comp_rasbp))->rrb_errlowsev_disp): \
	(((__err_sev) == MEDIUM_SEVERITY)?		\
		(((const rasr_block_t *)(__comp_rasbp))->rrb_errmedsev_disp): \
	ERROR_SYSTEM_DUMP))

#endif /* _KERNEL */

#endif /* _H_RAS_ERROR */
