Browse Source

Cleaning!

Elbing Miss 9 years ago
parent
commit
d6b7eaf9db

+ 4 - 1
sys/src/9/k10/boot.fs

@@ -1,6 +1,9 @@
 #!/boot/rc -m /boot/rcmain
 # boot script for file servers, including standalone ones
 path=(/boot /amd64/bin /rc/bin .)
-echo -n Greetings professor Falken
+prompt=('harvey@cpu% ' '	')
+echo
+echo 'Hello, I am Harvey :-)'
+echo
 exec /boot/rc -m/boot/rcmain -i
 

+ 0 - 1
sys/src/9/k10/i8254.c

@@ -85,7 +85,6 @@ i8254set(int port, int hz)
 		if(!(inb(port+Counter0) & RbNULL))
 			break;
 	}
-	hi("done i8254set\n");
 }
 
 int64_t

+ 75 - 105
sys/src/9/k10/main.c

@@ -95,7 +95,7 @@ options(int argc, char* argv[])
 void
 squidboy(int apicno)
 {
-	// no idea if this will work here. 
+	/* no idea if this will work here. */
 	Mach *m = machp();
 	int64_t hz;
 
@@ -253,7 +253,9 @@ HERE(void)
 	delay(5000);
 }
 
-// The old plan 9 standby ... wave ... 
+/* The old plan 9 standby ... wave ... */
+
+/* Keep to debug trap.c */
 void wave(int c)
 {
 	outb(0x3f8, c);
@@ -261,20 +263,22 @@ void wave(int c)
 
 void hi(char *s) 
 {
-	if (! s)
-		s = "<NULL>";
 	while (*s)
 		wave(*s++);
 }
-	// for gdb: 
-	// call this anywhere in your code. 
-	//die("yourturn with gdb\n");
-	// gdb 9k
-	// target remote localhost:1234
-	// display/i $pc
-	// set staydead = 0
-	// stepi, and debug. 
-	// note, you can always resume after a die. Just set staydead = 0
+
+/*
+ * for gdb: 
+ * call this anywhere in your code. 
+ *   die("yourturn with gdb\n");
+ *   gdb 9k
+ *   target remote localhost:1234
+ *   display/i $pc
+ *   set staydead = 0
+ *   stepi, and debug. 
+ * note, you can always resume after a die. Just set staydead = 0
+ */
+
 int staydead = 1;
 void die(char *s)
 {
@@ -286,6 +290,8 @@ void die(char *s)
 	while(staydead);
 	staydead = 1;
 }
+
+/*
 void bmemset(void *p)
 {
 	__asm__ __volatile__("1: jmp 1b");
@@ -315,6 +321,7 @@ void put64(uint64_t v)
 	put32(v>>32);
 	put32(v);
 }
+*/
 
 void debugtouser(void *va)
 {
@@ -328,12 +335,14 @@ void debugtouser(void *va)
 			m, m->pml4, m->pml4->va, (void *)pml4, *pte);
 }
 
