tape-kernel 1.0
a modular modern independent kernel
Loading...
Searching...
No Matches
ide.h File Reference
#include "../lib/types.h"
Include dependency graph for ide.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define IDE_DATA   0x1F0
#define IDE_PRIMARY_CONTROL   0x3F6
#define IDE_ERROR   0x1F1
#define IDE_SECTORS   0x1F2
#define IDE_LBA_LOW   0x1F3
#define IDE_LBA_MID   0x1F4
#define IDE_LBA_HIGH   0x1F5
#define IDE_DEVICE   0x1F6
#define IDE_COMMAND   0x1F7
#define IDE_STATUS   0x1F7
#define ideinit   __ideinit
#define irsec   __irsec
#define iwrt   __iwrt
#define idesize   __idesize

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

Macro Definition Documentation

◆ IDE_COMMAND

#define IDE_COMMAND   0x1F7

Definition at line 14 of file ide.h.

Referenced by __idesize(), __irsec(), and __iwrt().

◆ IDE_DATA

#define IDE_DATA   0x1F0

Definition at line 6 of file ide.h.

Referenced by __idesize(), __irsec(), and __iwrt().

◆ IDE_DEVICE

#define IDE_DEVICE   0x1F6

Definition at line 13 of file ide.h.

Referenced by __ideinit(), __idesize(), __irsec(), and __iwrt().

◆ IDE_ERROR

#define IDE_ERROR   0x1F1

Definition at line 8 of file ide.h.

◆ IDE_LBA_HIGH

#define IDE_LBA_HIGH   0x1F5

Definition at line 12 of file ide.h.

Referenced by __irsec(), and __iwrt().

◆ IDE_LBA_LOW

#define IDE_LBA_LOW   0x1F3

Definition at line 10 of file ide.h.

Referenced by __irsec(), and __iwrt().

◆ IDE_LBA_MID

#define IDE_LBA_MID   0x1F4

Definition at line 11 of file ide.h.

Referenced by __irsec(), and __iwrt().

◆ IDE_PRIMARY_CONTROL

#define IDE_PRIMARY_CONTROL   0x3F6

Definition at line 7 of file ide.h.

Referenced by __ideinit().

◆ IDE_SECTORS

#define IDE_SECTORS   0x1F2

Definition at line 9 of file ide.h.

Referenced by __irsec(), and __iwrt().

◆ IDE_STATUS

#define IDE_STATUS   0x1F7

Definition at line 15 of file ide.h.

Referenced by __ideinit(), __idesize(), __irsec(), and __iwrt().

◆ ideinit

#define ideinit   __ideinit

Definition at line 17 of file ide.h.

Referenced by ___init().

◆ idesize

#define idesize   __idesize

Definition at line 20 of file ide.h.

Referenced by __disksize().

◆ irsec

#define irsec   __irsec

Definition at line 18 of file ide.h.

Referenced by ___init(), __ffsinit(), __fsinit(), __fsread(), __fsreadb(), and cmd_readfile().

◆ iwrt

#define iwrt   __iwrt

Definition at line 19 of file ide.h.

Referenced by ___init(), __ffsinit(), __fsadd(), __fsdelete(), __fswrite(), __fswriteb(), and cmd_writefile().

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.