summaryrefslogtreecommitdiffhomepage
path: root/dev/boot/BootKit/HW/SATA.h
blob: 7e84c061250d69475c0bd31730f6ae8014f0707b (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
/* -------------------------------------------

  Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved.

------------------------------------------- */

#pragma once

#include <CompilerKit/CompilerKit.h>
#include <modules/AHCI/AHCI.h>

class BootDeviceSATA final {
 public:
  explicit BootDeviceSATA() noexcept;
  ~BootDeviceSATA() = default;

  NE_COPY_DEFAULT(BootDeviceSATA)

  struct SATATrait final {
    Kernel::SizeT   mBase{1024};
    Kernel::Boolean mErr{false};
    Kernel::Boolean mDetected{false};

    operator bool() { return !this->mErr; }
  };

  operator bool() { return this->Leak().mDetected; }

  BootDeviceSATA& Read(Kernel::WideChar* Buf, const Kernel::SizeT SecCount);
  BootDeviceSATA& Write(Kernel::WideChar* Buf, const Kernel::SizeT SecCount);

  SATATrait& Leak();

 private:
  SATATrait mTrait;
};

#define kAHCISectorSz 4096