2 * (c) 2013 Alexander Warg <warg@os.inf.tu-dresden.de>
3 * economic rights: Technische Universität Dresden (Germany)
5 * This file is part of TUD:OS and distributed under the terms of the
6 * GNU General Public License 2.
7 * Please see the COPYING-GPL-2 file for details.
11 #include "hw_device.h"
23 Acpi_ptr(Acpi_ptr const &) = delete;
24 Acpi_ptr &operator = (Acpi_ptr const &) = delete;
26 explicit Acpi_ptr(T *p = 0) : _p(p) {}
35 T &operator * () const { return *_p; }
36 T *operator -> () const { return _p; }
38 T **ref() { return &_p; }
39 T *get() const { return _p; }
44 struct Acpi_auto_buffer : ACPI_BUFFER
46 Acpi_auto_buffer() { Pointer = 0; Length = 0; }
53 void *release() { void *r = Pointer; Pointer = 0; return r; }
57 struct Acpi_buffer : ACPI_BUFFER
63 Length = sizeof(value);
69 ACPI_WALK_CALLBACK cb;
72 template<typename Functor>
74 : cb(invoke<Functor>), ctxt(reinterpret_cast<void*>(&f))
77 ACPI_STATUS walk(ACPI_OBJECT_TYPE type, ACPI_HANDLE root, unsigned max_depth)
79 return AcpiWalkNamespace(type, root, max_depth, cb, 0, ctxt, 0);
84 template< typename Functor >
85 static ACPI_STATUS invoke(ACPI_HANDLE obj, l4_uint32_t level, void *ctxt, void **)
87 return (*reinterpret_cast<typename cxx::remove_reference<Functor>::type *>(ctxt))(obj, level);
95 public Hw::Dev_feature
98 enum { Acpi_event = 0x8 };
100 Acpi_dev(ACPI_HANDLE obj)
101 : _obj(obj), _have_notification_handler(false) {}
103 ACPI_HANDLE handle() const { return _obj; }
105 void discover_crs(Hw::Device *host);
106 void enable_notifications(Hw::Device *host);
107 void disable_notifications(Hw::Device *host);
111 bool _have_notification_handler;
114 struct Acpi_device_driver
116 virtual Acpi_dev *probe(Hw::Device *device, ACPI_HANDLE acpi_hdl,
117 ACPI_DEVICE_INFO const *info);
118 virtual ~Acpi_device_driver() = 0;
120 static bool register_driver(char const *hid, Acpi_device_driver *driver);
121 static Acpi_device_driver* find(char const *hid);
124 inline Acpi_device_driver::~Acpi_device_driver() {}
128 void register_sci(Io_irq_pin *sci);
133 unsigned acpi_get_debug_level();