KallistiOS git master
Independent SDK for the Sega Dreamcast
Loading...
Searching...
No Matches
g1ata.h File Reference

G1 bus ATA interface. More...

#include <sys/cdefs.h>
#include <stdint.h>
#include <kos/blockdev.h>

Go to the source code of this file.

Macros

#define G1_ATA_MASTER   0x00
 ATA master device.
 
#define G1_ATA_MASTER_ALT   0x90
 ATA master device (compatible with old drives).
 
#define G1_ATA_SLAVE   0xB0
 ATA slave device.
 
#define G1_ATA_LBA_MODE   0x40
 Select LBA addressing mode.
 

Functions

int g1_dma_in_progress (void)
 Is there a G1 DMA in progress currently?
 
int g1_ata_mutex_lock (void)
 Lock the G1 ATA mutex.
 
int g1_ata_mutex_unlock (void)
 Unlock the G1 ATA mutex.
 
uint8_t g1_ata_select_device (uint8_t dev)
 Set the active ATA device.
 
int g1_ata_read_chs (uint16_t c, uint8_t h, uint8_t s, size_t count, void *buf)
 Read one or more disk sectors with Cylinder-Head-Sector addressing.
 
int g1_ata_write_chs (uint16_t c, uint8_t h, uint8_t s, size_t count, const void *buf)
 Write one or more disk sectors with Cylinder-Head-Sector addressing.
 
int g1_ata_read_lba (uint64_t sector, size_t count, void *buf)
 Read one or more disk sectors with Linear Block Addressing (LBA).
 
int g1_ata_read_lba_dma (uint64_t sector, size_t count, void *buf, int block)
 DMA read disk sectors with Linear Block Addressing (LBA).
 
int g1_ata_write_lba (uint64_t sector, size_t count, const void *buf)
 Write one or more disk sectors with Linear Block Addressing (LBA).
 
int g1_ata_write_lba_dma (uint64_t sector, size_t count, const void *buf, int block)
 DMA Write disk sectors with Linear Block Addressing (LBA).
 
int g1_ata_flush (void)
 Flush the write cache on the attached disk.
 
int g1_ata_lba_mode (void)
 Get LBA mode of the attached disk.
 
int g1_ata_blockdev_for_partition (int partition, int dma, kos_blockdev_t *rv, uint8_t *partition_type)
 Get a block device for a given partition on the slave ATA device.
 
int g1_ata_blockdev_for_device (int dma, kos_blockdev_t *rv)
 Get a block device for the attached ATA device.
 
int g1_ata_init (void)
 Initialize G1 ATA support.
 
void g1_ata_shutdown (void)
 Shut down G1 ATA support.
 

Detailed Description

G1 bus ATA interface.

This file provides support for accessing an ATA device on the G1 bus in the Dreamcast. The G1 bus usually contains a few useful pieces of the system, including the flashrom and the GD-ROM drive. The interesting piece here is that the GD-ROM drive itself is actually an ATA device.

Luckily, Sega left everything in place to access both a master and slave device on this ATA port. The GD-ROM drive should always be the master device on the chain, but you can hook up a hard drive or some other device as a slave. The functions herein are for accessing just such a slave device.

Note
The functions herein do not provide for direct access to the GD-ROM drive. There is not really any sort of compelling reason to access the GD-ROM drive directly instead of using the system calls, so you should continue to use the normal cdrom_* functions for accessing the GD-ROM drive. Also, currently there is no locking done to prevent you from doing "bad things" with concurrent access on the bus, so be careful. ;)
Author
Lawrence Sebald
Ruslan Rostovtsev