+/*
 void badcall(uint64_t where, uint64_t what)
 {
 	hi("Bad call from function "); put64(where); hi(" to "); put64(what); hi("\n");
 	while (1)
 		;
 }
+*/
 
 void errstr(char *s, int i) {
 	panic("errstr");
@@ -345,62 +354,52 @@ void
 main(uint32_t mbmagic, uint32_t mbaddress)
 {
 	Mach *m = entrym;
-  // when we get here, entrym is set to core0 mach.
+	/* when we get here, entrym is set to core0 mach. */
 	sys->machptr[m->machno] = m;
 	wrmsr(GSbase, PTR2UINT(&sys->machptr[m->machno]));
-	hi("m "); put64((uint64_t)m); hi(" machp "); put64((uint64_t)machp()); hi("\n");
 	if (machp() != m)
-		die("================= m and machp() are different");
-	hi("mbmagic "); put32(mbmagic); hi("\n");
-	hi("mbaddress "); put32(mbaddress); hi("\n");
+		panic("m and machp() are different!!\n");
 	assert(sizeof(Mach) <= PGSZ);
 	int64_t hz;
 
-	// Check that our data is on the right boundaries.
-	// This works because the immediate value is in code.
+	/*
+	 * Check that our data is on the right boundaries.
+	 * This works because the immediate value is in code.
+	 */
 	if (x != 0x123456) 
-		die("data is not set up correctly\n");
-	wave('H');
+		panic("Data is not set up correctly\n");
 	memset(edata, 0, end - edata);
 
 	m = (void *) (KZERO + 1048576 + 11*4096);
 	sys = (void *) (KZERO + 1048576);
-	wave('a');
+
 	/*
 	 * ilock via i8250enable via i8250console
 	 * needs m->machno, sys->machptr[] set, and
 	 * also 'up' set to nil.
 	 */
 	cgapost(sizeof(uintptr_t)*8);
-	wave('r');
 	memset(m, 0, sizeof(Mach));
-	wave('v');
+
 	m->machno = 0;
-	wave('1');
 	m->online = 1;
-	wave('2');
 	m->nixtype = NIXTC;
-	wave('3');
 	sys->machptr[m->machno] = &sys->mach;
-	wave('4');
 	m->stack = PTR2UINT(sys->machstk);
-	wave('5');
 	m->vsvm = sys->vsvmpage;
-	wave('6');
 	m->externup = (void *)0;
 	active.nonline = 1;
 	active.exiting = 0;
 	active.nbooting = 0;
-	wave('e');
+
 	asminit();
-	wave('y');
 	multiboot(mbmagic, mbaddress, 0);
-	wave(';');
 	options(oargc, oargv);
-	wave('s');
-	// later.
-	//crapoptions();
-	wave('a');
+	/*
+	 * later.
+	 * crapoptions();
+	 */
+
 	/*
 	 * Need something for initial delays
 	 * until a timebase is worked out.
@@ -409,68 +408,52 @@ main(uint32_t mbmagic, uint32_t mbaddress)
 	m->cpumhz = 2000;
 
 	cgainit();
-	wave('y');
 	i8250console("0");
 	
-	wave('1');
 	consputs = cgaconsputs;
 
-	wave('2');
-	// It all ends here.
+	/* It all ends here. */
 	vsvminit(MACHSTKSZ, NIXTC);
-	hi("we're back from vsvminit\n");
 	if (machp() != m)
-		die("================= after vsvminit, m and machp() are different");
-	wave('s');
-
+		panic("After vsvminit, m and machp() are different");
 	fmtinit();
 	
-	print("\nNIX\n");
-	print("NIX m = %p / sys = %p \n", m, sys);
-	hi("m is "); put64((uint64_t) m); hi("\n");
-	hi("sys is "); put64((uint64_t) sys); hi("\n");
+	print("\nHarvey\n");
 	sys->nmach = 1;			
 
 	if(1){
 		multiboot(mbmagic, mbaddress, vflag);
 	}
 
-	hi("m: "); put64((uint64_t)m); hi("\n");
 	m->perf.period = 1;
-	hi("archhz\n");
 	if((hz = archhz()) != 0ll){
 		m->cpuhz = hz;
 		m->cyclefreq = hz;
 		m->cpumhz = hz/1000000ll;
 	}
 
-hi("gdb\n");
-print("hi %d", 1);
-print("hi %d", 2);
-print("hi %d", 0x1234);
 	/*
 	 * Mmuinit before meminit because it
 	 * flushes the TLB via m->pml4->pa.
 	 */
-hi("call mmuinit\n");
-{	mmuinit(); hi("	mmuinit();\n");}
-
-hi("wait for gdb\n");
-{	ioinit(); hi("	ioinit();\n");}
-{	kbdinit(); hi("	kbdinit();\n");}
-{	meminit(); hi("	meminit();\n");}
-{	confinit(); hi("	confinit();\n");}
-{	archinit(); hi("	archinit();\n");}
-{	mallocinit(); hi("	mallocinit();\n");}
+	mmuinit();
+	ioinit();
+	kbdinit();
+	meminit();
+	confinit();
+	archinit();
+	mallocinit();
 
 	/* test malloc. It's easier to find out it's broken here, 
 	 * not deep in some call chain.
 	 * See next note. 
-	 */
+	 *
 	void *v = malloc(1234);
 	hi("v "); put64((uint64_t)v); hi("\n");
 	free(v);
 	hi("free ok\n");
+	 */
+
 	/*
 	 * Acpiinit will cause the first malloc
 	 * call to happen.
@@ -482,9 +465,9 @@ hi("wait for gdb\n");
 	 */
 if (0){	acpiinit(); hi("	acpiinit();\n");}
 	
-{	umeminit(); hi("	umeminit();\n");}
-{	trapinit(); hi("	trapinit();\n");}
-{	printinit(); hi("	printinit();\n");}
+	umeminit();
+	trapinit();
+	printinit();
 
 	/*
 	 * This is necessary with GRUB and QEMU.
@@ -492,27 +475,26 @@ if (0){	acpiinit(); hi("	acpiinit();\n");}
 	 * because the vector base is likely different, causing
 	 * havoc. Do it before any APIC initialisation.
 	 */
-{	i8259init(32); hi("	i8259init(32);\n");}
-
+	i8259init(32);
 
-{	procinit0(); hi("	procinit0();\n");}
-{	mpsinit(maxcores); hi("	mpsinit(maxcores);\n");}
-{	apiconline(); hi("	apiconline();\n");}
+	procinit0();
+	mpsinit(maxcores);
+	apiconline();
 if (0) sipi(); 
 
-{	timersinit(); hi("	timersinit();\n");}
-{	kbdenable(); hi("	kbdenable();\n");}
-{	fpuinit(); hi("	fpuinit();\n");}
-{	psinit(conf.nproc); hi("	psinit(conf.nproc);\n");}
-{	initimage(); hi("	initimage();\n");}
-{	links(); hi("	links();\n");}
-{	devtabreset(); hi("	devtabreset();\n");}
-{	pageinit(); hi("	pageinit();\n");}
-{	swapinit(); hi("	swapinit();\n");}
-{	userinit(); hi("	userinit();\n");}
-	if (0) { // NO NIX YET
-		{	nixsquids(); hi("	nixsquids();\n");}
-		{testiccs(); hi("testiccs();\n");}	
+	timersinit();
+	kbdenable();
+	fpuinit();
+	psinit(conf.nproc);
+	initimage();
+	links();
+	devtabreset();
+	pageinit();
+	swapinit();
+	userinit();
+	if (0) { /* NO NIX YET */
+			nixsquids();
+			testiccs();
 	}
 	print("schedinit...\n");
 	schedinit();
@@ -526,8 +508,10 @@ init0(void)
 
 	m->externup->nerrlab = 0;
 
-//	if(consuart == nil)
-//		i8250console("0");
+	/*
+	 * if(consuart == nil)
+	 * i8250console("0");
+	 */
 	spllo();
 
 	/*
@@ -555,7 +539,6 @@ init0(void)
 	}
 	kproc("alarm", alarmkproc, 0);
 	debugtouser((void *)UTZERO);
-	hi("TOUSER!\n");
 	touser(sp);
 }
 
@@ -603,7 +586,7 @@ userinit(void)
 	Segment *s;
 	KMap *k;
 	Page *pg;
-hi("1\n");
+
 	p = newproc();
 	p->pgrp = newpgrp();
 	p->egrp = smalloc(sizeof(Egrp));
@@ -612,12 +595,10 @@ hi("1\n");
 	p->rgrp = newrgrp();
 	p->procmode = 0640;
 
-hi("2\n");
 	kstrdup(&eve, "");
 	kstrdup(&p->text, "*init*");
 	kstrdup(&p->user, eve);
 
-hi("3\n");
 	/*
 	 * Kernel Stack
 	 *
@@ -628,10 +609,8 @@ hi("3\n");
 	 */
 	p->sched.pc = PTR2UINT(init0);
 	p->sched.sp = PTR2UINT(p->kstack+KSTACK-sizeof(m->externup->arg)-sizeof(uintptr_t));
-hi("SP "); put64(p->sched.sp); hi("\n");
 	p->sched.sp = STACKALIGN(p->sched.sp);
 
-hi("4\n");
 	/*
 	 * User Stack
 	 *
@@ -642,15 +621,12 @@ hi("4\n");
 	 */
 	s = newseg(SG_STACK, USTKTOP-USTKSIZE, USTKSIZE/ BIGPGSZ);
 	p->seg[SSEG] = s;
-
-hi("5\n");
 	pg = newpage(1, 0, USTKTOP-BIGPGSZ, BIGPGSZ, -1);
 	segpage(s, pg);
 	k = kmap(pg);
 	bootargs(VA(k));
 	kunmap(k);
 
-hi("6\n");
 	/*
 	 * Text
 	 */
@@ -658,10 +634,8 @@ hi("6\n");
 	s->flushme++;
 	p->seg[TSEG] = s;
 	pg = newpage(1, 0, UTZERO, BIGPGSZ, -1);
-hi("7\n");
 	memset(pg->cachectl, PG_TXTFLUSH, sizeof(pg->cachectl));
 	segpage(s, pg);
-hi("8\n");
 	k = kmap(s->map[0]->pages[0]);
 	//memmove(UINT2PTR(VA(k)), initcode, sizeof(initcode));
 	memmove(UINT2PTR(VA(k)), init_code_out, sizeof(init_code_out));
@@ -674,17 +648,13 @@ hi("8\n");
 	s->flushme++;
 	p->seg[DSEG] = s;
 	pg = newpage(1, 0, UTZERO + BIGPGSZ, BIGPGSZ, -1);
-hi("7\n");
 	memset(pg->cachectl, PG_TXTFLUSH, sizeof(pg->cachectl));
 	segpage(s, pg);
-hi("8\n");
 	k = kmap(s->map[0]->pages[0]);
 	//memmove(UINT2PTR(VA(k)), initcode, sizeof(initcode));
 	memmove(UINT2PTR(VA(k)), init_data_out, sizeof(init_data_out));
 	kunmap(k);
-hi("9\n");
 	ready(p);
-hi("done \n");
 }
 
 void

+ 1 - 1
sys/src/9/k10/multiboot.c

@@ -77,7 +77,7 @@ multiboot(uint32_t magic, uint32_t pmbi, int vflag)
 	if(vflag)
 		print("magic %#ux pmbi %#ux\n", magic, pmbi);
 	if(magic != 0x2badb002)
-		hi("no magic but hey ... \n");//return -1;
+		print("no magic in multiboot\n");//return -1;
 
 	mbi = KADDR(pmbi);
 	if(vflag)

+ 5 - 3
sys/src/9/k10/syscall.c

@@ -250,7 +250,9 @@ syscall(int badscallnr, Ureg *ureg)
 	int64_t startns, stopns;
 	Ar0 ar0;
 	static Ar0 zar0;
-	int printallsyscalls = 1;
+
+	/* Do you want to print syscalls for debugging? */
+	int printallsyscalls = 0;
 
 	if(!userureg(ureg))
 		panic("syscall: cs %#llux\n", ureg->cs);
@@ -362,7 +364,7 @@ syscall(int badscallnr, Ureg *ureg)
 		stopns = todget(nil);
 		sysretfmt(scallnr, &ar0, startns, stopns, a0, a1, a2, a3, a4, a5);
 		if(m->externup->syscalltrace) {
-			iprint("X %s\n", m->externup->syscalltrace);
+			if (0) iprint("X %s\n", m->externup->syscalltrace);
 			free(m->externup->syscalltrace);
 			m->externup->syscalltrace = nil;
 		}
@@ -473,7 +475,7 @@ sysrforkchild(Proc* child, Proc* parent)
 	/* Things from bottom of syscall which were never executed */
 	child->psstate = 0;
 	child->insyscall = 0;
-	iprint("Child SP set tp %p\n", (void *)child->sched.sp);
+	//iprint("Child SP set tp %p\n", (void *)child->sched.sp);
 
 	fpusysrforkchild(child, parent);
 }

+ 0 - 1
sys/src/9/k10/trap.c

@@ -679,7 +679,6 @@ iprint("could not fault %p\n", addr);
 	if (! user)
 		die("fault went bad in kernel\n");
 	else
-		hi("User mode fault\n");
 
 		/*
 		 * It is possible to get here with !user if, for example,

+ 5 - 13
sys/src/9/k10/vsvm.c

@@ -169,17 +169,15 @@ vsvminit(int size, int nixtype)
 		idtinit(idt64, PTR2UINT(idthandlers));
 		//idtinit(acidt64, PTR2UINT(acidthandlers));
 	}
-hi("set m->gdt\n");
 	m->gdt = m->vsvm;
 	memmove(m->gdt, gdt64, sizeof(gdt64));
 	m->tss = &m->vsvm[ROUNDUP(sizeof(gdt64), 16)];
 
 	sd = &((Sd*)m->gdt)[SiTSS];
 	*sd = mksd(PTR2UINT(m->tss), sizeof(Tss)-1, SdP|SdDPL0|SdaTSS, sd+1);
-hi("tssinti\n");
 	tssinit(m, m->stack+size);
 	gdtput(sizeof(gdt64)-1, PTR2UINT(m->gdt), SSEL(SiCS, SsTIGDT|SsRPL0));
-hi("gdtput\n");
+
 #if 0 // NO ACs YET
 	if(nixtype != NIXAC)
 #endif
@@ -192,16 +190,14 @@ hi("gdtput\n");
 	//trput(SSEL(SiTSS, SsTIGDT|SsRPL0));
 	asm volatile("ltr %w0"::"q" (SSEL(SiTSS, SsTIGDT|SsRPL0)));
 
-hi("idtput done\n");
-hi("write fsbase, then gsbase, then etc.\n");
 	wrmsr(FSbase, 0ull);
 	wrmsr(GSbase, PTR2UINT(&sys->machptr[m->machno]));
 	wrmsr(KernelGSbase, 0ull);
-hi("done that\n");
 
 	r = rdmsr(Efer);
 	r |= Sce;
 	wrmsr(Efer, r);
+
 	/* Hey! This is weird! Why a 32-bit CS?
 	 * Because, when you do a retq, the CPU adds 16 to
 	 * the bits derived from 63:48, and then uses that. See the
@@ -212,21 +208,17 @@ hi("done that\n");
 	 */
 	r = ((uint64_t)SSEL(SiU32CS, SsRPL3))<<48;
 	r |= ((uint64_t)SSEL(SiCS, SsRPL0))<<32;
-hi("wirte Star!\n");
 	wrmsr(Star, r);
-	uint64_t x = rdmsr(Star);
-iprint("start 0x%lx\n", x);
-hi("wirte Lstar!\n");
+
 	if(nixtype != NIXAC)
 		wrmsr(Lstar, PTR2UINT(syscallentry));
 	else
 		wrmsr(Lstar, PTR2UINT(acsyscallentry));
-hi("wirte Sfmask!\n");
+
 	wrmsr(Sfmask, If);
 	if (m != machp()) {
-		die("vsvminit: m is not machp() at end\n");
+		panic("vsvminit: m is not machp() at end\n");
 	}
-hi("vsvminit done!\n");
 }
 
 int

