Clean up extracting environment variables passed by the prom. No functional
change.
This commit is contained in:
parent
ef061fd462
commit
dd214a45b1
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: arcemu.c,v 1.13 2007/02/21 04:27:10 rumble Exp $ */
|
||||
/* $NetBSD: arcemu.c,v 1.14 2007/05/10 17:27:05 rumble Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2004 Steve Rumble
|
||||
@ -29,7 +29,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: arcemu.c,v 1.13 2007/02/21 04:27:10 rumble Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: arcemu.c,v 1.14 2007/05/10 17:27:05 rumble Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -107,7 +107,7 @@ static struct arcbios_fv arcemu_v = {
|
||||
* Establish our emulated ARCBIOS vector or return ARCBIOS failure.
|
||||
*/
|
||||
int
|
||||
arcemu_init(char **env)
|
||||
arcemu_init(const char **env)
|
||||
{
|
||||
switch (arcemu_identify()) {
|
||||
case MACH_SGI_IP12:
|
||||
@ -135,6 +135,25 @@ arcemu_identify()
|
||||
return (MACH_SGI_IP12); /* boy, that was easy! */
|
||||
}
|
||||
|
||||
static boolean_t
|
||||
extractenv(const char **env, const char *key, char *dest, int len)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (env == NULL)
|
||||
return (false);
|
||||
|
||||
for (i = 0; env[i] != NULL; i++) {
|
||||
if (strncasecmp(env[i], key, strlen(key)) == 0 &&
|
||||
env[i][strlen(key)] == '=') {
|
||||
strlcpy(dest, strchr(env[i], '=') + 1, len);
|
||||
return (true);
|
||||
}
|
||||
}
|
||||
|
||||
return (false);
|
||||
}
|
||||
|
||||
/*
|
||||
* IP12 specific
|
||||
*/
|
||||
@ -246,9 +265,8 @@ arcemu_ip12_eeprom_read()
|
||||
}
|
||||
|
||||
static void
|
||||
arcemu_ip12_init(char **env)
|
||||
arcemu_ip12_init(const char **env)
|
||||
{
|
||||
int i;
|
||||
|
||||
arcemu_v.GetPeer = arcemu_ip12_GetPeer;
|
||||
arcemu_v.GetChild = arcemu_ip12_GetChild;
|
||||
@ -262,38 +280,16 @@ arcemu_ip12_init(char **env)
|
||||
arcemu_ip12_eeprom_read();
|
||||
|
||||
memset(&ip12env, 0, sizeof(ip12env));
|
||||
for (i = 0; env[i] != NULL; i++) {
|
||||
if (strncasecmp(env[i], "dbaud=", 6) == 0)
|
||||
strlcpy(ip12env.dbaud, strchr(env[i], '=') + 1,
|
||||
sizeof(ip12env.dbaud));
|
||||
else if (strncasecmp(env[i], "rbaud=", 6) == 0)
|
||||
strlcpy(ip12env.rbaud, strchr(env[i], '=') + 1,
|
||||
sizeof(ip12env.rbaud));
|
||||
else if (strncasecmp(env[i], "bootmode=", 9) == 0)
|
||||
strlcpy(&ip12env.bootmode, strchr(env[i], '=') + 1,
|
||||
sizeof(ip12env.bootmode));
|
||||
else if (strncasecmp(env[i], "console=", 8) == 0)
|
||||
strlcpy(&ip12env.console, strchr(env[i], '=') + 1,
|
||||
sizeof(ip12env.console));
|
||||
else if (strncasecmp(env[i], "diskless=", 9) == 0)
|
||||
strlcpy(&ip12env.diskless, strchr(env[i], '=') + 1,
|
||||
sizeof(ip12env.diskless));
|
||||
else if (strncasecmp(env[i], "volume=", 7) == 0)
|
||||
strlcpy(ip12env.volume, strchr(env[i], '=') + 1,
|
||||
sizeof(ip12env.volume));
|
||||
else if (strncasecmp(env[i], "cpufreq=", 8) == 0)
|
||||
strlcpy(ip12env.cpufreq, strchr(env[i], '=') + 1,
|
||||
sizeof(ip12env.cpufreq));
|
||||
else if (strncasecmp(env[i], "gfx=", 4) == 0)
|
||||
strlcpy(ip12env.gfx, strchr(env[i], '=') + 1,
|
||||
sizeof(ip12env.gfx));
|
||||
else if (strncasecmp(env[i], "netaddr=", 8) == 0)
|
||||
strlcpy(ip12env.netaddr, strchr(env[i], '=') + 1,
|
||||
sizeof(ip12env.netaddr));
|
||||
else if (strncasecmp(env[i], "dlserver=", 9) == 0)
|
||||
strlcpy(ip12env.dlserver, strchr(env[i], '=') + 1,
|
||||
sizeof(ip12env.dlserver));
|
||||
}
|
||||
extractenv(env, "dbaud", ip12env.dbaud, sizeof(ip12env.dbaud));
|
||||
extractenv(env, "rbaud", ip12env.rbaud, sizeof(ip12env.rbaud));
|
||||
extractenv(env, "bootmode",&ip12env.bootmode, sizeof(ip12env.bootmode));
|
||||
extractenv(env, "console", &ip12env.console, sizeof(ip12env.console));
|
||||
extractenv(env, "diskless",&ip12env.diskless, sizeof(ip12env.diskless));
|
||||
extractenv(env, "volume", ip12env.volume, sizeof(ip12env.volume));
|
||||
extractenv(env, "cpufreq", ip12env.cpufreq, sizeof(ip12env.cpufreq));
|
||||
extractenv(env, "gfx", ip12env.gfx, sizeof(ip12env.gfx));
|
||||
extractenv(env, "netaddr", ip12env.netaddr, sizeof(ip12env.netaddr));
|
||||
extractenv(env, "dlserver", ip12env.dlserver, sizeof(ip12env.dlserver));
|
||||
|
||||
strcpy(arcbios_system_identifier, "SGI-IP12");
|
||||
strcpy(arcbios_sysid_vendor, "SGI");
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: arcemu.h,v 1.7 2007/02/21 04:27:10 rumble Exp $ */
|
||||
/* $NetBSD: arcemu.h,v 1.8 2007/05/10 17:27:06 rumble Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2004 Steve Rumble
|
||||
@ -35,19 +35,22 @@
|
||||
#include <dev/arcbios/arcbios.h>
|
||||
#include <dev/arcbios/arcbiosvar.h>
|
||||
|
||||
int arcemu_init(char **env);
|
||||
int arcemu_init(const char **env);
|
||||
|
||||
#ifdef _ARCEMU_PRIVATE
|
||||
|
||||
/* Platform identification */
|
||||
static int arcemu_identify(void);
|
||||
|
||||
/* Helper functions */
|
||||
static boolean_t extractenv(const char **, const char *, char *, int);
|
||||
|
||||
/*
|
||||
* IP12 Emulation
|
||||
*/
|
||||
|
||||
/* Prom Emulators */
|
||||
static void arcemu_ip12_init(char **);
|
||||
static void arcemu_ip12_init(const char **);
|
||||
static void * arcemu_ip12_GetPeer(void *);
|
||||
static void * arcemu_ip12_GetChild(void *);
|
||||
static const char * arcemu_ip12_GetEnvironmentVariable(const char *);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: machdep.c,v 1.110 2007/03/06 12:41:52 tsutsui Exp $ */
|
||||
/* $NetBSD: machdep.c,v 1.111 2007/05/10 17:27:06 rumble Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2000 Soren S. Jorvang
|
||||
@ -34,7 +34,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.110 2007/03/06 12:41:52 tsutsui Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.111 2007/05/10 17:27:06 rumble Exp $");
|
||||
|
||||
#include "opt_ddb.h"
|
||||
#include "opt_kgdb.h"
|
||||
@ -271,9 +271,16 @@ mach_init(int argc, char **argv, int magic, struct btinfo_common *btinfo)
|
||||
* try to init real arcbios, and if that fails (return value 1),
|
||||
* fall back to the emulator. If the latter fails also we
|
||||
* don't have much to panic with.
|
||||
*
|
||||
* The third argument (magic) is the environment variable array if
|
||||
* there's no bootinfo.
|
||||
*/
|
||||
if (arcbios_init(ARCS_VECTOR) == 1)
|
||||
arcemu_init((char **)magic);
|
||||
if (arcbios_init(ARCS_VECTOR) == 1) {
|
||||
if (magic == BOOTINFO_MAGIC)
|
||||
arcemu_init(NULL); /* XXX - need some prom env */
|
||||
else
|
||||
arcemu_init((const char **)magic);
|
||||
}
|
||||
|
||||
strcpy(cpu_model, arcbios_system_identifier);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user