The Pedigree Project
0.1
src
modules
drivers
common
ahci
AhciController.h
1
/*
2
* Copyright (c) 2026, Pedigree Developers
3
* SPDX-License-Identifier: ISC
4
*
5
* Permission to use, copy, modify, and distribute this software for any
6
* purpose with or without fee is hereby granted, provided that the above
7
* copyright notice and this permission notice appear in all copies.
8
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15
*/
16
#ifndef AHCI_CONTROLLER_H
17
#define AHCI_CONTROLLER_H
18
#include "pedigree/kernel/machine/Disk.h"
19
#include "pedigree/kernel/machine/IrqHandler.h"
20
#include "pedigree/kernel/process/Mutex.h"
21
22
#include "modules/drivers/common/scsi/ScsiController.h"
23
class
AhciPort
;
24
class
IoBase
;
25
class
AhciController
:
public
ScsiController
,
public
IrqHandler
{
26
public
:
27
explicit
AhciController
(
Device
* pci);
28
~AhciController
()
override
;
29
bool
initialiseController();
30
bool
supportsConcurrentReads
()
const override
{
31
return
true
;
32
}
33
void
shutdown();
34
bool
identify(
size_t
port, uint16_t* words,
bool
interruptProbe =
false
);
35
EXPORTED_PUBLIC
bool
readWrite(
size_t
port, uint64_t lba, uint16_t sectors,
void
* buffer,
36
size_t
bytes,
bool
write);
37
bool
readBatch(
size_t
port,
Disk::ReadBuffer
* buffers,
size_t
count);
38
bool
writeBatch(
size_t
port,
Disk::WriteBuffer
* buffers,
size_t
count);
39
bool
flush(
size_t
port,
bool
extended);
40
void
configureDisk(
size_t
port,
size_t
sectorBytes,
size_t
queueDepth);
41
EXPORTED_PUBLIC
size_t
interruptCompletions()
const
;
42
EXPORTED_PUBLIC
size_t
maximumOutstanding(
size_t
port)
const
;
43
IrqDisposition
irq
(irq_id_t number)
override
;
44
bool
sendCommand(
size_t
, uintptr_t, uint8_t, uintptr_t, uint16_t,
bool
)
override
{
45
return
false
;
46
}
47
48
protected
:
49
size_t
getNumUnits()
override
{
50
return
getNumChildren
();
51
}
52
53
private
:
54
bool
claimOwnership(uint32_t version);
55
bool
reset();
56
Device
* m_Pci;
57
IoBase
* m_Registers;
58
AhciPort
* m_Ports[32];
59
mutable
Mutex
m_IrqLock;
60
irq_id_t m_Irq;
61
uint32_t m_Implemented;
62
uint16_t m_OriginalCommand;
63
bool
m_PciChanged;
64
bool
m_HardwareOwned;
65
bool
m_Interrupts;
66
bool
m_Stopping;
67
bool
m_Shutdown;
68
};
69
#endif
AhciController
Definition
AhciController.h:25
AhciController::supportsConcurrentReads
bool supportsConcurrentReads() const override
Definition
AhciController.h:30
AhciController::irq
IrqDisposition irq(irq_id_t number) override
Definition
AhciController.cc:210
AhciPort
Definition
AhciPort.h:24
Device
Definition
Device.h:41
Device::getNumChildren
size_t getNumChildren()
Definition
Device.cc:131
IoBase
Abstrace base class for hardware I/O capabilities.
Definition
IoBase.h:32
IrqHandler
Definition
IrqHandler.h:73
Mutex
Definition
Mutex.h:56
ScsiController
Definition
ScsiController.h:38
IrqDisposition
IrqDisposition
Definition
IrqHandler.h:31
Disk::ReadBuffer
Definition
Disk.h:119
Disk::WriteBuffer
Definition
Disk.h:126
Generated on Tue Sep 22 2026 06:05:42 for The Pedigree Project by
1.9.8