summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/arch/i386/stand/libsa/Makefile4
-rw-r--r--sys/arch/i386/stand/libsa/alloca.S58
-rw-r--r--sys/arch/i386/stand/libsa/biosdev.c18
3 files changed, 67 insertions, 13 deletions
diff --git a/sys/arch/i386/stand/libsa/Makefile b/sys/arch/i386/stand/libsa/Makefile
index aba5ea1a4ee..8c1b4bf3004 100644
--- a/sys/arch/i386/stand/libsa/Makefile
+++ b/sys/arch/i386/stand/libsa/Makefile
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.11 1997/04/28 07:39:00 weingart Exp $
+# $OpenBSD: Makefile,v 1.12 1997/04/30 18:10:08 mickey Exp $
LIB= sa
@@ -17,7 +17,7 @@ AS+= -R
# i386 stuff (so, it will possibly load in the same 64k)
SRCS= unixsys.S bioscom.S biosdisk.S bioskbd.S biostime.S biosmem.S gidt.S \
debug_i386.S dev_i386.c exec_i386.c biosdev.c gateA20.c memprobe.c \
- time.c
+ time.c alloca.S
# stand routines
SRCS+= alloc.c exit.c exec.c getfile.c gets.c globals.c strcmp.c strlen.c \
diff --git a/sys/arch/i386/stand/libsa/alloca.S b/sys/arch/i386/stand/libsa/alloca.S
new file mode 100644
index 00000000000..6e14bbd3bc6
--- /dev/null
+++ b/sys/arch/i386/stand/libsa/alloca.S
@@ -0,0 +1,58 @@
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * William Jolitz.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+#if defined(LIBC_SCCS)
+ .text
+ .asciz "$OpenBSD: alloca.S,v 1.1 1997/04/30 18:10:06 mickey Exp $"
+#endif
+
+/* like alloc, but automatic automatic free in return */
+
+ENTRY(alloca)
+ popl %edx /* pop return addr */
+ popl %eax /* pop amount to allocate */
+ movl %esp,%ecx
+ addl $3,%eax /* round up to next word */
+ andl $-4,%eax
+ subl %eax,%esp
+ movl %esp,%eax /* base of newly allocated space */
+ pushl 8(%ecx) /* copy possible saved registers */
+ pushl 4(%ecx)
+ pushl 0(%ecx)
+ pushl %eax /* dummy to pop at callsite */
+ jmp %edx /* "return" */
diff --git a/sys/arch/i386/stand/libsa/biosdev.c b/sys/arch/i386/stand/libsa/biosdev.c
index 073a94eae33..29ec6df94d6 100644
--- a/sys/arch/i386/stand/libsa/biosdev.c
+++ b/sys/arch/i386/stand/libsa/biosdev.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: biosdev.c,v 1.14 1997/04/23 14:49:23 weingart Exp $ */
+/* $OpenBSD: biosdev.c,v 1.15 1997/04/30 18:10:07 mickey Exp $ */
/*
* Copyright (c) 1996 Michael Shalayeff
@@ -189,7 +189,7 @@ biosopen(struct open_file *f, ...)
}
}
- buf = alloc(DEV_BSIZE);
+ buf = alloca(DEV_BSIZE);
#ifdef BIOS_DEBUG
if (debug)
printf("loading disklabel @ %u\n", off);
@@ -201,7 +201,6 @@ biosopen(struct open_file *f, ...)
if (debug)
printf("failed to read disklabel\n");
#endif
- free(buf, 0);
free(bd, 0);
return errno;
}
@@ -211,12 +210,10 @@ biosopen(struct open_file *f, ...)
if (debug)
printf("%s\n", cp);
#endif
- free(buf, 0);
free(bd, 0);
return EINVAL;
}
- free(buf,0);
f->f_devdata = bd;
return 0;
@@ -306,7 +303,9 @@ biosstrategy(void *devdata, int rw,
/* use a bounce buffer to not cross 64k DMA boundary */
if ((((u_int32_t)buf) & ~0xffff) !=
(((u_int32_t)buf + n * DEV_BSIZE) & ~0xffff)) {
- bb = alloc(n * DEV_BSIZE);
+ /* XXX we beleive that all the io is buffered
+ by fs routines, so no big reads anyway */
+ bb = alloca(n * DEV_BSIZE);
if (rw != F_READ)
bcopy (buf, bb, n * DEV_BSIZE);
} else
@@ -338,11 +337,8 @@ biosstrategy(void *devdata, int rw,
}
}
- if (bb != buf) {
- if (rw == F_READ)
- bcopy (bb, buf, n * DEV_BSIZE);
- free (bb, n * DEV_BSIZE);
- }
+ if (bb != buf && rw == F_READ)
+ bcopy (bb, buf, n * DEV_BSIZE);
}
#ifdef BIOS_DEBUG