summaryrefslogtreecommitdiff
path: root/sys/stand/boot/bootarg.c
diff options
context:
space:
mode:
authorYASUOKA Masahiko <yasuoka@cvs.openbsd.org>2015-09-02 01:52:27 +0000
committerYASUOKA Masahiko <yasuoka@cvs.openbsd.org>2015-09-02 01:52:27 +0000
commit3a5c5695579399f3e89c4670dbdd139540a20752 (patch)
tree94e92b1413e81b36c4393124f483312489316269 /sys/stand/boot/bootarg.c
parent98bddd3337aaeb8aeaaf01bdac4e2a4e2610d590 (diff)
Initial commit of uefi boot loader of OpenBSD.
ok deraadt yuo
Diffstat (limited to 'sys/stand/boot/bootarg.c')
-rw-r--r--sys/stand/boot/bootarg.c47
1 files changed, 46 insertions, 1 deletions
diff --git a/sys/stand/boot/bootarg.c b/sys/stand/boot/bootarg.c
index 94ba6fc5c64..b3834e77a99 100644
--- a/sys/stand/boot/bootarg.c
+++ b/sys/stand/boot/bootarg.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bootarg.c,v 1.11 2014/06/27 16:05:20 tobias Exp $ */
+/* $OpenBSD: bootarg.c,v 1.12 2015/09/02 01:52:26 yasuoka Exp $ */
/*
* Copyright (c) 1997,1998 Michael Shalayeff
@@ -77,3 +77,48 @@ makebootargs(caddr_t v, size_t *lenp)
p->ba_type = BOOTARG_END;
}
+void
+makebootargs32(caddr_t v, size_t *lenp)
+{
+ bootarg_t *p;
+ u_char *q;
+ size_t l;
+ size_t adj;
+ struct bootarg32 {
+ int ba_type;
+ int ba_size;
+ int ba_nextX;
+ char ba_arg[1];
+ } *p32;
+
+ adj = (ssize_t)sizeof(struct bootarg32) - sizeof(bootarg_t);
+ /* get total size */
+ l = sizeof(*p32);
+ for (p = bootarg_list; p != NULL; p = p->ba_next) {
+ l += p->ba_size + adj;
+ if (*lenp < l) {
+#ifdef DEBUG
+ printf("makebootargs: too many args\n");
+#endif
+ l -= p->ba_size + adj;
+ break;
+ }
+ }
+ *lenp = l;
+ /* copy them out */
+ for (p = bootarg_list, q = v; p != NULL; p = p->ba_next) {
+ if (q + p->ba_size + adj > (u_char *)v + l - sizeof(*p32))
+ break;
+ p32 = (struct bootarg32 *)q;
+ p32->ba_type = p->ba_type;
+ p32->ba_size = p->ba_size + adj;
+ bcopy(p->ba_arg, p32->ba_arg,
+ p->ba_size - (sizeof(*p) - sizeof(p->ba_arg)));
+#ifdef DEBUG
+ printf("%d,%d ", p->ba_type, p->ba_size);
+#endif
+ q += p32->ba_size;
+ }
+ p32 = (struct bootarg32 *)q;
+ p32->ba_type = BOOTARG_END;
+}