aboutsummaryrefslogtreecommitdiff
path: root/kapi/include/kapi/devices.hpp
blob: 2028a645c3129c7d0ac4986cc6f306fb54bd10bd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#ifndef TEACHOS_KAPI_DEVICES_HPP
#define TEACHOS_KAPI_DEVICES_HPP

#include "kapi/devices/bus.hpp"     // IWYU pragma: export
#include "kapi/devices/device.hpp"  // IWYU pragma: export

#include <cstddef>

namespace kapi::devices
{

  //! @addtogroup kernel-defined
  //! @{

  //! Initialize the kernel's device management subsystem.
  auto init() -> void;

  //! Get the virtual system root bus.
  //!
  //! @warning This function will panic if the root bus has not been initialized.
  //!
  //! @return a reference to the root bus.
  auto get_root_bus() -> bus &;

  //! Ask the kernel to allocate a new major number.
  //!
  //! @return a new, unused major number.
  auto allocate_major_number() -> std::size_t;

  //! Register a new device with the kernel's device manager.
  //!
  //! @param device The device to register.
  //! @return true if the device was registered successfully, false otherwise.
  auto register_device(device & device) -> bool;

  //! Unregister a device from the kernel's device manager.
  //!
  //! @param device The device to unregister.
  //! @return true if the device was unregistered successfully, false otherwise.
  auto unregister_device(device & device) -> bool;

  //! @}

  //! @addtogroup platform-defined
  //! @{

  //! Initialize the platform's device tree.
  auto init_platform_devices() -> void;

  //! @}

}  // namespace kapi::devices

#endif