From owner-p4-projects Fri May 17 16:33: 0 2002 Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 6F84937B409; Fri, 17 May 2002 16:32:40 -0700 (PDT) Delivered-To: perforce@freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 5A02337B407 for ; Fri, 17 May 2002 16:32:39 -0700 (PDT) Received: (from perforce@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g4HNWdU24448 for perforce@freebsd.org; Fri, 17 May 2002 16:32:39 -0700 (PDT) (envelope-from jake@freebsd.org) Date: Fri, 17 May 2002 16:32:39 -0700 (PDT) Message-Id: <200205172332.g4HNWdU24448@freefall.freebsd.org> X-Authentication-Warning: freefall.freebsd.org: perforce set sender to jake@freebsd.org using -f From: Jake Burkholder Subject: PERFORCE change 11459 for review To: Perforce Change Reviews Sender: owner-p4-projects@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG http://people.freebsd.org/~peter/p4db/chv.cgi?CH=11459 Change 11459 by jake@jake_sparc64 on 2002/05/17 16:32:15 Inline the load function. Affected files ... ... //depot/projects/sparc64/sys/boot/sparc64/boot1/boot1.c#5 edit Differences ... ==== //depot/projects/sparc64/sys/boot/sparc64/boot1/boot1.c#5 (text+ko) ==== @@ -347,6 +347,10 @@ main(int ac, char **av) { const char *path; + Elf64_Ehdr eh; + Elf64_Phdr ph; + caddr_t p; + ino_t ino; int i; path = _PATH_LOADER; @@ -369,10 +373,29 @@ " Boot loader: %s\n", bootpath, path); if (mount(bootpath) == -1) - panic("mount"); - - load(path); - return (1); + panic("main: can't mount %s", bootpath); + if ((ino = lookup(path)) == 0) + panic("main: file %s not found", path); + if (fsread(ino, &eh, sizeof(eh)) != sizeof(eh)) + panic("main: can't read elf header"); + if (!IS_ELF(eh)) + panic("main: not an elf file"); + for (i = 0; i < eh.e_phnum; i++) { + fs_off = eh.e_phoff + i * eh.e_phentsize; + if (fsread(ino, &ph, sizeof(ph)) != sizeof(ph)) + panic("main: can't read program header %d", i); + if (ph.p_type != PT_LOAD) + continue; + fs_off = ph.p_offset; + p = (caddr_t)ph.p_vaddr; + if (fsread(ino, p, ph.p_filesz) != ph.p_filesz) + panic("main: can't read contents of section %d", i); + if (ph.p_filesz != ph.p_memsz) + bzero(p + ph.p_filesz, ph.p_memsz - ph.p_filesz); + } + ofw_close(bootdev); + (*(void (*)())eh.e_entry)(0, 0, 0, 0, ofw); + panic("main"); } static void @@ -411,48 +434,6 @@ return (0); } -static void -load(const char *fname) -{ - Elf64_Ehdr eh; - Elf64_Phdr ph; - caddr_t p; - ino_t ino; - int i; - - if ((ino = lookup(fname)) == 0) { - printf("File %s not found\n", fname); - return; - } - if (fsread(ino, &eh, sizeof(eh)) != sizeof(eh)) { - printf("Can't read elf header\n"); - return; - } - if (!IS_ELF(eh)) { - printf("Not an ELF file\n"); - return; - } - for (i = 0; i < eh.e_phnum; i++) { - fs_off = eh.e_phoff + i * eh.e_phentsize; - if (fsread(ino, &ph, sizeof(ph)) != sizeof(ph)) { - printf("Can't read program header %d\n", i); - return; - } - if (ph.p_type != PT_LOAD) - continue; - fs_off = ph.p_offset; - p = (caddr_t)ph.p_vaddr; - if (fsread(ino, p, ph.p_filesz) != ph.p_filesz) { - printf("Can't read content of section %d\n", i); - return; - } - if (ph.p_filesz != ph.p_memsz) - bzero(p + ph.p_filesz, ph.p_memsz - ph.p_filesz); - } - ofw_close(bootdev); - (*(void (*)(int, int, int, int, ofwfp_t))eh.e_entry)(0, 0, 0, 0, ofw); -} - static ino_t lookup(const char *path) { To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe p4-projects" in the body of the message