The Pedigree Project  0.1
UsbPnP.h
1 /*
2  * Copyright (c) 2008-2014, Pedigree Developers
3  *
4  * Please see the CONTRIB file in the root of the source tree for a full
5  * list of contributors.
6  *
7  * Permission to use, copy, modify, and distribute this software for any
8  * purpose with or without fee is hereby granted, provided that the above
9  * copyright notice and this permission notice appear in all copies.
10  *
11  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 #ifndef USBPNP_H
21 #define USBPNP_H
22 
23 #include "pedigree/kernel/compiler.h"
24 #include "pedigree/kernel/processor/types.h"
25 #include "pedigree/kernel/utilities/List.h"
26 #include "pedigree/kernel/utilities/new"
27 
28 class Device;
29 class UsbDevice;
30 
31 enum UsbPnPConstants
32 {
33  VendorIdNone = 0xFFFF,
34  ProductIdNone = 0xFFFF,
35  ClassNone = 0xFF,
36  SubclassNone = 0xFF,
37  ProtocolNone = 0xFF,
38 };
39 
41 {
42  private:
44  typedef UsbDevice *(*callback_t)(UsbDevice *);
45 
46  public:
47  UsbPnP();
48  virtual ~UsbPnP();
49 
51  static UsbPnP &instance()
52  {
53  return m_Instance;
54  }
55 
57  void registerCallback(
58  uint16_t nVendorId, uint16_t nProductId, callback_t callback);
59 
61  void registerCallback(
62  uint8_t nClass, uint8_t nSubclass, uint8_t nProtocol,
63  callback_t callback);
64 
66  bool probeDevice(Device *pDeviceBase);
67 
68  private:
71  Device *doProbe(Device *pDeviceBase);
72 
75 
77  void reprobeDevices(Device *pParent);
78 
81  struct CallbackItem
82  {
84  callback_t callback;
85 
87  uint16_t nVendorId;
88  uint16_t nProductId;
89 
91  uint8_t nClass;
92  uint8_t nSubclass;
93  uint8_t nProtocol;
94  };
95 
98 };
99 
100 #endif
callback_t callback
The callback function.
Definition: UsbPnP.h:84
uint16_t nVendorId
Vendor and product IDs.
Definition: UsbPnP.h:87
Definition: Device.h:43
Definition: List.h:64
Definition: UsbPnP.h:40
uint8_t nClass
Class, subclass and protocol numbers.
Definition: UsbPnP.h:91
static UsbPnP & instance()
Singleton design.
Definition: UsbPnP.h:51
List< CallbackItem * > m_Callbacks
Callback list.
Definition: UsbPnP.h:97
static UsbPnP m_Instance
Static instance.
Definition: UsbPnP.h:74