Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/amd64/stand/prekern prekern: add support for warnin...



details:   https://anonhg.NetBSD.org/src/rev/941c5be8a890
branches:  trunk
changeset: 1021052:941c5be8a890
user:      khorben <khorben%NetBSD.org@localhost>
date:      Tue May 04 21:09:16 2021 +0000

description:
prekern: add support for warning messages

As submitted on port-amd64@ (part 1/3)

Tested on NetBSD/amd64.

diffstat:

 sys/arch/amd64/stand/prekern/console.c |  23 +++++++++++++++++------
 sys/arch/amd64/stand/prekern/elf.c     |  12 ++++++------
 sys/arch/amd64/stand/prekern/mm.c      |  10 +++++-----
 sys/arch/amd64/stand/prekern/prekern.c |   6 +++---
 sys/arch/amd64/stand/prekern/prekern.h |  12 ++++++++++--
 5 files changed, 41 insertions(+), 22 deletions(-)

diffs (191 lines):

diff -r 8f5d3dec240e -r 941c5be8a890 sys/arch/amd64/stand/prekern/console.c
--- a/sys/arch/amd64/stand/prekern/console.c    Tue May 04 19:57:56 2021 +0000
+++ b/sys/arch/amd64/stand/prekern/console.c    Tue May 04 21:09:16 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: console.c,v 1.6 2020/05/23 08:25:32 maxv Exp $ */
+/*     $NetBSD: console.c,v 1.7 2021/05/04 21:09:16 khorben Exp $      */
 
 /*
  * Copyright (c) 2017-2020 The NetBSD Foundation, Inc. All rights reserved.
@@ -100,13 +100,24 @@
        print_ext(WHITE_ON_BLACK, buf);
 }
 
-void print_state(bool ok, char *buf)
+void print_state(state_t state, char *buf)
 {
        print("[");
-       if (ok)
-               print_ext(GREEN_ON_BLACK, "+");
-       else
-               print_ext(RED_ON_BLACK, "!");
+       switch (state)
+       {
+               case STATE_NORMAL:
+                       print_ext(GREEN_ON_BLACK, "+");
+                       break;
+               case STATE_ERROR:
+                       print_ext(RED_ON_BLACK, "!");
+                       break;
+               case STATE_WARNING:
+                       print_ext(YELLOW_ON_BLACK, "*");
+                       break;
+               default:
+                       print_ext(WHITE_ON_BLACK, "?");
+                       break;
+       }
        print("] ");
        print(buf);
        print("\n");
diff -r 8f5d3dec240e -r 941c5be8a890 sys/arch/amd64/stand/prekern/elf.c
--- a/sys/arch/amd64/stand/prekern/elf.c        Tue May 04 19:57:56 2021 +0000
+++ b/sys/arch/amd64/stand/prekern/elf.c        Tue May 04 21:09:16 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: elf.c,v 1.21 2020/05/07 17:58:26 maxv Exp $    */
+/*     $NetBSD: elf.c,v 1.22 2021/05/04 21:09:16 khorben Exp $ */
 
 /*
  * Copyright (c) 2017-2020 The NetBSD Foundation, Inc. All rights reserved.
@@ -426,7 +426,7 @@
        Elf_Sym *sym;
        size_t i, j;
 
-       print_state(true, "ELF info created");
+       print_state(STATE_NORMAL, "ELF info created");
 
        /*
         * Update all symbol values with the appropriate offset.
@@ -447,7 +447,7 @@
                }
        }
 
-       print_state(true, "Symbol values updated");
+       print_state(STATE_NORMAL, "Symbol values updated");
 
        /*
         * Perform relocations without addend if there are any.
@@ -482,7 +482,7 @@
                }
        }
 
-       print_state(true, "REL relocations applied");
+       print_state(STATE_NORMAL, "REL relocations applied");
 
        /*
         * Perform relocations with addend if there are any.
@@ -517,7 +517,7 @@
                }
        }
 
-       print_state(true, "RELA relocations applied");
+       print_state(STATE_NORMAL, "RELA relocations applied");
 
        /*
         * Get the entry point.
@@ -527,7 +527,7 @@
                fatal("elf_kernel_reloc: entry point not found");
        }
 
-       print_state(true, "Entry point found");
+       print_state(STATE_NORMAL, "Entry point found");
 
        return ent;
 }
diff -r 8f5d3dec240e -r 941c5be8a890 sys/arch/amd64/stand/prekern/mm.c
--- a/sys/arch/amd64/stand/prekern/mm.c Tue May 04 19:57:56 2021 +0000
+++ b/sys/arch/amd64/stand/prekern/mm.c Tue May 04 21:09:16 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mm.c,v 1.27 2020/05/07 17:58:26 maxv Exp $     */
+/*     $NetBSD: mm.c,v 1.28 2021/05/04 21:09:16 khorben Exp $  */
 
 /*
  * Copyright (c) 2017-2020 The NetBSD Foundation, Inc. All rights reserved.
@@ -148,7 +148,7 @@
                mm_mprotect(bootspace.segs[i].va, bootspace.segs[i].sz, prot);
        }
 
-       print_state(true, "Segments protection updated");
+       print_state(STATE_NORMAL, "Segments protection updated");
 }
 
 static size_t
@@ -493,9 +493,9 @@
 {
        memset(&bootspace, 0, sizeof(bootspace));
        mm_map_head();
-       print_state(true, "Head region mapped");
+       print_state(STATE_NORMAL, "Head region mapped");
        elf_map_sections();
-       print_state(true, "Segments mapped");
+       print_state(STATE_NORMAL, "Segments mapped");
        mm_map_boot();
-       print_state(true, "Boot region mapped");
+       print_state(STATE_NORMAL, "Boot region mapped");
 }
diff -r 8f5d3dec240e -r 941c5be8a890 sys/arch/amd64/stand/prekern/prekern.c
--- a/sys/arch/amd64/stand/prekern/prekern.c    Tue May 04 19:57:56 2021 +0000
+++ b/sys/arch/amd64/stand/prekern/prekern.c    Tue May 04 21:09:16 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: prekern.c,v 1.13 2020/05/23 08:25:32 maxv Exp $        */
+/*     $NetBSD: prekern.c,v 1.14 2021/05/04 21:09:16 khorben Exp $     */
 
 /*
  * Copyright (c) 2017-2020 The NetBSD Foundation, Inc. All rights reserved.
@@ -286,7 +286,7 @@
         */
        init_idt();
 
