summaryrefslogtreecommitdiff
path: root/sys/arch/sgi/stand
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2009-05-14 18:57:44 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2009-05-14 18:57:44 +0000
commitb24bc96a46b94d88c0d988562ee681b83827df5c (patch)
treee7c78288659e6e3c5e5d3c85282e4e7f7ea16c97 /sys/arch/sgi/stand
parent410d6152bc3883e0e4df720eb78f599ce6531fce (diff)
In addition to the existing IP32 boot block, build a real 64 bit boot block
as a relocatable object, suitable for IP27/IP30/IP35. Boot blocks are now found is /usr/mdec/boot{32,64}, with boot-IP## being hard links to them for easy boot block pick.
Diffstat (limited to 'sys/arch/sgi/stand')
-rw-r--r--sys/arch/sgi/stand/Makefile5
-rw-r--r--sys/arch/sgi/stand/Makefile.inc17
-rw-r--r--sys/arch/sgi/stand/Makefile32.inc25
-rw-r--r--sys/arch/sgi/stand/boot/Makefile20
-rw-r--r--sys/arch/sgi/stand/boot/arcbios.c168
-rw-r--r--sys/arch/sgi/stand/boot/boot.c28
-rw-r--r--sys/arch/sgi/stand/boot/conf.c4
-rw-r--r--sys/arch/sgi/stand/boot/start.S6
-rw-r--r--sys/arch/sgi/stand/boot32/Makefile18
-rw-r--r--sys/arch/sgi/stand/boot32/ld.script (renamed from sys/arch/sgi/stand/boot/ld.script)4
-rw-r--r--sys/arch/sgi/stand/boot64/Makefile19
-rw-r--r--sys/arch/sgi/stand/libsa/Makefile6
-rw-r--r--sys/arch/sgi/stand/libsa/heap.h35
-rw-r--r--sys/arch/sgi/stand/libsa32/Makefile4
-rw-r--r--sys/arch/sgi/stand/libz/Makefile5
-rw-r--r--sys/arch/sgi/stand/libz32/Makefile4
16 files changed, 216 insertions, 152 deletions
diff --git a/sys/arch/sgi/stand/Makefile b/sys/arch/sgi/stand/Makefile
index b002fcec130..86aed86675b 100644
--- a/sys/arch/sgi/stand/Makefile
+++ b/sys/arch/sgi/stand/Makefile
@@ -1,9 +1,10 @@
-# $OpenBSD: Makefile,v 1.5 2007/11/26 09:40:35 jsing Exp $
+# $OpenBSD: Makefile,v 1.6 2009/05/14 18:57:41 miod Exp $
SUBDIR= sgivol
.if ${MACHINE} == "sgi"
-SUBDIR+= libsa libz boot
+SUBDIR+= libsa libsa32 libz libz32
+SUBDIR+= boot64 boot32
.endif
.include <bsd.subdir.mk>
diff --git a/sys/arch/sgi/stand/Makefile.inc b/sys/arch/sgi/stand/Makefile.inc
index f19cdc6ef4d..d3176f089ed 100644
--- a/sys/arch/sgi/stand/Makefile.inc
+++ b/sys/arch/sgi/stand/Makefile.inc
@@ -1,11 +1,9 @@
-# $OpenBSD: Makefile.inc,v 1.4 2007/11/26 10:01:42 deraadt Exp $
+# $OpenBSD: Makefile.inc,v 1.5 2009/05/14 18:57:41 miod Exp $
# $NetBSD: Makefile.inc,v 1.7 2000/08/20 14:57:16 mrg Exp $
.ifndef __INCLUDED_STAND_MAKEFILE_INC
__INCLUDED_STAND_MAKEFILE_INC=
-#CEXTRAFLAGS?=-D_LP64
-
BINDIR= /usr/mdec
STANDALONE?= -D_STANDALONE
@@ -14,15 +12,16 @@ STANDALONE?= -D_STANDALONE
CPPFLAGS+= ${STANDALONE}
CPPFLAGS+= -I.
-CFLAGS+= -fno-stack-protector
+CFLAGS+= -fno-stack-protector -Wall
CFLAGS+= -fno-builtin-vprintf -fno-builtin-printf -fno-builtin-putchar
-SAABI= -mabi=32 -mips2 -Wl,-m=elf32btsmip
-AS= as -32
-LD= ld -m elf32btsmip
+SAABI?= -mips3 -mno-abicalls -G 0 -fno-pic -fno-common
+AS?= as
+LD?= ld
+LIBSA_CPPFLAGS?= -DNEEDS_HEAP_H
.endif
### Figure out what to use for libsa
-LIBSADIR= ${.CURDIR}/../libsa
+LIBSADIR?= ${.CURDIR}/../libsa
.if exists(${LIBSADIR}/obj.${MACHINE})
LIBSAOBJDIR= ${LIBSADIR}/obj.${MACHINE}
@@ -35,7 +34,7 @@ LIBSAOBJDIR= ${LIBSADIR}
LIBSA= ${LIBSAOBJDIR}/libsa.a
### Figure out what to use for libz
-LIBZDIR= ${.CURDIR}/../libz
+LIBZDIR?= ${.CURDIR}/../libz
.if exists(${LIBZDIR}/obj.${MACHINE})
LIBZOBJDIR= ${LIBZDIR}/obj.${MACHINE}
diff --git a/sys/arch/sgi/stand/Makefile32.inc b/sys/arch/sgi/stand/Makefile32.inc
new file mode 100644
index 00000000000..0be56f0d220
--- /dev/null
+++ b/sys/arch/sgi/stand/Makefile32.inc
@@ -0,0 +1,25 @@
+# $OpenBSD: Makefile32.inc,v 1.1 2009/05/14 18:57:41 miod Exp $
+
+.ifndef __INCLUDED_STAND_MAKEFILE32_INC
+__INCLUDED_STAND_MAKEFILE32_INC=
+
+.if ${MACHINE} == "sgi"
+# Silence warnings
+CFLAGS+= -fno-builtin-snprintf
+CFLAGS+= -fno-builtin-memcpy
+CFLAGS+= -fno-builtin-memcmp
+CFLAGS+= -fno-builtin-memset
+CFLAGS+= -fno-builtin-strncpy
+CFLAGS+= -fno-builtin-strncmp
+# Override toolchain options to force 32 bit binaries
+SAABI= -mabi=32 -mips2 -Wa,-G0
+AS= as -32
+LD= ld -m elf32btsmip
+LIBSA_CPPFLAGS=
+.endif
+
+### Figure out what to use for libsa and libz
+LIBSADIR= ${.CURDIR}/../libsa32
+LIBZDIR= ${.CURDIR}/../libz32
+
+.endif
diff --git a/sys/arch/sgi/stand/boot/Makefile b/sys/arch/sgi/stand/boot/Makefile
index e7b281e12c1..2774eb6009c 100644
--- a/sys/arch/sgi/stand/boot/Makefile
+++ b/sys/arch/sgi/stand/boot/Makefile
@@ -1,9 +1,8 @@
-# $OpenBSD: Makefile,v 1.10 2008/05/20 18:12:19 jsing Exp $
+# $OpenBSD: Makefile,v 1.11 2009/05/14 18:57:43 miod Exp $
-PROG= boot
NOMAN= noman
-CFLAGS+= -O2 ${SAABI} -mno-abicalls -D_NO_ABICALLS -nostdinc -D__sgi__ \
+CFLAGS+= ${SAABI} -mno-abicalls -D_NO_ABICALLS -nostdinc -D__sgi__ \
-I${.CURDIR}/../include -I${.CURDIR}/../../../.. \
-I${.CURDIR}/../../../../lib/libsa \
-I${.OBJDIR}
@@ -11,8 +10,6 @@ CFLAGS+= -D__INTERNAL_LIBSA_CREAD ${STANDALONE}
AFLAGS+= ${SAABI}
-LDFLAGS+= ${SALDFLAGS} -T ${.CURDIR}/ld.script -e __start
-
S= ${.CURDIR}/../../../..
SRCS= start.S boot.c filesystem.c conf.c diskio.c arcbios.c strstr.c
@@ -20,8 +17,8 @@ SRCS= start.S boot.c filesystem.c conf.c diskio.c arcbios.c strstr.c
SRCS+= loadfile.c
.PATH: ${S}/lib/libkern/arch/mips64 ${S}/lib/libkern
-SRCS+= strlcpy.c memcpy.c strlen.c strrchr.c strlcat.c ashrdi3.c strncmp.c \
- strcmp.S udivdi3.c umoddi3.c qdivrem.c
+SRCS+= strlcpy.c memcpy.c strlen.c strrchr.c strlcat.c strncmp.c \
+ strcmp.S
CLEANFILES+= machine mips64
@@ -30,12 +27,3 @@ CLEANFILES+= machine mips64
@([ -h machine ] || ln -s ${.CURDIR}/../../include machine)
@([ -h mips64 ] || ln -s ${.CURDIR}/../../../mips64/include mips64)
.endif
-
-${PROG}: $(OBJS) $(LDADD)
- $(LD) $(LDFLAGS) -o boot $(OBJS) -L${LIBSADIR} ${LIBSA} \
- -L${LIBZDIR} ${LIBZ}
-
-install:
- install -c -m 555 -g bin -o bin ${PROG} ${DESTDIR}/usr/mdec
-
-.include <bsd.prog.mk>
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;
+}
diff --git a/sys/arch/sgi/stand/boot/boot.c b/sys/arch/sgi/stand/boot/boot.c
index 7cab9da553b..f966ec4c0e3 100644
--- a/sys/arch/sgi/stand/boot/boot.c
+++ b/sys/arch/sgi/stand/boot/boot.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: boot.c,v 1.11 2008/05/20 18:12:19 jsing Exp $ */
+/* $OpenBSD: boot.c,v 1.12 2009/05/14 18:57:43 miod Exp $ */
/*
* Copyright (c) 2004 Opsycon AB, www.opsycon.se.
@@ -28,8 +28,6 @@
#include <sys/param.h>
#include <sys/stat.h>
-#include <sys/exec.h>
-#include <sys/exec_elf.h>
#include <stand.h>
#include <mips64/arcbios.h>
@@ -62,6 +60,9 @@ main(int argc, char *argv[])
char line[1024];
u_long entry;
int fd, i;
+ extern void arcbios_init(void);
+
+ arcbios_init();
dobootopts(argc, argv);
if (OSLoadPartition != NULL) {
@@ -101,7 +102,12 @@ main(int argc, char *argv[])
}
/* We failed to load the kernel. */
- printf("Boot FAILED!\n");
+ panic("Boot FAILED!");
+}
+
+__dead void
+_rtt()
+{
Bios_EnterInteractiveMode();
}
@@ -145,12 +151,20 @@ dobootopts(int argc, char **argv)
char *p;
strlcpy(loadpart, argv[0], sizeof loadpart);
- p = strstr(loadpart, "partition(8)");
- if (p) {
+ if ((p = strstr(loadpart, "partition(8)")) != NULL) {
p += strlen("partition(");
- p[0] = '0'; p[2] = 0;
+ p[0] = '0';
+ p[2] = '\0';
OSLoadPartition = loadpart;
OSLoadFilename = "/bsd.rd";
+ } else if (strncmp(loadpart, "dksc(", 5) == 0) {
+ p = strstr(loadpart, ",8)");
+ if (p != NULL) {
+ p[1] = '0';
+ p[3] = '\0';
+ OSLoadPartition = loadpart;
+ OSLoadFilename = "/bsd.rd";
+ }
}
}
}
diff --git a/sys/arch/sgi/stand/boot/conf.c b/sys/arch/sgi/stand/boot/conf.c
index 683f526e293..2964476870f 100644
--- a/sys/arch/sgi/stand/boot/conf.c
+++ b/sys/arch/sgi/stand/boot/conf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: conf.c,v 1.2 2008/03/08 16:52:28 jsing Exp $ */
+/* $OpenBSD: conf.c,v 1.3 2009/05/14 18:57:43 miod Exp $ */
/*
* Copyright (c) 1997 Per Fogelstrom
@@ -27,8 +27,6 @@
*/
#include <stand.h>
-int errno;
-
extern void nullsys();
extern int nodev();
extern int noioctl();
diff --git a/sys/arch/sgi/stand/boot/start.S b/sys/arch/sgi/stand/boot/start.S
index e2866f521b8..01498b7edca 100644
--- a/sys/arch/sgi/stand/boot/start.S
+++ b/sys/arch/sgi/stand/boot/start.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: start.S,v 1.2 2008/03/08 16:52:28 jsing Exp $ */
+/* $OpenBSD: start.S,v 1.3 2009/05/14 18:57:43 miod Exp $ */
/*
* Copyright (c) 2001 Opsycon AB (www.opsycon.se)
@@ -44,7 +44,9 @@
.globl __start
__start:
- la gp, _gp
+#ifndef __LP64__ /* LP64 code is compiled without gp support */
+ LA gp, _gp
+#endif
jal main
diff --git a/sys/arch/sgi/stand/boot32/Makefile b/sys/arch/sgi/stand/boot32/Makefile
new file mode 100644
index 00000000000..253fa906dc1
--- /dev/null
+++ b/sys/arch/sgi/stand/boot32/Makefile
@@ -0,0 +1,18 @@
+# $OpenBSD: Makefile,v 1.1 2009/05/14 18:57:43 miod Exp $
+
+.include "${.CURDIR}/../Makefile32.inc"
+LDSCRIPT= ${.CURDIR}/ld.script
+LDFLAGS+= ${SALDFLAGS} -T ${LDSCRIPT} -e __start -s
+PROG= boot32
+.PATH: ${.CURDIR}/../boot
+.include "${.CURDIR}/../boot/Makefile"
+
+SRCS+= ashrdi3.c udivdi3.c umoddi3.c qdivrem.c
+
+${PROG}: $(OBJS) $(LDADD)
+ $(LD) $(LDFLAGS) -o ${PROG} $(OBJS) -L${LIBSADIR} ${LIBSA} \
+ -L${LIBZDIR} ${LIBZ}
+
+LINKS= ${BINDIR}/${PROG} ${BINDIR}/boot-IP32
+
+.include <bsd.prog.mk>
diff --git a/sys/arch/sgi/stand/boot/ld.script b/sys/arch/sgi/stand/boot32/ld.script
index 1454b030c7d..7d5b81e7c6f 100644
--- a/sys/arch/sgi/stand/boot/ld.script
+++ b/sys/arch/sgi/stand/boot32/ld.script
@@ -1,5 +1,5 @@
-OUTPUT_FORMAT("elf32-tradbigmips", "elf32-tradlittlemips",
- "elf32-tradbigmips")
+OUTPUT_FORMAT("elf32-tradbigmips", "elf32-tradbigmips",
+ "elf32-tradlittlemips")
OUTPUT_ARCH(mips)
ENTRY(_start)
SECTIONS
diff --git a/sys/arch/sgi/stand/boot64/Makefile b/sys/arch/sgi/stand/boot64/Makefile
new file mode 100644
index 00000000000..a1fe2430a8c
--- /dev/null
+++ b/sys/arch/sgi/stand/boot64/Makefile
@@ -0,0 +1,19 @@
+# $OpenBSD: Makefile,v 1.1 2009/05/14 18:57:43 miod Exp $
+
+LDFLAGS+= ${SALDFLAGS} -r --oformat=elf64-tradbigmips -e __start
+STRIP= strip
+INSTALL_STRIP=
+
+PROG= boot64
+.PATH: ${.CURDIR}/../boot
+.include "${.CURDIR}/../boot/Makefile"
+
+${PROG}: $(OBJS) $(LDADD)
+ $(LD) $(LDFLAGS) -o ${PROG} $(OBJS) -L${LIBSADIR} ${LIBSA} \
+ -L${LIBZDIR} ${LIBZ}
+ $(STRIP) --strip-unneeded ${PROG}
+
+LINKS= ${BINDIR}/${PROG} ${BINDIR}/boot-IP27
+LINKS+= ${BINDIR}/${PROG} ${BINDIR}/boot-IP30
+
+.include <bsd.prog.mk>
diff --git a/sys/arch/sgi/stand/libsa/Makefile b/sys/arch/sgi/stand/libsa/Makefile
index 5553f38896a..ff6cb0acbb4 100644
--- a/sys/arch/sgi/stand/libsa/Makefile
+++ b/sys/arch/sgi/stand/libsa/Makefile
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.4 2007/11/26 10:26:02 deraadt Exp $
+# $OpenBSD: Makefile,v 1.5 2009/05/14 18:57:43 miod Exp $
LIB= sa
@@ -6,14 +6,14 @@ LIB= sa
CLEANFILES += machine mips64
-CFLAGS= ${CEXTRAFLAGS} -O2 ${SAABI} -nostdinc -mno-abicalls -D_NO_ABICALLS \
+CFLAGS+= ${CEXTRAFLAGS} ${SAABI} -nostdinc -mno-abicalls -D_NO_ABICALLS \
-I${.CURDIR} -I${.CURDIR}/../include -I${.CURDIR}/../.. \
-I${.CURDIR}/../../.. -I${.CURDIR}/../../../.. \
-I${.CURDIR}/../../../../lib/libsa \
-I${.OBJDIR}
CPPFLAGS+= -D__INTERNAL_LIBSA_CREAD ${STANDALONE}
-CPPFLAGS+= -DLIBSA_LONGLONG_PRINTF
+CPPFLAGS+= ${LIBSA_CPPFLAGS}
# stand routines
SRCS= alloc.c exit.c exec.c getfile.c gets.c globals.c \
diff --git a/sys/arch/sgi/stand/libsa/heap.h b/sys/arch/sgi/stand/libsa/heap.h
new file mode 100644
index 00000000000..da42d8b5e22
--- /dev/null
+++ b/sys/arch/sgi/stand/libsa/heap.h
@@ -0,0 +1,35 @@
+/* $OpenBSD: heap.h,v 1.1 2009/05/14 18:57:43 miod Exp $ */
+/* public domain */
+
+/*
+ * Declarations for the libsa heap allocator.
+ *
+ * Relocatable 64 bit bootblocks use memory below the load address and
+ * can not use the `end' symbol.
+ */
+
+#ifdef __LP64__
+#define NEEDS_HEAP_INIT
+
+#define HEAP_LIMIT heap_limit
+#define HEAP_SIZE (1UL << 20) /* 1MB */
+#define HEAP_START heap_start
+
+static unsigned long heap_start;
+static unsigned long heap_limit;
+static char *top; /* no longer declared in alloc.c */
+
+static inline void heap_init(void);
+static inline void
+heap_init()
+{
+ extern char __start[];
+
+ if (top == NULL) {
+ heap_limit = (unsigned long)&__start;
+ heap_start = heap_limit - HEAP_SIZE;
+ top = (char *)heap_start;
+ }
+}
+
+#endif
diff --git a/sys/arch/sgi/stand/libsa32/Makefile b/sys/arch/sgi/stand/libsa32/Makefile
new file mode 100644
index 00000000000..c22a59bb067
--- /dev/null
+++ b/sys/arch/sgi/stand/libsa32/Makefile
@@ -0,0 +1,4 @@
+# $OpenBSD: Makefile,v 1.1 2009/05/14 18:57:43 miod Exp $
+
+.include "${.CURDIR}/../Makefile32.inc"
+.include "${.CURDIR}/../libsa/Makefile"
diff --git a/sys/arch/sgi/stand/libz/Makefile b/sys/arch/sgi/stand/libz/Makefile
index c04e186885e..b80d1b5989d 100644
--- a/sys/arch/sgi/stand/libz/Makefile
+++ b/sys/arch/sgi/stand/libz/Makefile
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.2 2004/09/16 18:54:49 pefo Exp $
+# $OpenBSD: Makefile,v 1.3 2009/05/14 18:57:43 miod Exp $
S=${.CURDIR}/../../../..
ZDST=${.OBJDIR}
@@ -6,4 +6,5 @@ ZDST=${.OBJDIR}
.PATH: ${S}/lib/libz
.include "${S}/lib/libz/Makefile"
-CFLAGS+= ${SAABI} -mno-abicalls -D_NO_ABICALLS ${CEXTRAFLAGS} ${AFLAGS} -I${S}
+CFLAGS+= ${CEXTRAFLAGS} ${SAABI} -mno-abicalls -D_NO_ABICALLS \
+ ${AFLAGS} -I${S}
diff --git a/sys/arch/sgi/stand/libz32/Makefile b/sys/arch/sgi/stand/libz32/Makefile
new file mode 100644
index 00000000000..d217799d624
--- /dev/null
+++ b/sys/arch/sgi/stand/libz32/Makefile
@@ -0,0 +1,4 @@
+# $OpenBSD: Makefile,v 1.1 2009/05/14 18:57:43 miod Exp $
+
+.include "${.CURDIR}/../Makefile32.inc"
+.include "${.CURDIR}/../libz/Makefile"