6811333 Remove prom_printf() message in emlxs driver
[opensolaris.git] / usr / src / lib / libc / port / gen / rctlops.c
blobc61eb8ec41121f01cf1f8287d95a97188c16dcf6
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
19 * CDDL HEADER END
23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #pragma ident "%Z%%M% %I% %E% SMI"
29 #include "lint.h"
30 #include <sys/rctl_impl.h>
31 #include <stdlib.h>
32 #include <string.h>
33 #include <rctl.h>
36 * Resource control routines
38 * rctl_walk(3C)
40 * Resource control block manipulation routines
41 * The setrctl(2) and getrctl(2) interfaces are accessed via opaque resource
42 * control blocks, the characteristics of which are in turn set and fetched
43 * using the following functions. Applications using the following interfaces
44 * will be binary compatible across enhancements to the resource control
45 * subsystem that involve modification of the control block.
47 int
48 rctl_walk(int (*callback)(const char *rctlname, void *walk_data),
49 void *init_data)
51 int ret = 0;
52 char *ctl_names, *curr_name;
53 size_t sz = rctllist(NULL, 0);
55 if ((ctl_names = malloc(sz)) == NULL)
56 return (-1);
58 (void) rctllist(ctl_names, sz);
60 for (curr_name = ctl_names;
61 curr_name < ctl_names + sz;
62 curr_name += strlen(curr_name) + 1) {
63 if (ret = callback(curr_name, init_data)) {
64 free(ctl_names);
65 return (ret);
69 free(ctl_names);
70 return (ret);
73 uint_t
74 rctlblk_get_global_action(rctlblk_t *rblk)
76 rctl_opaque_t *ropaque = (rctl_opaque_t *)rblk;
78 return (ropaque->rcq_global_flagaction & (~RCTL_GLOBAL_ACTION_MASK));
81 uint_t
82 rctlblk_get_local_action(rctlblk_t *rblk, int *signal)
84 rctl_opaque_t *ropaque = (rctl_opaque_t *)rblk;
86 if (signal != NULL)
87 *signal = ropaque->rcq_local_signal;
88 return (ropaque->rcq_local_flagaction & (~RCTL_LOCAL_ACTION_MASK));
91 uint_t
92 rctlblk_get_global_flags(rctlblk_t *rblk)
94 rctl_opaque_t *ropaque = (rctl_opaque_t *)rblk;
96 return (ropaque->rcq_global_flagaction & RCTL_GLOBAL_ACTION_MASK);
99 uint_t
100 rctlblk_get_local_flags(rctlblk_t *rblk)
102 rctl_opaque_t *ropaque = (rctl_opaque_t *)rblk;
104 return (ropaque->rcq_local_flagaction & RCTL_LOCAL_ACTION_MASK);
107 hrtime_t
108 rctlblk_get_firing_time(rctlblk_t *rblk)
110 rctl_opaque_t *ropaque = (rctl_opaque_t *)rblk;
112 return (ropaque->rcq_firing_time);
115 id_t
116 rctlblk_get_recipient_pid(rctlblk_t *rblk)
118 rctl_opaque_t *ropaque = (rctl_opaque_t *)rblk;
120 return (ropaque->rcq_local_recipient_pid);
123 rctl_priv_t
124 rctlblk_get_privilege(rctlblk_t *rblk)
126 rctl_opaque_t *ropaque = (rctl_opaque_t *)rblk;
127 return (ropaque->rcq_privilege);
130 rctl_qty_t
131 rctlblk_get_value(rctlblk_t *rblk)
133 rctl_opaque_t *ropaque = (rctl_opaque_t *)rblk;
134 return (ropaque->rcq_value);
137 rctl_qty_t
138 rctlblk_get_enforced_value(rctlblk_t *rblk)
140 rctl_opaque_t *ropaque = (rctl_opaque_t *)rblk;
141 return (ropaque->rcq_enforced_value);
144 void
145 rctlblk_set_local_action(rctlblk_t *rblk, uint_t action, int signal)
147 rctl_opaque_t *ropaque = (rctl_opaque_t *)rblk;
148 ropaque->rcq_local_signal = signal;
149 ropaque->rcq_local_flagaction = (ropaque->rcq_local_flagaction &
150 RCTL_LOCAL_ACTION_MASK) | (action & ~RCTL_LOCAL_ACTION_MASK);
153 void
154 rctlblk_set_local_flags(rctlblk_t *rblk, uint_t flags)
156 rctl_opaque_t *ropaque = (rctl_opaque_t *)rblk;
157 ropaque->rcq_local_flagaction = (ropaque->rcq_local_flagaction &
158 ~RCTL_LOCAL_ACTION_MASK) | (flags & RCTL_LOCAL_ACTION_MASK);
161 void
162 rctlblk_set_recipient_pid(rctlblk_t *rblk, id_t pid)
164 rctl_opaque_t *ropaque = (rctl_opaque_t *)rblk;
165 ropaque->rcq_local_recipient_pid = pid;
168 void
169 rctlblk_set_privilege(rctlblk_t *rblk, rctl_priv_t privilege)
171 rctl_opaque_t *ropaque = (rctl_opaque_t *)rblk;
172 ropaque->rcq_privilege = privilege;
175 void
176 rctlblk_set_value(rctlblk_t *rblk, rctl_qty_t value)
178 rctl_opaque_t *ropaque = (rctl_opaque_t *)rblk;
179 ropaque->rcq_value = value;
182 size_t
183 rctlblk_size(void)
185 return (sizeof (rctl_opaque_t));