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

4.1155-freebsd-126-freebsd-12freebsd-9.3
Last change on this file since be8032d was 6ad03bf, checked in by Joel Sherrill <joel.sherrill@…>, on 03/08/12 at 16:31:56

Remove rtems/ from includes of RTEMS specific files

  • Property mode set to 100644
File size: 3.5 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 * The license and distribution terms for this file may be
19 * found in the file LICENSE in this distribution or at
20 * http://www.rtems.com/license/LICENSE.
21 */
22
23#include <freebsd/machine/rtems-bsd-config.h>
24
25#include <freebsd/sys/param.h>
26#include <freebsd/sys/types.h>
27#include <freebsd/sys/systm.h>
28#include <freebsd/sys/lock.h>
29#include <freebsd/sys/mutex.h>
30#include <freebsd/sys/callout.h>
31#include <freebsd/sys/condvar.h>
32#include <freebsd/sys/proc.h>
33
34#include <freebsd/bsd.h>
35#include <rtems/shell.h>
36
37static void
38rtems_bsd_dump_callout(void)
39{
40        rtems_chain_control *chain = &rtems_bsd_callout_chain;
41        rtems_chain_node *node = rtems_chain_first(chain);
42
43        printf("callout dump:\n");
44
45        while (!rtems_chain_is_tail(chain, node)) {
46                struct callout *c = (struct callout *) node;
47
48                printf("\t%08x\n", c->c_id);
49
50                node = rtems_chain_next(node);
51        }
52}
53
54static void
55rtems_bsd_dump_mtx(void)
56{
57        rtems_chain_control *chain = &rtems_bsd_mtx_chain;
58        rtems_chain_node *node = rtems_chain_first(chain);
59
60        printf("mtx dump:\n");
61
62        while (!rtems_chain_is_tail(chain, node)) {
63                struct lock_object *lo = (struct lock_object *) node;
64
65                printf("\t%s: 0x%08x\n", lo->lo_name, lo->lo_id);
66
67                node = rtems_chain_next(node);
68        }
69}
70
71static void
72rtems_bsd_dump_sx(void)
73{
74        rtems_chain_control *chain = &rtems_bsd_sx_chain;
75        rtems_chain_node *node = rtems_chain_first(chain);
76
77        printf("sx 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_condvar(void)
90{
91        rtems_chain_control *chain = &rtems_bsd_condvar_chain;
92        rtems_chain_node *node = rtems_chain_first(chain);
93
94        printf("condvar dump:\n");
95
96        while (!rtems_chain_is_tail(chain, node)) {
97                struct cv *cv = (struct cv *) node;
98
99                printf("\t%s: 0x%08x\n", cv->cv_description, cv->cv_id);
100
101                node = rtems_chain_next(node);
102        }
103}
104
105static void
106rtems_bsd_dump_thread(void)
107{
108        rtems_chain_control *chain = &rtems_bsd_thread_chain;
109        rtems_chain_node *node = rtems_chain_first(chain);
110
111        printf("thread dump:\n");
112
113        while (!rtems_chain_is_tail(chain, node)) {
114                struct thread *td = (struct thread *) node;
115
116                printf("\t%s: 0x%08x\n", td->td_name, td->td_id);
117
118                node = rtems_chain_next(node);
119        }
120}
121
122static const char rtems_bsd_usage [] =
123        "bsd {all|mtx|sx|condvar|thread|callout}";
124
125#define CMP(s) all || strcasecmp(argv [1], s) == 0
126
127static int
128rtems_bsd_info(int argc, char **argv)
129{
130        bool usage = true;
131
132        if (argc == 2) {
133                bool all = false;
134
135                if (CMP("all")) {
136                        all = true;
137                }
138
139                if (CMP("mtx")) {
140                        rtems_bsd_dump_mtx();
141                        usage = false;
142                }
143                if (CMP("sx")) {
144                        rtems_bsd_dump_sx();
145                        usage = false;
146                }
147                if (CMP("condvar")) {
148                        rtems_bsd_dump_condvar();
149                        usage = false;
150                }
151                if (CMP("thread")) {
152                        rtems_bsd_dump_thread();
153                        usage = false;
154                }
155                if (CMP("callout")) {
156                        rtems_bsd_dump_callout();
157                        usage = false;
158                }
159        }
160
161        if (usage) {
162                puts(rtems_bsd_usage);
163        }
164
165        return 0;
166}
167
168static rtems_shell_cmd_t rtems_bsd_info_command = {
169        .name = "bsd",
170        .usage = rtems_bsd_usage,
171        .topic = "bsp",
172        .command = rtems_bsd_info,
173        .alias = NULL,
174        .next = NULL
175};
176
177void
178rtems_bsd_shell_initialize(void)
179{
180        rtems_shell_add_cmd_struct(&rtems_bsd_info_command);
181}
Note: See TracBrowser for help on using the repository browser.