mirror of
https://github.com/vivier/EMILE.git
synced 2025-01-02 21:30:29 +00:00
add scsi support to load_image()
This commit is contained in:
parent
616da27146
commit
1abf16c567
@ -9,30 +9,50 @@
|
||||
#include "bank.h"
|
||||
#include "misc.h"
|
||||
#include "glue.h"
|
||||
#include "head.h"
|
||||
#include "load.h"
|
||||
|
||||
char* load_image(int unit, unsigned long offset, unsigned long size)
|
||||
#ifdef SCSI_SUPPORT
|
||||
#include "scsi.h"
|
||||
static char* load_container(struct emile_container* container, char* image)
|
||||
{
|
||||
char* base = image;
|
||||
int target;
|
||||
int i;
|
||||
int err;
|
||||
char* image;
|
||||
ParamBlockRec_t param_block;
|
||||
|
||||
if (size == 0)
|
||||
return NULL;
|
||||
target = container->unit_id;
|
||||
|
||||
image = malloc_contiguous(size + 4);
|
||||
if (image == 0)
|
||||
i = 0;
|
||||
while (container->blocks[i].count != 0)
|
||||
{
|
||||
err = scsi_READ(target, container->blocks[i].offset,
|
||||
container->blocks[i].count,
|
||||
image,
|
||||
container->block_size * container->blocks[i].count);
|
||||
if (err != noErr)
|
||||
{
|
||||
free(image);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
image = (char*)(((unsigned long)image + 3) & 0xFFFFFFFC);
|
||||
image += container->block_size * container->blocks[i].count;
|
||||
i++;
|
||||
}
|
||||
|
||||
return base;
|
||||
}
|
||||
#else /* SCSI_SUPPORT */
|
||||
|
||||
static char* load_blocks(unsigned long offset, unsigned long size, char *image)
|
||||
{
|
||||
int err;
|
||||
ParamBlockRec_t param_block;
|
||||
|
||||
memset(¶m_block, 0, sizeof(param_block));
|
||||
|
||||
param_block.ioBuffer = (unsigned long)image;
|
||||
param_block.ioVRefNum = unit;
|
||||
param_block.ioVRefNum = 1;
|
||||
param_block.ioRefNum = -5;
|
||||
param_block.ioReqCount = size;
|
||||
param_block.ioPosMode = fsFromStart;
|
||||
@ -47,3 +67,27 @@ char* load_image(int unit, unsigned long offset, unsigned long size)
|
||||
|
||||
return image;
|
||||
}
|
||||
#endif /* SCSI_SUPPORT */
|
||||
|
||||
char* load_image(unsigned long offset, unsigned long size)
|
||||
{
|
||||
char* image;
|
||||
|
||||
if (size == 0)
|
||||
return NULL;
|
||||
|
||||
image = malloc_contiguous(size + 4);
|
||||
if (image == 0)
|
||||
{
|
||||
free(image);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
image = (char*)(((unsigned long)image + 3) & 0xFFFFFFFC);
|
||||
|
||||
#ifdef SCSI_SUPPORT
|
||||
return load_container((struct emile_container*)offset, image);
|
||||
#else
|
||||
return load_blocks(offset, size, image);
|
||||
#endif
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user