240c7ff293b911c85e6e279b19494d89f5d302f4
[rpi-open-firmware.git] / drivers / IODevice.hpp
1 #pragma once
2
3 #include <lib/runtime.h>
4 #include <hardware.h>
5
6 enum IODeviceState {
7 kIODeviceUninitialized,
8 kIODeviceStarted,
9 kIODeviceStopped
10 };
11
12 struct IODevice {
13 const char* driverName;
14 IODeviceState deviceState;
15 uint32_t tag;
16
17 IODevice();
18
19 void driverLog(const char* fnName, const char* fmt, ...);
20 void registerDriver();
21
22 void inline setName(const char* name) {
23 driverName = name;
24 }
25
26 void inline setTag(uint32_t tag) {
27 this->tag = tag;
28 }
29
30 virtual void start();
31 virtual void stop();
32 virtual void init();
33
34 void _afterInit();
35 void _beforeInit();
36
37 virtual inline IODeviceState getDeviceState() {
38 return deviceState;
39 }
40
41 static IODevice* findByTag(uint32_t tag);
42 };
43
44 #define IODriverLog(fmt, ...) driverLog(__FUNCTION__, fmt, ##__VA_ARGS__)
45 #define IODriverCreateSingletonInstance(clazz) static clazz __IODriver_static_ ## clazz {}
46 #define IODriverConstructor(clazz) clazz() { _beforeInit(); init(); _afterInit(); }
This page took 0.067074 seconds and 3 git commands to generate.