+ 0 - 2
sys/src/9/port/devcons.c

@@ -443,7 +443,6 @@ panic(char *fmt, ...)
 	//dumpstack();
 	delay(1000);	/* give time to consoles */
 
-die(fmt);
 	exit(1);
 }
 #pragma profile 1
@@ -495,7 +494,6 @@ pprint(char *fmt, ...)
 	c->offset += n;
 	unlock(c);
 
-die("pprint");
 	return n;
 }
 

+ 0 - 4
sys/src/9/port/devtab.c

@@ -25,8 +25,6 @@ devtabreset(void)
 	int i;
 
 	for(i = 0; devtab[i] != nil; i++) {
-		hi("dtreset "); put64(i); hi(" call ");
-		put64((uint64_t)devtab[i]->reset); hi("\n");
 		devtab[i]->reset();
 	}
 }
@@ -37,8 +35,6 @@ devtabinit(void)
 	int i;
 
 	for(i = 0; devtab[i] != nil; i++) {
-		hi("dtinit "); put64(i); hi(" call ");
-		put64((uint64_t)devtab[i]->init); hi("\n");
 		devtab[i]->init();
 	}
 }

+ 2 - 2
sys/src/9/port/proc.c

@@ -1163,7 +1163,7 @@ sleep(Rendez *r, int (*f)(void*), void *arg)
 		iprint("double sleep called from %#p, %d %d\n",
 			getcallerpc(&r), r->_p->pid, m->externup->pid);
 		dumpstack();
