KallistiOS  ##version##
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
nmmgr.h
Go to the documentation of this file.
1 /* KallistiOS ##version##
2 
3  kos/nmmgr.h
4  Copyright (C)2003 Dan Potter
5 
6 */
7 
8 /** \file kos/nmmgr.h
9  \brief Name manager.
10 
11  This file contains the definitions of KOS' name manager. A "name" is a
12  generic identifier for some kind of module. These modules may include
13  services provided by the kernel (such as VFS handlers).
14 
15  \author Dan Potter
16 */
17 
18 #ifndef __KOS_NMMGR_H
19 #define __KOS_NMMGR_H
20 
21 #include <sys/cdefs.h>
22 __BEGIN_DECLS
23 
24 #include <arch/types.h>
25 #include <kos/limits.h>
26 #include <sys/queue.h>
27 
28 /* Pre-define list types */
29 struct nmmgr_handler;
30 
31 /** \brief Name handler list type.
32 
33  Contrary to what doxygen may think, this is not a function.
34 */
35 typedef LIST_HEAD(nmmgr_list, nmmgr_handler) nmmgr_list_t;
36 
37 /** \brief List entry initializer for static structs.
38 
39  If you are creating nmmgr handlers, this is what you should initialize the
40  list_ent member with.
41 */
42 #define NMMGR_LIST_INIT { NULL }
43 
44 /** \brief Name handler interface.
45 
46  Every name handler must begin its information structures with this header.
47  If the handler conforms to some well-defined interface (such as a VFS), then
48  the struct must more specifically be of that type.
49 
50  \headerfile kos/nmmgr.h
51 */
52 typedef struct nmmgr_handler {
53  char pathname[MAX_FN_LEN]; /* Path name */
54  int pid; /* Process table ID for handler (0 == static) */
55  uint32 version; /* Version code */
56  uint32 flags; /* Bitmask of flags */
57  uint32 type; /* Type of handler */
58  LIST_ENTRY(nmmgr_handler) list_ent; /* Linked list entry */
60 
61 /* Version codes ('version') have two pieces: a major and minor revision.
62  A major revision (top 16 bits) means that the interfaces are totally
63  incompatible. A minor revision (lower 16 bits) diffrentiates between
64  mostly-compatible but newer/older revisions of the implementing code. */
65 
66 /* Flag bits */
67 /** \brief This structure must be freed when removed. */
68 #define NMMGR_FLAGS_NEEDSFREE 0x00000001
69 
70 /** \defgroup nmmgr_types Name handler types
71 
72  This is the set of all defined types of name manager handlers. All system
73  types are defined below NMMGR_SYS_MAX.
74 
75  @{
76 */
77 /** \brief Unknown nmmgr type. */
78 #define NMMGR_TYPE_UNKNOWN 0x0000 /* ? */
79 /** \brief A mounted filesystem. */
80 #define NMMGR_TYPE_VFS 0x0010 /* Mounted file system */
81 /** \brief A block device. */
82 #define NMMGR_TYPE_BLOCKDEV 0x0020 /* Block device */
83 /** \brief A singleton service (e.g., /dev/irq) */
84 #define NMMGR_TYPE_SINGLETON 0x0030 /* Singleton service (e.g., /dev/irq) */
85 /** \brief A symbol table. */
86 #define NMMGR_TYPE_SYMTAB 0x0040 /* Symbol table */
87 /** \brief Everything this and above is a user type. */
88 #define NMMGR_SYS_MAX 0x10000 /* Here and above are user types */
89 /** @} */
90 
91 /** \brief Retrieve a name handler by name.
92 
93  This function will retrieve a name handler by its pathname.
94 
95  \param name The handler to look up
96  \return The handler, or NULL on failure.
97 */
98 nmmgr_handler_t * nmmgr_lookup(const char *name);
99 
100 /** \brief Get the head element of the name list.
101 
102  DO NOT MODIFY THE VALUE RETURNED BY THIS FUNCTION! In fact, don't ever call
103  this function.
104 
105  \return The head of the name handler list
106 */
107 nmmgr_list_t * nmmgr_get_list();
108 
109 /** \brief Add a name handler.
110 
111  This function adds a new name handler to the list in the kernel.
112 
113  \param hnd The handler to add
114  \retval 0 On success
115 */
117 
118 /** \brief Remove a name handler.
119 
120  This function removes a name handler from the list in the kernel.
121 
122  \param hnd The handler to remove
123  \retval 0 On success
124  \retval -1 If the handler wasn't found
125 */
127 
128 /** \cond */
129 /* Name manager init */
130 int nmmgr_init();
131 void nmmgr_shutdown();
132 /** \endcond */
133 
134 __END_DECLS
135 
136 #endif /* __KOS_NMMGR_H */
137 
LIST_ENTRY(nmmgr_handler) list_ent
Common integer types.
typedef LIST_HEAD(nmmgr_list, nmmgr_handler) nmmgr_list_t
Name handler list type.
uint32 type
Definition: nmmgr.h:57
#define MAX_FN_LEN
Max filename length.
Definition: limits.h:19
Name handler interface.
Definition: nmmgr.h:52
int nmmgr_handler_add(nmmgr_handler_t *hnd)
Add a name handler.
uint32 flags
Definition: nmmgr.h:56
int nmmgr_handler_remove(nmmgr_handler_t *hnd)
Remove a name handler.
int pid
Definition: nmmgr.h:54
unsigned long uint32
32-bit unsigned integer
Definition: types.h:28
uint32 version
Definition: nmmgr.h:55
nmmgr_list_t * nmmgr_get_list()
Get the head element of the name list.
Limits.
char pathname[MAX_FN_LEN]
Definition: nmmgr.h:53
nmmgr_handler_t * nmmgr_lookup(const char *name)
Retrieve a name handler by name.