FreeBSD/Linux Kernel Cross Reference
sys/i386ps2/nmi.c
1 /*
2 * Mach Operating System
3 * Copyright (c) 1991,1990,1989 Carnegie-Mellon University
4 * Copyright (c) 1991 IBM Corporation
5 * All Rights Reserved.
6 *
7 * Permission to use, copy, modify and distribute this software and its
8 * documentation is hereby granted, provided that both the copyright
9 * notice and this permission notice appear in all copies of the
10 * software, derivative works or modified versions, and any portions
11 * thereof, and that both notices appear in supporting documentation,
12 * and that the name IBM not be used in advertising or publicity
13 * pertaining to distribution of the software without specific, written
14 * prior permission.
15 *
16 * CARNEGIE MELLON AND IBM ALLOW FREE USE OF THIS SOFTWARE IN ITS "AS IS"
17 * CONDITION. CARNEGIE MELLON AND IBM DISCLAIM ANY LIABILITY OF ANY KIND FOR
18 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
19 *
20 * Carnegie Mellon requests users of this software to return to
21 *
22 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
23 * School of Computer Science
24 * Carnegie Mellon University
25 * Pittsburgh PA 15213-3890
26 *
27 * any improvements or extensions that they make and grant Carnegie Mellon
28 * the rights to redistribute these changes.
29 */
30
31 /*
32 * HISTORY
33 * $Log: nmi.c,v $
34 * Revision 2.2 93/02/04 08:01:27 danner
35 * Integrate PS2 code from IBM.
36 * [93/01/18 prithvi]
37 *
38 */
39
40 #include <platforms.h>
41 #include <cpus.h>
42
43 #include <sys/types.h>
44
45 #ifdef PS2
46 #include <i386ps2/abios.h>
47
48 struct NMI_params {
49 u_short Type;
50 u_char _Dummy1[12];
51 u_char Arb;
52 u_char Slot;
53 u_char _Dummy2;
54 u_char Reserved[2];
55 };
56
57 #define nmi_type un.nmi_params.Type
58 #define nmi_arb un.nmi_params.Arb
59 #define nmi_slot un.nmi_params.Slot
60 #define nmi_reserved un.nmi_params.Reserved
61
62 struct nmi_request {
63 struct Request_header request_header;
64 union {
65 struct Logical_id_params logical_id_params;
66 struct NMI_params nmi_params;
67 } un;
68 };
69 #define NMI_PARITY 0x01
70 #define NMI_CHANNEL 0x02
71 #define NMI_DMA 0x03
72 #define NMI_WATCHDOG 0x04
73
74 static struct nmi_request *nmi_request_block;
75 static struct nmi_request *nmi_enable_block;
76 static int nmi_flags;
77 char nqbuf[200]; /*XXX temparary.. should use kmem_alloc or whatever..*/
78
79 nmi_enable()
80 {
81 struct generic_request temp_request_block;
82 int rc;
83
84 temp_request_block.r_current_req_blck_len = ABIOS_MIN_REQ_SIZE;
85 temp_request_block.r_logical_id = abios_next_LID(NMI_ID,
86 ABIOS_FIRST_LID);
87 temp_request_block.r_unit = 0;
88 temp_request_block.r_function = ABIOS_LOGICAL_PARAMETER;
89 temp_request_block.r_return_code = ABIOS_UNDEFINED;
90
91 abios_common_start(&temp_request_block,0);
92 if (temp_request_block.r_return_code != ABIOS_DONE) {
93 printf("couldn't init abios nmi code!\n");
94 return;
95 }
96
97 /*
98 * now build the clock request for the hardware system clock
99 */
100 nmi_request_block = (struct nmi_request *)nqbuf;
101 nmi_request_block->r_current_req_blck_len =
102 temp_request_block.r_request_block_length;
103 nmi_request_block->r_logical_id = temp_request_block.r_logical_id;
104 nmi_request_block->r_unit = 0;
105 nmi_flags = temp_request_block.r_logical_id_flags;
106 nmi_request_block->r_return_code = ABIOS_UNDEFINED;
107 nmi_request_block->r_function = ABIOS_READ;
108 nmi_request_block->nmi_reserved[0] = 0;
109 nmi_request_block->nmi_reserved[1] = 0;
110
111 /* start the continuous read request */
112 abios_common_start(nmi_request_block,nmi_flags);
113
114 /* build the enable request structure */
115 nmi_enable_block = (struct nmi_request *)
116 (&nqbuf[temp_request_block.r_request_block_length]);
117 nmi_enable_block->r_current_req_blck_len =
118 temp_request_block.r_request_block_length;
119 nmi_enable_block->r_logical_id = temp_request_block.r_logical_id;
120 nmi_enable_block->r_unit = 0;
121 nmi_enable_block->r_return_code = ABIOS_UNDEFINED;
122 nmi_enable_block->r_function = ABIOS_ENABLE_INTR;
123 nmi_enable_block->nmi_reserved[0] = 0;
124 nmi_enable_block->nmi_reserved[1] = 0;
125 abios_common_start(nmi_enable_block,nmi_flags);
126 }
127
128
129
130 int
131 nmi_trap(type,code,pc,locr0)
132 int type,code,pc;
133 int *locr0;
134 {
135 if (nmi_request_block) {
136 nmi_request_block->r_return_code = ABIOS_UNDEFINED;
137 abios_common_interrupt(nmi_request_block,nmi_flags);
138 if (nmi_request_block->r_return_code != ABIOS_STAGE_ON_INT) {
139 printf("Unknown NMI: does not belong to system\n");
140 } else {
141 printf("NMI: type=");
142 switch(nmi_request_block->nmi_type) {
143 case NMI_PARITY:
144 printf("memory parity error");
145 break;
146 case NMI_CHANNEL:
147 printf(
148 "I/O channel check from card in slot %d\n",
149 nmi_request_block->nmi_slot);
150 break;
151 case NMI_DMA:
152 printf(
153 "DMA Bus timeout error on arb level %d\n",
154 nmi_request_block->nmi_arb);
155 break;
156
157 case NMI_WATCHDOG:
158 printf
159 ("system clock hardware watchdog timeout\n");
160 break;
161 default:
162 printf("Unknown");
163 break;
164 }
165 /*
166 * some day we may want to keep going. AT that point
167 * we should call abios_common_start with
168 * nmi_enable_block
169 */
170 printf(" not restarting\n");
171 }
172 }
173 return(0);
174 }
175 #endif
Cache object: 8657ac5ec98114f4138d21a43fcb1294
|