summaryrefslogtreecommitdiffhomepage
path: root/Private/KernelKit/PCI/IO.hpp
blob: 778650b60ccea9f889332b5bd2a281cdd3b5b6d2 (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
/*
 *	========================================================
 *
 *	HCore
 * 	Copyright Mahrouss Logic, all rights reserved.
 *
 * 	========================================================
 */

#pragma once

#include <ArchKit/Arch.hpp>
#include <NewKit/Array.hpp>
#include <NewKit/Defines.hpp>
#include <NewKit/Ref.hpp>

namespace HCore {
template <SizeT Sz>
class IOArray final {
 public:
  IOArray() = delete;

  IOArray(nullPtr) = delete;

  explicit IOArray(Array<UShort, Sz> &ports) : m_Ports(ports) {}
  ~IOArray() {}

  IOArray &operator=(const IOArray &) = default;

  IOArray(const IOArray &) = default;

  operator bool() { return !m_Ports.Empty(); }

 public:
  template <typename T>
  T In(SizeT index);

  template <typename T>
  void Out(SizeT index, T value);

 private:
  Array<UShort, Sz> m_Ports;
};

using IOArray16 = IOArray<16>;
}  // namespace HCore

#ifdef __x86_64__
#include <KernelKit/PCI/IO-Impl-AMD64.inl>
#else
#error Please provide platform specific code for the I/O
#endif  // ifdef __x86_64__