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.
29 #pragma ident "%Z%%M% %I% %E% SMI"
31 #include <sys/modctl.h>
33 #include <sys/machelf.h>
36 #include <sys/bootstat.h>
43 * List of modules maintained by kobj.c
46 struct module_list
*next
;
50 typedef unsigned short symid_t
; /* symbol table index */
51 typedef unsigned char *reloc_dest_t
;
53 typedef void module_mach
;
60 Shdr
*symhdr
, *strhdr
;
65 char *symspace
; /* symbols + strings + hashtbl, or NULL */
73 unsigned int symtbl_section
;
74 /* pointers into symspace, or NULL */
78 unsigned int hashsize
;
84 unsigned int bss_align
;
90 struct module_list
*head
, *tail
;
91 reloc_dest_t destination
;
92 module_mach
* machdata
;
100 caddr_t textwin_base
;
102 sdt_probedesc_t
*sdt_probes
;
112 struct kobj_mem
*km_next
;
113 struct kobj_mem
*km_prev
;
116 uintptr_t km_alloc_addr
;
117 size_t km_alloc_size
;
146 #define kobj_filename(p) ((p)->_name)
147 #define kobj_linenum(p) ((p)->_ln)
148 #define kobj_newline(p) ((p)->_ln++)
149 #define kobj_getc(p) (--(p)->_cnt >= 0 ? ((int)*(p)->_ptr++):kobj_filbuf(p))
150 #define kobj_ungetc(p) (++(p)->_cnt > (p)->_size ? -1 : ((int)*(--(p)->_ptr)))
151 #define kobj_comphdr(p) ((struct comphdr *)(p)->_dbuf)
153 /* Offset into buffer */
154 #define B_OFFSET(file, off) (off % (file)->_bsize)
157 #define F_PAGE(file, off) (off - B_OFFSET(file, off))
159 #define F_BLKS(file, size) ((size / (file)->_bsize) * (file)->_bsize)
163 extern int kobj_load_module(struct modctl
*, int);
164 extern void kobj_unload_module(struct modctl
*);
165 extern uintptr_t kobj_lookup(struct module
*, const char *);
166 extern Sym
*kobj_lookup_all(struct module
*, char *, int);
167 extern int kobj_addrcheck(void *, caddr_t
);
168 extern int kobj_module_to_id(void *);
169 extern void kobj_getmodinfo(void *, struct modinfo
*);
170 extern int kobj_get_needed(void *, short *, int);
171 extern uintptr_t kobj_getsymvalue(char *, int);
172 extern char *kobj_getsymname(uintptr_t, ulong_t
*);
173 extern char *kobj_searchsym(struct module
*, uintptr_t, ulong_t
*);
175 extern int kobj_fstat(intptr_t, struct bootstat
*);
176 extern intptr_t kobj_open(char *);
177 extern int kobj_path_exists(char *, int);
178 extern struct _buf
*kobj_open_path(char *, int);
179 extern int kobj_read(intptr_t, char *, unsigned int, unsigned int);
180 extern void kobj_close(intptr_t);
181 extern void *kobj_alloc(size_t, int);
182 extern void *kobj_zalloc(size_t, int);
183 extern void kobj_free(void *, size_t);
184 extern struct _buf
*kobj_open_file(char *);
185 extern void kobj_close_file(struct _buf
*);
186 extern int kobj_read_file(struct _buf
*, char *, unsigned, unsigned);
187 extern int kobj_get_filesize(struct _buf
*, uint64_t *size
);
188 extern uintptr_t kobj_getelfsym(char *, void *, int *);
189 extern void kobj_set_ctf(struct module
*, caddr_t data
, size_t size
);
191 extern int kobj_filbuf(struct _buf
*);
192 extern void kobj_sync(void);
193 #if defined(__i386) || defined(__sparc) || defined(__amd64)
194 extern void kobj_vmem_init(vmem_t
**, vmem_t
**);
196 #error "ISA not supported"
198 extern caddr_t
kobj_text_alloc(vmem_t
*, size_t);
199 extern caddr_t
kobj_texthole_alloc(caddr_t
, size_t);
200 extern void kobj_texthole_free(caddr_t
, size_t);
201 extern void kobj_stat_get(kobj_stat_t
*);
202 extern void kobj_textwin_alloc(struct module
*);
203 extern void kobj_textwin_free(struct module
*);
205 #endif /* defined(_KERNEL) */
211 #endif /* !_SYS_KOBJ_H */