shithub: 9ferno

Download patch

ref: 7e0a4aa1580becd93c8963ffc029e57fe361276b
parent: 926b447e2e705eb476de8ccee6898a3a3e1f0fef
author: 9ferno <gophone2015@gmail.com>
date: Fri Aug 6 10:53:26 EDT 2021

changes to get to the native amd64 shell prompt

--- a/lib/proto/os	Wed Aug  4 14:06:19 2021
+++ b/lib/proto/os	Fri Aug  6 10:53:26 2021
@@ -1,10 +1,12 @@
 Inferno
 	386
+		ipc	664
 		bin
 		include
 			*
 		lib
 	amd64
+		ipc64	664
 		bin
 		include
 			*
--- a/mkfile	Wed Aug  4 14:06:19 2021
+++ b/mkfile	Fri Aug  6 10:53:26 2021
@@ -287,7 +287,7 @@
 %.386.iso:
 	@{rfork n
 	objtype=386
-	kernel=/n/src9/$objtype/ipc
+	kernel=/n/src9/Inferno/$objtype/ipc
 	mk binds
 	mk $target.$pid.pc.iso
 	mv $target.$pid.pc.iso $target
@@ -296,7 +296,7 @@
 %.amd64.iso:
 	@{rfork n
 	objtype=amd64
-	kernel=/n/src9/$objtype/ipc64
+	kernel=/n/src9/Inferno/$objtype/ipc64
 	mk binds
 	mk $target.$pid.pc.iso
 	mv $target.$pid.pc.iso $target
@@ -308,15 +308,18 @@
 %.pc.iso:D:	install kernelinstall
 	@{rfork n
 	mk binds
-	{	echo 'console=0 b115200'
+	{	# echo 'console=0 b115200'
 		grep -v '^bootfile=' /n/src9/os/pc/plan9.ini
-		echo 'bootfile='^`{echo $kernel | sed 's!^/n/src9!!'}
+		#echo 'bootfile='^`{echo $kernel | sed 's!^/n/src9!!'}
+		echo 'bootfile=ipc64'
 	} > /env/plan9.ini
 	aux/stub /n/src9/cfg/plan9.ini
 	bind /env/plan9.ini /n/src9/cfg/plan9.ini
+	aux/stub /n/src9/ipc64
+	bind $kernel /n/src9/ipc64
 	cat /n/src9/cfg/plan9.ini
 	disk/mk9660 -c9j -B 386/9bootiso -E 386/efiboot.fat \
-		-p <{cat /n/src9/lib/proto/^(9boot inferno os src utils)} \
+		-p <{echo ipc64; cat /n/src9/lib/proto/^(9boot inferno os src utils)} \
 		-s /n/src9 -v 'Inferno 9 Front ('^$objtype^')' $target
 	if(test -r /n/src9/386/9boothyb){
 		dd -if /dev/zero -bs 2048 -count 1024 >> $target
--- a/os/pc/cga.c	Wed Aug  4 14:06:19 2021
+++ b/os/pc/cga.c	Fri Aug  6 10:53:26 2021
@@ -109,7 +109,7 @@
 		lock(&cgascreenlock);
 
 	while(n-- > 0){
-		outb(0x3D6, *s);
+		/* outb(0x3D6, *s); */
 		cgascreenputc(*s++);
 	}
 	movecursor();
--- a/os/pc64/mem.h	Wed Aug  4 14:06:19 2021
+++ b/os/pc64/mem.h	Fri Aug  6 10:53:26 2021
@@ -55,8 +55,8 @@
 /*
  * Fundamental addresses
  */
-#define	REBOOTADDR	(0x11000)		/* reboot code - physical address */
-#define	CONFADDR	(KDZERO+ 0x1200ull)	/* info passed from boot loader */
+#define	CONFADDR	(0x1200ull)		/* info passed from boot loader */
+#define	REBOOTADDR	(0x11000ull)	/* reboot code - physical address */
 #define	APBOOTSTRAP	(KDZERO+ 0x7000ull)	/* AP bootstrap code */
 #define	IDTADDR		(KDZERO+0x10000ull)	/* idt */
 #define GDTADDR		(KDZERO+0x11000ull)	/* gdt */
@@ -66,8 +66,6 @@
 /* 1 PD table has 512 entries
  * each entry maps to a 2MB page
  * 512 entries maps 1GiB and occupies 512*8 = 4096 bytes
- * TODO Drop the CPU0 prefix for the page tables and gdt
- * call them BOOTPML4 and PML4
  */
 #define PML4ADDR	(KDZERO+0x23000ull)
 #define PDPADDR		(KDZERO+0x24000ull)
@@ -79,7 +77,8 @@
 						/* fill with page tables until KTZERO */
 
 /*
- * Where configuration info is left for the loaded programme.
+ * Where configuration info is left for us by 9boot.
+ * (e.g. why parse the .ini file twice?).
  * There are 24064 bytes available at CONFADDR.
  */
 #define BOOTLINE	((char*)CONFADDR)
--- a/os/pc64/memory.c	Wed Aug  4 14:06:19 2021
+++ b/os/pc64/memory.c	Fri Aug  6 10:53:26 2021
@@ -426,7 +426,34 @@
 	return 0;
 }
 
-/* TODO untested */
+/*
+21:00 < joe7> ori, you around? I am trying to figure out how ramscan() works. When writing the pattern, why does it do this: *k0 = ~pat; ?
+21:01 < joe7> that value is not used anywhere else again in that subroutine.
+21:06 < joe7> nemo's kernel book on page 51 asks the same question too.
+21:06 < joe7> It says, "the author is saving the value actually stored at address KZERO, can you guess why?"
+0:36 < cinap_lenrek> joe7: it is to detect aliases
+00:36 < cinap_lenrek> joe7: it is a RAM tester basically
+00:36 < cinap_lenrek> joe7: you should not use this at all
+00:37 < cinap_lenrek> in modern machines, this approach is impossible
+00:37 < cinap_lenrek> because ram now contains life firmware for devices and megabytes of persistent firmware code
+00:40 < cinap_lenrek> if you write to that or damage that info the whole machine will just lock up or brick itself
+04:38 < joe7> cinap_lenrek: joe7: you should not use this at all -- which one? the ramscan() or *k = pat?
+04:39 < joe7> I see ramscan in 9front 9/pc/memory.c too
+04:39 < joe7> Iif(e820scan() < 0)
+04:39 < joe7> IIramscan(MemMin, -((uintptr)MemMin), 4*MB);
+04:39 < joe7> that is how the ram is being discovered
+04:46 < cinap_lenrek> e820scan() just reads the *e820= plan9.ini parameter
+04:46 < cinap_lenrek> ramscan() is a fallback
+04:46 < cinap_lenrek> when theres no memory map
+04:46 < cinap_lenrek> like on reeeeeally old machines
+04:46 < cinap_lenrek> or when bios is totally broken
+04:47 < cinap_lenrek> dont worry about it
+04:47 < cinap_lenrek> theres not really a point in supporting it anymore
+04:47 < cinap_lenrek> as i said
+04:47 < cinap_lenrek> it is a destructive memory test
+04:47 < joe7> oh, ok. I must have screwed up something as it is going to ramscan() each time.
+04:47 < joe7> I will fix it. Thanks.
+ */
 static void
 ramscan(uintptr pa, uintptr top)
 {
--- a/os/port/taslock.c	Wed Aug  4 14:06:19 2021
+++ b/os/port/taslock.c	Fri Aug  6 10:53:26 2021
@@ -105,8 +105,8 @@
 	if(l->key == 0)
 		print("unlock: not locked: pc %zux\n", getcallerpc(&l));
 	p = l->pri;
-	l->pc = 0;
 	l->key = 0;
+	l->pc = 0;
 	coherence();
 	if(up && islo()){
 		/*