summaryrefslogtreecommitdiff
path: root/sys/arch/sgi/stand/boot/arcbios.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/arch/sgi/stand/boot/arcbios.c')
-rw-r--r--sys/arch/sgi/stand/boot/arcbios.c168
1 files changed, 62 insertions, 106 deletions
diff --git a/sys/arch/sgi/stand/boot/arcbios.c b/sys/arch/sgi/stand/boot/arcbios.c
index ada86b01d14..f828bf109ef 100644
--- a/sys/arch/sgi/stand/boot/arcbios.c
+++ b/sys/arch/sgi/stand/boot/arcbios.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: arcbios.c,v 1.8 2009/05/09 18:08:59 miod Exp $ */
+/* $OpenBSD: arcbios.c,v 1.9 2009/05/14 18:57:43 miod Exp $ */
/*-
* Copyright (c) 1996 M. Warner Losh. All rights reserved.
* Copyright (c) 1996-2004 Opsycon AB. All rights reserved.
@@ -32,38 +32,11 @@
#include <mips64/archtype.h>
#include <stand.h>
-#define USE_SGI_PARTITIONS 1
+static int bios_is_32bit;
-int bios_is_32bit;
-
-void bios_configure_memory(void);
-int bios_get_system_type(void);
-const char *bios_get_path_component(const char *, char *, int *);
-
-static struct systypes {
- char *sys_vend; /* Vendor ID if name is ambiguous. */
- char *sys_name; /* May be left NULL if name is sufficient. */
- int sys_type;
-} sys_types[] = {
- { NULL, "PICA-61", ACER_PICA_61 },
- { NULL, "NEC-R94", ACER_PICA_61 },
- { NULL, "DESKTECH-TYNE", DESKSTATION_TYNE },
- { NULL, "DESKTECH-ARCStation I", DESKSTATION_RPC44 },
- { NULL, "Microsoft-Jazz", MAGNUM },
- { NULL, "RM200PCI", SNI_RM200 },
- { NULL, "SGI-IP17", SGI_CRIMSON },
- { NULL, "SGI-IP19", SGI_ONYX },
- { NULL, "SGI-IP20", SGI_INDIGO },
- { NULL, "SGI-IP21", SGI_POWER },
- { NULL, "SGI-IP22", SGI_INDY },
- { NULL, "SGI-IP25", SGI_POWER10 },
- { NULL, "SGI-IP26", SGI_POWERI },
- { NULL, "SGI-IP27", SGI_O200 },
- { NULL, "SGI-IP30", SGI_OCTANE },
- { NULL, "SGI-IP32", SGI_O2 }
-};
-
-#define KNOWNSYSTEMS (sizeof(sys_types) / sizeof(struct systypes))
+void arcbios_init(void);
+const char *boot_get_path_component(const char *, char *, int *);
+const char *boot_getnr(const char *, int *);
/*
* ARCBios trampoline code.
@@ -76,8 +49,16 @@ __asm__("\n" \
" .set noreorder\n" \
" .globl " #Name "\n" \
#Name":\n" \
-" lw $2, 0xffffffff80001020\n"\
-" lw $2," #Offset "($2)\n"\
+" lw $2, bios_is_32bit\n"\
+" beqz $2, 1f\n" \
+" nop\n" \
+" lw $2, 0xffffffff80001020\n"\
+" lw $2," #Offset "($2)\n"\
+" jr $2\n" \
+" nop\n" \
+"1:\n" \
+" ld $2, 0xffffffff80001040\n"\
+" ld $2, 2*" #Offset "($2)\n"\
" jr $2\n" \
" nop\n" \
" .end " #Name "\n" );
@@ -155,16 +136,11 @@ putchar(int c)
}
/*
- * Identify system type.
+ * Identify ARCBios type.
*/
-int
-bios_get_system_type()
+void
+arcbios_init()
{
- arc_config_t *cf;
- arc_sid_t *sid;
- char *sysid;
- int i, sysid_len;
-
/*
* Figure out if this is an ARCBios machine and if it is, see if we're
* dealing with a 32 or 64 bit version.
@@ -172,59 +148,10 @@ bios_get_system_type()
if ((ArcBiosBase32->magic == ARC_PARAM_BLK_MAGIC) ||
(ArcBiosBase32->magic == ARC_PARAM_BLK_MAGIC_BUG)) {
bios_is_32bit = 1;
- printf("ARCS32 Firmware Version %d.%d\n",
- ArcBiosBase32->version, ArcBiosBase32->revision);
} else if ((ArcBiosBase64->magic == ARC_PARAM_BLK_MAGIC) ||
(ArcBiosBase64->magic == ARC_PARAM_BLK_MAGIC_BUG)) {
bios_is_32bit = 0;
- printf("ARCS64 Firmware Version %d.%d\n",
- ArcBiosBase64->version, ArcBiosBase64->revision);
- } else
- return (-1); /* XXX BAD BAD BAD!!! */
-
- sid = (arc_sid_t *)Bios_GetSystemId();
-
- cf = (arc_config_t *)Bios_GetChild(NULL);
- if (cf != NULL) {
- if (bios_is_32bit) {
- sysid = (char *)(long)cf->id;
- sysid_len = cf->id_len;
- } else {
- sysid = (char *)((arc_config64_t *)cf)->id;
- sysid_len = ((arc_config64_t *)cf)->id_len;
- }
-
- if (sysid_len > 0 && sysid != NULL) {
- sysid_len--;
- for (i = 0; i < KNOWNSYSTEMS; i++) {
- if (strlen(sys_types[i].sys_name) !=sysid_len)
- continue;
- if (strncmp(sys_types[i].sys_name, sysid,
- sysid_len) != 0)
- continue;
- if (sys_types[i].sys_vend &&
- strncmp(sys_types[i].sys_vend, sid->vendor,
- 8) != 0)
- continue;
- return (sys_types[i].sys_type); /* Found it. */
- }
- }
- } else {
-#if defined(TGT_ORIGIN200) || defined(TGT_ORIGIN2000)
- if (IP27_KLD_KLCONFIG(0)->magic == IP27_KLDIR_MAGIC) {
- /* If we find a kldir assume IP27. */
- return (SGI_O200);
- }
-#endif
}
-
- printf("UNRECOGNIZED SYSTEM '%s' VENDOR '%8.8s' PRODUCT '%8.8s'\n",
- cf == NULL ? "??" : sysid, sid->vendor, sid->prodid);
- printf("See www.openbsd.org for further information.\n");
- printf("Halting system!\n");
- Bios_Halt();
- printf("Halting failed, use manual reset!\n");
- while (1);
}
/*
@@ -246,23 +173,43 @@ devopen(struct open_file *f, const char *fname, char **file)
/*
* Scan the component list and find device and partition.
*/
- while ((ncp = bios_get_path_component(cp, namebuf, &i)) != NULL) {
- if (strcmp(namebuf, "partition") == 0) {
- partition = i;
- if (USE_SGI_PARTITIONS)
- ecp = ncp;
- } else
+ if (strncmp(cp, "dksc(", 5) == 0) {
+ strncpy(devname, "scsi", sizeof(devname));
+ cp += 5;
+ cp = boot_getnr(cp, &i);
+ /* i = controller number */
+ if (*cp++ == ',') {
+ cp = boot_getnr(cp, &i);
+ /* i = target id */
+ if (*cp++ == ',') {
+
+ memcpy(namebuf, fname, cp - fname);
+ namebuf[cp - fname] = '\0';
+ strlcat(namebuf, "0)", sizeof namebuf);
+
+ cp = boot_getnr(cp, &i);
+ partition = i;
+ cp++; /* skip final ) */
+ }
+ }
+ } else {
+ ncp = boot_get_path_component(cp, namebuf, &i);
+ while (ncp != NULL) {
+ if (strcmp(namebuf, "partition") == 0)
+ partition = i;
ecp = ncp;
- /* XXX Do this with a table if more devs are added. */
- if (strcmp(namebuf, "scsi") == 0)
- strncpy(devname, namebuf, sizeof(devname));
+ /* XXX Do this with a table if more devs are added. */
+ if (strcmp(namebuf, "scsi") == 0)
+ strncpy(devname, namebuf, sizeof(devname));
- cp = ncp;
- }
+ cp = ncp;
+ ncp = boot_get_path_component(cp, namebuf, &i);
+ }
- memcpy(namebuf, fname, ecp - fname);
- namebuf[ecp - fname] = '\0';
+ memcpy(namebuf, fname, ecp - fname);
+ namebuf[ecp - fname] = '\0';
+ }
/*
* Dig out the driver.
@@ -270,7 +217,7 @@ devopen(struct open_file *f, const char *fname, char **file)
dp = devsw;
n = ndevs;
while(n--) {
- if (strcmp (devname, dp->dv_name) == 0) {
+ if (strcmp(devname, dp->dv_name) == 0) {
rc = (dp->dv_open)(f, namebuf, partition, 0);
if (!rc) {
f->f_dev = dp;
@@ -285,7 +232,7 @@ devopen(struct open_file *f, const char *fname, char **file)
}
const char *
-bios_get_path_component(const char *p, char *comp, int *no)
+boot_get_path_component(const char *p, char *comp, int *no)
{
while (*p && *p != '(')
*comp++ = *p++;
@@ -304,3 +251,12 @@ bios_get_path_component(const char *p, char *comp, int *no)
}
return (++p);
}
+
+const char *
+boot_getnr(const char *p, int *no)
+{
+ *no = 0;
+ while (*p >= '0' && *p <= '9')
+ *no = *no * 10 + *p++ - '0';
+ return p;
+}