1*6ca2c52aSchristos /* This file is part of the program psim.
2*6ca2c52aSchristos
3*6ca2c52aSchristos Copyright (C) 1994-1996, Andrew Cagney <cagney@highland.com.au>
4*6ca2c52aSchristos
5*6ca2c52aSchristos This program is free software; you can redistribute it and/or modify
6*6ca2c52aSchristos it under the terms of the GNU General Public License as published by
7*6ca2c52aSchristos the Free Software Foundation; either version 3 of the License, or
8*6ca2c52aSchristos (at your option) any later version.
9*6ca2c52aSchristos
10*6ca2c52aSchristos This program is distributed in the hope that it will be useful,
11*6ca2c52aSchristos but WITHOUT ANY WARRANTY; without even the implied warranty of
12*6ca2c52aSchristos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13*6ca2c52aSchristos GNU General Public License for more details.
14*6ca2c52aSchristos
15*6ca2c52aSchristos You should have received a copy of the GNU General Public License
16*6ca2c52aSchristos along with this program; if not, see <http://www.gnu.org/licenses/>.
17*6ca2c52aSchristos
18*6ca2c52aSchristos */
19*6ca2c52aSchristos
20*6ca2c52aSchristos
21*6ca2c52aSchristos #ifndef _HW_TRACE_C_
22*6ca2c52aSchristos #define _HW_TRACE_C_
23*6ca2c52aSchristos
24*6ca2c52aSchristos #include "device_table.h"
25*6ca2c52aSchristos #include <stdarg.h>
26*6ca2c52aSchristos
27*6ca2c52aSchristos /* DEVICE
28*6ca2c52aSchristos
29*6ca2c52aSchristos trace - the properties of this dummy device specify trace options
30*6ca2c52aSchristos
31*6ca2c52aSchristos DESCRIPTION
32*6ca2c52aSchristos
33*6ca2c52aSchristos The properties of this device are used, during initialization, to
34*6ca2c52aSchristos specify the value various simulation trace options. The
35*6ca2c52aSchristos initialization can occure implicitly (during device tree init) or
36*6ca2c52aSchristos explicitly using this devices ioctl method.
37*6ca2c52aSchristos
38*6ca2c52aSchristos The actual options and their default values (for a given target)
39*6ca2c52aSchristos are defined in the file debug.
40*6ca2c52aSchristos
41*6ca2c52aSchristos This device is normally a child of the /openprom node.
42*6ca2c52aSchristos
43*6ca2c52aSchristos EXAMPLE
44*6ca2c52aSchristos
45*6ca2c52aSchristos The trace option dump-device-tree can be enabled by specifying the
46*6ca2c52aSchristos option:
47*6ca2c52aSchristos
48*6ca2c52aSchristos | -o '/openprom/trace/dump-device-tree 0x1'
49*6ca2c52aSchristos
50*6ca2c52aSchristos Alternativly the shorthand version:
51*6ca2c52aSchristos
52*6ca2c52aSchristos | -t dump-device-tree
53*6ca2c52aSchristos
54*6ca2c52aSchristos can be used. */
55*6ca2c52aSchristos
56*6ca2c52aSchristos
57*6ca2c52aSchristos /* Hook to allow the initialization of the trace options at any time */
58*6ca2c52aSchristos
59*6ca2c52aSchristos static int
hw_trace_ioctl(device * me,cpu * processor,unsigned_word cia,device_ioctl_request request,va_list ap)60*6ca2c52aSchristos hw_trace_ioctl(device *me,
61*6ca2c52aSchristos cpu *processor,
62*6ca2c52aSchristos unsigned_word cia,
63*6ca2c52aSchristos device_ioctl_request request,
64*6ca2c52aSchristos va_list ap)
65*6ca2c52aSchristos {
66*6ca2c52aSchristos switch (request) {
67*6ca2c52aSchristos case device_ioctl_set_trace:
68*6ca2c52aSchristos {
69*6ca2c52aSchristos const device_property *prop = device_find_property(me, NULL);
70*6ca2c52aSchristos while (prop != NULL) {
71*6ca2c52aSchristos const char *name = prop->name;
72*6ca2c52aSchristos unsigned32 value = device_find_integer_property(me, name);
73*6ca2c52aSchristos trace_option(name, value);
74*6ca2c52aSchristos prop = device_next_property(prop);
75*6ca2c52aSchristos }
76*6ca2c52aSchristos }
77*6ca2c52aSchristos break;
78*6ca2c52aSchristos default:
79*6ca2c52aSchristos device_error(me, "insupported ioctl request");
80*6ca2c52aSchristos break;
81*6ca2c52aSchristos }
82*6ca2c52aSchristos return 0;
83*6ca2c52aSchristos }
84*6ca2c52aSchristos
85*6ca2c52aSchristos
86*6ca2c52aSchristos static device_callbacks const hw_trace_callbacks = {
87*6ca2c52aSchristos { NULL, }, /* init */
88*6ca2c52aSchristos { NULL, }, /* address */
89*6ca2c52aSchristos { NULL, }, /* IO */
90*6ca2c52aSchristos { NULL, }, /* DMA */
91*6ca2c52aSchristos { NULL, }, /* interrupt */
92*6ca2c52aSchristos { NULL, }, /* unit */
93*6ca2c52aSchristos NULL, /* instance-create */
94*6ca2c52aSchristos hw_trace_ioctl,
95*6ca2c52aSchristos };
96*6ca2c52aSchristos
97*6ca2c52aSchristos const device_descriptor hw_trace_device_descriptor[] = {
98*6ca2c52aSchristos { "trace", NULL, &hw_trace_callbacks },
99*6ca2c52aSchristos { NULL },
100*6ca2c52aSchristos };
101*6ca2c52aSchristos
102*6ca2c52aSchristos #endif /* _HW_TRACE_C_ */
103