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