General Info

Interface: IdeController
Files: idecontroller.h
Last change: 20/12/2003
Author: Luiz Henrique Shigunov
Description
Structures
System Functions

0x00 - GetDrive - Get a drive for use
0x01 - LockInterface - Lock an interface for exclusive use
0x02 - PutDrive - Free a drive
0x03 - ReadData - Read data from a drive

0x04 - SendRequest - Send a request to a drive
0x05 - SetupDrive - Setup a drive
0x06 - UnlockInterface - Unlock an interface
0x07 - WriteData - Write data to a drive

Description

This page describes the IdeController interface which provides services from an IDE controller.

Structures

typedef struct {
    unsigned char port;
    unsigned char data;
} IdeController_RequestPort;

typedef struct {
    unsigned int version;
    unsigned int interface;
    unsigned int drive;
    unsigned int timeout;
    int flags;
    unsigned int numIOs;
    unsigned char status;
    unsigned char error;
    IdeController_RequestPort IOs[1];
} IdeController_Request;

Where version is the structure version (version 1), interface the interface, drive the drive, timeout the amount of seconds to wait before time out the request, flags control the request and can be 0 or the sum of:

status and error will contain the status and error byte in return.

numIOs it is the size o the IO array which contains the IO ports and the data to be write in these ports.

The IO ports present in IO will be write from IO[0] till IO[numIOs-1] in this order.

port must contain one of these values:

typedef struct {
    unsigned int version;
    unsigned int interface;
    unsigned int drive;
    int flags;
} IdeController_Setup;

Where version it is the structure version (version 1), interface the interface, drive the drive and flags must be 0 or the sum of:

System Functions

These functions are exclusive for system modules.

0x00 - GetDrive

Syntax

int IdeController_GetDrive(unsigned int interface, unsigned int drive);

Properties

Description

This function gets drive from interface for exclusive use.

drive and interface start at zero.

To free drive use PutDrive.

Return value

0x01 - LockInterface

Syntax

int IdeController_LockInterface(unsigned int interface);

Properties

Description

This function locks interface for exclusive use.

The calling thread will block until it gets exclusive use.

interface starts at zero.

Before an IDE interface can be used on any IdeController function it must be locked for exclusive use using LockInterface.

To unlock use UnlockInterface.

Return value

0x02 - PutDrive

Syntax

int IdeController_PutDrive(unsigned int interface, unsigned int drive);

Properties

Description

This function frees drive from interface.

drive and interface start at zero.

If drive was not got nothing happens and the function returns success.

Return value

0x03 - ReadData

Syntax

int IdeController_ReadData(unsigned int interface, void *buf, unsigned int size);

Properties

Description

This function reads size bytes from interface and puts them in buf.

interface starts at zero.

Return value

0x04 - SendRequest

Syntax

int IdeController_SendRequest(IdeController_Request *rq);

Properties

Description

This function processes the request rq.

Return value

0x05 - SetupDrive

Syntax

int IdeController_SetupDrive(const IdeController_Setup *set);

Properties

Description

This function sets up the drive acording to set.

Return value

0x06 - UnlockInterface

Syntax

int IdeController_UnlockInterface(unsigned int interface);

Properties

Description

This function unlocks interface.

interface starts at zero.

Return value

0x07 - WriteData

Syntax

int IdeController_WriteData(unsigned int interface, const void *buf, unsigned int size);

Properties

Description

This function writes size bytes from buf into interface.

interface starts at zero.

Return value