KallistiOS git master
Independent SDK for the Sega Dreamcast
Loading...
Searching...
No Matches
exports.h
Go to the documentation of this file.
1/* KallistiOS ##version##
2
3 kos/exports.h
4 Copyright (C) 2003 Megan Potter
5 Copyright (C) 2024 Ruslan Rostovtsev
6
7*/
8
9/** \file kos/exports.h
10 \brief Kernel exported symbols support.
11 \ingroup system_libraries
12
13 This file contains support related to dynamic linking of the kernel of KOS.
14 The kernel (at compile time) produces a list of exported symbols, which can
15 be looked through using the functionality in this file.
16
17 \author Megan Potter
18 \author Ruslan Rostovtsev
19*/
20
21#ifndef __KOS_EXPORTS_H
22#define __KOS_EXPORTS_H
23
24#include <kos/cdefs.h>
25__BEGIN_DECLS
26
27#include <stdint.h>
28
29/** \addtogroup system_libraries
30 @{
31*/
32
33/** \brief A single export symbol.
34
35 This structure holds a single symbol that has been exported from the kernel.
36 These will be patched into loaded ELF binaries at load time.
37
38 \headerfile kos/exports.h
39*/
40typedef struct export_sym {
41 const char *name; /**< \brief The name of the symbol. */
42 uintptr_t ptr; /**< \brief A pointer to the symbol. */
44
45/** \cond */
46/* These are the platform-independent exports */
47extern export_sym_t kernel_symtab[];
48
49/* And these are the arch-specific exports */
50extern export_sym_t arch_symtab[];
51/** \endcond */
52
53#ifndef __EXPORTS_FILE
54#include <kos/nmmgr.h>
55
56/** \brief A symbol table "handler" for nmmgr.
57 \headerfile kos/exports.h
58*/
59typedef struct symtab_handler {
60 struct nmmgr_handler nmmgr; /**< \brief Name manager handler header */
61 export_sym_t *table; /**< \brief Location of the first entry */
63#endif
64
65/** \brief Setup initial kernel exports. */
66void export_init(void);
67
68/** \brief Look up a symbol by name.
69 \param name The symbol to look up
70 \return The export structure, or NULL on failure
71*/
72export_sym_t *export_lookup(const char *name);
73
74/** \brief Look up a symbol by name and Name Manager path.
75 \param name The symbol to look up
76 \param path The Name Manager path to look up
77 \return The export structure, or NULL on failure
78*/
79export_sym_t *export_lookup_path(const char *name, const char *path);
80
81/** \brief Look up a symbol by approx addr.
82 It can be useful for unhandled exceptions messages.
83 \param addr The symbol to look up
84 \return The export structure, or NULL on failure
85*/
87
88/** @} */
89
90__END_DECLS
91
92#endif /* __KOS_EXPORTS_H */
Various common macros used throughout the codebase.
export_sym_t * export_lookup_path(const char *name, const char *path)
Look up a symbol by name and Name Manager path.
export_sym_t * export_lookup(const char *name)
Look up a symbol by name.
void export_init(void)
Setup initial kernel exports.
export_sym_t * export_lookup_addr(uintptr_t addr)
Look up a symbol by approx addr.
Name manager.
A single export symbol.
Definition exports.h:40
uintptr_t ptr
A pointer to the symbol.
Definition exports.h:42
const char * name
The name of the symbol.
Definition exports.h:41
A symbol table "handler" for nmmgr.
Definition exports.h:59
export_sym_t * table
Location of the first entry.
Definition exports.h:61