NetBSD Problem Report #22140
Received: (qmail 2351 invoked by uid 605); 15 Jul 2003 09:26:58 -0000
Message-Id: <200307150927.h6F9RwAr048710@lorien.int.gecko.de>
Date: Tue, 15 Jul 2003 11:27:58 +0200 (MEST)
From: gni@gecko.de
Sender: gnats-bugs-owner@NetBSD.org
Reply-To: gni@gecko.de
To: gnats-bugs@gnats.netbsd.org
Subject: update for /dev/reload
X-Send-Pr-Version: 3.95
>Number: 22140
>Category: port-amiga
>Synopsis: update for /dev/reload
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: port-amiga-maintainer
>State: analyzed
>Class: change-request
>Submitter-Id: net
>Arrival-Date: Tue Jul 15 09:27:00 +0000 2003
>Closed-Date:
>Last-Modified: Thu Jun 24 12:03:15 +0000 2004
>Originator: Gunther Nikl
>Release: NetBSD 1.6.1
>Organization:
>Environment:
Architecture: m68k
Machine: amiga
>Description:
Since the switch to ELF on NetBSD/amiga with 1.6 /dev/reload cannot be used
anymore since it works for a.out kernels only. Additionally, /dev/reload
does still require chipmem to reload a kernel and the reload code must be
at exactly the same location in the new kernel and the currently running
kernel (because reload continues in chipmem after the MMU is switched off).
>How-To-Repeat:
Copy an ELF kernel into /dev/reload. This will fail.
>Fix:
The attached diff for amiga/amiga_init.c replaces the a.out support with an
ELF loader including symbol loading. The attached diff for amiga/locore.s
removes the chipmem limitation and reload code match constraint. That allows
to reload into arbitary kernels with no size restriction since it places the
new kernel in fastmem. The old code used chipmem because the kernel could
only load from there. This restriction is long gone.
The patches are against -current sources and apply with a small change
(AOUT_LDPGSZ -> __LDPGSZ) on 1.6.1. The new /dev/reload code was only tested
with 1.6.1 and a 68060.
begin 644 dev_reload.tgz
M'XL(`-._$S\"`^T\:W/3R+)\=7[%L!2L'<E!?N9%@$#,PMF$4$G892^7<BF2
M'`O;DE>2"6'AOY_NGAEI1H\D[.[94W6OIL"/4<],3[^[9QS7GVS,0R>,O(WX
MSG^H61W+&O;[=RS+ZFP..OAN6=T^?[>L0;<SN&-M;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5+3Q#]U6``^>Z+9`6CXD?6H--#=95H(MI[9.\&MH+C'=K,!4#Q6O"23RF%<$
MB[>JHQ(_M-I6.CL=G^?#AQ([61U%E@>2.?2UN4LBBN("&H8Y+P+>'?\P2)4#
MT!BNA$OYU<K+Z)4+_QUBL54MP%P'A6?1!?FV,G-M\,G+TM?'GY55X*($542>
M5:)3%G_>.@2ME)G2:T8EIEFUPS)T[A>DKUC>5;VRQNF2JFVCJG);**'J+KZJ
M3%SFZTO6S);4;%LF7-G5)$%<-:T1CI\7:@2@\A"3]K)AWRK*WX7+\=]5PE5S
M^.HB;N"VBA6#[RG7JLO(/X&47BO32IAIYC7[E(1<>@BA5I9]*Q>^Q$6N?#']
MQDHMK['GZK2"+7IU-H.\56U6$NGU\=G)"/_(T`'?];<U1E5ZY1J!(7Y]EEUM
MDU=5Z>=G5".5CY0"J:'=A>/%474J.IXMG8E?4\Q-)$YSLWG4TP41(>D_,L/?
M!HIR5?UW&^I6M[K5K6YUJUO=ZE:WNM6M;G6K6]WJ5K>ZU:UN=:M;W>I6M[K5
<K6YUJUO=ZE:WNM6M;G6KV__?]F\W].WJ`'@`````
`
end
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->feedback
State-Changed-By: is
State-Changed-When: Thu May 27 19:49:59 UTC 2004
State-Changed-Why:
Sorry for the delay. Would you please KNFify the diffs?
From: Gunther Nikl <gni@gecko.de>
To: gnats-bugs@gnats.netbsd.org
Cc:
Subject: Re: port-amiga/22140
Date: Thu, 10 Jun 2004 16:10:36 +0200
On Thu, May 27, 2004 at 07:51:20PM -0000, is@netbsd.org wrote:
> Sorry for the delay. Would you please KNFify the diffs?
Done. The patches are against 1.6.1. The C part applies on current (2.0)
after replacing __LDPGSZ with AOUT_LDPGSZ in the c patch part.
There are some possible changes for kernel_reload:
- the paraemter list in the comment of this function in locore.s
isn't correct.
- boothowto and machineid could also be parameters.
- mmutype could also be passed as parameter.
--- ../locore.s Sun Jan 12 01:03:43 2003
+++ locore.s Fri Jul 4 20:37:26 2003
@@ -458,7 +458,7 @@ ENTRY_NOPROFILE(lev5intr)
moveml %d0/%d1/%a0/%a1,%sp@-
#include "ser.h"
#if NSER > 0
- jsr _C_LABEL(ser_fastint)
+ jbsr _C_LABEL(ser_fastint)
#else
INTREQWADDR(%a0)
movew #INTF_RBF,%a0@ | clear RBF interrupt in intreq
@@ -1857,31 +1858,32 @@ LdoDraCoBoot:
* fastram_start, fastram_size, chipram_start, esym, eclockfreq)
*/
ENTRY_NOPROFILE(kernel_reload)
- lea Lreload_copy,%a0 | cursory validity check of new kernel
- movl %a0@,%d0 | to see if the kernel reload code
- addl %sp@(4),%a0 | in new image matches running kernel
- cmpl %a0@,%d0
- jeq Lreload_ok
- rts | It doesn't match - can't reload
-Lreload_ok:
- jsr _C_LABEL(bootsync)
- CUSTOMADDR(%a5)
-
- movew #(1<<9),%a5@(0x096) | disable DMA (before clobbering chipmem)
+ CUSTOMADDR(%a0)
+ movew #(1<<9),%a0@(0x96) | disable DMA (before clobbering chipmem)
movl #CACHE_OFF,%d0
cmpl #MMU_68040,_C_LABEL(mmutype)
jne Lreload1
- .word 0xf4f8 | cpusha bc - push and invalidate caches
+ .word 0xf4f8 | cpusha bc - push and invalidate caches
nop
movl #CACHE40_OFF,%d0
Lreload1:
movc %d0,%cacr | disable on-chip cache(s)
movw #0x2700,%sr | cut off any interrupts
- movel _C_LABEL(boothowto),%d7 | save boothowto
- movel _C_LABEL(machineid),%d5 | (and machineid)
+ lea Ldoreload,%a1
+ movl _C_LABEL(CHIPMEMADDR),%a0
+ lea Ldorebootend,%a2
+ addl %a1,%a0
+Lreload_copy:
+ movel %a1@+,%a0@+
+ cmpl %a2,%a1
+ jle Lreload_copy
+
+ movel %sp@(4),%a5 | pa of new kernel image
+ movel %sp@(8),%d2 | copy kernelsize
+ movel %sp@(12),%a6 | find entrypoint
movel %sp@(16),%a0 | load memory parameters
movel %sp@(20),%d0
movel %sp@(24),%d1
@@ -1890,17 +1892,11 @@ Lreload1:
movel %sp@(36),%d3 | AGA mode
movel %sp@(40),%a2 | sync inhibit flags
movel %sp@(44),%d6 | boot partition offset
+ movel _C_LABEL(boothowto),%d7
+ movel _C_LABEL(machineid),%d5
+ addl %a0,%a6
- movel %sp@(12),%a6 | find entrypoint (a6)
-
- movel %sp@(4),%a1 | copy kernel to low chip memory
- movel %sp@(8),%d2
- movl _C_LABEL(CHIPMEMADDR),%a3
-Lreload_copy:
- movel %a1@+,%a3@+
- subl #4,%d2
- jcc Lreload_copy
-
+Ldoreload:
| ok, turn off MMU..
cmpl #MMU_68040,_C_LABEL(mmutype)
jeq Lreload040
@@ -1911,18 +1907,23 @@ Lreload_copy:
pmove %a3@,%srp | Really, really, turn off MMU
jra Lreload2
Lreload040:
- movl #0,%d2
- .word 0x4e7b,0x2003 | movc d2,TC
- .word 0x4e7b,0x2806 | movc d2,URP
- .word 0x4e7b,0x2807 | movc d2,SRP
+ subl %a3,%a3
+ .word 0x4e7b,0xb003 | movc a3,TC
+ .word 0x4e7b,0xb806 | movc a3,URP
+ .word 0x4e7b,0xb807 | movc a3,SRP
Lreload2:
- moveq #0,%d2 | clear unused registers
+ movel %a0,%a3
+Lreload_copy2:
+ movel %a5@+,%a3@+
+ subql #4,%d2
+ jcc Lreload_copy2
+
+ movq #0,%d2 | clear unused registers
subl %a1,%a1
subl %a3,%a3
subl %a5,%a5
jmp %a6@ | start new kernel
-
| A do-nothing MMU root pointer (includes the following long as well)
--- ../amiga_init.c Sun Jan 12 01:03:12 2003
+++ /tmp/amiga_init.c3 Thu Jun 3 14:27:21 2004
@@ -53,7 +53,7 @@
#include <sys/domain.h>
#include <sys/dkbad.h>
#include <sys/reboot.h>
-#include <sys/exec.h>
+#include <sys/exec_elf.h>
#include <machine/pte.h>
#include <machine/cpu.h>
#include <amiga/amiga/cc.h>
@@ -131,8 +131,9 @@
void rollcolor(int);
static int kernel_image_magic_size(void);
static void kernel_image_magic_copy(u_char *);
+static int kernel_skip(struct uio *, size_t, caddr_t, size_t);
int kernel_reload_write(struct uio *);
-extern void kernel_reload(char *, u_long, u_long, u_long, u_long,
+extern void kernel_reload(caddr_t, u_long, u_long, u_long, u_long,
u_long, u_long, u_long, u_long, u_long, u_long);
extern void etext(void);
void start_c_finish(void);
@@ -959,13 +956,6 @@
* Kernel reloading code
*/
-static struct exec kernel_exec;
-static u_char *kernel_image;
-static u_long kernel_text_size, kernel_load_ofs;
-static u_long kernel_load_phase;
-static u_long kernel_load_endseg;
-static u_long kernel_symbol_size, kernel_symbol_esym;
-
/* This supports the /dev/reload device, major 2, minor 20,
hooked into mem.c. Author: Bryan Ford. */
@@ -979,8 +969,8 @@
int sz;
/* 4 + cfdev's + Mem_Seg's + 4 */
- sz = 8 + ncfdev * sizeof(struct cfdev)
- + memlist->m_nseg * sizeof(struct boot_memseg);
+ sz = 4 + ncfdev * sizeof(struct cfdev)
+ + memlist->m_nseg * sizeof(struct boot_memseg) + 4;
return(sz);
}
@@ -991,158 +981,402 @@
{
*((int*)dest) = ncfdev;
dest += 4;
- bcopy(cfdev, dest, ncfdev * sizeof(struct cfdev)
+ memcpy(dest, cfdev, ncfdev * sizeof(struct cfdev)
+ memlist->m_nseg * sizeof(struct boot_memseg) + 4);
}
-#undef __LDPGSZ
-#define __LDPGSZ 8192 /* XXX ??? */
+/* Skip any unused data. */
+static int
+kernel_skip(uio, skip, buf, bsiz)
+ struct uio *uio;
+ size_t skip;
+ caddr_t buf;
+ size_t bsiz;
+{
+ int error = ENOEXEC;
+ if ((int)skip >= 0) {
+ for (error=skip; skip != 0;) {
+ size_t len = min(min(skip, bsiz), MAXPHYS);
+ skip -= len;
+ if ((error = uiomove(buf, len, uio)) != 0)
+ break;
+ }
+ }
+ return error;
+}
+
+#define MAKE_ID(a,b,c,d) \
+ ((u_long)(a)<<24|(u_long)(b)<<16|(u_long)(c)<<8|(u_long)(d))
int
kernel_reload_write(uio)
struct uio *uio;
{
extern int eclockfreq;
- struct iovec *iov;
- int error, c;
-
- iov = uio->uio_iov;
+ static struct _k {
+ u_long phase;
+ Elf32_Phdr *phdr;
+ caddr_t image;
+ size_t ksiz;
+ size_t msiz;
+ size_t esym;
+ size_t shsz;
+ size_t esiz;
+ u_long readcnt;
+ u_short segnum, pad;
+ u_long offset;
+ u_long endseg;
+ union {
+ Elf32_Ehdr e;
+ u_long m;
+ } hdr;
+ #define magic hdr.m
+ #define ehdr hdr.e
+ } kernel_reload_data;
+ struct _k *kp = &kernel_reload_data;
+ size_t ksize, psiz, esiz, pos;
+ Elf32_Phdr *phdr;
+ Elf32_Shdr *shdr;
+ caddr_t img, kend;
+ u_short idx;
+ u_long i, j;
+ int error = 0;
+ int c;
+
+ /* load kernel */
+
+ switch (kp->phase) {
+ case 0:
+ /* load phdr array */
- if (kernel_image == 0) {
/*
* We have to get at least the whole exec header
* in the first write.
*/
- if (iov->iov_len < sizeof(kernel_exec))
- return ENOEXEC; /* XXX */
+ if (uio->uio_resid < sizeof(kp->ehdr))
+ return ENOEXEC;
/*
* Pull in the exec header and check it.
*/
- if ((error = uiomove((caddr_t)&kernel_exec, sizeof(kernel_exec),
- uio)) != 0)
- return(error);
- printf("loading kernel %ld+%ld+%ld+%ld\n", kernel_exec.a_text,
- kernel_exec.a_data, kernel_exec.a_bss,
- esym == NULL ? 0 : kernel_exec.a_syms);
- /*
- * Looks good - allocate memory for a kernel image.
- */
- kernel_text_size = (kernel_exec.a_text
- + __LDPGSZ - 1) & (-__LDPGSZ);
- /*
- * Estimate space needed for symbol names, since we don't
- * know how big it really is.
- */
- if (esym != NULL) {
- kernel_symbol_size = kernel_exec.a_syms;
- kernel_symbol_size += 16 * (kernel_symbol_size / 12);
+ error = uiomove((caddr_t)&kp->ehdr, sizeof(kp->ehdr), uio);
+ if (error != 0)
+ return (error);
+
+ if (kp->magic != MAKE_ID(ELFMAG0,ELFMAG1,ELFMAG2,ELFMAG3)
+ || kp->ehdr.e_ident[EI_CLASS] != ELFCLASS32
+ || kp->ehdr.e_ident[EI_DATA] != ELFDATA2MSB
+ || kp->ehdr.e_ident[EI_VERSION] != EV_CURRENT
+ || kp->ehdr.e_type != ET_EXEC
+ || kp->ehdr.e_machine != EM_68K
+ || kp->ehdr.e_version != EV_CURRENT
+ || kp->ehdr.e_ehsize != sizeof(kp->ehdr)
+ || kp->ehdr.e_phentsize != sizeof(*kp->phdr))
+ return ENOEXEC;
+
+ /* allocate phdr space */
+ psiz = kp->ehdr.e_phnum * sizeof(*kp->phdr);
+ c = kp->ehdr.e_phoff - sizeof(kp->ehdr);
+ if (uio->uio_resid < c + psiz)
+ return ENOEXEC;
+ kp->phdr = phdr = malloc(psiz, M_TEMP, M_WAITOK);
+
+ /* get array */
+ error = kernel_skip(uio, c, (caddr_t)phdr, psiz);
+ if (error != 0)
+ break;
+ error = uiomove((caddr_t)phdr, psiz, uio);
+ if (error != 0)
+ break;
+
+ /* prepare loading program segments */
+ kp->segnum = 0;
+ kp->readcnt = kp->ehdr.e_phoff + psiz;
+
+ /* init */
+ ksize = 0;
+
+ /* calculate kernel size */
+ idx = 0;
+ do {
+ /* loadable? */
+ if ((phdr->p_type != PT_LOAD) ||
+ (phdr->p_flags & (PF_W|PF_X)) == 0)
+ continue;
+ /* sanity */
+ pos = phdr->p_memsz;
+ if (phdr->p_filesz > pos)
+ break;
+ /* real size */
+ pos += phdr->p_vaddr;
+ if (pos > ksize)
+ ksize = pos;
+ } while (++phdr, ++idx < kp->ehdr.e_phnum);
+
+ /* sanity */
+ error = ENOEXEC;
+ if (idx != kp->ehdr.e_phnum || ksize == 0)
+ break;
+
+ /* align size */
+ kp->ksiz = roundup(ksize, 4);
+ kp->msiz = kernel_image_magic_size();
+ kp->shsz = esym != NULL && kp->ehdr.e_shentsize == sizeof(Elf32_Shdr)
+ ? kp->ehdr.e_shnum * sizeof(Elf32_Shdr) : 0;
+ kp->image = malloc(kp->ksiz + kp->msiz +
+ (kp->shsz != 0 ? kp->ksiz/6 : 0),
+ M_TEMP, M_WAITOK);
+
+ /* done */
+ ++kp->phase;
+
+ /*FALLTHROUGH*/
+
+ case 1:
+ case 2:
+ case 3:
+
+ img = &kp->image[0];
+
+ /* load program segments */
+ do {
+ phdr = &kp->phdr[kp->segnum];
+ switch (kp->phase) {
+ case 1:
+ /* loadable? */
+ if ((phdr->p_type != PT_LOAD) ||
+ (phdr->p_flags & (PF_W|PF_X)) == 0)
+ continue;
+ kp->offset = phdr->p_vaddr;
+ kp->endseg = kp->offset + phdr->p_filesz;
+ ++kp->phase;
+
+ /*FALLTHROUGH*/
+
+ case 2:
+ c = min(uio->uio_resid, phdr->p_offset - kp->readcnt);
+ error = kernel_skip(uio, c, &img[kp->offset], phdr->p_filesz);
+ if (error != 0)
+ break;
+ kp->readcnt += c;
+ if (kp->readcnt != phdr->p_offset)
+ return (0);
+ kp->readcnt += phdr->p_filesz;
+ ++kp->phase;
+
+ /*FALLTHROUGH*/
+
+ case 3:
+ c = min(uio->uio_resid, kp->endseg - kp->offset);
+ c = min(c, MAXPHYS);
+ error = uiomove(&img[kp->offset], c, uio);
+ if (error != 0)
+ break;
+ kp->offset += c;
+ if (kp->offset != kp->endseg)
+ return (0);
+ /* zero BSS part */
+ c = phdr->p_memsz - phdr->p_filesz;
+ if (c != 0)
+ memset(&img[kp->offset], 0, c);
+ kp->phase -= 2;
+ }
}
+ while (++kp->segnum < kp->ehdr.e_phnum);
+
+ /* sanity */
+
+ if (error != 0)
+ break;
+
+ /* Say operation not supported */
+ error = ENODEV;
+ if (*(u_short *)&img[kp->ehdr.e_entry-2] != 3)
+ break;
+
+ /* done */
+ kp->phase = 4;
+
+ /*FALLTHROUGH*/
+
+ default:
+
+ kend = &kp->image[kp->ksiz];
+
/*
- * XXX - should check that image will fit in CHIP memory
- * XXX return an error if it doesn't
+ * handle symbols, any error in this part is ignored!
*/
- if ((kernel_text_size + kernel_exec.a_data +
- kernel_exec.a_bss + kernel_symbol_size +
- kernel_image_magic_size()) > boot_cphysize)
- return (EFBIG);
- kernel_image = malloc(kernel_text_size + kernel_exec.a_data
- + kernel_exec.a_bss
- + kernel_symbol_size
- + kernel_image_magic_size(),
- M_TEMP, M_WAITOK);
- kernel_load_ofs = 0;
- kernel_load_phase = 0;
- kernel_load_endseg = kernel_exec.a_text;
- return(0);
- }
- /*
- * Continue loading in the kernel image.
- */
- c = min(iov->iov_len, kernel_load_endseg - kernel_load_ofs);
- c = min(c, MAXPHYS);
- if ((error = uiomove(kernel_image + kernel_load_ofs, (int)c, uio)) != 0)
- return(error);
- kernel_load_ofs += c;
-
- /*
- * Fun and games to handle loading symbols - the length of the
- * string table isn't know until after the symbol table has
- * been loaded. We have to load the kernel text, data, and
- * the symbol table, then get the size of the strings. A
- * new kernel image is then allocated and the data currently
- * loaded moved to the new image. Then continue reading the
- * string table. This has problems if there isn't enough
- * room to allocate space for the two copies of the kernel
- * image. So the approach I took is to guess at the size
- * of the symbol strings. If the guess is wrong, the symbol
- * table is ignored.
- */
-
- if (kernel_load_ofs != kernel_load_endseg)
- return(0);
-
- switch (kernel_load_phase) {
- case 0: /* done loading kernel text */
- kernel_load_ofs = kernel_text_size;
- kernel_load_endseg = kernel_load_ofs + kernel_exec.a_data;
- kernel_load_phase = 1;
- break;
- case 1: /* done loading kernel data */
- for(c = 0; c < kernel_exec.a_bss; c++)
- kernel_image[kernel_load_ofs + c] = 0;
- kernel_load_ofs += kernel_exec.a_bss;
- if (esym) {
- kernel_load_endseg = kernel_load_ofs
- + kernel_exec.a_syms + 8;
- *((u_long *)(kernel_image + kernel_load_ofs)) =
- kernel_exec.a_syms;
- kernel_load_ofs += 4;
- kernel_load_phase = 3;
- break;
+ if (kp->shsz != 0) {
+
+ switch (kp->phase) {
+ case 4:
+ /* load shdr array */
+ c = min(uio->uio_resid, kp->ehdr.e_shoff - kp->readcnt);
+ error = kernel_skip(uio, c, kend, kp->ksiz/6);
+ if (error != 0)
+ break;
+ kp->readcnt += c;
+ if (kp->readcnt != kp->ehdr.e_shoff)
+ return (0);
+ kp->offset = 0;
+ kp->endseg = kp->shsz;
+ ++kp->phase;
+
+ /*FALLTHROUGH*/
+
+ case 5:
+ shdr = (Elf32_Shdr *)&kend[sizeof(kp->ehdr)];
+
+ c = min(uio->uio_resid, kp->endseg - kp->offset);
+ c = min(c, MAXPHYS);
+ error = uiomove((caddr_t)shdr + kp->offset, c, uio);
+ if (error != 0)
+ break;
+ kp->offset += c;
+ if (kp->offset != kp->endseg)
+ return (0);
+ kp->readcnt += kp->shsz;
+
+ /* calculate symbol size */
+ esiz = sizeof(kp->ehdr) + roundup(kp->shsz, 4);
+ i = 0;
+ do {
+ /* since .shstrtab isn't loaded, zero the name */
+ shdr[i].sh_name = 0;
+ /* handle section types */
+ switch(shdr[i].sh_type) {
+ case SHT_STRTAB:
+ /* make sure, the table is used */
+ j = 0;
+ do {
+ if (shdr[j].sh_type == SHT_SYMTAB &&
+ shdr[j].sh_link == i)
+ goto havesym;
+ } while (++j < kp->ehdr.e_shnum);
+ /* FALLTHROUGH */
+ default:
+ /* not loading section, zero the offset */
+ shdr[i].sh_offset = 0;
+ break;
+ havesym:
+ case SHT_SYMTAB:
+ /* align section size */
+ esiz += roundup(shdr[i].sh_size, 4);
+ break;
+ }
+ } while (++i < kp->ehdr.e_shnum);
+
+ /* enough space? */
+ if (esiz > kp->ksiz/6)
+ break;
+ kp->esiz = esiz;
+
+ /* copy ELF header */
+ kp->ehdr.e_phoff = 0;
+ kp->ehdr.e_shoff = sizeof(kp->ehdr);
+ kp->ehdr.e_phentsize = 0;
+ kp->ehdr.e_phnum = 0;
+ kp->ehdr.e_shstrndx = 0;
+ memcpy(kend, &kp->ehdr, sizeof(kp->ehdr));
+
+ /* prepare loading symbols */
+ kp->offset = sizeof(kp->ehdr) + roundup(kp->shsz, 4);
+ kp->segnum = 0;
+
+ /* done */
+ ++kp->phase;
+
+ /*FALLTHROUGH*/
+
+ case 6:
+ case 7:
+ case 8:
+ /* load symbols */
+ do {
+ shdr = &((Elf32_Shdr *)&kend[sizeof(kp->ehdr)])[kp->segnum];
+ switch(kp->phase) {
+ case 6:
+ /* set? */
+ if (shdr->sh_offset == 0)
+ continue;
+ ++kp->phase;
+
+ /*FALLTHROUGH*/
+
+ case 7:
+ c = min(uio->uio_resid, shdr->sh_offset - kp->readcnt);
+ error = kernel_skip(uio, c, &kend[kp->offset], shdr->sh_size);
+ if (error != 0)
+ break;
+ kp->readcnt += c;
+ if (kp->readcnt != shdr->sh_offset)
+ return (0);
+ kp->readcnt += shdr->sh_size;
+ /* incore offset */
+ shdr->sh_offset = kp->offset;
+ kp->endseg = kp->offset + shdr->sh_size;
+ ++kp->phase;
+
+ /*FALLTHROUGH*/
+
+ case 8:
+ /* load section */
+ c = min(uio->uio_resid, kp->endseg - kp->offset);
+ c = min(c, MAXPHYS);
+ error = uiomove(&kend[kp->offset], c, uio);
+ if (error != 0)
+ break;
+ kp->offset += c;
+ if (kp->offset != kp->endseg)
+ return (0);
+ /* align size */
+ kp->offset = roundup(kp->offset, 4);
+ kp->phase -= 2;
+ }
+
+ /* sanity */
+
+ if (error != 0)
+ break;
+
+ } while (++kp->segnum < kp->ehdr.e_shnum);
+
+ /* sanity */
+
+ if (error == 0) {
+ kp->ksiz += kp->esiz;
+ kp->esym = kp->ksiz;
+ kend += kp->esiz;
+ }
+ }
}
- /*FALLTHROUGH*/
- case 2: /* done loading kernel */
/*
* Put the finishing touches on the kernel image.
*/
- kernel_image_magic_copy(kernel_image + kernel_load_ofs);
+ kernel_image_magic_copy(kend);
+
/*
* Start the new kernel with code in locore.s.
*/
- kernel_reload(kernel_image,
- kernel_load_ofs + kernel_image_magic_size(),
- kernel_exec.a_entry, boot_fphystart, boot_fphysize,
- boot_cphysize, kernel_symbol_esym, eclockfreq,
- boot_flags, scsi_nosync, boot_partition);
- /*
- * kernel_reload() now checks to see if the reload_code
- * is at the same location in the new kernel.
- * If it isn't, it will return and we will return
- * an error.
- */
- free(kernel_image, M_TEMP);
- kernel_image = NULL;
- return (ENODEV); /* Say operation not supported */
- case 3: /* done loading kernel symbol table */
- c = *((u_long *)(kernel_image + kernel_load_ofs - 4));
- if (c > 16 * (kernel_exec.a_syms / 12))
- c = 16 * (kernel_exec.a_syms / 12);
- kernel_load_endseg += c - 4;
- kernel_symbol_esym = kernel_load_endseg;
-#ifdef notyet
- kernel_image_copy = kernel_image;
- kernel_image = malloc(kernel_load_ofs + c
- + kernel_image_magic_size(), M_TEMP, M_WAITOK);
- if (kernel_image == NULL)
- panic("kernel_reload failed second malloc");
- for (c = 0; c < kernel_load_ofs; c += MAXPHYS)
- bcopy(kernel_image_copy + c, kernel_image + c,
- (kernel_load_ofs - c) > MAXPHYS ? MAXPHYS :
- kernel_load_ofs - c);
-#endif
- kernel_load_phase = 2;
+ bootsync();
+ kernel_reload((caddr_t)kvtop(kp->image), kp->ksiz + kp->msiz,
+ kp->ehdr.e_entry, boot_fphystart, boot_fphysize,
+ boot_cphysize, kp->esym, eclockfreq,
+ boot_flags, scsi_nosync, boot_partition);
+
+ /*NOTREACHED*/
}
- return(0);
+
+ if (kp->image != NULL)
+ free(kp->image, M_TEMP);
+ kp->image = NULL;
+
+ if (kp->phdr != NULL)
+ free(kp->phdr, M_TEMP);
+ kp->phdr = NULL;
+
+ kp->phase = 0;
+
+ return error;
}
State-Changed-From-To: feedback->analyzed
State-Changed-By: is
State-Changed-When: Thu Jun 24 12:02:45 UTC 2004
State-Changed-Why:
Received updated patch.
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.