mirror of
https://github.com/vivier/EMILE.git
synced 2025-01-03 12:31:57 +00:00
load_image() doesn't malloc memory anymore, we must provide the buffer
This commit is contained in:
parent
13bfc6ee2a
commit
208344ca0d
@ -14,9 +14,9 @@
|
||||
|
||||
#ifdef SCSI_SUPPORT
|
||||
#include "scsi.h"
|
||||
static char* load_container(struct emile_container* container, char* image)
|
||||
|
||||
static int load_container(struct emile_container* container, char* image)
|
||||
{
|
||||
char* base = image;
|
||||
int target;
|
||||
int i;
|
||||
int err;
|
||||
@ -31,20 +31,17 @@ static char* load_container(struct emile_container* container, char* image)
|
||||
image,
|
||||
container->block_size * container->blocks[i].count);
|
||||
if (err != noErr)
|
||||
{
|
||||
free(image);
|
||||
return NULL;
|
||||
}
|
||||
return -1;
|
||||
|
||||
image += container->block_size * container->blocks[i].count;
|
||||
i++;
|
||||
}
|
||||
|
||||
return base;
|
||||
return 0;
|
||||
}
|
||||
#else /* SCSI_SUPPORT */
|
||||
|
||||
static char* load_blocks(unsigned long offset, unsigned long size, char *image)
|
||||
static int load_blocks(unsigned long offset, unsigned long size, char *image)
|
||||
{
|
||||
int err;
|
||||
ParamBlockRec_t param_block;
|
||||
@ -60,30 +57,19 @@ static char* load_blocks(unsigned long offset, unsigned long size, char *image)
|
||||
|
||||
err = PBReadSync(¶m_block);
|
||||
if (err != noErr)
|
||||
{
|
||||
free(image);
|
||||
return NULL;
|
||||
}
|
||||
return -1;
|
||||
|
||||
return image;
|
||||
return 0;
|
||||
}
|
||||
#endif /* SCSI_SUPPORT */
|
||||
|
||||
char* load_image(unsigned long offset, unsigned long size)
|
||||
int load_image(unsigned long offset, unsigned long size, char *image)
|
||||
{
|
||||
char* image;
|
||||
|
||||
if (size == 0)
|
||||
return NULL;
|
||||
return -1;
|
||||
|
||||
image = malloc_contiguous(size + 4);
|
||||
if (image == 0)
|
||||
{
|
||||
free(image);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
image = (char*)(((unsigned long)image + 3) & 0xFFFFFFFC);
|
||||
if (image == NULL)
|
||||
return -1;
|
||||
|
||||
#ifdef SCSI_SUPPORT
|
||||
return load_container((struct emile_container*)offset, image);
|
||||
|
@ -4,4 +4,4 @@
|
||||
*
|
||||
*/
|
||||
|
||||
extern char* load_image(unsigned long offset, unsigned long size);
|
||||
extern int load_image(unsigned long offset, unsigned long size, char *image);
|
||||
|
@ -69,6 +69,8 @@ int start(emile_l2_header_t* info)
|
||||
bank_dump();
|
||||
#endif
|
||||
|
||||
printf("Available Memory: %ld kB\n", bank_mem_avail() / 1024);
|
||||
|
||||
if (info->gestaltID != 0) {
|
||||
machine_id = info->gestaltID;
|
||||
printf("User forces gestalt ID to %ld\n", machine_id);
|
||||
@ -77,15 +79,20 @@ int start(emile_l2_header_t* info)
|
||||
/* load kernel */
|
||||
|
||||
printf("vmlinux %s\n", info->command_line);
|
||||
printf("Loading kernel...\n");
|
||||
#ifdef SCSI_SUPPORT
|
||||
info->kernel_image_offset = (unsigned long)info->kernel_image_offset + (unsigned long)info;
|
||||
#endif
|
||||
kernel_image_start = (unsigned long)load_image(
|
||||
(unsigned long)info->kernel_image_offset,
|
||||
info->kernel_image_size);
|
||||
printf("Kernel image loaded at 0x%lx\n", kernel_image_start);
|
||||
printf("Kernel image size is %d Bytes\n", info->kernel_image_size);
|
||||
kernel_image_start = (unsigned long)malloc_contiguous(
|
||||
info->kernel_image_size + 4);
|
||||
kernel_image_start = (kernel_image_start + 3) & 0xFFFFFFFC;
|
||||
printf("Kernel image base at 0x%lx\n", kernel_image_start);
|
||||
|
||||
printf("Loading kernel...\n");
|
||||
ret = load_image((unsigned long)info->kernel_image_offset,
|
||||
info->kernel_image_size, (char*)kernel_image_start);
|
||||
if (ret == -1)
|
||||
error("Cannot load kernel image\n");
|
||||
|
||||
/* where is mapped my boot function ? */
|
||||
|
||||
@ -102,8 +109,6 @@ int start(emile_l2_header_t* info)
|
||||
disable_cache = MMU030_disable_cache;
|
||||
}
|
||||
|
||||
printf("Available Memory: %ld kB\n", bank_mem_avail() / 1024);
|
||||
|
||||
if (info->kernel_image_size == 0)
|
||||
error("Kernel is missing !!!!\n");
|
||||
else
|
||||
@ -152,12 +157,18 @@ int start(emile_l2_header_t* info)
|
||||
|
||||
if (info->ramdisk_size != 0)
|
||||
{
|
||||
printf("Loading RAMDISK...\n");
|
||||
ramdisk_start = (unsigned long)load_image(
|
||||
(unsigned long)info->ramdisk_offset,
|
||||
info->ramdisk_size);
|
||||
printf("RAMDISK loaded at 0x%lx\n", ramdisk_start);
|
||||
printf("RAMDISK size is %d Bytes\n", info->ramdisk_size);
|
||||
ramdisk_start = (unsigned long)malloc_contiguous(
|
||||
info->ramdisk_size + 4);
|
||||
ramdisk_start = (ramdisk_start + 3) & 0xFFFFFFFC;
|
||||
printf("RAMDISK base at 0x%lx\n", ramdisk_start);
|
||||
|
||||
printf("Loading RAMDISK...\n");
|
||||
ret = load_image((unsigned long)info->ramdisk_offset,
|
||||
info->ramdisk_size, (char*)ramdisk_start);
|
||||
if (ret == -1)
|
||||
error("Cannot load ramdisk\n");
|
||||
|
||||
if (!check_full_in_bank(ramdisk_start, info->ramdisk_size))
|
||||
error("ramdisk between two banks, contact maintainer\n");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user