Search
lxdream.org :: lxdream/src/gdrom/gdrom.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/gdrom/gdrom.c
changeset 143:9446fb6df0c5
prev142:2f631c3a3946
next149:d88dd2e9a190
author nkeynes
date Wed May 03 12:52:38 2006 +0000 (14 years ago)
permissions -rw-r--r--
last change Add (track) mode parameter to read sectors call
Fix missing interrupt on end-of-packet read.
file annotate diff log raw
1.1 --- a/src/gdrom/gdrom.c Tue May 02 14:09:11 2006 +0000
1.2 +++ b/src/gdrom/gdrom.c Wed May 03 12:52:38 2006 +0000
1.3 @@ -1,5 +1,5 @@
1.4 /**
1.5 - * $Id: gdrom.c,v 1.2 2006-05-02 14:09:11 nkeynes Exp $
1.6 + * $Id: gdrom.c,v 1.3 2006-05-03 12:52:38 nkeynes Exp $
1.7 *
1.8 * GD-Rom access functions.
1.9 *
1.10 @@ -20,10 +20,11 @@
1.11
1.12 #include "gdrom/ide.h"
1.13 #include "gdrom/gdrom.h"
1.14 +#include "gdrom/packet.h"
1.15 #include "dream.h"
1.16
1.17 static void gdrom_image_destroy( gdrom_disc_t );
1.18 -static uint32_t gdrom_image_read_sectors( gdrom_disc_t, uint32_t, uint32_t, char * );
1.19 +static uint32_t gdrom_image_read_sectors( gdrom_disc_t, uint32_t, uint32_t, int, char *, uint32_t * );
1.20
1.21
1.22 gdrom_disc_t gdrom_disc = NULL;
1.23 @@ -59,7 +60,8 @@
1.24 }
1.25
1.26 static uint32_t gdrom_image_read_sectors( gdrom_disc_t disc, uint32_t sector,
1.27 - uint32_t sector_count, char *buf )
1.28 + uint32_t sector_count, int mode, char *buf,
1.29 + uint32_t *length )
1.30 {
1.31 int i, track = -1, track_offset, read_len;
1.32
1.33 @@ -71,21 +73,24 @@
1.34 }
1.35 }
1.36 if( track == -1 )
1.37 - return 0;
1.38 + return PKT_ERR_BADREAD;
1.39 + if( mode == GDROM_GD && disc->track[i].mode != GDROM_GD )
1.40 + return PKT_ERR_BADREADMODE;
1.41
1.42 track_offset = disc->track[track].sector_size * (sector - disc->track[track].lba);
1.43 read_len = disc->track[track].sector_size * sector_count;
1.44 fseek( disc->file, disc->track[track].offset + track_offset, SEEK_SET );
1.45 fread( buf, disc->track[track].sector_size, sector_count, disc->file );
1.46 - return read_len;
1.47 + *length = read_len;
1.48 + return PKT_ERR_OK;
1.49 }
1.50
1.51 uint32_t gdrom_read_sectors( uint32_t sector, uint32_t sector_count,
1.52 - char *buf )
1.53 + int mode, char *buf, uint32_t *length )
1.54 {
1.55 if( gdrom_disc == NULL )
1.56 - return 0; /* No media */
1.57 - return gdrom_disc->read_sectors( gdrom_disc, sector, sector_count, buf );
1.58 + return PKT_ERR_NODISC; /* No media */
1.59 + return gdrom_disc->read_sectors( gdrom_disc, sector, sector_count, mode, buf, length );
1.60 }
1.61
1.62
.