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"
24 Acpi_ptr(Acpi_ptr const &) = delete;
25 Acpi_ptr &operator = (Acpi_ptr const &) = delete;
27 explicit Acpi_ptr(T *p = 0) : _p(p) {}
36 T &operator * () const { return *_p; }
37 T *operator -> () const { return _p; }
39 T **ref() { return &_p; }
40 T *get() const { return _p; }
45 struct Acpi_auto_buffer : ACPI_BUFFER
47 Acpi_auto_buffer() { Pointer = 0; Length = 0; }
54 void *release() { void *r = Pointer; Pointer = 0; return r; }
58 struct Acpi_buffer : ACPI_BUFFER
64 Length = sizeof(value);
70 ACPI_WALK_CALLBACK cb;
73 template<typename Functor>
75 : cb(invoke<Functor>), ctxt(reinterpret_cast<void*>(&f))
78 ACPI_STATUS walk(ACPI_OBJECT_TYPE type, ACPI_HANDLE root, unsigned max_depth)
80 return AcpiWalkNamespace(type, root, max_depth, cb, 0, ctxt, 0);
85 template< typename Functor >
86 static ACPI_STATUS invoke(ACPI_HANDLE obj, l4_uint32_t level, void *ctxt, void **)
88 return (*reinterpret_cast<typename cxx::remove_reference<Functor>::type *>(ctxt))(obj, level);
96 public Hw::Dev_feature
99 enum { Acpi_event = 0x8 };
101 Acpi_dev(ACPI_HANDLE obj)
102 : _obj(obj), _have_notification_handler(false) {}
104 ACPI_HANDLE handle() const { return _obj; }
106 void discover_crs(Hw::Device *host);
107 void enable_notifications(Hw::Device *host);
108 void disable_notifications(Hw::Device *host);
112 bool _have_notification_handler;
115 struct Acpi_device_driver
117 virtual Acpi_dev *probe(Hw::Device *device, ACPI_HANDLE acpi_hdl,
118 ACPI_DEVICE_INFO const *info);
119 virtual ~Acpi_device_driver() = 0;
121 static bool register_driver(char const *hid, Acpi_device_driver *driver);
122 static bool register_driver(unsigned short type, Acpi_device_driver *driver);
123 static Acpi_device_driver* find(char const *hid);
124 static Acpi_device_driver* find(unsigned short type);
127 inline Acpi_device_driver::~Acpi_device_driver() {}
131 void register_sci(Io_irq_pin *sci);
136 unsigned acpi_get_debug_level();
138 extern Hw::Pci::Root_bridge *
139 (*acpi_create_pci_root_bridge)(int, int busnum, Hw::Device *device);