Module Name:    src
Committed By:   maxv
Date:           Fri Nov 17 07:07:52 UTC 2017

Modified Files:
        src/sys/arch/amd64/stand/prekern: Makefile console.c elf.c pdir.h
            prekern.c

Log Message:
style


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/amd64/stand/prekern/Makefile
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/amd64/stand/prekern/console.c \
    src/sys/arch/amd64/stand/prekern/pdir.h
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/amd64/stand/prekern/elf.c
cvs rdiff -u -r1.5 -r1.6 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/stand/prekern/Makefile
diff -u src/sys/arch/amd64/stand/prekern/Makefile:1.3 src/sys/arch/amd64/stand/prekern/Makefile:1.4
--- src/sys/arch/amd64/stand/prekern/Makefile:1.3	Tue Nov 14 07:06:34 2017
+++ src/sys/arch/amd64/stand/prekern/Makefile	Fri Nov 17 07:07:52 2017
@@ -1,7 +1,7 @@
-#	$NetBSD: Makefile,v 1.3 2017/11/14 07:06:34 maxv Exp $
+#	$NetBSD: Makefile,v 1.4 2017/11/17 07:07:52 maxv Exp $
 
 PROG=		prekern
-SRCS=	locore.S trap.S prekern.c mm.c console.c elf.c
+SRCS=		locore.S trap.S prekern.c mm.c console.c elf.c
 
 NOSSP=		# defined
 NOPIE=		# defined
@@ -22,8 +22,8 @@ CPPFLAGS+=	-D_STANDALONE
 .include <bsd.klinks.mk>
 
 CPPFLAGS+=	-DKERNEL -D__x86_64__
-CFLAGS+=	-Wall -Werror -mno-red-zone -mno-mmx -mno-sse -mno-avx -ffreestanding
-CFLAGS+=	-Wstrict-prototypes
+CFLAGS+=	-Wall -Werror -Wstrict-prototypes
+CFLAGS+=	-mno-red-zone -mno-mmx -mno-sse -mno-avx -ffreestanding
 STRIPFLAG=
 LINKFLAGS=	-X -z max-page-size=0x100000 -Ttext 0x100000 -T prekern.ldscript
 

Index: src/sys/arch/amd64/stand/prekern/console.c
diff -u src/sys/arch/amd64/stand/prekern/console.c:1.2 src/sys/arch/amd64/stand/prekern/console.c:1.3
--- src/sys/arch/amd64/stand/prekern/console.c:1.2	Tue Nov 14 07:06:34 2017
+++ src/sys/arch/amd64/stand/prekern/console.c	Fri Nov 17 07:07:52 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: console.c,v 1.2 2017/11/14 07:06:34 maxv Exp $	*/
+/*	$NetBSD: console.c,v 1.3 2017/11/17 07:07:52 maxv Exp $	*/
 
 /*
  * Copyright (c) 2017 The NetBSD Foundation, Inc. All rights reserved.
@@ -108,7 +108,7 @@ void print_state(bool ok, char *buf)
 
 void print_banner(void)
 {
-	char *banner = 
+	char *banner =
 		"           __________                 __                        \n"
 		"           \\______   \\_______   ____ |  | __ ___________  ____  \n"
 		"            |     ___/\\_  __ \\_/ __ \\|  |/ // __ \\_  __ \\/    \\ \n"
Index: src/sys/arch/amd64/stand/prekern/pdir.h
diff -u src/sys/arch/amd64/stand/prekern/pdir.h:1.2 src/sys/arch/amd64/stand/prekern/pdir.h:1.3
--- src/sys/arch/amd64/stand/prekern/pdir.h:1.2	Sun Nov  5 16:27:18 2017
+++ src/sys/arch/amd64/stand/prekern/pdir.h	Fri Nov 17 07:07:52 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: pdir.h,v 1.2 2017/11/05 16:27:18 maxv Exp $	*/
+/*	$NetBSD: pdir.h,v 1.3 2017/11/17 07:07:52 maxv Exp $	*/
 
 /*
  * Copyright (c) 2017 The NetBSD Foundation, Inc. All rights reserved.
@@ -28,11 +28,11 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
-#define PREKERNBASE		0x0
+#define PREKERNBASE	0x0
 #define PREKERNTEXTOFF	(PREKERNBASE + 0x100000)
 
 #define L4_SLOT_PREKERN	0 /* pl4_i(PREKERNBASE) */
-#define L4_SLOT_PTE		255
+#define L4_SLOT_PTE	255
 
 #define PDIR_SLOT_KERN	L4_SLOT_PREKERN
 #define PDIR_SLOT_PTE	L4_SLOT_PTE

