1 /* $NetBSD: monitor.c,v 1.6 2006/04/10 18:40:06 garbled Exp $ */
4 * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
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.
34 #include <lib/libsa/stand.h>
35 #include <lib/libkern/libkern.h>
43 void db_cmd_dump(int, char **);
44 void db_cmd_get(int, char **);
45 void db_cmd_mf(int, char **);
46 void db_cmd_mt(int, char **);
47 void db_cmd_put(int, char **);
48 void db_cmd_help(int, char **);
50 unsigned int mfmsr((void);
51 void mtmsr(unsigned int);
57 void (*fcn
)(int, char **);
59 { "dump", db_cmd_dump
},
60 { "get", db_cmd_get
},
63 { "put", db_cmd_put
},
64 { "help", db_cmd_help
},
81 for(p
= line
, argc
= 0; *p
!= '\0'; p
++) {
82 if (*p
!= ' ' && *p
!= '\t') {
99 while (db_cmd
[tmp
].name
!= NULL
) {
100 if (!strcmp("continue", argv
[0]))
102 if (!strcmp(db_cmd
[tmp
].name
, argv
[0])) {
103 (db_cmd
[tmp
].fcn
)(argc
, argv
);
108 if (db_cmd
[tmp
].name
== NULL
)
109 db_cmd_help(argc
, argv
);
117 int b
= 0, width
, tmp
, exp
, x
= 0;
126 for (tmp
= 1; tmp
<= width
; tmp
++)
127 exp
*= (x
? 16 : 10);
128 if (*p
>= '0' && *p
<= '9') {
140 db_cmd_dump(int argc
, char **argv
)
143 int mode
, add
, size
, i
;
178 printf("\n0x%x:", add
);
181 printf(" %x", *(unsigned char *)add
);
188 printf(" %x", *(unsigned short *)add
);
195 printf(" %x", *(unsigned int *)add
);
207 printf("dump [-b][-h][-w] address size\n");
212 db_cmd_get(int argc
, char **argv
)
244 printf("0x%x: ", add
);
247 printf("0x%x", *(char *)add
);
250 printf("0x%x", *(short *)add
);
253 printf("0x%x", *(int *)add
);
260 printf("get [-b][-h][-w] address\n");
265 db_cmd_put(int argc
, char **argv
)
300 printf("0x%x: 0x%x", add
, data
);
306 *(short *)add
= data
;
316 printf("put [-b][-h][-w] address data\n");
323 unsigned int mf ## x() { \
325 __asm volatile (STR(mf ## x %0) : STR(=r)(tmp)); \
328 void mt ## x(unsigned int data) \
330 __asm volatile (STR(mt ## x %0) :: STR(r)(data)); \
334 { #x, mf ## x, mt ## x }
340 unsigned int (*mf
)(void);
341 void (*mt
)(unsigned int);
344 { NULL
, NULL
, NULL
},
348 db_cmd_mf(int argc
, char **argv
)
353 printf("mf register\nregister:");
354 while (mreg
[i
].op
!= NULL
)
355 printf(" %s", mreg
[i
++].op
);
360 while (mreg
[i
].op
!= NULL
) {
361 if (!strcmp(mreg
[i
].op
, argv
[1])) {
362 printf(" 0x%x\n", (mreg
[i
].mf
)());
370 db_cmd_mt(int argc
, char **argv
)
375 printf("mt register data\nregister:");
376 while (mreg
[i
].op
!= NULL
)
377 printf(" %s", mreg
[i
++].op
);
382 while (mreg
[i
].op
!= NULL
) {
383 if (!strcmp(mreg
[i
].op
, argv
[1])) {
384 (mreg
[i
].mt
)((unsigned int)db_atob(argv
[2]));
385 printf(" 0x%x\n", db_atob(argv
[2]));
393 db_cmd_help(int argc
, char **argv
)
397 while (db_cmd
[i
].name
!= NULL
)
398 printf("%s, ", db_cmd
[i
++].name
);
399 printf("continue\n");
402 #endif /* DBMONITOR */