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