Index: src/sys/arch/amd64/stand/prekern/elf.c
diff -u src/sys/arch/amd64/stand/prekern/elf.c:1.15 src/sys/arch/amd64/stand/prekern/elf.c:1.16
--- src/sys/arch/amd64/stand/prekern/elf.c:1.15	Wed Nov 15 20:45:16 2017
+++ src/sys/arch/amd64/stand/prekern/elf.c	Fri Nov 17 07:07:52 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: elf.c,v 1.15 2017/11/15 20:45:16 maxv Exp $	*/
+/*	$NetBSD: elf.c,v 1.16 2017/11/17 07:07:52 maxv Exp $	*/
 
 /*
  * Copyright (c) 2017 The NetBSD Foundation, Inc. All rights reserved.
@@ -292,6 +292,7 @@ elf_map_sections(void)
 		secalign = shdr->sh_addralign;
 		ASSERT(shdr->sh_offset != 0);
 		ASSERT(secpa % PAGE_SIZE == 0);
+		ASSERT(secpa + secsz <= kernpa_end);
 
 		secva = mm_map_segment(segtype, secpa, secsz, secalign);
 

Index: src/sys/arch/amd64/stand/prekern/prekern.c
diff -u src/sys/arch/amd64/stand/prekern/prekern.c:1.5 src/sys/arch/amd64/stand/prekern/prekern.c:1.6
--- src/sys/arch/amd64/stand/prekern/prekern.c:1.5	Tue Nov 14 07:06:34 2017
+++ src/sys/arch/amd64/stand/prekern/prekern.c	Fri Nov 17 07:07:52 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: prekern.c,v 1.5 2017/11/14 07:06:34 maxv Exp $	*/
+/*	$NetBSD: prekern.c,v 1.6 2017/11/17 07:07:52 maxv Exp $	*/
 
 /*
  * Copyright (c) 2017 The NetBSD Foundation, Inc. All rights reserved.
@@ -46,10 +46,9 @@ struct bootinfo bootinfo;
 
 extern paddr_t kernpa_start, kernpa_end;
 
-extern uint64_t *gdt64_start;
-uint8_t idtstore[PAGE_SIZE];
-uint8_t faultstack[PAGE_SIZE];
-struct x86_64_tss prekern_tss;
+static uint8_t idtstore[PAGE_SIZE];
+static uint8_t faultstack[PAGE_SIZE];
+static struct x86_64_tss prekern_tss;
 
 /* GDT offsets */
 #define PREKERN_GDT_NUL_OFF	(0 * 8)
@@ -117,7 +116,7 @@ static char *trap_type[] = {
 	"SSE FP exception",			/* 19 T_XMM */
 	"reserved trap",			/* 20 T_RESERVED */
 };
-int	trap_types = __arraycount(trap_type);
+static int trap_types = __arraycount(trap_type);
 
 /*
  * Trap handler.
@@ -152,7 +151,7 @@ setregion(struct region_descriptor *rd, 
 
 static void
 setgate(struct gate_descriptor *gd, void *func, int ist, int type, int dpl,
-	int sel)
+    int sel)
 {
 	gd->gd_looffset = (uint64_t)func & 0xffff;
 	gd->gd_selector = sel;
@@ -169,7 +168,7 @@ setgate(struct gate_descriptor *gd, void
 
 static void
 set_sys_segment(struct sys_segment_descriptor *sd, void *base, size_t limit,
-	int type, int dpl, int gran)
+    int type, int dpl, int gran)
 {
 	memset(sd, 0, sizeof(*sd));
 	sd->sd_lolimit = (unsigned)limit;
@@ -186,13 +185,15 @@ static void
 set_sys_gdt(int slotoff, void *base, size_t limit, int type, int dpl, int gran)
 {
 	struct sys_segment_descriptor sd;
+	extern uint64_t *gdt64_start;
 
 	set_sys_segment(&sd, base, limit, type, dpl, gran);
 
 	memcpy(&gdt64_start + slotoff, &sd, sizeof(sd));
 }
 
-static void init_tss(void)
+static void
+init_tss(void)
 {
 	memset(&prekern_tss, 0, sizeof(prekern_tss));
 	prekern_tss.tss_ist[0] = (uintptr_t)(&faultstack[PAGE_SIZE-1]) & ~0xf;
@@ -201,7 +202,8 @@ static void init_tss(void)
 	    sizeof(struct x86_64_tss) - 1, SDT_SYS386TSS, SEL_KPL, 0);
 }
 
-static void init_idt(void)
+static void
+init_idt(void)
 {
 	struct region_descriptor region;
 	struct gate_descriptor *idt;

Reply via email to