tape-kernel 1.0
a modular modern independent kernel
Loading...
Searching...
No Matches
ide.c File Reference
#include "ide.h"
#include "../io/io.h"
#include "../lib/err.h"
Include dependency graph for ide.c:

Go to the source code of this file.

Functions

void __ideinit (void)
 ideinit initializes the ide disk controller
void __irsec (uint32_t lba, uint8_t *buff)
 irsec reads a single 512 byte sector from disk
void __iwrt (uint32_t lba, uint8_t *buff)
 iwrt writes a single 512 byte sector to disk
int __idesize (uint32_t *secs)
 idesize queries the ide drive for its total sector count

Function Documentation

◆ __ideinit()

void __ideinit ( void )

ideinit initializes the ide disk controller

ideinit is a function that resets the ide controller, selects the master drive, and verifies the drive is present and ready

using ideinit is done with

#include "../fs/ide.h" //or just ide.h
#define ideinit
Definition ide.h:17
See also
ffsinit(), irsec(), iwrt()

Definition at line 21 of file ide.c.

References assert, IDE_DEVICE, IDE_PRIMARY_CONTROL, IDE_STATUS, inb, and outb.

◆ __idesize()

int __idesize ( uint32_t * secs)

idesize queries the ide drive for its total sector count

idesize is a function that sends the IDENTIFY command to the ide drive and reads back the total number of lba28 sectors

Parameters
secs,apointer to store the total sector count

using idesize is done with

#include "../fs/ide.h" //or just ide.h
uint32_t total_secs;
if (idesize(&total_secs)) {
//total_secs now holds the drive sector count
}
#define idesize
Definition ide.h:20
unsigned int uint32_t
Definition types.h:30
See also
disksize(), ideinit()

Definition at line 144 of file ide.c.

References IDE_COMMAND, IDE_DATA, IDE_DEVICE, IDE_STATUS, inb, inw, and outb.

◆ __irsec()

void __irsec ( uint32_t lba,
uint8_t * buff )

irsec reads a single 512 byte sector from disk

irsec is a function that reads one sector from the ide drive at the given lba

Parameters
lba,thelogical block address to read from
buff,the512 byte buffer to store the read data

using irsec is done with

#include "../fs/ide.h" //or just ide.h
uint8_t sector[512];
irsec(0, sector); //read the boot sector
#define irsec
Definition ide.h:18
unsigned char uint8_t
Definition types.h:28
See also
iwrt(), idesize()

Definition at line 59 of file ide.c.

References assert, IDE_COMMAND, IDE_DATA, IDE_DEVICE, IDE_LBA_HIGH, IDE_LBA_LOW, IDE_LBA_MID, IDE_SECTORS, IDE_STATUS, inb, inw, NULL, and outb.

◆ __iwrt()

void __iwrt ( uint32_t lba,
uint8_t * buff )

iwrt writes a single 512 byte sector to disk

iwrt is a function that writes one sector to the ide drive at the given lba

Parameters
lba,thelogical block address to write to
buff,the512 byte buffer containing the data to write

using iwrt is done with

#include "../fs/ide.h" //or just ide.h
uint8_t sector[512];
iwrt(1, sector); //write to sector 1
#define iwrt
Definition ide.h:19
See also
irsec(), fswrite()

Definition at line 99 of file ide.c.

References assert, IDE_COMMAND, IDE_DATA, IDE_DEVICE, IDE_LBA_HIGH, IDE_LBA_LOW, IDE_LBA_MID, IDE_SECTORS, IDE_STATUS, inb, NULL, outb, and outw.