Module Name: src
Committed By: maxv
Date: Thu Aug 2 17:18:00 UTC 2018
Modified Files:
src/sys/arch/amd64/amd64: prekern.c
src/sys/arch/amd64/stand/prekern: prekern.c
Log Message:
Add a "version" field in the prekern_args structure. The kernel checks it,
and if it's not happy it returns back to the prekern.
To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/amd64/amd64/prekern.c
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/amd64/stand/prekern/prekern.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/amd64/amd64/prekern.c
diff -u src/sys/arch/amd64/amd64/prekern.c:1.2 src/sys/arch/amd64/amd64/prekern.c:1.3
--- src/sys/arch/amd64/amd64/prekern.c:1.2 Thu Aug 2 16:58:00 2018
+++ src/sys/arch/amd64/amd64/prekern.c Thu Aug 2 17:18:00 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: prekern.c,v 1.2 2018/08/02 16:58:00 maxv Exp $ */
+/* $NetBSD: prekern.c,v 1.3 2018/08/02 17:18:00 maxv Exp $ */
/*
* Copyright (c) 2017 The NetBSD Foundation, Inc. All rights reserved.
@@ -46,7 +46,10 @@
#include <dev/isa/isareg.h>
#include <machine/isa_machdep.h>
+#define PREKERN_API_VERSION 1
+
struct prekern_args {
+ int version;
int boothowto;
void *bootinfo;
void *bootspace;
@@ -122,6 +125,10 @@ start_prekern(struct prekern_args *pkarg
{
paddr_t first_avail;
+ if (pkargs->version != PREKERN_API_VERSION) {
+ return -1;
+ }
+
prekern_copy_args(pkargs);
first_avail = pkargs->first_avail;
@@ -134,5 +141,5 @@ start_prekern(struct prekern_args *pkarg
panic("main returned");
- return -1;
+ return 0;
}
Index: src/sys/arch/amd64/stand/prekern/prekern.c
diff -u src/sys/arch/amd64/stand/prekern/prekern.c:1.8 src/sys/arch/amd64/stand/prekern/prekern.c:1.9
--- src/sys/arch/amd64/stand/prekern/prekern.c:1.8 Fri May 25 15:52:11 2018
+++ src/sys/arch/amd64/stand/prekern/prekern.c Thu Aug 2 17:18:00 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: prekern.c,v 1.8 2018/05/25 15:52:11 maxv Exp $ */
+/* $NetBSD: prekern.c,v 1.9 2018/08/02 17:18:00 maxv Exp $ */
/*
* Copyright (c) 2017 The NetBSD Foundation, Inc. All rights reserved.
@@ -221,7 +221,10 @@ init_idt(void)
/* -------------------------------------------------------------------------- */
+#define PREKERN_API_VERSION 1
+
struct prekern_args {
+ int version;
int boothowto;
void *bootinfo;
void *bootspace;
@@ -253,6 +256,7 @@ init_prekern_args(void)
extern paddr_t pa_avail;
memset(&pkargs, 0, sizeof(pkargs));
+ pkargs.version = PREKERN_API_VERSION;
pkargs.boothowto = boothowto;
pkargs.bootinfo = (void *)&bootinfo;
pkargs.bootspace = &bootspace;
@@ -285,9 +289,9 @@ exec_kernel(vaddr_t ent)
ret = (*jumpfunc)(&pkargs);
if (ret == -1) {
- fatal("kernel returned -1");
+ fatal("kernel returned: wrong API version");
} else {
- fatal("kernel returned unknown value");
+ fatal("kernel returned: unknown value");
}
}