summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorKenji Aoyama <aoyama@cvs.openbsd.org>2004-06-14 12:57:03 +0000
committerKenji Aoyama <aoyama@cvs.openbsd.org>2004-06-14 12:57:03 +0000
commit7831bdb3bfb46302af273312a88b3cef2a2d64ca (patch)
tree1bbb9dc39205091c0e2d1c4d062af0cf47cda2ce /sys
parentd62c0213b317180a9ec0b3a65791610101ff3b90 (diff)
Added some codes that check if the machine is LUNA-88K or LUNA-88K2
and retrieve the boot device information from NVRAM. Only works on LUNA-88K2 at this moment.
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/luna88k/include/board.h3
-rw-r--r--sys/arch/luna88k/luna88k/disksubr.c75
-rw-r--r--sys/arch/luna88k/luna88k/machdep.c106
-rw-r--r--sys/arch/luna88k/luna88k/pmap_table.c3
4 files changed, 173 insertions, 14 deletions
diff --git a/sys/arch/luna88k/include/board.h b/sys/arch/luna88k/include/board.h
index e98bb54a6bc..0fd24e18ba1 100644
--- a/sys/arch/luna88k/include/board.h
+++ b/sys/arch/luna88k/include/board.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: board.h,v 1.2 2004/04/29 14:35:22 miod Exp $ */
+/* $OpenBSD: board.h,v 1.3 2004/06/14 12:57:02 aoyama Exp $ */
/*
* Mach Operating System
* Copyright (c) 1993-1991 Carnegie Mellon University
@@ -86,6 +86,7 @@
#define OBIO_CAL_DAY U(0x45001FF4) /* days */
#define OBIO_CAL_MON U(0x45001FF8) /* months */
#define OBIO_CAL_YEAR U(0x45001FFC) /* years */
+#define NVRAM_ADDR_88K2 U(0x47000000) /* Non Volatile RAM area for LUNA-88K2 */
#define OBIO_PIO0_BASE U(0x49000000) /* PIO-0 */
#define OBIO_PIO0_SPACE U(0x0000000C)
#define OBIO_PIO0A U(0x49000000) /* PIO-0 port A */
diff --git a/sys/arch/luna88k/luna88k/disksubr.c b/sys/arch/luna88k/luna88k/disksubr.c
index 7e13d9f0fba..3aec25a9e3e 100644
--- a/sys/arch/luna88k/luna88k/disksubr.c
+++ b/sys/arch/luna88k/luna88k/disksubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disksubr.c,v 1.1 2004/04/21 15:23:59 aoyama Exp $ */
+/* $OpenBSD: disksubr.c,v 1.2 2004/06/14 12:57:02 aoyama Exp $ */
/* $NetBSD: disksubr.c,v 1.12 2002/02/19 17:09:44 wiz Exp $ */
/*
@@ -52,6 +52,11 @@
#include <sys/disk.h>
#include <sys/dkbad.h>
+#include <scsi/scsi_all.h>
+#include <scsi/scsiconf.h>
+
+#include <machine/autoconf.h>
+
#include <dev/sun/disklabel.h>
/*
@@ -99,6 +104,7 @@
char *disklabel_om_to_bsd(char *, struct disklabel *);
int disklabel_bsd_to_om(struct disklabel *, char *);
+void get_autoboot_device(void);
/*
* Attempt to read a disk label from a device
@@ -319,36 +325,85 @@ bad:
return (-1);
}
+/*
+ * Get 'auto-boot' information from NVRAM
+ */
+struct autoboot_t
+{
+ char cont[16];
+ int targ;
+ int part;
+} autoboot;
+
+char *nvram_by_symbol(char *); /* in machdep.c */
+
+void
+get_autoboot_device(void)
+{
+ char *value, c;
+ int i, len, part;
+
+ /* Assume default controler is internal spc (spc0) */
+ strlcpy(autoboot.cont, "spc0", sizeof(autoboot.cont));
+
+ /* Get boot controler and SCSI target from NVRAM */
+ value = nvram_by_symbol("boot_unit");
+ if (value != NULL) {
+ len = strlen(value);
+ if (len == 1) {
+ c = value[0];
+ } else if (len == 2) {
+ if (value[0] == '1') {
+ /* External spc (spc1) */
+ strlcpy(autoboot.cont, "spc1", sizeof(autoboot.cont));
+ c = value[1];
+ }
+ }
+
+ if ((c >= '0') && (c <= '6'))
+ autoboot.targ = 6 - (c - '0');
+ }
+
+ /* Get partition number from NVRAM */
+ value = nvram_by_symbol("boot_partition");
+ if (value != NULL) {
+ len = strlen(value);
+ part = 0;
+ for (i = 0; i < len; i++)
+ part = part * 10 + (value[i] - '0');
+ autoboot.part = part;
+ }
+}
+
void
dk_establish(dk, dev)
struct disk *dk;
struct device *dev;
{
-#if 0 /* taken from OpenBSD/mvme88k */
struct scsibus_softc *sbsc;
+ struct device *spcsc;
int target, lun;
- if (bootpart == -1) /* ignore flag from controller driver? */
- return;
-
/*
- * scsi: sd,cd
+ * scsi: sd,cd XXX: Can LUNA88K boot from CD-ROM?
*/
if (strncmp("sd", dev->dv_xname, 2) == 0 ||
strncmp("cd", dev->dv_xname, 2) == 0) {
sbsc = (struct scsibus_softc *)dev->dv_parent;
- target = get_target(); /* Work the Motorola Magic */
+ spcsc = dev->dv_parent->dv_parent;
+ target = autoboot.targ;
lun = 0;
-
- if (sbsc->sc_link[target][lun] != NULL &&
+
+ if (strncmp(autoboot.cont, spcsc->dv_xname, 4) == 0 &&
+ sbsc->sc_link[target][lun] != NULL &&
sbsc->sc_link[target][lun]->device_softc == (void *)dev) {
bootdv = dev;
+ bootpart = autoboot.part;
return;
}
}
-#endif
}
/************************************************************************
diff --git a/sys/arch/luna88k/luna88k/machdep.c b/sys/arch/luna88k/luna88k/machdep.c
index de60f0c84ab..cd1871a6d97 100644
--- a/sys/arch/luna88k/luna88k/machdep.c
+++ b/sys/arch/luna88k/luna88k/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.5 2004/06/02 13:49:43 miod Exp $ */
+/* $OpenBSD: machdep.c,v 1.6 2004/06/14 12:57:02 aoyama Exp $ */
/*
* Copyright (c) 1998, 1999, 2000, 2001 Steve Murphree, Jr.
* Copyright (c) 1996 Nivas Madhur
@@ -118,6 +118,10 @@ void load_u_area(struct proc *);
void dumpconf(void);
void luna88k_ext_int(u_int v, struct trapframe *eframe);
void powerdown(void);
+void get_fuse_rom_data(void);
+void get_nvram_data(void);
+char *nvram_by_symbol(char *);
+void get_autoboot_device(void); /* in disksubr.c */
/*
* *int_mask_reg[CPU]
@@ -140,6 +144,24 @@ unsigned int *volatile clock_reg[MAX_CPUS] = {
(unsigned int *)OBIO_CLOCK3
};
+/*
+ * FUSE ROM and NVRAM data
+ */
+struct fuse_rom_byte {
+ u_int32_t h;
+ u_int32_t l;
+};
+#define FUSE_ROM_BYTES (FUSE_ROM_SPACE / sizeof(struct fuse_rom_byte))
+static char fuse_rom_data[FUSE_ROM_BYTES];
+
+#define NNVSYM 8
+#define NVSYMLEN 16
+#define NVVALLEN 16
+struct nvram_t {
+ char symbol[NVSYMLEN];
+ char value[NVVALLEN];
+} nvram[NNVSYM];
+
volatile vaddr_t obiova;
int ssir;
@@ -201,7 +223,7 @@ char cpu_model[120];
extern char *esym;
#endif
-int machtype = LUNA_88K2; /* XXX: aoyama */
+int machtype = LUNA_88K; /* may be overwritten in cpu_startup() */
int cputyp = CPU_88100; /* XXX: aoyama */
int boothowto; /* XXX: should be set in boot loader and locore.S */
int bootdev; /* XXX: should be set in boot loader and locore.S */
@@ -408,6 +430,16 @@ cpu_startup()
pmap_update(pmap_kernel());
initmsgbuf((caddr_t)msgbufp, round_page(MSGBUFSIZE));
+ /* Determine the machine type from FUSE ROM data */
+ get_fuse_rom_data();
+ if (strncmp(fuse_rom_data, "MNAME=LUNA88K+", 14) == 0) {
+ machtype = LUNA_88K2;
+ }
+
+ /* Determine the 'auto-boot' device from NVRAM data */
+ get_nvram_data();
+ get_autoboot_device();
+
/*
* Good {morning,afternoon,evening,night}.
*/
@@ -1816,3 +1848,73 @@ powerdown(void)
p1->cntrl = (PIO1_POWER << 1) | PIO1_DISABLE;
*(volatile u_int8_t *)&p1->portC;
}
+
+/* Get data from FUSE ROM */
+
+void
+get_fuse_rom_data(void)
+{
+ int i;
+ struct fuse_rom_byte *p = (struct fuse_rom_byte *)FUSE_ROM_ADDR;
+
+ for (i = 0; i < FUSE_ROM_BYTES; i++) {
+ fuse_rom_data[i] =
+ (char)((((p->h) >> 24) & 0x000000f0) |
+ (((p->l) >> 28) & 0x0000000f));
+ p++;
+ }
+}
+
+/* Get data from NVRAM */
+
+void
+get_nvram_data(void)
+{
+ int i;
+ u_int8_t *page;
+ char *data;
+
+ if (machtype == LUNA_88K) {
+#if 0
+ /* this is not tested... */
+ int i;
+ struct nvram_byte *p = (struct nvram_byte *)NVRAM_ADDR;
+
+ for (i = 0; i < NVRAM_BYTES; i++) {
+ nvram_data[i] = p->data;
+ p++;
+ }
+#endif
+ } else if (machtype == LUNA_88K2) {
+ page = (u_int8_t *)(NVRAM_ADDR_88K2 + 0x20);
+
+ for (i = 0; i < NNVSYM; i++) {
+ *page = (u_int8_t)i;
+
+ data = (char *)NVRAM_ADDR_88K2;
+ strlcpy(nvram[i].symbol, data, sizeof(nvram[i].symbol));
+
+ data = (char *)(NVRAM_ADDR_88K2 + 0x10);
+ strlcpy(nvram[i].value, data, sizeof(nvram[i].value));
+ }
+ }
+}
+
+char *
+nvram_by_symbol(symbol)
+ char *symbol;
+{
+ char *value;
+ int i;
+
+ value = NULL;
+
+ for (i = 0; i < NNVSYM; i++) {
+ if (strncmp(nvram[i].symbol, symbol, NVSYMLEN) == 0) {
+ value = nvram[i].value;
+ break;
+ }
+ }
+
+ return value;
+}
diff --git a/sys/arch/luna88k/luna88k/pmap_table.c b/sys/arch/luna88k/luna88k/pmap_table.c
index 2979b902a72..22792e2fc99 100644
--- a/sys/arch/luna88k/luna88k/pmap_table.c
+++ b/sys/arch/luna88k/luna88k/pmap_table.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pmap_table.c,v 1.2 2004/06/02 13:49:43 miod Exp $ */
+/* $OpenBSD: pmap_table.c,v 1.3 2004/06/14 12:57:02 aoyama Exp $ */
/*
* Mach Operating System
@@ -46,6 +46,7 @@ luna88k_board_table[] = {
{ PROM_ADDR , PROM_ADDR , PROM_SPACE , R, CI },
{ FUSE_ROM_ADDR, FUSE_ROM_ADDR, FUSE_ROM_SPACE, RW, CI },
{ NVRAM_ADDR , NVRAM_ADDR , NVRAM_SPACE , RW, CI },
+ { NVRAM_ADDR_88K2, NVRAM_ADDR_88K2, PAGE_SIZE, RW, CI },
{ OBIO_PIO0_BASE, OBIO_PIO0_BASE, PAGE_SIZE, RW, CI },
{ OBIO_PIO1_BASE, OBIO_PIO1_BASE, PAGE_SIZE, RW, CI },
{ OBIO_SIO , OBIO_SIO, PAGE_SIZE, RW, CI },