1 #ifndef _CONTROLLER_H
2 #define _CONTROLLER_H
3 
4 #include <stdbool.h>
5 #include <list.h>
6 #include <resource.h>
7 #include <util.h>
8 
9 #define CONTROLLER_START(_name) \
10 	static struct controller _controller = { \
11 		.name = #_name,
12 #define CONTROLLER_END \
13 	}; \
14 	static void _unregister(void) \
15 	{ \
16 		list_remove(&controllers, &_controller); \
17 	} \
18 	INITIALIZER(_register) \
19 	{ \
20 		list_insert(&controllers, &_controller); \
21 		atexit(_unregister); \
22 	}
23 
24 typedef void controller_mach_data_t;
25 typedef void controller_priv_data_t;
26 
27 struct controller_instance;
28 
29 struct controller {
30 	char *name;
31 	bool (*init)(struct controller_instance *instance);
32 	void (*reset)(struct controller_instance *instance);
33 	void (*deinit)(struct controller_instance *instance);
34 };
35 
36 struct controller_instance {
37 	char *controller_name;
38 	int bus_id;
39 	struct resource *resources;
40 	int num_resources;
41 	controller_mach_data_t *mach_data;
42 	controller_priv_data_t *priv_data;
43 	struct controller *controller;
44 };
45 
46 bool controller_add(struct controller_instance *instance);
47 void controller_reset_all();
48 void controller_remove_all();
49 
50 extern struct list_link *controllers;
51 
52 #endif
53 
54