MentOS
0.8.0
The Mentoring Operating System
|
Drivers for the Advanced Technology Attachment (ATA) devices. More...
Classes | |
struct | ata_identity_t |
IDENTIFY device data (response to 0xEC). More... | |
struct | prdt_t |
Physical Region Descriptor Table (PRDT) entry. More... | |
struct | ata_device_t |
Stores information about an ATA device. More... | |
Macros | |
#define | __DEBUG_HEADER__ "[ATA ]" |
Change header. | |
#define | __DEBUG_LEVEL__ LOGLEVEL_NOTICE |
Set log level. | |
#define | ATA_SECTOR_SIZE 512 |
The sector size. | |
#define | ATA_DMA_SIZE 512 |
The size of the DMA area. | |
Typedefs | |
typedef struct ata_identity_t | ata_identity_t |
IDENTIFY device data (response to 0xEC). | |
typedef struct prdt_t | prdt_t |
Physical Region Descriptor Table (PRDT) entry. More... | |
typedef struct ata_device_t | ata_device_t |
Stores information about an ATA device. | |
Functions | |
int | ata_initialize (void) |
Initializes the ATA drivers. More... | |
int | ata_finalize (void) |
De-initializes the ATA drivers. More... | |
static const char * | ata_get_device_error_str (uint8_t error) |
Returns the set of ATA errors as a string. More... | |
static const char * | ata_get_device_status_str (uint8_t status) |
Returns the device status as a string. More... | |
static const char * | ata_get_device_settings_str (ata_device_t *dev) |
Returns the device configuration as string. More... | |
static const char * | ata_get_device_type_str (ata_device_type_t type) |
Returns the device type as string. More... | |
static void | ata_dump_device (ata_device_t *dev) |
Dumps on debugging output the device data. More... | |
static void | ata_io_wait (ata_device_t *dev) |
Waits for approximately 400 nanoseconds by performing four I/O reads. More... | |
static int | ata_status_wait_not (ata_device_t *dev, long mask, long timeout) |
Waits until the status bits selected through the mask are zero. More... | |
static int | ata_status_wait_for (ata_device_t *dev, long mask, long timeout) |
Waits until the status bits selected through the mask are set. More... | |
static void | ata_print_status_error (ata_device_t *dev) |
Prints the status and error information about the device. More... | |
static uint64_t | ata_max_offset (ata_device_t *dev) |
Ge the maximum offset for the given device. More... | |
static void | ata_fix_string (char *str, size_t len) |
Fixes all ATA-related strings. More... | |
static void | ata_soft_reset (ata_device_t *dev) |
Performs a soft reset of the device. More... | |
static uintptr_t | ata_dma_alloc (size_t size, uintptr_t *physical) |
Creates the DMA memory area used to write and read on the device. More... | |
static int | ata_dma_free (uintptr_t logical_addr) |
Frees the DMA memory area previously allocated. More... | |
static int | ata_dma_enable_bus_mastering (void) |
Enables bus mastering, allowing Direct Memory Access (DMA) transactions. More... | |
static int | ata_dma_disable_bus_mastering (void) |
Disables bus mastering, preventing Direct Memory Access (DMA) transactions. More... | |
static int | ata_dma_initialize_bus_mastering_address (ata_device_t *dev) |
Initializes the bus mastering register (BMR) fields of the ATA device. More... | |
static ata_device_type_t | ata_detect_device_type (ata_device_t *dev) |
Detects the type of device. More... | |
static bool_t | ata_device_init (ata_device_t *dev) |
Initialises the given device. More... | |
static void | ata_device_read_sector (ata_device_t *dev, uint32_t lba_sector, uint8_t *buffer) |
Reads an ATA sector. More... | |
static void | ata_device_write_sector (ata_device_t *dev, uint32_t lba_sector, uint8_t *buffer) |
Writs an ATA sector. More... | |
static vfs_file_t * | ata_open (const char *path, int flags, mode_t mode) |
Implements the open function for an ATA device. More... | |
static int | ata_close (vfs_file_t *file) |
Closes an ATA device. More... | |
static ssize_t | ata_read (vfs_file_t *file, char *buffer, off_t offset, size_t size) |
Reads from an ATA device. More... | |
static ssize_t | ata_write (vfs_file_t *file, const void *buffer, off_t offset, size_t size) |
Writes on an ATA device. More... | |
static int | _ata_stat (const ata_device_t *dev, stat_t *stat) |
Stats an ATA device. More... | |
static int | ata_fstat (vfs_file_t *file, stat_t *stat) |
Retrieves information concerning the file at the given position. More... | |
static int | ata_stat (const char *path, stat_t *stat) |
Retrieves information concerning the file at the given position. More... | |
static vfs_file_t * | ata_mount_callback (const char *path, const char *device) |
The mount call-back, which prepares everything and calls the actual ATA mount function. More... | |
static vfs_file_t * | ata_device_create (ata_device_t *dev) |
Creates a VFS file, starting from an ATA device. More... | |
static ata_device_type_t | ata_device_detect (ata_device_t *dev) |
Detects and mount the given ATA device. More... | |
static void | ata_irq_handler_master (pt_regs *f) |
static void | ata_irq_handler_slave (pt_regs *f) |
static void | pci_find_ata (uint32_t device, uint16_t vendorid, uint16_t deviceid, void *extra) |
Used while scanning the PCI interface. More... | |
Variables | |
static char | ata_drive_char = 'a' |
Keeps track of the incremental letters for the ATA drives. | |
static int | cdrom_number = 0 |
Keeps track of the incremental number for removable media. | |
static uint32_t | ata_pci = 0x00000000 |
We store the ATA pci address here. | |
static ata_device_t | ata_primary_master |
The ATA primary master control register locations. More... | |
static ata_device_t | ata_primary_slave |
The ATA primary slave control register locations. More... | |
static ata_device_t | ata_secondary_master |
The ATA secondary master control register locations. More... | |
static ata_device_t | ata_secondary_slave |
The ATA secondary slave control register locations. More... | |
static file_system_type | ata_file_system_type |
Filesystem information. More... | |
static vfs_sys_operations_t | ata_sys_operations |
Filesystem general operations. More... | |
static vfs_file_operations_t | ata_fs_operations |
ATA filesystem file operations. More... | |
Drivers for the Advanced Technology Attachment (ATA) devices.
Physical Region Descriptor Table (PRDT) entry.
The physical memory region to be transferred is described by a Physical Region Descriptor (PRD). The data transfer will proceed until all regions described by the PRDs in the table have been transferred. Each Physical Region Descriptor entry is 8 bytes in length. | byte 3 | byte 2 | byte 1 | byte 0 | Dword 0 | Memory Region Physical Base Address [31:1] |0| Dword 1 | EOT | reserved | Byte Count [15:1] |0|
enum ata_control_t |
ATA Control Bits.
enum ata_device_type_t |
enum ata_dma_command_t |
enum ata_error_t |
enum ata_status_t |
ATA Status Bits.
|
static |
Stats an ATA device.
dev | the ATA device. |
stat | the stat buffer. |
|
static |
Closes an ATA device.
file | the VFS file associated with the ATA device. |
|
inlinestatic |
Detects the type of device.
dev | The device for which we are checking the type. |
|
static |
Creates a VFS file, starting from an ATA device.
dev | the ATA device. |
|
static |
Detects and mount the given ATA device.
dev | the device we want to handle. |
|
static |
Initialises the given device.
dev | the device to initialize. |
|
static |
Reads an ATA sector.
dev | the device on which we perform the read. |
lba_sector | the sector where we write. |
buffer | the buffer we are writing. |
|
static |
Writs an ATA sector.
dev | the device on which we perform the write. |
lba_sector | the sector where we read. |
buffer | the buffer where we store what we read. |
Creates the DMA memory area used to write and read on the device.
size | the size of the DMA memory area. |
physical | the physical address of the DMA memory area. |
|
inlinestatic |
Disables bus mastering, preventing Direct Memory Access (DMA) transactions.
This function reads the PCI command register and clears the bus mastering bit. If bus mastering is already disabled, it logs a warning.
|
inlinestatic |
Enables bus mastering, allowing Direct Memory Access (DMA) transactions.
This function reads the PCI command register and enables bus mastering if not already enabled. It checks if the bus mastering bit is already set, and if not, sets it and verifies the change. If bus mastering cannot be enabled, it signals an error.
|
inlinestatic |
Frees the DMA memory area previously allocated.
logical_addr | the logical (low-memory) address to free. |
|
inlinestatic |
Initializes the bus mastering register (BMR) fields of the ATA device.
dev | The device to initialize. |
When retrieving the actual base address of a Base Address Register (BAR), it's essential to mask the lower bits to ensure you're working with the correct address space.
|
inlinestatic |
Dumps on debugging output the device data.
dev | the device to dump. |
int ata_finalize | ( | void | ) |
De-initializes the ATA drivers.
|
inlinestatic |
Fixes all ATA-related strings.
str | string to fix. |
len | length of the string. |
|
static |
Retrieves information concerning the file at the given position.
file | the file. |
stat | the structure where the information are stored. |
|
inlinestatic |
Returns the set of ATA errors as a string.
error | the variable containing all the error flags. |
|
inlinestatic |
Returns the device configuration as string.
dev | the devce. |
|
inlinestatic |
Returns the device status as a string.
status | the device status. |
|
inlinestatic |
Returns the device type as string.
type | the device type value. |
int ata_initialize | ( | void | ) |
Initializes the ATA drivers.
|
inlinestatic |
Waits for approximately 400 nanoseconds by performing four I/O reads.
dev | The device on which we wait. |
|
static |
f | The interrupt stack frame. |
|
static |
f | The interrupt stack frame. |
|
inlinestatic |
Ge the maximum offset for the given device.
dev |
|
static |
The mount call-back, which prepares everything and calls the actual ATA mount function.
path | the path where the filesystem should be mounted. |
device | the device we mount. |
|
static |
Implements the open function for an ATA device.
path | the phat to the device we want to open. |
flags | we ignore these. |
mode | we currently ignore this. |
|
inlinestatic |
Prints the status and error information about the device.
dev | the device for which we print the information. |
|
static |
Reads from an ATA device.
file | the VFS file associated with the ATA device. |
buffer | the buffer where we store what we read. |
offset | the offset where we want to read. |
size | the size of the buffer. |
|
inlinestatic |
Performs a soft reset of the device.
For non-ATAPI drives, the only method a driver has of resetting a drive after a major error is to do a "software reset" on the bus. Set bit 2 (SRST, value = 4) in the proper Control Register for the bus. This will reset both ATA devices on the bus.
dev | the device on which we perform the soft reset. |
|
static |
Retrieves information concerning the file at the given position.
path | the path where the file resides. |
stat | the structure where the information are stored. |
|
inlinestatic |
Waits until the status bits selected through the mask are set.
dev | The device we need to wait for. |
mask | The mask used to check the status bits. |
timeout | The maximum number of cycles to wait before timing out. |
|
inlinestatic |
Waits until the status bits selected through the mask are zero.
dev | The device we need to wait for. |
mask | The mask used to check the status bits. |
timeout | The maximum number of cycles to wait before timing out. |
|
static |
Writes on an ATA device.
file | the VFS file associated with the ATA device. |
buffer | the buffer we use to write. |
offset | the offset where we want to write. |
size | the size of the buffer. |
|
static |
Used while scanning the PCI interface.
device | the device we want to find. |
vendorid | its vendor ID. |
deviceid | its device ID. |
extra | the devoce once we find it. |
|
static |
Filesystem information.
|
static |
ATA filesystem file operations.
|
static |
The ATA primary master control register locations.
|
static |
The ATA primary slave control register locations.
|
static |
The ATA secondary master control register locations.
|
static |
The ATA secondary slave control register locations.
|
static |