shithub: 9ferno

Download patch

ref: 2de7940afebf1e4daba04a57b77d43f52f9915b8
parent: 1971857799205f6226d2b8fa354df153d035dae4
author: 9ferno <gophone2015@gmail.com>
date: Mon Aug 9 10:23:44 EDT 2021

cleaned up the boot messages

--- a/os/pc/bootargs.c	Mon Aug  9 10:23:14 2021
+++ b/os/pc/bootargs.c	Mon Aug  9 10:23:44 2021
@@ -198,7 +198,8 @@
 {
 	int i;
 
+	print("Boot configuration\n");
 	for(i = 0; i < nconf; i++){
-		print("%s=%s\n", confname[i], confval[i]);
+		print("	%s=%s\n", confname[i], confval[i]);
 	}
 }
--- a/os/pc64/main.c	Mon Aug  9 10:23:14 2021
+++ b/os/pc64/main.c	Mon Aug  9 10:23:44 2021
@@ -27,7 +27,7 @@
 static void
 doc(char *m)
 {
-	int i;
+	/*int i;*/
 	print("%s...\n", m);
 	/*for(i = 0; i < 100*1024*1024; i++)
 		i++;*/
@@ -78,38 +78,45 @@
 }
 
 void
-ptedebug(uintptr pa)
+ptedebug(uintptr pa, char *desc)
 {
 	uintptr *pml4e, *pdpe, *pde;
+	char pdestr[64] = "unmapped";
 
 	pml4e = mmuwalk((uintptr*)PML4ADDR, pa, 3, 0);
 	pdpe = mmuwalk((uintptr*)PML4ADDR, pa, 2, 0);
 	pde = mmuwalk((uintptr*)PML4ADDR, pa, 1, 0);
-	print("pml4 @ 0x%p pa 0x%zux page is \n"
-		"\tpml4 entry @ 0x%p i %zd\n"
-		"\tpdp entry @ 0x%p i %zd\n"
-		"\tpd entry @ 0x%p i %zd\n",
-		m->pml4, pa,
-		pml4e, (pml4e-m->pml4)/sizeof(intptr),
-		pdpe, ((intptr)pdpe-(intptr)PDPADDR)/sizeof(intptr),
-		pde, ((intptr)pde-(intptr)PD0ADDR)/sizeof(intptr));
+	if((intptr)pde > 0){
+		snprint(pdestr, 64, "at 0x%p i %zd",
+				pde, ((intptr)pde-(intptr)PD0ADDR)/sizeof(intptr));
+	}
+	print("\tpage of address 0x%zux (%s) with pml4 at 0x%p\n"
+			"\t\tpml4 entry at 0x%p i %zd\n"
+			"\t\tpdp entry at 0x%p i %zd\n"
+			"\t\tpd entry %s\n",
+			pa, desc, m->pml4,
+			pml4e, (pml4e-m->pml4)/sizeof(intptr),
+			pdpe, ((intptr)pdpe-(intptr)PDPADDR)/sizeof(intptr),
+			pdestr);
 }
 
 void
 showconfig(void)
 {
 	showconf();
-	print("kdzero 0x%p confaddr 0x%p apbootstrap 0x%p idtaddr 0x%p\n"
+	print("Important Addresses\n"
+		"\tkdzero 0x%p confaddr 0x%p apbootstrap 0x%p idtaddr 0x%p\n"
 		"\tcpu0mach 0x%p cpu0sp 0x%p cpu0gdt 0x%p\n"
 		"\tcpu0pml4 0x%p cpu0pdp 0x%p  cpu0pd 0x%p\n"
 		"\tcpu0end 0x%p\n",
 		(void*)KDZERO, CONFADDR,APBOOTSTRAP,
 		IDTADDR, CPU0MACH, CPU0SP, GDTADDR,
 		PML4ADDR, PDPADDR, PD0ADDR, CPU0END);
-	ptedebug(1*MiB);
-	ptedebug(2*MiB);
-	ptedebug(1*GiB);
-	ptedebug(4ull*GiB);
+	print("Some page table entries\n");
+	ptedebug(1*MiB,"1 MiB");
+	ptedebug(2*MiB,"2 MiB");
+	ptedebug(1*GiB,"1 GiB");
+	ptedebug(4ull*GiB,"4 GiB");
 }
 
 /* to check from acid on whether the data segment is being trashed */
--- a/os/pc64/mem.h	Mon Aug  9 10:23:14 2021
+++ b/os/pc64/mem.h	Mon Aug  9 10:23:44 2021
@@ -29,7 +29,7 @@
 #define	FPalign		64
 
 #define	MAXMACH		128			/* max # cpus system can run */
-#define	KSTACK		(32*KiB)		/* Size of kernel stack */
+#define	KSTACK		(32*KiB)	/* Size of kernel stack */
 #define	MACHSIZE	(2*KSTACK)
 
 /*
@@ -62,6 +62,7 @@
 #define GDTADDR		(KDZERO+0x11000ull)	/* gdt */
 #define	CPU0MACH	(KDZERO+0x12000ull)	/* Mach for bootstrap processor */
 #define CPU0END		(KDZERO+0x22000ull)	/* CPU0MACH + (MACHSIZE = 64 KiB = 0x10 000) */
+										/* MACHSIZE includes stack size */
 #define CPU0SP		(KDZERO+0x22000ull)
 /* 1 PD table has 512 entries
  * each entry maps to a 2MB page
--- a/os/pc64/memory.c	Mon Aug  9 10:23:14 2021
+++ b/os/pc64/memory.c	Mon Aug  9 10:23:44 2021
@@ -584,9 +584,11 @@
 {
 	uintptr prevbase = 0, base, size = 0;
 
-	print("MemMin 0x%llux end 0x%p KZERO 0x%x KDZERO 0x%x\n"
+	print("Memory Configuration\n"
+		"\tMemMin 0x%llux end 0x%p KZERO 0x%x KDZERO 0x%x\n"
 		"\tKTZERO 0x%x etext 0x%p\n\tCPU0END 0x%llux\n"
-		"\tPADDR(PGROUND((uintptr)end)) 0x%zux MemMin-PADDR(PGROUND((uintptr)end)) 0x%zux\n",
+		"\tPADDR(PGROUND((uintptr)end)) 0x%zux\n"
+		"\tMemMin-PADDR(PGROUND((uintptr)end)) 0x%zux\n",
 		MemMin, end, KZERO, KDZERO, KTZERO, etext, (uintptr)CPU0END,
 		PADDR(PGROUND((uintptr)end)), MemMin-PADDR(PGROUND((uintptr)end)));
 	/*