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