KallistiOS git master
Independent SDK for the Sega Dreamcast
Loading...
Searching...
No Matches
nmmgr.h
Go to the documentation of this file.
1/* KallistiOS ##version##
2
3 kos/nmmgr.h
4 Copyright (C)2003 Megan Potter
5
6*/
7
8/** \file kos/nmmgr.h
9 \brief Name manager.
10 \ingroup system_namemgr
11
12 This file contains the definitions of KOS' name manager. A "name" is a
13 generic identifier for some kind of module. These modules may include
14 services provided by the kernel (such as VFS handlers).
15
16 \author Megan Potter
17*/
18
19#ifndef __KOS_NMMGR_H
20#define __KOS_NMMGR_H
21
22#include <sys/cdefs.h>
23__BEGIN_DECLS
24
25#include <arch/types.h>
26#include <kos/limits.h>
27#include <sys/queue.h>
28
29/** \defgroup system_namemgr Name Manager
30 \brief Abstract Module System for KOS's VFS
31 \ingroup system
32*/
33
34/* Pre-define list types */
35struct nmmgr_handler;
36
37/** \brief Name handler list type.
38 \ingroup system_namemgr
39
40 Contrary to what doxygen may think, this is not a function.
41*/
42typedef LIST_HEAD(nmmgr_list, nmmgr_handler) nmmgr_list_t;
43
44/** \brief List entry initializer for static structs.
45 \ingroup system_namemgr
46
47 If you are creating nmmgr handlers, this is what you should initialize the
48 list_ent member with.
49*/
50#define NMMGR_LIST_INIT { NULL }
51
52/** \brief Name handler interface.
53 \ingroup system_namemgr
54
55 Every name handler must begin its information structures with this header.
56 If the handler conforms to some well-defined interface (such as a VFS), then
57 the struct must more specifically be of that type.
58
59 \headerfile kos/nmmgr.h
60*/
61typedef struct nmmgr_handler {
62 char pathname[NAME_MAX]; /* Path name */
63 int pid; /* Process table ID for handler (0 == static) */
64 uint32 version; /* Version code */
65 uint32 flags; /* Bitmask of flags */
66 uint32 type; /* Type of handler */
67 LIST_ENTRY(nmmgr_handler) list_ent; /* Linked list entry */
69
70/** \brief Alias handler interface.
71 \ingroup system_namemgr
72
73 The smallest possible extension of name handler, it has its own name
74 but holds a pointer to a full handler of the appropriate type. This
75 prevents the need to duplicate large vfs structures.
76
77*/
78typedef struct alias_handler {
79 /** \brief Name manager handler header */
81
84
85/* Version codes ('version') have two pieces: a major and minor revision.
86 A major revision (top 16 bits) means that the interfaces are totally
87 incompatible. A minor revision (lower 16 bits) differentiates between
88 mostly-compatible but newer/older revisions of the implementing code. */
89
90/* Flag bits */
91/** \brief This structure must be freed when removed.
92 \ingroup system_namemgr
93*/
94#define NMMGR_FLAGS_NEEDSFREE 0x00000001
95
96/** \brief This structure maps into /dev/.
97 \ingroup system_namemgr
98*/
99#define NMMGR_FLAGS_INDEV 0x00000002
100
101/** \brief This structure aliases another.
102 \ingroup system_namemgr
103*/
104#define NMMGR_FLAGS_ALIAS 0x00000004
105
106/** \defgroup nmmgr_types Handler Types
107 \brief Name handler types
108 \ingroup system_namemgr
109
110 This is the set of all defined types of name manager handlers. All system
111 types are defined below NMMGR_SYS_MAX.
112
113 @{
114*/
115/** \brief Unknown nmmgr type. */
116#define NMMGR_TYPE_UNKNOWN 0x0000 /* ? */
117/** \brief A mounted filesystem. */
118#define NMMGR_TYPE_VFS 0x0010 /* Mounted file system */
119/** \brief A block device. */
120#define NMMGR_TYPE_BLOCKDEV 0x0020 /* Block device */
121/** \brief A singleton service (e.g., /dev/irq) */
122#define NMMGR_TYPE_SINGLETON 0x0030 /* Singleton service (e.g., /dev/irq) */
123/** \brief A symbol table. */
124#define NMMGR_TYPE_SYMTAB 0x0040 /* Symbol table */
125/** \brief Everything this and above is a user type. */
126#define NMMGR_SYS_MAX 0x10000 /* Here and above are user types */
127/** @} */
128
129/** \brief Retrieve a name handler by name.
130 \ingroup system_namemgr
131
132 This function will retrieve a name handler by its pathname.
133
134 \param name The handler to look up
135
136 \return The handler, or NULL on failure.
137*/
138nmmgr_handler_t * nmmgr_lookup(const char *name);
139
140/** \brief Get the head element of the name list.
141 \ingroup system_namemgr
142
143 \warning
144 DO NOT MODIFY THE VALUE RETURNED BY THIS FUNCTION! In fact, don't ever call
145 this function.
146
147 \return The head of the name handler list
148*/
149nmmgr_list_t * nmmgr_get_list(void);
150
151/** \brief Add a name handler.
152 \ingroup system_namemgr
153
154 This function adds a new name handler to the list in the kernel.
155
156 \param hnd The handler to add
157
158 \retval 0 On success
159*/
161
162/** \brief Remove a name handler.
163 \ingroup system_namemgr
164
165 This function removes a name handler from the list in the kernel.
166
167 \param hnd The handler to remove
168
169 \retval 0 On success
170 \retval -1 If the handler wasn't found
171*/
173
174/** \cond */
175/* Name manager init */
176void nmmgr_init(void);
177void nmmgr_shutdown(void);
178/** \endcond */
179
180__END_DECLS
181
182#endif /* __KOS_NMMGR_H */
183
int nmmgr_handler_add(nmmgr_handler_t *hnd)
Add a name handler.
nmmgr_list_t * nmmgr_get_list(void)
Get the head element of the name list.
int nmmgr_handler_remove(nmmgr_handler_t *hnd)
Remove a name handler.
typedef LIST_HEAD(nmmgr_list, nmmgr_handler) nmmgr_list_t
Name handler list type.
nmmgr_handler_t * nmmgr_lookup(const char *name)
Retrieve a name handler by name.
#define NAME_MAX
Max filename length.
Definition limits.h:25
unsigned long uint32
32-bit unsigned integer
Definition types.h:33
Limits.
Alias handler interface.
Definition nmmgr.h:78
nmmgr_handler_t * alias
Definition nmmgr.h:82
nmmgr_handler_t nmmgr
Name manager handler header.
Definition nmmgr.h:80
Name handler interface.
Definition nmmgr.h:61
int pid
Definition nmmgr.h:63
uint32 version
Definition nmmgr.h:64
LIST_ENTRY(nmmgr_handler) list_ent
uint32 type
Definition nmmgr.h:66
uint32 flags
Definition nmmgr.h:65
Common integer types.