Search
lxdream.org :: lxdream/src/gdrom/ide.h
lxdream 0.9.1
released Jun 29
Download Now
filename src/gdrom/ide.h
changeset 152:d42a4c5cc709
prev149:d88dd2e9a190
next240:9ae4bd697292
author nkeynes
date Tue Sep 12 11:54:19 2006 +0000 (17 years ago)
permissions -rw-r--r--
last change Bug #0005 Implement translucent poly sorting
Implement quick-and-dirty sorting based on min-z. It's not remotely complete
but damn that looks so much better ^_^
view annotate diff log raw
     1 /**
     2  * $Id: ide.h,v 1.8 2006-05-23 13:11:45 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     /* IDE interface registers */
    30     uint8_t status;  /* A05F709C + A05F7018 Read-only */
    31     uint8_t control; /* A05F7018 Write-only 01110 */
    32     uint8_t error;   /* A05F7084 Read-only  10001 */
    33     uint8_t feature; /* A05F7084 Write-only 10001 */
    34     uint8_t count;   /* A05F7088 Read/Write 10010 */
    35     uint8_t disc;    /* A05F708C Read-only 10011 */
    36     uint8_t lba0;    /* A05F708C Write-only 10011 (NB: Presumed, TBV */
    37     uint8_t lba1;    /* A05F7090 Read/Write 10100 */
    38     uint8_t lba2;    /* A05F7094 Read/Write 10101 */
    39     uint8_t device;  /* A05F7098 Read/Write 10110 */
    40     uint8_t command; /* A05F709C Write-only 10111 */
    42     /* Internal IDE state */
    43     uint8_t intrq_pending; /* Flag to indicate if the INTRQ line is active */
    44     int state;
    46     /* Sense response for the last executed packet command */
    47     unsigned char gdrom_sense[10];
    50     /* offset in the buffer of the next word to read/write, or -1
    51      * if inactive.
    52      */ 
    53     int data_offset;
    54     int data_length;
    56     int block_length; /* Used to determine the transfer unit size */
    57     int block_left; /* Bytes remaining in the current block */
    58 };
    60 #define IDE_STATE_IDLE      0 
    61 #define IDE_STATE_CMD_WRITE 1
    62 #define IDE_STATE_PIO_READ  2
    63 #define IDE_STATE_PIO_WRITE 3
    64 #define IDE_STATE_DMA_READ  4
    65 #define IDE_STATE_DMA_WRITE 5
    66 #define IDE_STATE_BUSY      6
    68 /* Flag bits */
    69 #define IDE_STATUS_BSY  0x80    /* Busy */
    70 #define IDE_STATUS_DRDY 0x40    /* Device ready */
    71 #define IDE_STATUS_DMRD 0x20    /* DMA Request */
    72 #define IDE_STATUS_SERV 0x10   
    73 #define IDE_STATUS_DRQ  0x08
    74 #define IDE_STATUS_CHK  0x01    /* Check condition (ie error) */
    76 #define IDE_FEAT_DMA 0x01
    77 #define IDE_FEAT_OVL 0x02
    79 #define IDE_COUNT_CD 0x01       /* Command (1)/Data (0) */
    80 #define IDE_COUNT_IO 0x02       /* Input (0)/Output (1) */
    81 #define IDE_COUNT_REL 0x04      /* Release device */
    84 #define IDE_CTL_RESET 0x04
    85 #define IDE_CTL_IRQEN 0x02 /* IRQ enabled when == 0 */
    87 #define IDE_CMD_RESET_DEVICE 0x08
    88 #define IDE_CMD_PACKET 0xA0
    89 #define IDE_CMD_IDENTIFY_PACKET_DEVICE 0xA1
    90 #define IDE_CMD_SERVICE 0xA2
    91 #define IDE_CMD_SET_FEATURE 0xEF
    93 #define IDE_FEAT_SET_TRANSFER_MODE 0x03
    94 #define IDE_XFER_PIO        0x00
    95 #define IDE_XFER_PIO_FLOW   0x08
    96 #define IDE_XFER_MULTI_DMA  0x20
    97 #define IDE_XFER_ULTRA_DMA  0x40
    99 extern struct ide_registers idereg;
   101 /* Note: control can be written at any time - all other registers are writable
   102  * only when ide_can_write_regs() is true
   103  */
   104 #define ide_can_write_regs() ((idereg.status&0x88)==0)
   105 #define IS_IDE_IRQ_ENABLED() ((idereg.control&0x02)==0)
   108 uint16_t ide_read_data_pio(void);
   109 void ide_write_data_pio( uint16_t value );
   110 uint32_t ide_read_data_dma( uint32_t addr, uint32_t length );
   111 uint8_t ide_read_status(void);
   112 void ide_write_buffer( unsigned char *data, int length ); 
   114 void ide_write_command( uint8_t command );
   115 void ide_write_control( uint8_t value );
   117 void ide_dma_read_req( uint32_t addr, uint32_t length );
   118 #endif
.