Try to page align all segments up to 4MB pages.

This commit is contained in:
eeh 2000-03-06 01:29:04 +00:00
parent 39546c529f
commit 4a8841ada2
3 changed files with 30 additions and 13 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.13 2000/01/23 17:04:11 mycroft Exp $ # $NetBSD: Makefile,v 1.14 2000/03/06 01:29:04 eeh Exp $
CURDIR= ${.CURDIR} CURDIR= ${.CURDIR}
S= ${CURDIR}/../../../.. S= ${CURDIR}/../../../..
@ -14,9 +14,9 @@ SRCS= srt0.s Locore.c boot.c ofdev.c alloc.c net.c netif_of.c
.PATH: ${S}/arch/sparc64/sparc64 .PATH: ${S}/arch/sparc64/sparc64
.if CROSS .if CROSS
CEXTRAFLAGS= -nostdinc CEXTRAFLAGS?= -nostdinc
.else .else
CEXTRAFLAGS= -D_LP64 CEXTRAFLAGS?= -D_LP64
.endif .endif
CFLAGS+= ${COPTS} -DNETIF_DEBUG -D__ELF__ ${CEXTRAFLAGS} -D_STANDALONE CFLAGS+= ${COPTS} -DNETIF_DEBUG -D__ELF__ ${CEXTRAFLAGS} -D_STANDALONE
@ -91,7 +91,7 @@ ${PROG}: ${OBJS} ${LIBSA} ${LIBZ} ${LIBKERN}
.if CROSS .if CROSS
AFLAGS= -x assembler-with-cpp -Wa,-Av9a -traditional-cpp -D_LOCORE -D__ELF__ AFLAGS= -x assembler-with-cpp -Wa,-Av9a -traditional-cpp -D_LOCORE -D__ELF__
.else .else
AFLAGS= -x assembler-with-cpp -traditional-cpp -D_LOCORE -D__ELF__ -D_LP64 -Wa,-Av9 #-Wa,-Av8plusa AFLAGS= -x assembler-with-cpp -traditional-cpp -D_LOCORE -D__ELF__ -Wa,-Av9a ${CEXTRAFLAGS} #-Wa,-Av8plusa
.endif .endif
NORMAL_S= ${CC} ${AFLAGS} ${CPPFLAGS} -c $< NORMAL_S= ${CC} ${AFLAGS} ${CPPFLAGS} -c $<
srt0.o: srt0.s srt0.o: srt0.s

View File

@ -1,4 +1,4 @@
/* $NetBSD: boot.c,v 1.10 1999/10/25 14:04:38 kleink Exp $ */ /* $NetBSD: boot.c,v 1.11 2000/03/06 01:29:04 eeh Exp $ */
#define DEBUG #define DEBUG
/* /*
* Copyright (c) 1997, 1999 Eduardo E. Horvath. All rights reserved. * Copyright (c) 1997, 1999 Eduardo E. Horvath. All rights reserved.
@ -61,6 +61,8 @@
#include <sparc64/stand/ofwboot/ofdev.h> #include <sparc64/stand/ofwboot/ofdev.h>
#include <sparc64/stand/ofwboot/openfirm.h> #include <sparc64/stand/ofwboot/openfirm.h>
#define MEG (1024*1024)
/* /*
* Boot device is derived from ROM provided information, or if there is none, * Boot device is derived from ROM provided information, or if there is none,
* this list is used in sequence, to find a kernel. * this list is used in sequence, to find a kernel.
@ -403,6 +405,7 @@ elf32_exec(fd, elf, entryp, ssymp, esymp)
void *addr; void *addr;
size_t size; size_t size;
int i, first = 1; int i, first = 1;
long align;
int n; int n;
/* /*
@ -429,7 +432,15 @@ elf32_exec(fd, elf, entryp, ssymp, esymp)
printf("%s%lu@0x%lx", first ? "" : "+", phdr.p_filesz, printf("%s%lu@0x%lx", first ? "" : "+", phdr.p_filesz,
(u_long)phdr.p_vaddr); (u_long)phdr.p_vaddr);
(void)lseek(fd, phdr.p_offset, SEEK_SET); (void)lseek(fd, phdr.p_offset, SEEK_SET);
/* NB need to do 4MB allocs here */
/*
* If the segment's VA is aligned on a 4MB boundary, align its
* request 4MB aligned physical memory. Otherwise use default
* alignment.
*/
align = phdr.p_align;
if ((phdr.p_vaddr & (4*MEG-1)) == 0)
align = 4*MEG;
if (OF_claim((void *)phdr.p_vaddr, phdr.p_memsz, phdr.p_align) == if (OF_claim((void *)phdr.p_vaddr, phdr.p_memsz, phdr.p_align) ==
(void *)-1) (void *)-1)
panic("cannot claim memory"); panic("cannot claim memory");

View File

