Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/amd64 Add a "version" field in the prekern_args str...



details:   https://anonhg.NetBSD.org/src/rev/66d792559360
branches:  trunk
changeset: 365146:66d792559360
user:      maxv <maxv%NetBSD.org@localhost>
date:      Thu Aug 02 17:18:00 2018 +0000

description:
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.

diffstat:

 sys/arch/amd64/amd64/prekern.c         |  11 +++++++++--
 sys/arch/amd64/stand/prekern/prekern.c |  10 +++++++---
 2 files changed, 16 insertions(+), 5 deletions(-)

diffs (78 lines):

diff -r c45f13b8c001 -r 66d792559360 sys/arch/amd64/amd64/prekern.c
--- a/sys/arch/amd64/amd64/prekern.c    Thu Aug 02 16:58:00 2018 +0000
+++ b/sys/arch/amd64/amd64/prekern.c    Thu Aug 02 17:18:00 2018 +0000
@@ -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 @@
 {
        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 @@
 
        panic("main returned");
 
-       return -1;
+       return 0;
 }
diff -r c45f13b8c001 -r 66d792559360 sys/arch/amd64/stand/prekern/prekern.c
--- a/sys/arch/amd64/stand/prekern/prekern.c    Thu Aug 02 16:58:00 2018 +0000
+++ b/sys/arch/amd64/stand/prekern/prekern.c    Thu Aug 02 17:18:00 2018 +0000
@@ -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 @@
 
 /* -------------------------------------------------------------------------- */
 
+#define PREKERN_API_VERSION    1
+
 struct prekern_args {
+       int version;
        int boothowto;
        void *bootinfo;
        void *bootspace;
@@ -253,6 +256,7 @@
        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 @@
        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");
        }
 }
 



Home | Main Index | Thread Index | Old Index