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]
22 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
27 * Kernel Run-Time Linker/Loader private interfaces.
30 #ifndef _SYS_KOBJ_IMPL_H
31 #define _SYS_KOBJ_IMPL_H
33 #pragma ident "%Z%%M% %I% %E% SMI"
43 * Boot/aux vector attributes.
78 * Implementation-specific flags.
80 #define KOBJ_EXEC 0x0004 /* executable (unix module) */
81 #define KOBJ_INTERP 0x0008 /* the interpreter module */
82 #define KOBJ_PRIM 0x0010 /* a primary kernel module */
83 #define KOBJ_RESOLVED 0x0020 /* fully resolved */
84 #define KOBJ_TNF_PROBE 0x0040 /* Contains TNF probe(s) */
85 #define KOBJ_RELOCATED 0x0080 /* relocation completed */
86 #define KOBJ_NOPARENTS 0x0200 /* nothing can depend on this module */
87 #define KOBJ_IGNMULDEF 0x0400 /* ignore dups during sym resolution */
88 #define KOBJ_NOKSYMS 0x0800 /* module's symbols don't go into ksyms */
89 #define KOBJ_EXPORTED 0x1000 /* ctf, syms copied to vmem */
92 * kobj_notify_add() data notification structure
94 typedef void kobj_notify_f(uint_t
, struct modctl
*);
96 typedef struct kobj_notify_list
{
97 kobj_notify_f
*kn_func
; /* notification func */
98 uint_t kn_type
; /* notification type */
99 struct kobj_notify_list
*kn_prev
;
100 struct kobj_notify_list
*kn_next
;
101 } kobj_notify_list_t
;
104 * krtld can provide notification to external clients on the
107 #define KOBJ_NOTIFY_MODLOADING 1 /* very early in module load */
108 #define KOBJ_NOTIFY_MODUNLOADING 2 /* before module unload */
109 #define KOBJ_NOTIFY_MODLOADED 3 /* after module load */
110 #define KOBJ_NOTIFY_MODUNLOADED 4 /* after module unload */
111 #define KOBJ_NOTIFY_MAX 4
113 #define ALIGN(x, a) ((a) == 0 ? (uintptr_t)(x) : \
114 (((uintptr_t)(x) + (uintptr_t)(a) - 1l) & ~((uintptr_t)(a) - 1l)))
124 #define D_DEBUG 0x001 /* general debugging */
125 #define D_SYMBOLS 0x002 /* debug symbols */
126 #define D_RELOCATIONS 0x004 /* debug relocations */
127 #define D_LOADING 0x008 /* section loading */
129 extern int kobj_debug
; /* different than moddebug */
133 * Flags for kobj memory allocation.
135 #define KM_WAIT 0x0 /* wait for it */
136 #define KM_NOWAIT 0x1 /* return immediately */
138 #define KM_TMP 0x1000 /* freed before kobj_init returns */
139 #define KM_SCRATCH 0x2000 /* not freed until kobj_sync */
141 #ifdef KOBJ_OVERRIDES
143 * Until the kernel is fully linked, all code running in the
144 * context of krtld/kobj using bcopy or bzero must be directed
145 * to the kobj equivalents. All (ok, most) references to bcopy
146 * or bzero are thus so vectored.
148 #define bcopy(s, d, n) kobj_bcopy((s), (d), (n))
149 #define bzero(p, n) kobj_bzero((p), (n))
150 #define strlcat(s, d, n) kobj_strlcat((s), (d), (n))
153 extern kdi_t kobj_kdi
;
157 extern struct modctl_list
*kobj_linkmaps
[];
159 extern char *kobj_kmdb_argv
[];
161 extern int kobj_mmu_pagesize
;
163 extern void kobj_init(void *romvec
, void *dvec
,
164 struct bootops
*bootvec
, val_t
*bootaux
);
165 extern int kobj_notify_add(kobj_notify_list_t
*);
166 extern int kobj_notify_remove(kobj_notify_list_t
*);
167 extern int do_relocations(struct module
*);
168 extern int do_relocate(struct module
*, char *, Word
, int, int, Addr
);
169 extern struct bootops
*ops
;
170 extern void exitto(caddr_t
);
171 extern void kobj_sync_instruction_memory(caddr_t
, size_t);
172 extern uint_t
kobj_gethashsize(uint_t
);
173 extern void * kobj_mod_alloc(struct module
*, size_t, int, reloc_dest_t
*);
174 extern void mach_alloc_funcdesc(struct module
*);
175 extern uint_t
kobj_hash_name(const char *);
176 extern caddr_t
kobj_segbrk(caddr_t
*, size_t, size_t, caddr_t
);
177 extern int get_progbits_size(struct module
*, struct proginfo
*,
178 struct proginfo
*, struct proginfo
*);
179 extern Sym
*kobj_lookup_kernel(const char *);
180 extern struct modctl
*kobj_boot_mod_lookup(const char *);
181 extern void kobj_export_module(struct module
*);
182 extern int kobj_load_primary_module(struct modctl
*);
183 extern int boot_compinfo(int, struct compinfo
*);
184 extern void mach_modpath(char *, const char *);
186 extern void kobj_setup_standalone_vectors(void);
187 extern void kobj_restore_vectors(void);
188 extern void (*_kobj_printf
)(void *, const char *fmt
, ...);
189 extern void (*kobj_bcopy
)(const void *, void *, size_t);
190 extern void (*kobj_bzero
)(void *, size_t);
191 extern size_t (*kobj_strlcat
)(char *, const char *, size_t);
193 #define KOBJ_LM_PRIMARY 0x0
194 #define KOBJ_LM_DEBUGGER 0x1
196 extern void kobj_lm_append(int, struct modctl
*modp
);
197 extern struct modctl_list
*kobj_lm_lookup(int);
198 extern void kobj_lm_dump(int);
204 #endif /* _SYS_KOBJ_IMPL_H */