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