Search
lxdream.org :: lxdream/src/gdrom/ide.h
lxdream 0.9.1
released Jun 29
Download Now
filename src/gdrom/ide.h
changeset 138:afabd7e6d26d
prev125:49bf45f8210a
next142:2f631c3a3946
author nkeynes
date Sun Apr 30 01:51:08 2006 +0000 (15 years ago)
permissions -rw-r--r--
last change Add Nero file format handler and general gdrom disc hooks
view annotate diff log raw
     1 /**
     2  * $Id: ide.h,v 1.5 2006-04-30 01:51:08 nkeynes Exp $
     3  *
     4  * This file defines the interface and structures of the dreamcast's IDE 
     5  * port. Note that the register definitions are in asic.h, as the registers
     6  * fall into the general ASIC ranges (and I don't want to use smaller pages
     7  * at this stage). The registers here are exactly as per the ATA 
     8  * specifications, which makes things a little easier.
     9  *
    10  * Copyright (c) 2005 Nathan Keynes.
    11  *
    12  * This program is free software; you can redistribute it and/or modify
    13  * it under the terms of the GNU General Public License as published by
    14  * the Free Software Foundation; either version 2 of the License, or
    15  * (at your option) any later version.
    16  *
    17  * This program is distributed in the hope that it will be useful,
    18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    20  * GNU General Public License for more details.
    21  */
    23 #ifndef dream_ide_H
    24 #define dream_ide_H 1
    26 #include "dream.h"
    28 struct ide_registers {
    29     uint8_t status;  /* A05F709C + A05F7018 Read-only */
    30     uint8_t control; /* A05F7018 Write-only 01110 */
    31     uint8_t error;   /* A05F7084 Read-only  10001 */
    32     uint8_t feature; /* A05F7084 Write-only 10001 */
    33     uint8_t count;   /* A05F7088 Read/Write 10010 */
    34     uint8_t disc;    /* A05F708C Read-only 10011 */
    35     uint8_t lba0;    /* A05F708C Write-only 10011 (NB: Presumed, TBV */
    36     uint8_t lba1;    /* A05F7090 Read/Write 10100 */
    37     uint8_t lba2;    /* A05F7094 Read/Write 10101 */
    38     uint8_t device;  /* A05F7098 Read/Write 10110 */
    39     uint8_t command; /* A05F709C Write-only 10111 */
    40     uint8_t intrq_pending; /* Flag to indicate if the INTRQ line is active */
    42     /* We don't keep the data register per se, rather the currently pending
    43      * data is kept here and read out a byte at a time (in PIO mode) or all at
    44      * once (in DMA mode). The IDE routines are responsible for managing this
    45      * memory. If dataptr == NULL, there is no data available.
    46      */
    47     unsigned char *data;
    48     uint16_t *readptr, *writeptr;
    49     int datalen;
    50     int blocksize; /* Used to determine the transfer unit size */
    51     int blockleft; /* Bytes remaining in the current block */
    52 };
    54 #define IDE_ST_BUSY  0x80
    55 #define IDE_ST_READY 0x40
    56 #define IDE_ST_SERV  0x10
    57 #define IDE_ST_DATA  0x08
    58 #define IDE_ST_ERROR 0x01
    60 #define IDE_CTL_RESET 0x04
    61 #define IDE_CTL_IRQEN 0x02 /* IRQ enabled when == 0 */
    63 #define IDE_CMD_RESET_DEVICE 0x08
    64 #define IDE_CMD_PACKET 0xA0
    65 #define IDE_CMD_IDENTIFY_PACKET_DEVICE 0xA1
    66 #define IDE_CMD_SERVICE 0xA2
    67 #define IDE_CMD_SET_FEATURE 0xEF
    69 #define IDE_FEAT_SET_TRANSFER_MODE 0x03
    70 #define IDE_XFER_PIO        0x00
    71 #define IDE_XFER_PIO_FLOW   0x08
    72 #define IDE_XFER_MULTI_DMA  0x20
    73 #define IDE_XFER_ULTRA_DMA  0x40
    77 #define PKT_CMD_RESET    0x00 /* Wild-ass guess */
    78 #define PKT_CMD_IDENTIFY 0x11
    79 #define PKT_CMD_SENSE    0x13
    80 #define PKT_CMD_READ_TOC 0x14
    81 #define PKT_CMD_READ_SECTOR 0x30
    83 extern struct ide_registers idereg;
    85 /* Note: control can be written at any time - all other registers are writable
    86  * only when ide_can_write_regs() is true
    87  */
    88 #define ide_can_write_regs() ((idereg.status&0x88)==0)
    89 #define IS_IDE_IRQ_ENABLED() ((idereg.control&0x02)==0)
    92 uint16_t ide_read_data_pio(void);
    93 uint8_t ide_read_status(void);
    94 void ide_write_data_pio( uint16_t value );
    95 void ide_write_buffer( unsigned char *data, int length ); 
    97 void ide_write_command( uint8_t command );
    98 void ide_write_control( uint8_t value );
    99 #endif
.