2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
6 * Copyright (C) 1992 - 1997, 2000-2003 Silicon Graphics, Inc. All rights reserved.
8 #ifndef _ASM_IA64_SN_IOERROR_H
9 #define _ASM_IA64_SN_IOERROR_H
13 #include <linux/types.h>
14 #include <asm/sn/types.h>
17 * Macros defining the various Errors to be handled as part of
22 * List of errors to be handled by each subsystem.
23 * "error_code" field will take one of these values.
24 * The error code is built up of single bits expressing
25 * our confidence that the error was that type; note
26 * that it is possible to have a PIO or DMA error where
27 * we don't know whether it was a READ or a WRITE, or
28 * even a READ or WRITE error that we're not sure whether
29 * to call a PIO or DMA.
31 * It is also possible to set both PIO and DMA, and possible
32 * to set both READ and WRITE; the first may be nonsensical
33 * but the second *could* be used to designate an access
34 * that is known to be a read-modify-write cycle. It is
35 * quite possible that nobody will ever use PIO|DMA or
36 * READ|WRITE ... but being flexible is good.
38 #define IOECODE_UNSPEC 0
39 #define IOECODE_READ 1
40 #define IOECODE_WRITE 2
44 #define IOECODE_PIO_READ (IOECODE_PIO|IOECODE_READ)
45 #define IOECODE_PIO_WRITE (IOECODE_PIO|IOECODE_WRITE)
46 #define IOECODE_DMA_READ (IOECODE_DMA|IOECODE_READ)
47 #define IOECODE_DMA_WRITE (IOECODE_DMA|IOECODE_WRITE)
49 /* support older names, but try to move everything
50 * to using new names that identify which package
51 * controls their values ...
53 #define PIO_READ_ERROR IOECODE_PIO_READ
54 #define PIO_WRITE_ERROR IOECODE_PIO_WRITE
55 #define DMA_READ_ERROR IOECODE_DMA_READ
56 #define DMA_WRITE_ERROR IOECODE_DMA_WRITE
59 * List of error numbers returned by error handling sub-system.
62 #define IOERROR_HANDLED 0 /* Error Properly handled. */
63 #define IOERROR_NODEV 0x1 /* No such device attached */
64 #define IOERROR_BADHANDLE 0x2 /* Received bad handle */
65 #define IOERROR_BADWIDGETNUM 0x3 /* Bad widget number */
66 #define IOERROR_BADERRORCODE 0x4 /* Bad error code passed in */
67 #define IOERROR_INVALIDADDR 0x5 /* Invalid address specified */
69 #define IOERROR_WIDGETLEVEL 0x6 /* Some failure at widget level */
70 #define IOERROR_XTALKLEVEL 0x7
72 #define IOERROR_HWGRAPH_LOOKUP 0x8 /* hwgraph lookup failed for path */
73 #define IOERROR_UNHANDLED 0x9 /* handler rejected error */
75 #define IOERROR_PANIC 0xA /* subsidiary handler has already
76 * started decode: continue error
77 * data dump, and panic from top
78 * caller in error chain.
82 * IO errors at the bus/device driver level
85 #define IOERROR_DEV_NOTFOUND 0x10 /* Device matching bus addr not found */
86 #define IOERROR_DEV_SHUTDOWN 0x11 /* Device has been shutdown */
90 * Indicates the direction of transfer that caused the error.
92 #define IOERROR_ADDR_PIO 1 /* Error Address generated due to PIO */
93 #define IOERROR_ADDR_DMA 2 /* Error address generated due to DMA */
98 * This structure would expand to hold the information retrieved from
99 * all IO related error registers.
101 * This structure is defined to hold all system specific
102 * information related to a single error.
104 * This serves a couple of purpose.
105 * - Error handling often involves translating one form of address to other
106 * form. So, instead of having different data structures at each level,
107 * we have a single structure, and the appropriate fields get filled in
109 * - This provides a way to dump all error related information in any layer
110 * of erorr handling (debugging aid).
112 * A second possibility is to allow each layer to define its own error
113 * data structure, and fill in the proper fields. This has the advantage
114 * of isolating the layers.
115 * A big concern is the potential stack usage (and overflow), if each layer
116 * defines these structures on stack (assuming we don't want to do kmalloc.
118 * Any layer wishing to pass extra information to a layer next to it in
119 * error handling hierarchy, can do so as a separate parameter.
122 typedef struct io_error_s {
123 /* Bit fields indicating which structure fields are valid */
126 unsigned ievb_errortype:1;
127 unsigned ievb_widgetnum:1;
128 unsigned ievb_widgetdev:1;
129 unsigned ievb_srccpu:1;
130 unsigned ievb_srcnode:1;
131 unsigned ievb_errnode:1;
132 unsigned ievb_sysioaddr:1;
133 unsigned ievb_xtalkaddr:1;
134 unsigned ievb_busspace:1;
135 unsigned ievb_busaddr:1;
136 unsigned ievb_vaddr:1;
137 unsigned ievb_memaddr:1;
140 unsigned ievb_tnum:1;
145 short ie_errortype; /* error type: extra info about error */
146 short ie_widgetnum; /* Widget number that's in error */
147 short ie_widgetdev; /* Device within widget in error */
148 cpuid_t ie_srccpu; /* CPU on srcnode generating error */
149 cnodeid_t ie_srcnode; /* Node which caused the error */
150 cnodeid_t ie_errnode; /* Node where error was noticed */
151 iopaddr_t ie_sysioaddr; /* Sys specific IO address */
152 iopaddr_t ie_xtalkaddr; /* Xtalk (48bit) addr of Error */
153 iopaddr_t ie_busspace; /* Bus specific address space */
154 iopaddr_t ie_busaddr; /* Bus specific address */
155 caddr_t ie_vaddr; /* Virtual address of error */
156 paddr_t ie_memaddr; /* Physical memory address */
157 caddr_t ie_epc; /* pc when error reported */
158 caddr_t ie_ef; /* eframe when error reported */
159 short ie_tnum; /* Xtalk TNUM field */
162 #define IOERROR_INIT(e) do { (e)->ie_v.iev_a = 0; } while (0)
163 #define IOERROR_SETVALUE(e,f,v) do { (e)->ie_ ## f = (v); (e)->ie_v.iev_b.ievb_ ## f = 1; } while (0)
164 #define IOERROR_FIELDVALID(e,f) ((unsigned long long)((e)->ie_v.iev_b.ievb_ ## f) != (unsigned long long) 0)
165 #define IOERROR_NOGETVALUE(e,f) (ASSERT(IOERROR_FIELDVALID(e,f)), ((e)->ie_ ## f))
166 #define IOERROR_GETVALUE(p,e,f) ASSERT(IOERROR_FIELDVALID(e,f)); p=((e)->ie_ ## f)
168 /* hub code likes to call the SysAD address "hubaddr" ... */
169 #define ie_hubaddr ie_sysioaddr
170 #define ievb_hubaddr ievb_sysioaddr
174 * Error handling Modes.
177 MODE_DEVPROBE, /* Probing mode. Errors not fatal */
178 MODE_DEVERROR, /* Error while system is running */
179 MODE_DEVUSERERROR, /* Device Error created due to user mode access */
180 MODE_DEVREENABLE /* Reenable pass */
184 typedef int error_handler_f(void *, int, ioerror_mode_t, ioerror_t *);
185 typedef void *error_handler_arg_t;
188 #define IOERR_PRINTF(x) (x)
190 #define IOERR_PRINTF(x)
191 #endif /* ERROR_DEBUG */
193 #endif /* _ASM_IA64_SN_IOERROR_H */