KallistiOS git master
Independent SDK for the Sega Dreamcast
Loading...
Searching...
No Matches
init.h
Go to the documentation of this file.
1/* KallistiOS ##version##
2
3 include/kos/init.h
4 Copyright (C) 2001 Megan Potter
5 Copyright (C) 2023 Lawrence Sebald
6 Copyright (C) 2023 Paul Cercueil
7 Copyright (C) 2023 Falco Girgis
8
9*/
10
11/** \file kos/init.h
12 \brief Initialization-related flags and macros.
13 \ingroup init_flags
14
15 This file provides initialization-related flags and macros that can be used
16 to set up various subsystems of KOS on startup. Only flags that are
17 architecture-independent are specified here, however this file also includes
18 the architecture-specific file to bring in those flags as well.
19
20 \sa arch/init_flags.h
21 \sa kos/init_base.h
22
23 \author Megan Potter
24 \author Lawrence Sebald
25 \author Paul Cercueil
26 \author Falco Girgis
27*/
28
29#ifndef __KOS_INIT_H
30#define __KOS_INIT_H
31
32#ifdef __cplusplus
33extern "C" {
34#endif
35
36#include <kos/cdefs.h>
37__BEGIN_DECLS
38
39#include <arch/init_flags.h>
40#include <kos/init_base.h>
41#include <stdint.h>
42
43/** \defgroup init_flags Initialization
44 \brief KOS Driver Subsystem and Component Initialization Flags
45 \ingroup system
46*/
47
48/** \cond */
49#ifdef __cplusplus
50#define __kos_cplusplus 1
51#else
52#define __kos_cplusplus 0
53#endif
54
55#define __KOS_INIT_FLAGS_0(flags) \
56 const uint32_t __kos_init_flags = (flags); \
57 KOS_INIT_FLAG(flags, INIT_NET, arch_init_net); \
58 KOS_INIT_FLAG(flags, INIT_NET, net_shutdown); \
59 KOS_INIT_FLAG(flags, INIT_NET, bba_la_init); \
60 KOS_INIT_FLAG(flags, INIT_NET, bba_la_shutdown); \
61 KOS_INIT_FLAG(flags, INIT_FS_ROMDISK, fs_romdisk_init); \
62 KOS_INIT_FLAG(flags, INIT_FS_ROMDISK, fs_romdisk_shutdown); \
63 KOS_INIT_FLAG(flags, INIT_EXPORT, export_init); \
64 KOS_INIT_FLAG_NONE(flags, INIT_NO_SHUTDOWN, kos_shutdown); \
65 KOS_INIT_FLAGS_ARCH(flags)
66
67#define __KOS_INIT_FLAGS_1(flags) \
68 extern "C" { \
69 __KOS_INIT_FLAGS_0(flags); \
70 }
71
72#define __KOS_INIT_FLAGS(flags, cp) \
73 __KOS_INIT_FLAGS_##cp(flags)
74
75#define _KOS_INIT_FLAGS(flags, cp) \
76 __KOS_INIT_FLAGS(flags, cp)
77
78extern const uint32_t __kos_init_flags;
79/** \endcond */
80
81/** \brief Exports and initializes the given KOS subsystems.
82 \ingroup init_flags
83
84 KOS_INIT_FLAGS() provides a mechanism through which various components
85 of KOS can be enabled and initialized depending on whether their flag
86 has been included within the list.
87
88 \note
89 When no KOS_INIT_FLAGS() have been explicitly provided, the default
90 flags used by KOS are equivalent to KOS_INIT_FLAGS(INIT_DEFAULT).
91
92 \param flags Parts of KOS to init.
93 */
94#define KOS_INIT_FLAGS(flags) \
95 _KOS_INIT_FLAGS(flags, __kos_cplusplus)
96
97/** \brief Deprecated and not useful anymore. */
98#define KOS_INIT_ROMDISK(rd) \
99 const void *__kos_romdisk = (rd); \
100 extern void fs_romdisk_mount_builtin_legacy(void); \
101 void (*fs_romdisk_mount_builtin_legacy_weak)(void) = fs_romdisk_mount_builtin_legacy
102
103
104/** \brief Built-in romdisk. Do not modify this directly! */
105extern const void * __kos_romdisk;
106
107/** \brief State that you don't want a romdisk. */
108#define KOS_INIT_ROMDISK_NONE NULL
109
110/** \brief Register a single function to be called very early in the boot
111 process, before the BSS section is cleared.
112 \ingroup init_flags
113
114 \param func The function to register. The prototype should be
115 void func(void)
116*/
117#define KOS_INIT_EARLY(func) void (*__kos_init_early_fn)(void) = (func)
118
119/** \defgroup kos_initflags Generic Flags
120 \brief Generic flags for use with KOS_INIT_FLAGS()
121 \ingroup init_flags
122
123 These are the architecture-independent flags that can be specified with
124 KOS_INIT_FLAGS.
125
126 \see dreamcast_initflags
127 @{
128*/
129/** \brief Default init flags (IRQs on, preemption enabled, romdisks). */
130#define INIT_DEFAULT (INIT_IRQ | INIT_THD_PREEMPT | INIT_FS_ROMDISK | \
131 INIT_DEFAULT_ARCH)
132
133#define INIT_NONE 0x00000000 /**< \brief Don't init optional things */
134#define INIT_IRQ 0x00000001 /**< \brief Enable IRQs at startup */
135/* Preemptive mode is the only mode now. Keeping define for compatibility. */
136#define INIT_THD_PREEMPT 0x00000002 /**< \deprecated Already default mode */
137#define INIT_NET 0x00000004 /**< \brief Enable built-in networking */
138#define INIT_MALLOCSTATS 0x00000008 /**< \brief Enable malloc statistics */
139#define INIT_QUIET 0x00000010 /**< \brief Disable dbgio */
140#define INIT_EXPORT 0x00000020 /**< \brief Export kernel symbols */
141#define INIT_FS_ROMDISK 0x00000040 /**< \brief Enable support for romdisks */
142#define INIT_NO_SHUTDOWN 0x00000080 /**< \brief Disable hardware shutdown */
143/** @} */
144
145__END_DECLS
146
147#ifdef __cplusplus
148};
149#endif
150
151#endif /* !__KOS_INIT_H */
Definitions for builtin attributes and compiler directives.
const void * __kos_romdisk
Built-in romdisk.
Shared initialization macros and utilities.
Dreamcast-specific initialization-related flags and macros.