summaryrefslogtreecommitdiff
path: root/sys/arch/sgi/stand/boot/boot.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/arch/sgi/stand/boot/boot.c')
-rw-r--r--sys/arch/sgi/stand/boot/boot.c40
1 files changed, 39 insertions, 1 deletions
diff --git a/sys/arch/sgi/stand/boot/boot.c b/sys/arch/sgi/stand/boot/boot.c
index 27c597ec9ff..c5451b603bf 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.14 2009/11/24 13:31:41 miod Exp $ */
+/* $OpenBSD: boot.c,v 1.15 2009/11/30 05:19:20 miod Exp $ */
/*
* Copyright (c) 2004 Opsycon AB, www.opsycon.se.
@@ -34,6 +34,7 @@
#include <mips64/arcbios.h>
#include <mips64/cpu.h>
+#include <sys/exec_elf.h>
#include "loadfile.h"
char *strstr(char *, const char *); /* strstr.c */
@@ -175,3 +176,40 @@ dobootopts(int argc, char **argv)
}
}
}
+
+/*
+ * Prevent loading a wrong kernel.
+ */
+int
+check_phdr(void *v)
+{
+ Elf64_Phdr *phdr = (Elf64_Phdr *)v;
+ uint64_t addr;
+
+ switch (IP) {
+ case 27:
+ addr = 0xa800000000000000ULL >> 28;
+ break;
+ case 30:
+ addr = 0xa800000020000000ULL >> 28;
+ break;
+ case 32:
+ addr = 0xffffffff80000000ULL >> 28;
+ break;
+ default:
+ /*
+ * If the system could not be identified, accept any
+ * address and hope the user knows what's he's doing.
+ */
+ return 0;
+ }
+
+ if ((phdr->p_vaddr >> 28) != addr) {
+ /* I'm sorry Dave, I can't let you do that. */
+ printf("This kernel does not seem to be compiled for this"
+ " machine type.\nYou need to boot an IP%d kernel.\n", IP);
+ return 1;
+ }
+
+ return 0;
+}