summaryrefslogtreecommitdiffhomepage
path: root/src/loader/dev.c
diff options
context:
space:
mode:
authorMarvin Borner2021-07-06 22:07:04 +0200
committerMarvin Borner2021-07-06 22:07:04 +0200
commitb2880945ae17ad857bd425540acd3dc75b2cff6b (patch)
treef5dea0028fb5e2b9072aa15f60c497bc7e20d13b /src/loader/dev.c
parent23aa6f84539ba320a91235fb81681d0754178f62 (diff)
Basic multiboot 1 detection and verification
Diffstat (limited to 'src/loader/dev.c')
-rw-r--r--src/loader/dev.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/loader/dev.c b/src/loader/dev.c
index 591d5a2..3cdef10 100644
--- a/src/loader/dev.c
+++ b/src/loader/dev.c
@@ -19,12 +19,26 @@ static const char *dev_resolve_type(enum dev_type type)
}
}
-struct dev *dev_get(u8 id)
+struct dev *dev_get_by_id(u8 id)
{
assert(id < COUNT(devices));
return &devices[id];
}
+struct dev *dev_get_by_name(const char *name, u32 len)
+{
+ if (!name || !name[0])
+ return NULL;
+
+ for (u8 i = 0; i < COUNT(devices); i++) {
+ struct dev *dev = &devices[i];
+ if (strncmp(dev->name, name, MIN(sizeof(dev->name), len)) == 0)
+ return dev;
+ }
+
+ return NULL;
+}
+
void dev_foreach(enum dev_type type, u8 (*cb)(struct dev *))
{
for (u8 i = 0; i < COUNT(devices); i++) {