| | 1 | #ifndef KEDEV_BUS_H |
| | 2 | #define KEDEV_BUS_H |
| | 3 | |
| | 4 | #include <completion.h> |
| | 5 | #include <keobject.h> |
| | 6 | #include <llist.h> |
| | 7 | #include <fs/icfs.h> |
| | 8 | |
| | 9 | #define BUS_STARTING 0 |
| | 10 | #define BUS_RUNNING 1 |
| | 11 | |
| | 12 | struct KeBus |
| | 13 | { |
| | 14 | struct ListHead deviceList; |
| | 15 | struct ListHead next, node; |
| | 16 | int index, state; |
| | 17 | struct KeBusType* busType; |
| | 18 | |
| | 19 | /* Used in the startup code to wait for all initial bus scans to complete. |
| | 20 | * This does not mean all the devices have been linked with drivers (but |
| | 21 | * the devices that match to drivers have been). */ |
| | 22 | struct Completion initialBusScan; |
| | 23 | |
| | 24 | struct KeSet set; |
| | 25 | }; |
| | 26 | |
| | 27 | struct KeBusType |
| | 28 | { |
| | 29 | /* These members should be specified before calling KeBusTypeRegister */ |
| | 30 | char* name; |
| | 31 | |
| | 32 | struct IcAttribute* busEntryAttrs; |
| | 33 | int busEntryOffset; |
| | 34 | |
| | 35 | /* Private members. */ |
| | 36 | struct KeSet set; |
| | 37 | |
| | 38 | /* List of all drivers that detect drivers on this bus type. */ |
| | 39 | struct ListHead driverList; |
| | 40 | |
| | 41 | /* List of all the KeBuses that are of this type. */ |
| | 42 | struct ListHead busList; |
| | 43 | }; |
| | 44 | |
| | 45 | struct KeBusEntry |
| | 46 | { |
| | 47 | struct KeObject object; |
| | 48 | }; |
| | 49 | |
| | 50 | int KeBusTypeRegister(struct KeBusType* busType); |
| | 51 | int KeBusRegister(struct KeBusType* busType, struct KeBus* bus, int index); |
| | 52 | int KeBusEntryRegister(struct KeBus* bus, struct KeBusEntry* entry, char* name, ...); |
| | 53 | void KeBusStart(struct KeBus* bus); |
| | 54 | |
| | 55 | #endif |