driver: track number of users on driver

Signed-off-by: Michael Shaw <m@michaelsshaw.com>
This commit is contained in:
Michael Shaw 2026-08-12 14:44:56 -04:00
commit 8d147a14c4
Signed by: michaelsshaw
GPG key ID: 5A5E0FB20708A9E7
3 changed files with 10 additions and 3 deletions

View file

@ -32,6 +32,7 @@ struct driver *driver_register(const char *name, u32 type, void *init, void *dei
driver->exit = NULL;
driver->base = NULL;
driver->size = 0;
driver->n_users = 0;
}
driver->type = type;

View file

@ -242,10 +242,13 @@ static int elf_load(const char *name, const char *file, size_t fsize)
void (*exit)(void) = NULL;
for (size_t i = 0; i < n_sec; i++) {
if (!secs[i].loadable) continue;
if (!str_prefix(shstrtab + shdr[i].sh_name, ".exitcall")) continue;
if (!secs[i].loadable)
continue;
if (!str_prefix(shstrtab + shdr[i].sh_name, ".exitcall"))
continue;
void (**fn)(void) = (void (**)(void))(base + secs[i].load_off);
if (fn[0]) exit = fn[0];
if (fn[0])
exit = fn[0];
break;
}
@ -256,6 +259,7 @@ static int elf_load(const char *name, const char *file, size_t fsize)
d->exit = exit;
d->base = base;
d->size = total;
d->n_users = 1;
list_insert(&pending_drivers, d);
}
}