Take $MACHINE into account when looking for modules.

This commit is contained in:
ad 2008-05-20 16:04:08 +00:00
parent ef621e3353
commit e69aa3297c
4 changed files with 27 additions and 11 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: exec.c,v 1.26 2008/05/20 14:46:54 ad Exp $ */
/* $NetBSD: exec.c,v 1.27 2008/05/20 16:04:08 ad Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@ -146,6 +146,7 @@ exec_netbsd(const char *file, physaddr_t loadaddr, int boothowto)
u_long xmsmem;
physaddr_t origaddr = loadaddr;
#endif
char *machine;
#ifdef DEBUG
printf("exec: file=%s loadaddr=0x%lx\n",
@ -235,17 +236,28 @@ exec_netbsd(const char *file, physaddr_t loadaddr, int boothowto)
/* pull in any modules if necessary */
if (boot_modules_enabled) {
switch (netbsd_elf_class) {
case ELFCLASS32:
machine = "i386";
break;
case ELFCLASS64:
machine = "amd64";
break;
default:
machine = "generic";
break;
}
if (netbsd_version / 1000000 % 100 == 99) {
/* -current */
snprintf(module_base, sizeof(module_base),
"/stand/modules/%d.%d.%d",
"/stand/%s/%d.%d.%d/modules", machine,
netbsd_version / 100000000,
netbsd_version / 1000000 % 100,
netbsd_version / 100 % 100);
} else if (netbsd_version != 0) {
/* release */
snprintf(module_base, sizeof(module_base),
"/stand/modules/%d.%d",
"/stand/%s/%d.%d/modules", machine,
netbsd_version / 100000000,
netbsd_version / 1000000 % 100);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_module.c,v 1.16 2008/05/20 14:11:55 ad Exp $ */
/* $NetBSD: kern_module.c,v 1.17 2008/05/20 16:04:08 ad Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@ -37,7 +37,7 @@
#include "opt_modular.h"
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kern_module.c,v 1.16 2008/05/20 14:11:55 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: kern_module.c,v 1.17 2008/05/20 16:04:08 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -112,11 +112,11 @@ module_init(void)
#endif
#if __NetBSD_Version__ / 1000000 % 100 == 99 /* -current */
snprintf(module_base, sizeof(module_base), "/stand/modules/%s",
osrelease);
snprintf(module_base, sizeof(module_base), "/stand/%s/%s/modules",
machine, osrelease);
#else /* release */
snprintf(module_base, sizeof(module_base), "/stand/modules/%d.%d",
__NetBSD_Version__ / 100000000,
snprintf(module_base, sizeof(module_base), "/stand/%s/%d.%d/modules",
machine, __NetBSD_Version__ / 100000000,
__NetBSD_Version__ / 1000000 % 100);
#endif
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: loadfile.c,v 1.29 2008/05/20 14:41:06 ad Exp $ */
/* $NetBSD: loadfile.c,v 1.30 2008/05/20 16:04:08 ad Exp $ */
/*-
* Copyright (c) 1997, 2008 The NetBSD Foundation, Inc.
@ -83,6 +83,7 @@
#include "loadfile.h"
uint32_t netbsd_version;
u_int netbsd_elf_class;
/*
* Open 'filename', read in program and return the opened file
@ -157,12 +158,14 @@ fdloadfile(int fd, u_long *marks, int flags)
#ifdef BOOT_ELF32
if (memcmp(hdr.elf32.e_ident, ELFMAG, SELFMAG) == 0 &&
hdr.elf32.e_ident[EI_CLASS] == ELFCLASS32) {
netbsd_elf_class = ELFCLASS32;
rval = loadfile_elf32(fd, &hdr.elf32, marks, flags);
} else
#endif
#ifdef BOOT_ELF64
if (memcmp(hdr.elf64.e_ident, ELFMAG, SELFMAG) == 0 &&
hdr.elf64.e_ident[EI_CLASS] == ELFCLASS64) {
netbsd_elf_class = ELFCLASS64;
rval = loadfile_elf64(fd, &hdr.elf64, marks, flags);
} else
#endif

View File

@ -1,4 +1,4 @@
/* $NetBSD: loadfile.h,v 1.8 2008/05/20 14:41:06 ad Exp $ */
/* $NetBSD: loadfile.h,v 1.9 2008/05/20 16:04:08 ad Exp $ */
/*-
* Copyright (c) 1998, 2008 The NetBSD Foundation, Inc.
@ -88,3 +88,4 @@ int loadfile_aout(int, struct exec *, u_long *, int);
#endif
extern uint32_t netbsd_version;
extern u_int netbsd_elf_class;