mirror of
https://github.com/vivier/EMILE.git
synced 2024-06-12 19:22:46 +00:00
Read the capacity of the disk and the sector size
This commit is contained in:
parent
0db7640ed5
commit
3d8cfe6db6
|
@ -9,7 +9,7 @@ CPPFLAGS = -I$(TOP)/../libmacos -DARCH_M68K
|
|||
LIBRARY = libscsi.a
|
||||
|
||||
SOURCES = scsi_read_sector.c scsi_command.c scsi_INQUIRY.c scsi_READ.c \
|
||||
scsi_open.c scsi_close.c
|
||||
scsi_open.c scsi_close.c scsi_READ_CAPACITY.c
|
||||
|
||||
HEADERS = libscsi.h
|
||||
|
||||
|
|
|
@ -10,12 +10,14 @@
|
|||
typedef struct {
|
||||
int target;
|
||||
unsigned int sector_size;
|
||||
unsigned long capacity;
|
||||
} scsi_device_t;
|
||||
|
||||
extern int scsi_command(int target, char* cdb, int count, TIB_t* tib);
|
||||
extern int scsi_INQUIRY(int target, char* buffer, size_t count);
|
||||
extern int scsi_READ(int target, unsigned long offset, unsigned short nb_blocks,
|
||||
char *buffer, int buffer_size);
|
||||
extern int scsi_READ_CAPACITY(int target, char *buffer, size_t count);
|
||||
|
||||
extern scsi_device_t *scsi_open(int target);
|
||||
extern int scsi_read_sector(scsi_device_t *device, off_t offset, void* buffer, size_t size);
|
||||
|
|
|
@ -11,9 +11,9 @@
|
|||
|
||||
#include "libscsi.h"
|
||||
|
||||
int scsi_INQUIRY(int target, char *buffer, size_t count)
|
||||
int scsi_READ_CAPACITY(int target, char *buffer, size_t count)
|
||||
{
|
||||
char cdb[8];
|
||||
char cdb[10];
|
||||
TIB_t tib[2];
|
||||
|
||||
cdb[0] = READ_CAPACITY;
|
||||
|
@ -24,6 +24,8 @@ int scsi_INQUIRY(int target, char *buffer, size_t count)
|
|||
cdb[5] = 0;
|
||||
cdb[6] = 0;
|
||||
cdb[7] = 0;
|
||||
cdb[8] = 0;
|
||||
cdb[9] = 0;
|
||||
|
||||
tib[0].opcode = op_no_inc;
|
||||
tib[0].param1 = (int)buffer;
|
||||
|
@ -32,5 +34,5 @@ int scsi_INQUIRY(int target, char *buffer, size_t count)
|
|||
tib[1].param1 = 0;
|
||||
tib[1].param2 = 0;
|
||||
|
||||
return scsi_command(target, cdb, 6, tib);
|
||||
return scsi_command(target, cdb, 10, tib);
|
||||
}
|
||||
|
|
|
@ -6,19 +6,26 @@
|
|||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "libscsi.h"
|
||||
#include <macos/errors.h>
|
||||
|
||||
#define SECTOR_SIZE (2048)
|
||||
#include "libscsi.h"
|
||||
|
||||
scsi_device_t *scsi_open(int target)
|
||||
{
|
||||
scsi_device_t *dev;
|
||||
unsigned char buff[8];
|
||||
OSErr err;
|
||||
|
||||
err = scsi_READ_CAPACITY(target, buff, 8);
|
||||
if (err != noErr)
|
||||
return NULL;
|
||||
|
||||
dev = (scsi_device_t *)malloc(sizeof(scsi_device_t));
|
||||
if (dev == NULL)
|
||||
return NULL;
|
||||
dev->target = target;
|
||||
dev->sector_size = SECTOR_SIZE;
|
||||
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];
|
||||
|
||||
return dev;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user