PERFORCE change 32142 for review

Peter Wemm peter at FreeBSD.org
Fri May 30 18:53:00 PDT 2003


http://perforce.freebsd.org/chv.cgi?CH=32142

Change 32142 by peter at peter_hammer on 2003/05/30 18:52:09

	Minor tweaks.  Have hammer_time() take arguments and return
	the new stack location.  Have locore switch to the proc0 kstack
	rather than run mi_startup (aka proc0) on the tiny bootstack -
	this is bad because acpica overflows it.  Tidy up locore.S.

Affected files ...

.. //depot/projects/hammer/sys/amd64/amd64/locore.S#6 edit
.. //depot/projects/hammer/sys/amd64/amd64/machdep.c#42 edit

Differences ...

==== //depot/projects/hammer/sys/amd64/amd64/locore.S#6 (text+ko) ====

@@ -69,17 +69,15 @@
 
 	/* Find the metadata pointers before we lose them */
 	movq	%rsp, %rbp
-	xorq	%rax, %rax
-	movl	4(%rbp),%eax		/* modulep */
-	movq	%rax,modulep
-	movl	8(%rbp),%eax		/* kernend */
-	movq	%rax,physfree
+	movl	4(%rbp),%edi		/* modulep (arg 1) */
+	movl	8(%rbp),%esi		/* kernend (arg 2) */
 
 	/* Get onto a stack that we can trust - there is no going back now. */
 	movq	$bootstack,%rsp
-	xorq	%rbp, %rbp
+	xorl	%ebp, %ebp
 
 	call	hammer_time		/* set up cpu for unix operation */
+	movq	%rax,%rsp		/* set up kstack for mi_startup() */
 	call	mi_startup		/* autoconfiguration, mountroot etc */
 0:	hlt
 	jmp	0b

==== //depot/projects/hammer/sys/amd64/amd64/machdep.c#42 (text+ko) ====

@@ -112,7 +112,7 @@
 #include <sys/ptrace.h>
 #include <machine/sigframe.h>
 
-extern void hammer_time(void);
+extern u_int64_t hammer_time(u_int64_t, u_int64_t);
 extern void dblfault_handler(void);
 
 extern void printcpuinfo(void);	/* XXX header file */
@@ -131,9 +131,6 @@
 int	_udatasel, _ucodesel, _ucode32sel;
 u_long	atdevbase;
 
-u_int64_t	modulep;	/* phys addr of metadata table */
-u_int64_t	physfree;	/* first free page after kernel */
-
 int cold = 1;
 
 long Maxmem = 0;
@@ -1070,19 +1067,8 @@
 	avail_end = phys_avail[pa_indx];
 }
 
-static u_int64_t
-allocpages(int n)
-{
-	u_int64_t ret;
-
-	ret = physfree;
-	bzero((void *)ret, n * PAGE_SIZE);
-	physfree += n * PAGE_SIZE;
-	return (ret);
-}
-
-void
-hammer_time(void)
+u_int64_t
+hammer_time(u_int64_t modulep, u_int64_t physfree)
 {
 	caddr_t kmdp;
 	int gsel_tss, off, x;
@@ -1095,10 +1081,15 @@
 	msr = rdmsr(MSR_EFER) | EFER_NXE;
 	wrmsr(MSR_EFER, msr);
 
-	proc0.p_uarea = (struct user *)(allocpages(UAREA_PAGES) + KERNBASE);
-	thread0.td_kstack = allocpages(KSTACK_PAGES) + KERNBASE;
+	proc0.p_uarea = (struct user *)(physfree + KERNBASE);
+	bzero(proc0.p_uarea, UAREA_PAGES * PAGE_SIZE);
+	physfree += UAREA_PAGES * PAGE_SIZE;
+	thread0.td_kstack = physfree + KERNBASE;
+	bzero((void *)thread0.td_kstack, KSTACK_PAGES * PAGE_SIZE);
+	physfree += KSTACK_PAGES * PAGE_SIZE;
 	thread0.td_pcb = (struct pcb *)
 	   (thread0.td_kstack + KSTACK_PAGES * PAGE_SIZE) - 1;
+
 	atdevbase = ISA_HOLE_START + KERNBASE;
 
 	/*
@@ -1244,6 +1235,9 @@
         env = getenv("kernelname");
 	if (env != NULL)
 		strlcpy(kernelname, env, sizeof(kernelname));
+
+	/* Location of kernel stack for locore */
+	return ((u_int64_t)thread0.td_pcb);
 }
 
 void


More information about the p4-projects mailing list