@ -1,6 +1,7 @@
/* $NetBSD: elfXX_exec.c,v 1.4 1999/10/25 14:04:38 kleink Exp $ */ /* $NetBSD: elfXX_exec.c,v 1.5 2000/03/06 01:29:04 eeh Exp $ */
/* /*
* Copyright (c) 1998-2000 Eduardo Horvath. All rights reserved.
* Copyright (c) 1997 Jason R. Thorpe. All rights reserved. * Copyright (c) 1997 Jason R. Thorpe. All rights reserved.
* Copyright (C) 1995, 1996 Wolfgang Solfrank. * Copyright (C) 1995, 1996 Wolfgang Solfrank.
* Copyright (C) 1995, 1996 TooLs GmbH. * Copyright (C) 1995, 1996 TooLs GmbH.
@ -44,6 +45,7 @@
#define CONCAT(x,y) __CONCAT(x,y) #define CONCAT(x,y) __CONCAT(x,y)
#define CAT3(s,m,e) CONCAT(s,CONCAT(m,e)) #define CAT3(s,m,e) CONCAT(s,CONCAT(m,e))
#define MEG (1024*1024)
#if 0 #if 0
int CAT3(elf,ELFSIZE,_exec) __P((int, CAT3(Elf,ELFSIZE,_Ehdr) *, u_int64_t *, void **, void **)); int CAT3(elf,ELFSIZE,_exec) __P((int, CAT3(Elf,ELFSIZE,_Ehdr) *, u_int64_t *, void **, void **));
@ -61,6 +63,7 @@ CAT3(elf, ELFSIZE, _exec)(fd, elf, entryp, ssymp, esymp)
CAT3(Elf,ELFSIZE,_Off) off; CAT3(Elf,ELFSIZE,_Off) off;
void *addr; void *addr;
size_t size; size_t size;
u_int align;
int i, first = 1; int i, first = 1;
int n; int n;
@ -72,18 +75,14 @@ CAT3(elf, ELFSIZE, _exec)(fd, elf, entryp, ssymp, esymp)
printf("elf%d_exec: ", ELFSIZE); printf("elf%d_exec: ", ELFSIZE);
#endif #endif
printf("Booting %s\n", opened_name); printf("Booting %s\n", opened_name);
printf("reading %ld program headers\n", (long)elf->e_phnum);
for (i = 0; i < elf->e_phnum; i++) { for (i = 0; i < elf->e_phnum; i++) {
CAT3(Elf,ELFSIZE,_Phdr) phdr; CAT3(Elf,ELFSIZE,_Phdr) phdr;
printf("reading phdr %d at %lx\n", i, (long)(elf->e_phoff + sizeof(phdr) * i));
size = lseek(fd, (size_t)(elf->e_phoff + sizeof(phdr) * i), SEEK_SET); size = lseek(fd, (size_t)(elf->e_phoff + sizeof(phdr) * i), SEEK_SET);
printf("lseek sez: %lx %s\n", (long)size, (size<0)?strerror(errno):"");
if (read(fd, (void *)&phdr, sizeof(phdr)) != sizeof(phdr)) { if (read(fd, (void *)&phdr, sizeof(phdr)) != sizeof(phdr)) {
printf("read phdr: %s\n", strerror(errno)); printf("read phdr: %s\n", strerror(errno));
return (1); return (1);
} }
printf("reading phdr worked, type %lx flags %lx\n", (long)phdr.p_type, (long)phdr.p_flags);
if (phdr.p_type != PT_LOAD || if (phdr.p_type != PT_LOAD ||
(phdr.p_flags & (PF_W|PF_X)) == 0) (phdr.p_flags & (PF_W|PF_X)) == 0)
continue; continue;
@ -92,8 +91,15 @@ printf("reading phdr worked, type %lx flags %lx\n", (long)phdr.p_type, (long)phd
printf("%s%lu@0x%lx", first ? "" : "+", (u_long)phdr.p_filesz, printf("%s%lu@0x%lx", first ? "" : "+", (u_long)phdr.p_filesz,
(u_long)phdr.p_vaddr); (u_long)phdr.p_vaddr);
(void)lseek(fd, (size_t)phdr.p_offset, SEEK_SET); (void)lseek(fd, (size_t)phdr.p_offset, SEEK_SET);
/* NB need to do 4MB allocs here */ /*
if (OF_claim((void *)(long)phdr.p_vaddr, phdr.p_memsz, phdr.p_align) == * If the segment's VA is aligned on a 4MB boundary, align its
* request 4MB aligned physical memory. Otherwise use default
* alignment.
*/
align = phdr.p_align;
if ((phdr.p_vaddr & (4*MEG-1)) == 0)
align = 4*MEG;
if (OF_claim((void *)(long)phdr.p_vaddr, phdr.p_memsz, align) ==
(void *)-1) (void *)-1)
panic("cannot claim memory"); panic("cannot claim memory");
if (read(fd, (void *)(long)phdr.p_vaddr, phdr.p_filesz) != if (read(fd, (void *)(long)phdr.p_vaddr, phdr.p_filesz) !=