Go to the documentation of this file.
23 int main(
int argc,
char **argv)
33 ERROR(
"failed to initialize: result = " << (
int) result);
66 NOTICE(
"No ATA drive(s) detected");
78 for (
int i = 0; i < 256; i++)
105 u8 sectors =
CEIL(size, 512);
107 u32 lba = offset / 512;
132 for (
int i = 0; i < 256; i++)
138 Size bytes = (size - result) < 512 - (off % 512) ?
139 (size - result) : 512 - (off % 512);
155 INFO(
"ATA interrupted on IRQ " << vector);
#define ATA_REG_DATA
Data port.
#define ATA_REG_ADDR2
Partial Disk Sector address.
#define ATA_REG_COUNT
Sector Count.
virtual FileSystem::Result interrupt(const Size vector)
Process ATA interrupts.
#define NOTICE(msg)
Output a notice message.
virtual FileSystem::Result initialize()
Configures the ATA controller.
u32 getNextInode()
Get next unused inode.
struct ATADrive ATADrive
Represents a Drive on the ATA bus.
ATAController(const u32 inode)
Constructor.
AT Attachment (ATA) Host Controller Device.
#define IDENTIFY_TEXT_SWAP(field, size)
Swap ASCII bytes from IDENTIFY.
FileSystem::Result bufferedWrite(const void *buffer, const Size size)
Buffered write bytes to the I/O buffer.
void pollReady(bool noData=false)
Polls the Regular Status register.
#define ATA_STATUS_BUSY
Drive is preparing to accept or send data.
Abstract device class interface.
#define ATA_SEL_MASTER_28
Master Drive in 28-bit LBA mode.
int run()
Enters an infinite loop, serving incoming requests.
#define ATA_BASE_CMD0
First ATA Bus Command I/O Base.
Represents a Drive on the ATA bus.
virtual bool isEmpty() const
Check if the List is empty.
#define ATA_REG_ADDR1
Partial Disk Sector address.
int main(int argc, char **argv)
Program entry point.
Log to the kernel using PrivExec().
void registerDevice(Device *dev, const char *path)
Add a Device.
#define ATA_CMD_READ
Reads sectors from an ATA device.
#define ATA_REG_SELECT
Drive Select bit, Flag bits, Extra address bits.
void append(T t)
Insert an item at the end of the list.
unsigned short u16
Unsigned 16-bit number.
#define INFO(msg)
Output a regular message to standard output.
Abstract Input/Output buffer.
unsigned int u32
Unsigned 32-bit number.
#define CEIL(number, divisor)
Calculate a division, and round to up any remaining.
#define ATA_REG_ADDR0
Partial Disk Sector address.
unsigned int Size
Any sane size indicator cannot go negative.
List< ATADrive * > drives
Drives detected on the ATA bus.
Arch::IO m_io
Port I/O object.
virtual FileSystem::Result initialize()
Initialize DeviceServer.
virtual FileSystem::Result status(FileSystem::FileStat &st)
Retrieve file statistics.
IdentifyData identity
Bytes returned from IDENTIFY.
String m_identifier
Unique identifier for this Device.
#define ERROR(msg)
Output an error message.
#define ATA_REG_STATUS
Regular Status port.
Result
Result code for filesystem Actions.
unsigned char u8
Unsigned 8-bit number.
T first()
Get the first value in the list.
#define ATA_STATUS_DATA
Drive data ready for transfer.
#define ATA_SEL_MASTER
Master Drive in Legacy mode.
#define ATA_CMD_IDENTIFY
Identifies an ATA device, if any.
#define ATA_REG_CMD
Command port and Regular Status port.
virtual FileSystem::Result read(IOBuffer &buffer, Size &size, const Size offset)
Read bytes from a drive attached to the ATA controller.