source: rtems-libbsd/rtemsbsd/src/rtems-bsd-shell.c @ 8420b94

4.115-freebsd-12freebsd-9.3
Last change on this file since 8420b94 was 8420b94, checked in by Jennifer Averett <jennifer.averett@…>, on May 8, 2012 at 2:14:42 PM

Modified copyright on rtems-bsd-xxx files to be consistant with FreeBSD copyright.

  • Property mode set to 100644
File size: 4.6 KB
Line 
1/**
2 * @file
3 *
4 * @ingroup rtems_bsd_rtems
5 *
6 * @brief TODO.
7 */
8
9/*
10 * Copyright (c) 2009, 2010 embedded brains GmbH.  All rights reserved.
11 *
12 *  embedded brains GmbH
13 *  Obere Lagerstr. 30
14 *  82178 Puchheim
15 *  Germany
16 *  <rtems@embedded-brains.de>
17 *
18 * Redistribution and use in source and binary forms, with or without
19 * modification, are permitted provided that the following conditions
20 * are met:
21 * 1. Redistributions of source code must retain the above copyright
22 *    notice, this list of conditions and the following disclaimer.
23 * 2. Redistributions in binary form must reproduce the above copyright
24 *    notice, this list of conditions and the following disclaimer in the
25 *    documentation and/or other materials provided with the distribution.
26 *
27 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
28 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
31 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
32 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
33 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
34 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 * SUCH DAMAGE.
38 */
39
40#include <freebsd/machine/rtems-bsd-config.h>
41
42#include <freebsd/sys/param.h>
43#include <freebsd/sys/types.h>
44#include <freebsd/sys/systm.h>
45#include <freebsd/sys/lock.h>
46#include <freebsd/sys/mutex.h>
47#include <freebsd/sys/callout.h>
48#include <freebsd/sys/condvar.h>
49#include <freebsd/sys/proc.h>
50
51#include <freebsd/bsd.h>
52#include <rtems/shell.h>
53
54static void
55rtems_bsd_dump_callout(void)
56{
57        rtems_chain_control *chain = &rtems_bsd_callout_chain;
58        rtems_chain_node *node = rtems_chain_first(chain);
59
60        printf("callout dump:\n");
61
62        while (!rtems_chain_is_tail(chain, node)) {
63                struct callout *c = (struct callout *) node;
64
65                printf("\t%08x\n", c->c_id);
66
67                node = rtems_chain_next(node);
68        }
69}
70
71static void
72rtems_bsd_dump_mtx(void)
73{
74        rtems_chain_control *chain = &rtems_bsd_mtx_chain;
75        rtems_chain_node *node = rtems_chain_first(chain);
76
77        printf("mtx dump:\n");
78
79        while (!rtems_chain_is_tail(chain, node)) {
80                struct lock_object *lo = (struct lock_object *) node;
81
82                printf("\t%s: 0x%08x\n", lo->lo_name, lo->lo_id);
83
84                node = rtems_chain_next(node);
85        }
86}
87
88static void
89rtems_bsd_dump_sx(void)
90{
91        rtems_chain_control *chain = &rtems_bsd_sx_chain;
92        rtems_chain_node *node = rtems_chain_first(chain);
93
94        printf("sx dump:\n");
95
96        while (!rtems_chain_is_tail(chain, node)) {
97                struct lock_object *lo = (struct lock_object *) node;
98
99                printf("\t%s: 0x%08x\n", lo->lo_name, lo->lo_id);
100
101                node = rtems_chain_next(node);
102        }
103}
104
105static void
106rtems_bsd_dump_condvar(void)
107{
108        rtems_chain_control *chain = &rtems_bsd_condvar_chain;
109        rtems_chain_node *node = rtems_chain_first(chain);
110
111        printf("condvar dump:\n");
112
113        while (!rtems_chain_is_tail(chain, node)) {
114                struct cv *cv = (struct cv *) node;
115
116                printf("\t%s: 0x%08x\n", cv->cv_description, cv->cv_id);
117
118                node = rtems_chain_next(node);
119        }
120}
121
122static void
123rtems_bsd_dump_thread(void)
124{
125        rtems_chain_control *chain = &rtems_bsd_thread_chain;
126        rtems_chain_node *node = rtems_chain_first(chain);
127
128        printf("thread dump:\n");
129
130        while (!rtems_chain_is_tail(chain, node)) {
131                struct thread *td = (struct thread *) node;
132
133                printf("\t%s: 0x%08x\n", td->td_name, td->td_id);
134
135                node = rtems_chain_next(node);
136        }
137}
138
139static const char rtems_bsd_usage [] =
140        "bsd {all|mtx|sx|condvar|thread|callout}";
141
142#define CMP(s) all || strcasecmp(argv [1], s) == 0
143
144static int
145rtems_bsd_info(int argc, char **argv)
146{
147        bool usage = true;
148
149        if (argc == 2) {
150                bool all = false;
151
152                if (CMP("all")) {
153                        all = true;
154                }
155
156                if (CMP("mtx")) {
157                        rtems_bsd_dump_mtx();
158                        usage = false;
159                }
160                if (CMP("sx")) {
161                        rtems_bsd_dump_sx();
162                        usage = false;
163                }
164                if (CMP("condvar")) {
165                        rtems_bsd_dump_condvar();
166                        usage = false;
167                }
168                if (CMP("thread")) {
169                        rtems_bsd_dump_thread();
170                        usage = false;
171                }
172                if (CMP("callout")) {
173                        rtems_bsd_dump_callout();
174                        usage = false;
175                }
176        }
177
178        if (usage) {
179                puts(rtems_bsd_usage);
180        }
181
182        return 0;
183}
184
185static rtems_shell_cmd_t rtems_bsd_info_command = {
186        .name = "bsd",
187        .usage = rtems_bsd_usage,
188        .topic = "bsp",
189        .command = rtems_bsd_info,
190        .alias = NULL,
191        .next = NULL
192};
193
194void
195rtems_bsd_shell_initialize(void)
196{
197        rtems_shell_add_cmd_struct(&rtems_bsd_info_command);
198}
Note: See TracBrowser for help on using the repository browser.