8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / lib / efcode / fcdriver / fcdebug.c
blobfee58574ebcff0a2628ace4a01cfc85c88f68a3e
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
7 * with the License.
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
20 * CDDL HEADER END
23 * Copyright (c) 1999 by Sun Microsystems, Inc.
24 * All rights reserved.
27 #pragma ident "%Z%%M% %I% %E% SMI"
29 #include <sys/stat.h>
30 #include <fcntl.h>
31 #include <unistd.h>
32 #include <stdlib.h>
33 #include <stdio.h>
34 #include <strings.h>
36 #include <fcode/private.h>
37 #include <fcode/log.h>
39 #include <fcdriver/fcdriver.h>
41 static void
42 dump_private(fcode_env_t *env)
44 common_data_t *cdp;
45 private_data_t *p;
47 if (env->current_device) {
48 p = env->current_device->private;
49 if (p) {
50 cdp = p->common;
51 } else
52 cdp = NULL;
53 } else {
54 cdp = env->private;
55 p = NULL;
58 if (cdp == NULL) {
59 log_message(MSG_ERROR, "dump_private: NULL private ptr!\n");
60 return;
63 log_message(MSG_DEBUG, "Private Data:\n");
64 log_message(MSG_DEBUG, "Progname: %s\n", cdp->Progname);
65 log_message(MSG_DEBUG, "fcode_fd: %8p\n", cdp->fcode_fd);
66 log_message(MSG_DEBUG, "attach: %llx\n", cdp->attach);
67 log_message(MSG_DEBUG, "Params: (%8p)\n", &cdp->fc);
68 log_message(MSG_DEBUG, " size: %d\n", cdp->fc.fcode_size);
69 log_message(MSG_DEBUG, " unit: %s\n", cdp->fc.unit_address);
70 if (p != NULL) {
71 log_message(MSG_DEBUG, "Node: %p\n", p->node);
72 log_message(MSG_DEBUG, "Parent: %p\n", p->parent);
73 log_message(MSG_DEBUG, "upload: %d\n", p->upload);
74 log_message(MSG_DEBUG, "debug: %8x\n", p->debug);
78 static void
79 trigger(fcode_env_t *env)
81 common_data_t *cdp = (common_data_t *)env->private;
83 ASSERT(cdp);
85 cdp->fcode_fd = open("/dev/fcode", O_RDONLY);
86 if (cdp->fcode_fd >= 0) {
87 log_message(MSG_INFO, "Trigger...");
88 if (!fc_get_request(cdp))
89 log_message(MSG_ERROR, "fc_get_request failed\n");
90 else
91 log_message(MSG_INFO, "\n");
92 } else
93 forth_abort(env, "Can't open /dev/fcode\n");
96 static void
97 do_trigger(fcode_env_t *env)
99 trigger(env);
100 build_tree(env);
101 install_builtin_nodes(env);
104 #pragma init(_init)
106 static void
107 _init(void)
109 fcode_env_t *env = initial_env;
111 ASSERT(env);
112 NOTICE;
114 FORTH(0, "dump-private", dump_private);
115 FORTH(0, "trigger", do_trigger);