Module Name: src Committed By: khorben Date: Tue May 4 21:09:16 UTC 2021
Modified Files: src/sys/arch/amd64/stand/prekern: console.c elf.c mm.c prekern.c prekern.h Log Message: prekern: add support for warning messages As submitted on port-amd64@ (part 1/3) Tested on NetBSD/amd64. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/arch/amd64/stand/prekern/console.c cvs rdiff -u -r1.21 -r1.22 src/sys/arch/amd64/stand/prekern/elf.c cvs rdiff -u -r1.27 -r1.28 src/sys/arch/amd64/stand/prekern/mm.c cvs rdiff -u -r1.13 -r1.14 src/sys/arch/amd64/stand/prekern/prekern.c cvs rdiff -u -r1.23 -r1.24 src/sys/arch/amd64/stand/prekern/prekern.h 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/stand/prekern/console.c diff -u src/sys/arch/amd64/stand/prekern/console.c:1.6 src/sys/arch/amd64/stand/prekern/console.c:1.7 --- src/sys/arch/amd64/stand/prekern/console.c:1.6 Sat May 23 08:25:32 2020 +++ src/sys/arch/amd64/stand/prekern/console.c Tue May 4 21:09:16 2021 @@ -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 @@ void print(char *buf) 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"); Index: src/sys/arch/amd64/stand/prekern/elf.c diff -u src/sys/arch/amd64/stand/prekern/elf.c:1.21 src/sys/arch/amd64/stand/prekern/elf.c:1.22 --- src/sys/arch/amd64/stand/prekern/elf.c:1.21 Thu May 7 17:58:26 2020 +++ src/sys/arch/amd64/stand/prekern/elf.c Tue May 4 21:09:16 2021 @@ -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_kernel_reloc(void) 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 @@ elf_kernel_reloc(void) } } - 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 @@ elf_kernel_reloc(void) } } - 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 @@ elf_kernel_reloc(void) } } - print_state(true, "RELA relocations applied"); + print_state(STATE_NORMAL, "RELA relocations applied"); /* * Get the entry point. @@ -527,7 +527,7 @@ elf_kernel_reloc(void) fatal("elf_kernel_reloc: entry point not found"); } - print_state(true, "Entry point found"); + print_state(STATE_NORMAL, "Entry point found"); return ent; } Index: src/sys/arch/amd64/stand/prekern/mm.c diff -u src/sys/arch/amd64/stand/prekern/mm.c:1.27 src/sys/arch/amd64/stand/prekern/mm.c:1.28 --- src/sys/arch/amd64/stand/prekern/mm.c:1.27 Thu May 7 17:58:26 2020 +++ src/sys/arch/amd64/stand/prekern/mm.c Tue May 4 21:09:16 2021 @@ -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_bootspace_mprotect(void) 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 @@ mm_map_kernel(void) { 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"); } Index: src/sys/arch/amd64/stand/prekern/prekern.c diff -u src/sys/arch/amd64/stand/prekern/prekern.c:1.13 src/sys/arch/amd64/stand/prekern/prekern.c:1.14 --- src/sys/arch/amd64/stand/prekern/prekern.c:1.13 Sat May 23 08:25:32 2020 +++ src/sys/arch/amd64/stand/prekern/prekern.c Tue May 4 21:09:16 2021 @@ -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_prekern(paddr_t pa_start) */ init_idt(); - print_state(true, "Prekern loaded"); + print_state(STATE_NORMAL, "Prekern loaded"); /* * Init the PRNG. @@ -309,7 +309,7 @@ init_prekern(paddr_t pa_start) /* * 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!"); Index: src/sys/arch/amd64/stand/prekern/prekern.h diff -u src/sys/arch/amd64/stand/prekern/prekern.h:1.23 src/sys/arch/amd64/stand/prekern/prekern.h:1.24 --- src/sys/arch/amd64/stand/prekern/prekern.h:1.23 Sat May 23 08:25:32 2020 +++ src/sys/arch/amd64/stand/prekern/prekern.h Tue May 4 21:09:16 2021 @@ -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 @@ typedef uint64_t pte_prot_t; #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 @@ typedef uint64_t pte_prot_t; #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 @@ struct bootspace { 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 */