From b2880945ae17ad857bd425540acd3dc75b2cff6b Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Tue, 6 Jul 2021 22:07:04 +0200 Subject: Basic multiboot 1 detection and verification --- src/loader/dev.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src/loader/dev.c') 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++) { -- cgit v1.2.3