driver: load driver file by alias only
Signed-off-by: Michael Shaw <m@michaelsshaw.com>
This commit is contained in:
parent
0aec18db63
commit
20905ec95f
6 changed files with 69 additions and 39 deletions
|
|
@ -12,8 +12,7 @@
|
|||
#define DRIVER_EXIT(fn) static void (*__exitcall_##fn)(void) __attribute((used, section(".exitcall"))) = fn
|
||||
|
||||
#define DRIVER_ALIAS(_alias) \
|
||||
static const char __driver_alias_##__LINE__[] \
|
||||
__attribute__((used, section(".modinfo"), aligned(1))) = "alias=" _alias
|
||||
static const char __driver_alias_##__LINE__[] __attribute__((used, section(".modinfo"), aligned(1))) = "alias=" _alias
|
||||
|
||||
#define DRIVER_PCI 1
|
||||
|
||||
|
|
@ -33,11 +32,13 @@ struct driver {
|
|||
void *base;
|
||||
size_t size;
|
||||
|
||||
char alias[64];
|
||||
|
||||
u32 n_users;
|
||||
};
|
||||
|
||||
struct driver *driver_register(const char *name, u32 type, void *init, void *deinit, u32 class);
|
||||
struct driver *driver_find(u32 type, u32 class);
|
||||
struct driver *driver_register(const char *name, u32 type, void *init, void *deinit, const char *alias);
|
||||
struct driver *driver_find(const char *alias);
|
||||
int driver_load(const char *name);
|
||||
int driver_unload(const char *name);
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
#define _ht_H_
|
||||
|
||||
#include <kernel/common.h>
|
||||
#include <kernel/mtx.h>
|
||||
|
||||
typedef struct ht_entry {
|
||||
char *key;
|
||||
|
|
@ -17,6 +18,8 @@ typedef struct {
|
|||
ht_entry_t **buckets;
|
||||
size_t capacity;
|
||||
size_t size;
|
||||
|
||||
mtx_t lock;
|
||||
} ht_t;
|
||||
|
||||
ht_t *ht_create(size_t capacity);
|
||||
|
|
@ -24,5 +27,7 @@ void ht_destroy(ht_t *ht);
|
|||
int ht_insert(ht_t *ht, const char *key, void *value);
|
||||
void *ht_lookup(ht_t *ht, const char *key);
|
||||
int ht_delete(ht_t *ht, const char *key);
|
||||
void ht_lock(ht_t *ht);
|
||||
void ht_unlock(ht_t *ht);
|
||||
|
||||
#endif /* _ht_H_ */
|
||||
|
|
|
|||
Loading…
Reference in a new issue