ppcrcd/trunk/yaboot/yaboot.c
sparky
cvs at pld-linux.org
Sat Feb 25 21:08:51 CET 2006
Author: sparky
Date: Sat Feb 25 21:08:48 2006
New Revision: 7013
Modified:
ppcrcd/trunk/yaboot/yaboot.c
Log:
- sync with 1.3.14rc1
Modified: ppcrcd/trunk/yaboot/yaboot.c
==============================================================================
--- ppcrcd/trunk/yaboot/yaboot.c (original)
+++ ppcrcd/trunk/yaboot/yaboot.c Sat Feb 25 21:08:48 2006
@@ -467,7 +467,7 @@
if (opened)
file.fs->close(&file);
- if (result != 1 && conf_file)
+ if (conf_file)
free(conf_file);
return result;
@@ -987,6 +987,7 @@
0x100000, 0);
if (sysmap_base == (void *)-1) {
prom_printf("Claim failed for sysmap memory\n");
+ prom_pause();
sysmap_base = 0;
} else {
sysmap_size = file.fs->read(&file, 0xfffff, sysmap_base);
@@ -1090,7 +1091,7 @@
prom_printf("%s:%d,", params.rd.dev, params.rd.part);
prom_perror(result, params.rd.file);
} else {
-#define INITRD_CHUNKSIZE 0x200000
+#define INITRD_CHUNKSIZE 0x100000
initrd_base = prom_claim(loadinfo.base+loadinfo.memsize,
INITRD_CHUNKSIZE, 0);
if (initrd_base == (void *)-1) {
@@ -1113,6 +1114,7 @@
if (initrd_more != initrd_want) {
prom_printf("\nClaim failed for initrd memory"
" at %p rc=%p\n",initrd_want,initrd_more);
+ prom_pause();
break;
}
initrd_read = file.fs->read(&file,
@@ -1215,7 +1217,7 @@
{
int i;
Elf32_Ehdr *e = &(loadinfo->elf.elf32hdr);
- Elf32_Phdr *p, *ph;
+ Elf32_Phdr *p, *ph = NULL;
int size = sizeof(Elf32_Ehdr) - sizeof(Elf_Ident);
unsigned long addr, loadaddr;
@@ -1225,7 +1227,7 @@
(*(file->fs->read))(file, size, &e->e_version)
) < size) {
prom_printf("\nCan't read Elf32 image header\n");
- return 0;
+ goto bail;
}
DEBUG_F("Elf32 header:\n");
@@ -1244,13 +1246,13 @@
if (e->e_phnum > MAX_HEADERS) {
prom_printf ("Can only load kernels with one program header\n");
- return 0;
+ goto bail;
}
ph = (Elf32_Phdr *)malloc(sizeof(Elf32_Phdr) * e->e_phnum);
if (!ph) {
prom_printf ("Malloc error\n");
- return 0;
+ goto bail;
}
/* Now, we read the section header */
@@ -1259,14 +1261,14 @@
(*(file->fs->seek))(file, e->e_phoff)
) != FILE_ERR_OK) {
prom_printf ("seek error\n");
- return 0;
+ goto bail;
}
if ( ( compressed_file ?
gunzip_read(ph, sizeof(Elf32_Phdr) * e->e_phnum) :
(*(file->fs->read))(file, sizeof(Elf32_Phdr) * e->e_phnum, ph)
) != sizeof(Elf32_Phdr) * e->e_phnum) {
prom_printf ("read error\n");
- return 0;
+ goto bail;
}
/* Scan through the program header
@@ -1294,7 +1296,7 @@
if (loadinfo->memsize == 0) {
prom_printf("Can't find a loadable segment !\n");
- return 0;
+ goto bail;
}
/* Determine whether we are trying to boot a vmlinux or some
@@ -1306,7 +1308,7 @@
loadaddr = KERNELADDR;
} else {
flat_vmlinux = 0;
- loadaddr = e->e_entry;
+ loadaddr = loadinfo->load_loc;
}
if ( kernel_position > 0 ) {
flat_vmlinux = 1;
@@ -1333,7 +1335,7 @@
}
if (loadinfo->base == (void *)-1) {
prom_printf("Claim error, can't allocate kernel memory\n");
- return 0;
+ goto bail;
}
DEBUG_F("After ELF parsing, load base: %p, mem_sz: 0x%08lx\n",
@@ -1356,7 +1358,7 @@
) != FILE_ERR_OK) {
prom_printf ("Seek error\n");
prom_release(loadinfo->base, loadinfo->memsize);
- return 0;
+ goto bail;
}
offset = p->p_vaddr - loadinfo->load_loc;
if ( ( compressed_file ?
@@ -1365,7 +1367,7 @@
) != p->p_filesz ) {
prom_printf ("Read failed\n");
prom_release(loadinfo->base, loadinfo->memsize);
- return 0;
+ goto bail;
}
}
} else {
@@ -1373,19 +1375,19 @@
if ( (*(file->fs->seek))(file, kernel_position) != FILE_ERR_OK) {
prom_printf ("Seek error\n");
prom_release(loadinfo->base, loadinfo->memsize);
- return 0;
+ goto bail;
}
gunzip_file = *file;
gunzip_test_header();
if ( !compressed_file ) {
prom_printf ("Error: not compressed data at vmlinux position\n");
prom_release(loadinfo->base, loadinfo->memsize);
- return 0;
+ goto bail;
}
if ( gunzip_read(loadinfo->base, kernel_size) != kernel_size ) {
prom_printf ("Gunzip read failed\n");
prom_release(loadinfo->base, loadinfo->memsize);
- return 0;
+ goto bail;
} else {
prom_printf ("vmlinux extracted successfully !\n");
}
@@ -1395,6 +1397,11 @@
/* Return success at loading the Elf32 kernel */
return 1;
+
+bail:
+ if (ph)
+ free(ph);
+ return 0;
}
static int
@@ -1402,14 +1409,14 @@
{
int i;
Elf64_Ehdr *e = &(loadinfo->elf.elf64hdr);
- Elf64_Phdr *p, *ph;
+ Elf64_Phdr *p, *ph = NULL;
int size = sizeof(Elf64_Ehdr) - sizeof(Elf_Ident);
unsigned long addr, loadaddr;
/* Read the rest of the Elf header... */
if ((*(file->fs->read))(file, size, &e->e_version) < size) {
prom_printf("\nCan't read Elf64 image header\n");
- return 0;
+ goto bail;
}
DEBUG_F("Elf64 header:\n");
@@ -1428,24 +1435,24 @@
if (e->e_phnum > MAX_HEADERS) {
prom_printf ("Can only load kernels with one program header\n");
- return 0;
+ goto bail;
}
ph = (Elf64_Phdr *)malloc(sizeof(Elf64_Phdr) * e->e_phnum);
if (!ph) {
prom_printf ("Malloc error\n");
- return 0;
+ goto bail;
}
/* Now, we read the section header */
if ((*(file->fs->seek))(file, e->e_phoff) != FILE_ERR_OK) {
prom_printf ("Seek error\n");
- return 0;
+ goto bail;
}
if ((*(file->fs->read))(file, sizeof(Elf64_Phdr) * e->e_phnum, ph) !=
sizeof(Elf64_Phdr) * e->e_phnum) {
prom_printf ("Read error\n");
- return 0;
+ goto bail;
}
/* Scan through the program header
@@ -1473,7 +1480,7 @@
if (loadinfo->memsize == 0) {
prom_printf("Can't find a loadable segment !\n");
- return 0;
+ goto bail;
}
/* leave some room (1Mb) for boot infos */
@@ -1502,7 +1509,7 @@
}
if (loadinfo->base == (void *)-1) {
prom_printf("Claim error, can't allocate kernel memory\n");
- return 0;
+ goto bail;
}
DEBUG_F("After ELF parsing, load base: %p, mem_sz: 0x%08lx\n",
@@ -1521,14 +1528,14 @@
if ((*(file->fs->seek))(file, p->p_offset) != FILE_ERR_OK) {
prom_printf ("Seek error\n");
prom_release(loadinfo->base, loadinfo->memsize);
- return 0;
+ goto bail;
}
offset = p->p_vaddr - loadinfo->load_loc;
if ((*(file->fs->read))(file, p->p_filesz, loadinfo->base+offset)
!= p->p_filesz) {
prom_printf ("Read failed\n");
prom_release(loadinfo->base, loadinfo->memsize);
- return 0;
+ goto bail;
}
}
@@ -1536,6 +1543,11 @@
/* Return success at loading the Elf64 kernel */
return 1;
+
+bail:
+ if (ph)
+ free(ph);
+ return 0;
}
static int
@@ -1715,6 +1727,8 @@
prom_printf("\nWARNING: Bootstrap partition type is wrong:"
" \"%s\"\n"
" type should be: \"Apple_Bootstrap\"\n\n", ptype);
+ if (ptype)
+ free(ptype);
}
}
More information about the pld-cvs-commit
mailing list