device_test.c revision 1.1.18.2 1 1.1.18.2 yamt /* $NetBSD: device_test.c,v 1.1.18.2 2006/06/21 14:51:20 yamt Exp $ */
2 1.1.18.2 yamt
3 1.1.18.2 yamt /*-
4 1.1.18.2 yamt * Copyright (c) 2004 The NetBSD Foundation, Inc.
5 1.1.18.2 yamt * All rights reserved.
6 1.1.18.2 yamt *
7 1.1.18.2 yamt * This code is derived from software contributed to The NetBSD Foundation
8 1.1.18.2 yamt * by UCHIYAMA Yasushi.
9 1.1.18.2 yamt *
10 1.1.18.2 yamt * Redistribution and use in source and binary forms, with or without
11 1.1.18.2 yamt * modification, are permitted provided that the following conditions
12 1.1.18.2 yamt * are met:
13 1.1.18.2 yamt * 1. Redistributions of source code must retain the above copyright
14 1.1.18.2 yamt * notice, this list of conditions and the following disclaimer.
15 1.1.18.2 yamt * 2. Redistributions in binary form must reproduce the above copyright
16 1.1.18.2 yamt * notice, this list of conditions and the following disclaimer in the
17 1.1.18.2 yamt * documentation and/or other materials provided with the distribution.
18 1.1.18.2 yamt * 3. All advertising materials mentioning features or use of this software
19 1.1.18.2 yamt * must display the following acknowledgement:
20 1.1.18.2 yamt * This product includes software developed by the NetBSD
21 1.1.18.2 yamt * Foundation, Inc. and its contributors.
22 1.1.18.2 yamt * 4. Neither the name of The NetBSD Foundation nor the names of its
23 1.1.18.2 yamt * contributors may be used to endorse or promote products derived
24 1.1.18.2 yamt * from this software without specific prior written permission.
25 1.1.18.2 yamt *
26 1.1.18.2 yamt * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 1.1.18.2 yamt * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 1.1.18.2 yamt * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 1.1.18.2 yamt * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 1.1.18.2 yamt * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 1.1.18.2 yamt * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 1.1.18.2 yamt * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 1.1.18.2 yamt * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 1.1.18.2 yamt * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 1.1.18.2 yamt * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 1.1.18.2 yamt * POSSIBILITY OF SUCH DAMAGE.
37 1.1.18.2 yamt */
38 1.1.18.2 yamt
39 1.1.18.2 yamt #include <lib/libsa/stand.h>
40 1.1.18.2 yamt #include <lib/libkern/libkern.h>
41 1.1.18.2 yamt
42 1.1.18.2 yamt #include <machine/sbd.h>
43 1.1.18.2 yamt #include <machine/gavar.h>
44 1.1.18.2 yamt
45 1.1.18.2 yamt #include "console.h" /* zskbd_print_keyscan */
46 1.1.18.2 yamt #include "cmd.h"
47 1.1.18.2 yamt #include "local.h"
48 1.1.18.2 yamt #include "common.h"
49 1.1.18.2 yamt
50 1.1.18.2 yamt struct ga ga;
51 1.1.18.2 yamt
52 1.1.18.2 yamt extern boolean_t lance_test(void);
53 1.1.18.2 yamt int fdd_test(void);
54 1.1.18.2 yamt int i82589_test(void);
55 1.1.18.2 yamt int picnic_test(void);
56 1.1.18.2 yamt int beep_test(void);
57 1.1.18.2 yamt int clut_test(int);
58 1.1.18.2 yamt
59 1.1.18.2 yamt int
60 1.1.18.2 yamt cmd_ga_test(int argc, char *argp[], int interactive)
61 1.1.18.2 yamt {
62 1.1.18.2 yamt int i;
63 1.1.18.2 yamt
64 1.1.18.2 yamt switch (strtoul(argp[1], 0, 0)) {
65 1.1.18.2 yamt default:
66 1.1.18.2 yamt break;
67 1.1.18.2 yamt case 0:
68 1.1.18.2 yamt if (SBD_INFO->machine == MACHINE_TR2A)
69 1.1.18.2 yamt ga.flags = 0x0001;
70 1.1.18.2 yamt ga_init(&ga);
71 1.1.18.2 yamt break;
72 1.1.18.2 yamt case 1:
73 1.1.18.2 yamt for (i = 0; i < 256; i++)
74 1.1.18.2 yamt fb_clear(240, 240, 240, 240, i);
75 1.1.18.2 yamt break;
76 1.1.18.2 yamt case 2:
77 1.1.18.2 yamt ga_plane_mask_test(&ga);
78 1.1.18.2 yamt break;
79 1.1.18.2 yamt }
80 1.1.18.2 yamt
81 1.1.18.2 yamt return 0;
82 1.1.18.2 yamt }
83 1.1.18.2 yamt
84 1.1.18.2 yamt int
85 1.1.18.2 yamt cmd_kbd_scancode(int argc, char *argp[], int interactive)
86 1.1.18.2 yamt {
87 1.1.18.2 yamt
88 1.1.18.2 yamt if (argc < 2) {
89 1.1.18.2 yamt printf("ks on/off\n");
90 1.1.18.2 yamt return 1;
91 1.1.18.2 yamt }
92 1.1.18.2 yamt
93 1.1.18.2 yamt if (argp[1][1] == 'n')
94 1.1.18.2 yamt zskbd_print_keyscan(1);
95 1.1.18.2 yamt else if (argp[1][1] == 'f')
96 1.1.18.2 yamt zskbd_print_keyscan(0);
97 1.1.18.2 yamt
98 1.1.18.2 yamt return 0;
99 1.1.18.2 yamt }
100 1.1.18.2 yamt
101 1.1.18.2 yamt int
102 1.1.18.2 yamt cmd_ether_test(int argc, char *argp[], int interactive)
103 1.1.18.2 yamt {
104 1.1.18.2 yamt
105 1.1.18.2 yamt if (SBD_INFO->machine == MACHINE_TR2)
106 1.1.18.2 yamt i82589_test();
107 1.1.18.2 yamt if (SBD_INFO->machine == MACHINE_TR2A)
108 1.1.18.2 yamt lance_test();
109 1.1.18.2 yamt
110 1.1.18.2 yamt return 0;
111 1.1.18.2 yamt }
112 1.1.18.2 yamt
113 1.1.18.2 yamt int
114 1.1.18.2 yamt i82589_test(void)
115 1.1.18.2 yamt {
116 1.1.18.2 yamt #define SCP_ADDR 0xa0800000
117 1.1.18.2 yamt #define IEE_ADDR ((volatile uint32_t *)0xbb060000)
118 1.1.18.2 yamt volatile uint32_t cmd;
119 1.1.18.2 yamt volatile uint16_t u16;
120 1.1.18.2 yamt int i;
121 1.1.18.2 yamt
122 1.1.18.2 yamt /* Board reset */
123 1.1.18.2 yamt *IEE_ADDR = 0;
124 1.1.18.2 yamt *IEE_ADDR = 0;
125 1.1.18.2 yamt
126 1.1.18.2 yamt for (i = 0; i < 100; i++)
127 1.1.18.2 yamt ;
128 1.1.18.2 yamt
129 1.1.18.2 yamt /* Board self test */
130 1.1.18.2 yamt *(uint32_t *)(SCP_ADDR + 4) = 0xffffffff;
131 1.1.18.2 yamt cmd = (SCP_ADDR & 0x0ffffff0) | /* i82586-mode, A24-A31 are omitted */
132 1.1.18.2 yamt 0x1/*Self test */;
133 1.1.18.2 yamt cmd = (cmd << 16) | (cmd >> 16);
134 1.1.18.2 yamt printf("self test command 0x%x\n", cmd);
135 1.1.18.2 yamt *IEE_ADDR = cmd;
136 1.1.18.2 yamt *IEE_ADDR = cmd;
137 1.1.18.2 yamt for (i = 0; i < 0x60000; i++) /* 393216 */
138 1.1.18.2 yamt if ((u16 = *(volatile uint16_t *)(SCP_ADDR + 6)) == 0)
139 1.1.18.2 yamt break;
140 1.1.18.2 yamt
141 1.1.18.2 yamt if (i != 0x60000) {
142 1.1.18.2 yamt printf("i82596 self test success. (loop %d)\n", i);
143 1.1.18.2 yamt } else {
144 1.1.18.2 yamt printf("i82586 self test failed.\n");
145 1.1.18.2 yamt return 1;
146 1.1.18.2 yamt }
147 1.1.18.2 yamt
148 1.1.18.2 yamt u16 = *(uint16_t *)(SCP_ADDR + 4);
149 1.1.18.2 yamt printf("SCP_ADDR+4=0x%x\n", u16);
150 1.1.18.2 yamt if ((u16 & 0x103c) != 0) {
151 1.1.18.2 yamt printf("i82589 self test data error.\n");
152 1.1.18.2 yamt return 1;
153 1.1.18.2 yamt } else {
154 1.1.18.2 yamt printf("i82589 self test data OK.\n");
155 1.1.18.2 yamt }
156 1.1.18.2 yamt
157 1.1.18.2 yamt return 0;
158 1.1.18.2 yamt }
159 1.1.18.2 yamt
160 1.1.18.2 yamt int
161 1.1.18.2 yamt picnic_test(void)
162 1.1.18.2 yamt {
163 1.1.18.2 yamt
164 1.1.18.2 yamt /* PICNIC test */
165 1.1.18.2 yamt printf("--------------------\n");
166 1.1.18.2 yamt printf("%x ", *(uint8_t *)0xbb000000); /* 0x00 */
167 1.1.18.2 yamt printf("%x ", *(uint8_t *)0xbb000004); /* 0xc0 */
168 1.1.18.2 yamt printf("%x ", *(uint8_t *)0xbb000008); /* 0x00 */
169 1.1.18.2 yamt printf("%x ", *(uint8_t *)0xbb000010); /* 0x01 */
170 1.1.18.2 yamt printf("\n");
171 1.1.18.2 yamt printf("%x ", *(uint8_t *)0xbb001000); /* 0x00 */
172 1.1.18.2 yamt printf("%x ", *(uint8_t *)0xbb001004); /* 0x00 */
173 1.1.18.2 yamt printf("%x ", *(uint8_t *)0xbb001008); /* 0x00 */
174 1.1.18.2 yamt printf("%x\n", *(uint8_t *)0xbb001010);/* 0x01 */
175 1.1.18.2 yamt printf("--------------------\n");
176 1.1.18.2 yamt *(uint8_t *)0xbb001010 = 0;
177 1.1.18.2 yamt #if 0
178 1.1.18.2 yamt *(uint32_t *)0xbb060000 = 0;
179 1.1.18.2 yamt #endif
180 1.1.18.2 yamt printf("--------------------\n");
181 1.1.18.2 yamt printf("%x ", *(uint8_t *)0xbb000000);
182 1.1.18.2 yamt printf("%x ", *(uint8_t *)0xbb000004);
183 1.1.18.2 yamt printf("%x ", *(uint8_t *)0xbb000008);
184 1.1.18.2 yamt printf("%x ", *(uint8_t *)0xbb000010);
185 1.1.18.2 yamt printf("\n");
186 1.1.18.2 yamt printf("%x ", *(uint8_t *)0xbb001000);
187 1.1.18.2 yamt printf("%x ", *(uint8_t *)0xbb001004);
188 1.1.18.2 yamt printf("%x ", *(uint8_t *)0xbb001008);
189 1.1.18.2 yamt printf("%x\n", *(uint8_t *)0xbb001010);
190 1.1.18.2 yamt printf("--------------------\n");
191 1.1.18.2 yamt
192 1.1.18.2 yamt return 0;
193 1.1.18.2 yamt }
194 1.1.18.2 yamt
195 1.1.18.2 yamt int
196 1.1.18.2 yamt beep_test(void)
197 1.1.18.2 yamt {
198 1.1.18.2 yamt
199 1.1.18.2 yamt /* Beep test */
200 1.1.18.2 yamt for (;;)
201 1.1.18.2 yamt *(volatile uint8_t *)0xbb007000 = 0xff;
202 1.1.18.2 yamt
203 1.1.18.2 yamt return 0;
204 1.1.18.2 yamt }
205 1.1.18.2 yamt
206 1.1.18.2 yamt int
207 1.1.18.2 yamt fdd_test(void)
208 1.1.18.2 yamt {
209 1.1.18.2 yamt
210 1.1.18.2 yamt /* ROM_FDRDWR test */
211 1.1.18.2 yamt uint8_t buf[512];
212 1.1.18.2 yamt int i, err;
213 1.1.18.2 yamt int pos, cnt;
214 1.1.18.2 yamt
215 1.1.18.2 yamt for (i = 0; i < 1989; i++) {
216 1.1.18.2 yamt memset(buf, 0, 512);
217 1.1.18.2 yamt blk_to_2d_position(i, &pos, &cnt);
218 1.1.18.2 yamt err = ROM_FD_RW(0, pos, cnt, buf);
219 1.1.18.2 yamt printf("%d err=%d\n", i, err);
220 1.1.18.2 yamt if (err != 0)
221 1.1.18.2 yamt break;
222 1.1.18.2 yamt #if 0
223 1.1.18.2 yamt for (j = 0; j < 512; j++)
224 1.1.18.2 yamt printf("%x", buf[j]);
225 1.1.18.2 yamt printf("\n");
226 1.1.18.2 yamt #else
227 1.1.18.2 yamt printf("%s\n", buf);
228 1.1.18.2 yamt #endif
229 1.1.18.2 yamt }
230 1.1.18.2 yamt return 0;
231 1.1.18.2 yamt }
232