Search
lxdream.org :: lxdream :: r149:d88dd2e9a190
lxdream 0.9.1
released Jun 29
Download Now
changeset149:d88dd2e9a190
parent148:3f31c2d9b783
child150:c728a442b43f
authornkeynes
dateSat May 20 06:24:49 2006 +0000 (14 years ago)
Add disc info + spin up (probably seek) commands
src/gdrom/gdrom.c
src/gdrom/gdrom.h
src/gdrom/ide.c
src/gdrom/ide.h
src/gdrom/packet.h
1.1 --- a/src/gdrom/gdrom.c Sat May 20 02:40:51 2006 +0000
1.2 +++ b/src/gdrom/gdrom.c Sat May 20 06:24:49 2006 +0000
1.3 @@ -1,5 +1,5 @@
1.4 /**
1.5 - * $Id: gdrom.c,v 1.3 2006-05-03 12:52:38 nkeynes Exp $
1.6 + * $Id: gdrom.c,v 1.4 2006-05-20 06:24:49 nkeynes Exp $
1.7 *
1.8 * GD-Rom access functions.
1.9 *
1.10 @@ -105,13 +105,13 @@
1.11 }
1.12 }
1.13
1.14 -gboolean gdrom_get_toc( char *buf )
1.15 +gdrom_error_t gdrom_get_toc( char *buf )
1.16 {
1.17 struct gdrom_toc *toc = (struct gdrom_toc *)buf;
1.18 int i;
1.19
1.20 if( gdrom_disc == NULL )
1.21 - return FALSE;
1.22 + return PKT_ERR_NODISC;
1.23
1.24 for( i=0; i<gdrom_disc->track_count; i++ ) {
1.25 toc->track[i] = htonl( gdrom_disc->track[i].lba ) | gdrom_disc->track[i].flags;
1.26 @@ -122,7 +122,23 @@
1.27 gdrom_disc->track[i-1].flags;
1.28 for( ;i<99; i++ )
1.29 toc->track[i] = 0xFFFFFFFF;
1.30 - return TRUE;
1.31 + return PKT_ERR_OK;
1.32 +}
1.33 +
1.34 +gdrom_error_t gdrom_get_info( char *buf )
1.35 +{
1.36 + if( gdrom_disc == NULL )
1.37 + return PKT_ERR_NODISC;
1.38 + struct gdrom_track *last_track = &gdrom_disc->track[gdrom_disc->track_count-1];
1.39 + unsigned int end_of_disc = last_track->lba + last_track->sector_count;
1.40 +
1.41 + buf[0] = 0x01; /* Unknown. First session? */
1.42 + buf[1] = 0;
1.43 + buf[2] = last_track->session+1; /* last session */
1.44 + buf[3] = (end_of_disc >> 16) & 0xFF;
1.45 + buf[4] = (end_of_disc >> 8) & 0xFF;
1.46 + buf[5] = end_of_disc & 0xFF;
1.47 + return PKT_ERR_OK;
1.48 }
1.49
1.50 void gdrom_mount_disc( gdrom_disc_t disc )
2.1 --- a/src/gdrom/gdrom.h Sat May 20 02:40:51 2006 +0000
2.2 +++ b/src/gdrom/gdrom.h Sat May 20 06:24:49 2006 +0000
2.3 @@ -1,5 +1,5 @@
2.4 /**
2.5 - * $Id: gdrom.h,v 1.4 2006-05-03 12:52:38 nkeynes Exp $
2.6 + * $Id: gdrom.h,v 1.5 2006-05-20 06:24:49 nkeynes Exp $
2.7 *
2.8 * This file defines the structures and functions used by the GD-Rom
2.9 * disc driver. (ie, the modules that supply a CD image to be used by the
2.10 @@ -23,6 +23,8 @@
2.11
2.12 #include "dream.h"
2.13
2.14 +typedef uint16_t gdrom_error_t;
2.15 +
2.16 struct gdrom_toc {
2.17 uint32_t track[99];
2.18 uint32_t first, last, leadout;
2.19 @@ -95,9 +97,15 @@
2.20 /**
2.21 * Retrieve the disc table of contents, and write it into the buffer in the
2.22 * format expected by the DC.
2.23 - * @return TRUE on success, FALSE on failure (eg no disc mounted)
2.24 + * @return 0 on success, error code on failure (eg no disc mounted)
2.25 */
2.26 -gboolean gdrom_get_toc( char *buf );
2.27 +gdrom_error_t gdrom_get_toc( char *buf );
2.28 +
2.29 +/**
2.30 + * Retrieve the short (6-byte) disc info, and write it into the buffer.
2.31 + * @return 0 on success, error code on failure.
2.32 + */
2.33 +gdrom_error_t gdrom_get_info( char *buf );
2.34
2.35 /**
2.36 * Shortcut to open and mount an image file
3.1 --- a/src/gdrom/ide.c Sat May 20 02:40:51 2006 +0000
3.2 +++ b/src/gdrom/ide.c Sat May 20 06:24:49 2006 +0000
3.3 @@ -1,5 +1,5 @@
3.4 /**
3.5 - * $Id: ide.c,v 1.12 2006-05-03 12:52:38 nkeynes Exp $
3.6 + * $Id: ide.c,v 1.13 2006-05-20 06:24:49 nkeynes Exp $
3.7 *
3.8 * IDE interface implementation
3.9 *
3.10 @@ -187,6 +187,7 @@
3.11 ide_reset();
3.12 break;
3.13 case IDE_CMD_PACKET:
3.14 + idereg.count = 0x01;
3.15 ide_set_write_buffer(command_buffer,12);
3.16 break;
3.17 case IDE_CMD_SET_FEATURE:
3.18 @@ -278,15 +279,27 @@
3.19 ide_set_read_buffer( data_buffer, length , blocksize );
3.20 break;
3.21 case PKT_CMD_READ_TOC:
3.22 - if( !gdrom_get_toc( data_buffer ) ) {
3.23 - ide_set_packet_error( PKT_ERR_NODISC ); /* No disc in drive */
3.24 + status = gdrom_get_toc( data_buffer );
3.25 + if( status != PKT_ERR_OK ) {
3.26 + ide_set_packet_error( status );
3.27 return;
3.28 - }
3.29 + }
3.30 length = (cmd[3]<<8) | cmd[4];
3.31 if( length > sizeof(struct gdrom_toc) )
3.32 length = sizeof(struct gdrom_toc);
3.33 ide_set_read_buffer( data_buffer, length, blocksize );
3.34 break;
3.35 + case PKT_CMD_DISC_INFO:
3.36 + status = gdrom_get_info( data_buffer );
3.37 + if( status != PKT_ERR_OK ) {
3.38 + ide_set_packet_error( status );
3.39 + return;
3.40 + }
3.41 + length = cmd[4];
3.42 + if( length > 6 )
3.43 + length = 6;
3.44 + ide_set_read_buffer( data_buffer, length, blocksize );
3.45 + break;
3.46 case PKT_CMD_READ_SECTOR:
3.47 lba = cmd[2] << 16 | cmd[3] << 8 | cmd[4];
3.48 length = cmd[8] << 16 | cmd[9] << 8 | cmd[10]; /* blocks */
3.49 @@ -317,6 +330,9 @@
3.50 }
3.51 ide_set_read_buffer( data_buffer, datalen, blocksize );
3.52 break;
3.53 + case PKT_CMD_SPIN_UP:
3.54 + /* do nothing? */
3.55 + break;
3.56 default:
3.57 ide_set_packet_error( PKT_ERR_BADCMD ); /* Invalid command */
3.58 return;
4.1 --- a/src/gdrom/ide.h Sat May 20 02:40:51 2006 +0000
4.2 +++ b/src/gdrom/ide.h Sat May 20 06:24:49 2006 +0000
4.3 @@ -1,5 +1,5 @@
4.4 /**
4.5 - * $Id: ide.h,v 1.6 2006-05-02 14:09:11 nkeynes Exp $
4.6 + * $Id: ide.h,v 1.7 2006-05-20 06:24:49 nkeynes Exp $
4.7 *
4.8 * This file defines the interface and structures of the dreamcast's IDE
4.9 * port. Note that the register definitions are in asic.h, as the registers
4.10 @@ -58,6 +58,14 @@
4.11 #define IDE_ST_DATA 0x08
4.12 #define IDE_ST_ERROR 0x01
4.13
4.14 +#define IDE_FEAT_DMA 0x01
4.15 +#define IDE_FEAT_OVL 0x02
4.16 +
4.17 +#define IDE_COUNT_CD 0x01
4.18 +#define IDE_COUNT_IO 0x02
4.19 +#define IDE_COUNT_REL 0x04
4.20 +
4.21 +
4.22 #define IDE_CTL_RESET 0x04
4.23 #define IDE_CTL_IRQEN 0x02 /* IRQ enabled when == 0 */
4.24
5.1 --- a/src/gdrom/packet.h Sat May 20 02:40:51 2006 +0000
5.2 +++ b/src/gdrom/packet.h Sat May 20 06:24:49 2006 +0000
5.3 @@ -1,5 +1,5 @@
5.4 /**
5.5 - * $Id: packet.h,v 1.2 2006-05-03 12:52:38 nkeynes Exp $
5.6 + * $Id: packet.h,v 1.3 2006-05-20 06:24:49 nkeynes Exp $
5.7 *
5.8 * This file defines the command codes and any other flags used by the
5.9 * GD-Rom ATAPI packet commands.
5.10 @@ -50,7 +50,9 @@
5.11 #define PKT_CMD_IDENTIFY 0x11
5.12 #define PKT_CMD_SENSE 0x13
5.13 #define PKT_CMD_READ_TOC 0x14
5.14 +#define PKT_CMD_DISC_INFO 0x15
5.15 #define PKT_CMD_READ_SECTOR 0x30
5.16 +#define PKT_CMD_SPIN_UP 0x70 /* ??? */
5.17
5.18 #define PKT_ERR_OK 0x0000
5.19 #define PKT_ERR_NODISC 0x3A02
.