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_FS_NULL, fs_null_init); \
64 KOS_INIT_FLAG(flags, INIT_FS_NULL, fs_null_shutdown); \
65 KOS_INIT_FLAG(flags, INIT_FS_PTY, fs_pty_init); \
66 KOS_INIT_FLAG(flags, INIT_FS_PTY, fs_pty_shutdown); \
67 KOS_INIT_FLAG(flags, INIT_FS_RAMDISK, fs_ramdisk_init); \
68 KOS_INIT_FLAG(flags, INIT_FS_RAMDISK, fs_ramdisk_shutdown); \
69 KOS_INIT_FLAG(flags, INIT_FS_RND, fs_rnd_init); \
70 KOS_INIT_FLAG(flags, INIT_FS_RND, fs_rnd_shutdown); \
71 KOS_INIT_FLAG(flags, INIT_FS_DEV, fs_dev_init); \
72 KOS_INIT_FLAG(flags, INIT_FS_DEV, fs_dev_shutdown); \
73 KOS_INIT_FLAG(flags, INIT_EXPORT, export_init); \
74 KOS_INIT_FLAG(flags, INIT_LIBRARY, library_init); \
75 KOS_INIT_FLAG(flags, INIT_LIBRARY, library_shutdown); \
76 KOS_INIT_FLAG_NONE(flags, INIT_NO_SHUTDOWN, kos_shutdown); \
77 KOS_INIT_FLAGS_ARCH(flags)
78
79#define __KOS_INIT_FLAGS_1(flags) \
80 extern "C" { \
81 __KOS_INIT_FLAGS_0(flags); \
82 }
83
84#define __KOS_INIT_FLAGS(flags, cp) \
85 __KOS_INIT_FLAGS_##cp(flags)
86
87#define _KOS_INIT_FLAGS(flags, cp) \
88 __KOS_INIT_FLAGS(flags, cp)
89
90extern const uint32_t __kos_init_flags;
91/** \endcond */
92
93/** \brief Exports and initializes the given KOS subsystems.
94 \ingroup init_flags
95
96 KOS_INIT_FLAGS() provides a mechanism through which various components
97 of KOS can be enabled and initialized depending on whether their flag
98 has been included within the list.
99
100 \note
101 When no KOS_INIT_FLAGS() have been explicitly provided, the default
102 flags used by KOS are equivalent to KOS_INIT_FLAGS(INIT_DEFAULT).
103
104 \param flags Parts of KOS to init.
105 */
106#define KOS_INIT_FLAGS(flags) \
107 _KOS_INIT_FLAGS(flags, __kos_cplusplus)
108
109/** \brief Deprecated and not useful anymore. */
110#define KOS_INIT_ROMDISK(rd) \
111 const void *__kos_romdisk = (rd); \
112 extern void fs_romdisk_mount_builtin_legacy(void); \
113 void (*fs_romdisk_mount_builtin_legacy_weak)(void) = fs_romdisk_mount_builtin_legacy
114
115
116/** \brief Built-in romdisk. Do not modify this directly! */
117extern const void * __kos_romdisk;
118
119/** \brief State that you don't want a romdisk. */
120#define KOS_INIT_ROMDISK_NONE NULL
121
122/** \brief Register a single function to be called very early in the boot
123 process, before the BSS section is cleared.
124 \ingroup init_flags
125
126 \param func The function to register. The prototype should be
127 void func(void)
128*/
129#define KOS_INIT_EARLY(func) void (*__kos_init_early_fn)(void) = (func)
130
131/** \defgroup kos_initflags Generic Flags
132 \brief Generic flags for use with KOS_INIT_FLAGS()
133 \ingroup init_flags
134
135 These are the architecture-independent flags that can be specified with
136 KOS_INIT_FLAGS.
137
138 \see dreamcast_initflags
139 @{
140*/
141
142/** Default init flags (IRQs on, preemption enabled, romdisks). */
143#define INIT_DEFAULT (INIT_IRQ | INIT_THD_PREEMPT | INIT_FS_ALL | \
144 INIT_LIBRARY | INIT_DEFAULT_ARCH)
145
146/** Init flags to include all virtual filesystems within `/dev` */
147#define INIT_FS_DEV (INIT_FS_NULL | INIT_FS_RND)
148
149/** Init flags to include all virtual filesystems (default). */
150#define INIT_FS_ALL (INIT_FS_ROMDISK | INIT_FS_RAMDISK | \
151 INIT_FS_PTY | INIT_FS_DEV)
152
153#define INIT_NONE 0x00000000 /**< Don't init optional things */
154#define INIT_THD_PREEMPT 0x00000000 /**< \deprecated Already default mode */
155#define INIT_IRQ 0x00000001 /**< Enable IRQs at startup */
156#define INIT_NET 0x00000002 /**< Enable built-in networking */
157#define INIT_MALLOCSTATS 0x00000004 /**< Enable malloc statistics */
158#define INIT_QUIET 0x00000008 /**< Disable dbgio */
159#define INIT_EXPORT 0x00000010 /**< Export kernel symbols/dynamic libs */
160#define INIT_LIBRARY 0x00000010 /**< Export kernel symbols/dynamic libs */
161
162#define INIT_FS_ROMDISK 0x00000020 /**< Enable support for romdisks */
163#define INIT_FS_RAMDISK 0x00000040 /**< Enable support for ramdisk VFS */
164#define INIT_FS_PTY 0x00000080 /**< Enable support for PTY VFS */
165#define INIT_FS_NULL 0x00000100 /**< Enable support for /dev/null VFS */
166#define INIT_FS_RND 0x00000200 /**< Enable support for /dev/urandom VFS */
167
168#define INIT_NO_SHUTDOWN 0x00000400 /**< Disable hardware shutdown */
169/** @} */
170
171__END_DECLS
172
173#ifdef __cplusplus
174};
175#endif
176
177#endif /* !__KOS_INIT_H */
Various common macros used throughout the codebase.
const void * __kos_romdisk
Built-in romdisk.
Shared initialization macros and utilities.
Dreamcast-specific initialization-related flags and macros.