mirror of
https://github.com/vivier/EMILE.git
synced 2024-11-14 22:04:43 +00:00
Add support for non-standard (i.e. non apple) CDROM drive that doesnot gives a capacity
This commit is contained in:
parent
a072a95201
commit
0abca62f09
@ -4,21 +4,34 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <macos/errors.h>
|
||||
|
||||
#include "libscsi.h"
|
||||
|
||||
#define BUFFER_SIZE (255)
|
||||
extern void memdump(unsigned char* addr, unsigned long size);
|
||||
scsi_device_t *scsi_open(int target)
|
||||
{
|
||||
scsi_device_t *dev;
|
||||
unsigned char buff[8];
|
||||
unsigned char buff[BUFFER_SIZE];
|
||||
OSErr err;
|
||||
|
||||
err = scsi_READ_CAPACITY(target, buff, 8);
|
||||
err = scsi_TEST_UNIT_READY(target, buff, BUFFER_SIZE);
|
||||
if (err != noErr)
|
||||
printf("WARNING: cannot execute TEST_UNIT_READY\n");
|
||||
|
||||
err = scsi_INQUIRY(target, buff, BUFFER_SIZE);
|
||||
if (err != noErr)
|
||||
printf("WARNING: cannot execute INQUIRY\n");
|
||||
|
||||
err = scsi_READ_CAPACITY(target, buff, BUFFER_SIZE);
|
||||
if (err != noErr) {
|
||||
printf("ERROR: cannot execute READ_CAPACITY\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
dev = (scsi_device_t *)malloc(sizeof(scsi_device_t));
|
||||
if (dev == NULL)
|
||||
@ -27,5 +40,9 @@ scsi_device_t *scsi_open(int target)
|
||||
dev->capacity = (buff[0] << 24) | (buff[1] << 16) | (buff[2] << 8) | buff[3];
|
||||
dev->sector_size = (buff[4] << 24) | (buff[5] << 16) | (buff[6] << 8) | buff[7];
|
||||
|
||||
if ((dev->sector_size != 512) && (dev->sector_size != 2048))
|
||||
{
|
||||
dev->sector_size = 2048;
|
||||
}
|
||||
return dev;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user