-		die("double sleep");
+		panic("double sleep");
 	}
 
 	/*
@@ -1527,7 +1527,7 @@ pexit(char *exitstr, int freemem)
 		if(p == 0) {
 			if(exitstr == 0)
 				exitstr = "unknown";
-			die("bootprocessdeath");
+			//die("bootprocessdeath");
 			panic("boot process died: %s", exitstr);
 		}
 

+ 0 - 1
sys/src/9/port/segment.c

@@ -251,7 +251,6 @@ segpage(Segment *s, Page *p)
 		s->color = p->color;
 	if(s->pgszi != p->pgszi) {
 		iprint("s %p s->pgszi %d p %p p->pgszi %p\n", s, s->pgszi, p, p->pgszi);
-		die("BAD!");
 		panic("segpage: s->pgszi != p->pgszi");
 	}
 

+ 1 - 63
sys/src/cmd/rc/exec.c

@@ -130,6 +130,7 @@ newvar(char *name, var *next)
 	v->next = next;
 	return v;
 }
+
 /*
  * get command line flags, initialize keywords & traps.
  * get values from environment.
@@ -138,72 +139,9 @@ newvar(char *name, var *next)
  * start interpreting code
  */
 
-#ifndef CRAP
-// The old plan 9 standby ... wave ... 
-void wave(int c)
-{
-	write(1, &c, 1);
-}
-
-void hi(char *s) 
-{
-	while (*s)
-		wave(*s++);
-}
-	// for gdb: 
-	// call this anywhere in your code. 
-	//die("yourturn with gdb\n");
-	// gdb 9k
-	// target remote localhost:1234
-	// display/i $pc
-	// set staydead = 0
-	// stepi, and debug. 
-	// note, you can always resume after a die. Just set staydead = 0
-int staydead = 1;
-void die(char *s)
-{
-	wave('d');
-	wave('i');
-	wave('e');
-	wave(':');
-	hi(s);
-	while(staydead);
-	staydead = 1;
-}
-void bmemset(void *p)
-{
-	__asm__ __volatile__("1: jmp 1b");
-}
-
-void put8(uint8_t c)
-{
-	static char x[] = "0123456789abcdef";
-	wave(x[c>>4]);
-	wave(x[c&0xf]);
-}
-
-void put16(uint16_t s)
-{
-	put8(s>>8);
-	put8(s);
-}
-
-void put32(uint32_t u)
-{
-	put16(u>>16);
-	put16(u);
-}
-
-void put64(uint64_t v)
-{
-	put32(v>>32);
-	put32(v);
-}
-#endif
 void
 main(int argc, char *argv[])
 {
-	print("Hello, I am Harvey!!\n");
 	code bootstrap[17];
 	char num[12], *rcmain;
 	int i;