MicrOS
harddisk_header.h File Reference
#include <stdint.h>
#include <stddef.h>
#include "assembly/io.h"
#include "cpu/timer/timer.h"
#include "harddisk_identify_device_data.h"
#include "harddisk_pio_mode_header.h"

Go to the source code of this file.

Classes

struct  harddisk_states
 Defines status of hard disks in system. More...
 
struct  harddisk_configuration
 Defines configuration of harddisk driver. More...
 

Macros

#define HARDDISK_BSY_ERROR_DELAY_MS   10000
 Delay after which we assume drive failed during BSY pooling. More...
 

Enumerations

enum  HARDDISK_ATA_BUS_TYPE { HARDDISK_ATA_PRIMARY_BUS = 1, HARDDISK_ATA_SECONDARY_BUS = 2 }
 Enum represent bus type. More...
 
enum  HARDDISK_ATA_MASTER_SLAVE { HARDDISK_ATA_MASTER = 1, HARDDISK_ATA_SLAVE = 2 }
 Enum represent hard disk type. More...
 
enum  HARDDISK_STATE {
  HARDDISK_ERROR = -1, HARDDISK_NOT_PRESENT = 0, HARDDISK_ATA_PRESENT = 1, HARDDISK_ATAPI_PRESENT = 2,
  HARDDISK_SATA_PRESENT = 3, HARDDISK_SATAPI_PRESENT = 4
}
 Enum represent hard disk status. More...
 

Functions

int8_t __harddisk_soft_reset_port (uint16_t control_port)
 Perform soft reset for given control_port. More...
 
void __harddisk_400ns_delay (uint16_t control_port)
 Makes 400ns delay. More...
 
int8_t __harddisk_bsy_poll (uint16_t control_port)
 Pools BSY bit until clears. More...
 
void __harddisk_get_pointers (HARDDISK_ATA_MASTER_SLAVE type, HARDDISK_ATA_BUS_TYPE bus, const HARDDISK_STATE **state, const harddisk_identify_device_data **data)
 Gets pointers to hard disk data. More...
 

Macro Definition Documentation

◆ HARDDISK_BSY_ERROR_DELAY_MS

#define HARDDISK_BSY_ERROR_DELAY_MS   10000

Delay after which we assume drive failed during BSY pooling.

Enumeration Type Documentation

◆ HARDDISK_ATA_BUS_TYPE

Enum represent bus type.

Enumerator
HARDDISK_ATA_PRIMARY_BUS 

Primary bus.

HARDDISK_ATA_SECONDARY_BUS 

Secondary bus.

◆ HARDDISK_ATA_MASTER_SLAVE

Enum represent hard disk type.

Enumerator
HARDDISK_ATA_MASTER 

Master hard disk.

HARDDISK_ATA_SLAVE 

Slave hard disk.

◆ HARDDISK_STATE

Enum represent hard disk status.

Enumerator
HARDDISK_ERROR 

Error.

HARDDISK_NOT_PRESENT 

Not present.

HARDDISK_ATA_PRESENT 

ATA device present.

HARDDISK_ATAPI_PRESENT 

ATAPI device present.

HARDDISK_SATA_PRESENT 

SATA device present.

HARDDISK_SATAPI_PRESENT 

SATAPI device present.

Function Documentation

◆ __harddisk_400ns_delay()

void __harddisk_400ns_delay ( uint16_t  control_port)

Makes 400ns delay.

Makes 400ns delay by checking drive status 15 times. User after switching type of drive in bus.

Parameters
portPort for do delay.

◆ __harddisk_bsy_poll()

int8_t __harddisk_bsy_poll ( uint16_t  control_port)

Pools BSY bit until clears.

Pools BSY bit until clears, if pooling takes too long exits with error.

Parameters
portPort for pooling.
Returns
1 if success, -1 if error

◆ __harddisk_get_pointers()

void __harddisk_get_pointers ( HARDDISK_ATA_MASTER_SLAVE  type,
HARDDISK_ATA_BUS_TYPE  bus,
const HARDDISK_STATE **  state,
const harddisk_identify_device_data **  data 
)

Gets pointers to hard disk data.

Sets state to proper state and data from harddisk_states structure to proper values for given harddisk and bus type.

Parameters
typeType of harddisk.
busType of bus.
statePointer to state.
busPointer to data.

◆ __harddisk_soft_reset_port()

int8_t __harddisk_soft_reset_port ( uint16_t  control_port)

Perform soft reset for given control_port.

Soft reset should set bit SRST in Device Control Register for 5 us.

Parameters
control_portControl port to perform reset
Returns
1 if success, -1 if error