xref: /haiku/src/libs/compat/freebsd_network/shared.h (revision 5b189b0e1e2f51f367bfcb126b2f00a3702f352d)
1 /*
2  * Copyright 2009, Colin Günther, coling@gmx.de. All Rights Reserved.
3  * Copyright 2007, Axel Dörfler, axeld@pinc-software.de. All Rights Reserved.
4  * Copyright 2007, Hugo Santos. All Rights Reserved.
5  * Copyright 2004, Marcus Overhagen. All Rights Reserved.
6  * Distributed under the terms of the MIT License.
7  */
8 #ifndef SHARED_H_
9 #define SHARED_H_
10 
11 
12 #include <sys/bus.h>
13 
14 
15 #define MAX_DEVICES	8
16 
17 
18 struct ifnet;
19 
20 struct device {
21 	struct device	*parent;
22 	struct device	*root;
23 
24 	driver_t		*driver;
25 	struct list		children;
26 
27 	uint32			flags;
28 
29 	char			device_name[128];
30 	int				unit;
31 	char			nameunit[64];
32 	const char		*description;
33 	void			*softc;
34 	void			*ivars;
35 
36 	struct {
37 		void* (*device_register)(device_t dev);
38 		int (*probe)(device_t dev);
39 		int (*attach)(device_t dev);
40 		int (*detach)(device_t dev);
41 		int (*suspend)(device_t dev);
42 		int (*resume)(device_t dev);
43 		void (*shutdown)(device_t dev);
44 
45 		int (*miibus_readreg)(device_t, int, int);
46 		int (*miibus_writereg)(device_t, int, int, int);
47 		void (*miibus_statchg)(device_t);
48 		void (*miibus_linkchg)(device_t);
49 		void (*miibus_mediainit)(device_t);
50 
51 		int (*bus_child_location_str)(device_t dev __unused, device_t child,
52 			char *buf, size_t buflen);
53 		int (*bus_child_pnpinfo_str)(device_t dev __unused, device_t child,
54 			char *buf, size_t buflen);
55 		void (*bus_hinted_child)(device_t dev, const char *name, int unit);
56 		int (*bus_print_child)(device_t dev, device_t child);
57 		int (*bus_read_ivar)(device_t dev, device_t child __unused, int which,
58 		    uintptr_t *result);
59 		bus_dma_tag_t (*bus_get_dma_tag)(device_t dev);
60 	} methods;
61 
62 	struct list_link link;
63 };
64 
65 
66 extern const char *gDeviceNameList[];
67 extern struct ifnet *gDevices[];
68 extern int32 gDeviceCount;
69 
70 #endif /* SHARED_H_ */
71