Commit | Line | Data |
---|---|---|
85b35630 CT |
1 | /* |
2 | * Copyright (c) 1993 The Regents of the University of California. | |
3 | * All rights reserved. | |
4 | * | |
5 | * %sccs.include.redist.c% | |
6 | */ | |
7 | ||
8 | #ifndef lint | |
9 | static char sccsid[] = "@(#)getdev.c 5.1 (Berkeley) %G%"; | |
10 | #endif /* not lint */ | |
11 | ||
12 | #include <sys/types.h> | |
13 | #include <sys/device.h> | |
14 | ||
15 | #include <kvm.h> | |
16 | ||
17 | #include "getdev.h" | |
18 | ||
19 | extern kvm_t *kd; | |
20 | ||
21 | extern void errexit __P((const char *, ...)); | |
22 | extern void kread __P((u_long, void *, size_t, char *)); | |
23 | ||
24 | /* | |
25 | * Read in devices and add those whose predicate matches. | |
26 | */ | |
27 | void | |
28 | getdev(alladdr, take, add) | |
29 | u_long alladdr; | |
30 | int (*take) __P((struct device *)); | |
31 | void (*add) __P((u_long, struct device *)); | |
32 | { | |
33 | register u_long addr; | |
34 | struct device dev, *alldevs; | |
35 | ||
36 | kread(alladdr, &alldevs, sizeof(alldevs), "alldevs"); | |
37 | for (addr = (u_long)alldevs; addr != 0; addr = (u_long)dev.dv_next) { | |
38 | kread(addr, &dev, sizeof(dev), "(device)"); | |
39 | if (take(&dev)) | |
40 | add(addr, &dev); | |
41 | } | |
42 | } |