kobj.h revision b1b8ab34de515a5e83206da22c3d7e563241b021
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _SYS_KOBJ_H
#define _SYS_KOBJ_H
#pragma ident "%Z%%M% %I% %E% SMI"
#include <sys/bootstat.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* List of modules maintained by kobj.c
*/
struct module_list {
struct module_list *next;
};
typedef unsigned short symid_t; /* symbol table index */
typedef unsigned char *reloc_dest_t;
typedef void module_mach;
struct module {
int total_allocated;
char *shdrs;
char *depends_on;
char *symspace; /* symbols + strings + hashtbl, or NULL */
int flags;
char *text;
char *data;
unsigned int symtbl_section;
/* pointers into symspace, or NULL */
char *symtbl;
char *strings;
unsigned int hashsize;
unsigned int nsyms;
unsigned int bss_align;
char *filename;
char *ctfdata;
char *fbt_tab;
char *sdt_tab;
char *sigdata;
};
struct kobj_mem {
};
struct _buf {
char *_ptr;
char *_base;
char *_name;
int _size;
int _cnt;
int _off;
int _ln;
};
/*
* Statistical info.
*/
typedef struct {
int nalloc;
int nfree;
int nalloc_calls;
int nfree_calls;
} kobj_stat_t;
#define kobj_filename(p) ((p)->_name)
#define kobj_linenum(p) ((p)->_ln)
#define kobj_newline(p) ((p)->_ln++)
#if defined(_KERNEL)
extern int kobj_load_module(struct modctl *, int);
extern void kobj_unload_module(struct modctl *);
extern int kobj_addrcheck(void *, caddr_t);
extern int kobj_module_to_id(void *);
extern void kobj_getmodinfo(void *, struct modinfo *);
extern int kobj_get_needed(void *, short *, int);
extern uintptr_t kobj_getsymvalue(char *, int);
extern int kobj_path_exists(char *, int);
extern struct _buf *kobj_open_path(char *, int, int);
extern void kobj_close(intptr_t);
extern void *kobj_alloc(size_t, int);
extern void *kobj_zalloc(size_t, int);
extern struct _buf *kobj_open_file(char *);
extern void kobj_close_file(struct _buf *);
extern int kobj_read_file(struct _buf *, char *, unsigned, unsigned);
extern uintptr_t kobj_getelfsym(char *, void *, int *);
extern int kobj_filbuf(struct _buf *);
extern void kobj_sync(void);
#else
#error "ISA not supported"
#endif
extern void kobj_stat_get(kobj_stat_t *);
extern void kobj_textwin_alloc(struct module *);
extern void kobj_textwin_free(struct module *);
#endif /* defined(_KERNEL) */
#ifdef __cplusplus
}
#endif
#endif /* !_SYS_KOBJ_H */