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