-       print_state(true, "Prekern loaded");
+       print_state(STATE_NORMAL, "Prekern loaded");
 
        /*
         * Init the PRNG.
@@ -309,7 +309,7 @@
        /*
         * Finally, jump into the kernel.
         */
-       print_state(true, "Jumping into the kernel");
+       print_state(STATE_NORMAL, "Jumping into the kernel");
        jump_kernel(ent);
 
        fatal("init_prekern: unreachable!");
diff -r 8f5d3dec240e -r 941c5be8a890 sys/arch/amd64/stand/prekern/prekern.h
--- a/sys/arch/amd64/stand/prekern/prekern.h    Tue May 04 19:57:56 2021 +0000
+++ b/sys/arch/amd64/stand/prekern/prekern.h    Tue May 04 21:09:16 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: prekern.h,v 1.23 2020/05/23 08:25:32 maxv Exp $        */
+/*     $NetBSD: prekern.h,v 1.24 2021/05/04 21:09:16 khorben Exp $     */
 
 /*
  * Copyright (c) 2017-2020 The NetBSD Foundation, Inc. All rights reserved.
@@ -42,6 +42,7 @@
 #define WHITE_ON_BLACK 0x07
 #define RED_ON_BLACK 0x04
 #define GREEN_ON_BLACK 0x02
+#define YELLOW_ON_BLACK 0x0e
 
 #define HEAD_WINDOW_BASE       (KERNBASE - NBPD_L3)
 #define HEAD_WINDOW_SIZE       NBPD_L3
@@ -49,6 +50,13 @@
 #define KASLR_WINDOW_BASE      KERNBASE                /* max - 2GB */
 #define KASLR_WINDOW_SIZE      (2LLU * (1 << 30))      /* 2GB */
 
+typedef enum
+{
+       STATE_NORMAL = 0,
+       STATE_ERROR,
+       STATE_WARNING
+} state_t;
+
 /* -------------------------------------------------------------------------- */
 
 #define BTSEG_NONE     0
@@ -83,7 +91,7 @@
 void init_cons(void);
 void print_ext(int, char *);
 void print(char *);
-void print_state(bool, char *);
+void print_state(state_t, char *);
 void print_banner(void);
 
 /* elf.c */



Home | Main Index | Thread Index | Old Index