diff options
author | Marvin Borner | 2021-07-05 16:48:07 +0200 |
---|---|---|
committer | Marvin Borner | 2021-07-05 16:51:23 +0200 |
commit | 46ce42e9b13ce209c8c971084cfc849a83848270 (patch) | |
tree | a85283f85c970bb26df6690a4ba08b017f1d4e25 /src/loader/dev.c | |
parent | 981342ef807ebcefba8eeba74511cdcedf9c36bd (diff) |
Added PCI, MBR, bugs and fixes
Diffstat (limited to 'src/loader/dev.c')
-rw-r--r-- | src/loader/dev.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/loader/dev.c b/src/loader/dev.c index 441aaed..be15083 100644 --- a/src/loader/dev.c +++ b/src/loader/dev.c @@ -2,6 +2,7 @@ // Device manager #include <dev.h> +#include <fs.h> #include <lib.h> #include <pnc.h> @@ -19,11 +20,18 @@ static const char *dev_resolve_type(enum dev_type type) } } -u32 dev_register(enum dev_type type, char *name, u32 data, - s32 (*read)(void *, u32, u32, struct dev *), - s32 (*write)(const void *, u32, u32, struct dev *)) +struct dev *dev_get(u8 id) +{ + assert(id < COUNT(devices)); + return &devices[id]; +} + +u8 dev_register(enum dev_type type, char *name, u32 data, + s32 (*read)(void *, u32, u32, struct dev *), + s32 (*write)(const void *, u32, u32, struct dev *)) { static u8 id = 0; + assert(id + 1 < 0xff); struct dev *dev = &devices[id]; dev->id = id; @@ -36,6 +44,9 @@ u32 dev_register(enum dev_type type, char *name, u32 data, assert(strlen(name) < sizeof(dev->name)); memcpy(dev->name, name, sizeof(dev->name)); + if (type == DEV_DISK) + fs_detect(dev); + return id++; } |