driver: track number of users on driver
Signed-off-by: Michael Shaw <m@michaelsshaw.com>
This commit is contained in:
parent
3b83b2f741
commit
8d147a14c4
3 changed files with 10 additions and 3 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue