dmake: do not set MAKEFLAGS=k
[unleashed/tickless.git] / usr / src / cmd / mdb / common / kmdb / kctl / kctl_auxv.c
blob773a0887837a85ddf18ca3bd4bf11f3a84e660a6
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
22 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 #pragma ident "%Z%%M% %I% %E% SMI"
28 #include <kmdb/kctl/kctl.h>
30 #include <sys/modctl.h>
31 #include <sys/bootconf.h>
32 #include <sys/kobj.h>
33 #include <sys/kobj_impl.h>
34 #include <sys/kmdb.h>
36 static uintptr_t
37 kctl_lookup_by_name(char *modname, char *symname)
39 struct modctl *mctl;
40 Sym *ksym;
41 uintptr_t addr;
43 if ((mctl = mod_hold_by_name(modname)) == NULL)
44 return (0);
45 if ((ksym = kobj_lookup_all(mctl->mod_mp, symname, 1)) == NULL) {
46 mod_release_mod(mctl);
47 return (0);
50 addr = ksym->st_value;
52 mod_release_mod(mctl);
54 return (addr);
57 static uintptr_t
58 kctl_boot_lookup_by_name(char *modname, char *symname)
60 struct modctl *mctl;
61 Sym *ksym;
63 if ((mctl = kobj_boot_mod_lookup(modname)) == NULL)
64 return (0);
66 if ((ksym = kobj_lookup_all(mctl->mod_mp, symname, 1)) == NULL)
67 return (0);
69 return (ksym->st_value);
72 void
73 kctl_auxv_init(kmdb_auxv_t *kav, const char *cfg, const char **argv, void *romp)
75 bzero(kav, sizeof (kmdb_auxv_t));
76 kav->kav_dseg = kctl.kctl_dseg;
77 kav->kav_dseg_size = kctl.kctl_dseg_size;
78 kav->kav_pagesize = PAGESIZE;
79 kav->kav_ncpu = NCPU;
80 kav->kav_kdi = &kobj_kdi;
81 kav->kav_wrintr_fire = kctl_wrintr_fire;
83 kav->kav_config = cfg;
84 kav->kav_argv = argv;
85 kav->kav_modpath = kobj_module_path;
87 kctl_dprintf("kctl_auxv_init: modpath '%s'", kav->kav_modpath);
89 if (kctl.kctl_boot_loaded) {
90 kav->kav_lookup_by_name = kctl_boot_lookup_by_name;
91 kav->kav_flags |= KMDB_AUXV_FL_NOUNLOAD;
92 } else
93 kav->kav_lookup_by_name = kctl_lookup_by_name;
95 if (kctl.kctl_flags & KMDB_F_TRAP_NOSWITCH)
96 kav->kav_flags |= KMDB_AUXV_FL_NOTRPSWTCH;
98 kctl_auxv_init_isadep(kav, romp); /* can modify anything in kav */
101 void
102 kctl_auxv_fini(kmdb_auxv_t *kav)
104 kctl_auxv_fini_isadep(kav);