PERFORCE change 28383 for review
Peter Wemm
peter at FreeBSD.org
Sun Apr 6 18:41:49 PDT 2003
http://perforce.freebsd.org/chv.cgi?CH=28383
Change 28383 by peter at peter_overcee on 2003/04/06 18:41:33
Strip out create_pagetables with the intention of doing it in
machdep.c. Test the console hacks. Call printf (varargs, ugh)
to check it.
Affected files ...
.. //depot/projects/hammer/sys/x86_64/x86_64/locore.s#29 edit
Differences ...
==== //depot/projects/hammer/sys/x86_64/x86_64/locore.s#29 (text+ko) ====
@@ -71,68 +71,22 @@
*
*/
-#define ALLOCPAGES(foo) \
- movq physfree, %rsi ; \
- movq $((foo)*PAGE_SIZE), %rax ; \
- addq %rsi, %rax ; \
- movq %rax, physfree ; \
- movq %rsi, %rdi ; \
- movq $((foo)*PAGE_SIZE), %rcx ; \
- xorq %rax, %rax ; \
- cld ; \
- rep ; \
- stosb
-
-/*
- * fillkpt
- * eax = page frame address
- * ebx = index into page table
- * ecx = how many pages to map
- * base = base address of page dir/table
- * prot = protection bits
- */
-#define fillkpt(base, prot) \
- shll $PTESHIFT,%ebx ; \
- addl base,%ebx ; \
- orl $PG_V,%eax ; \
- orl prot,%eax ; \
-1: movl %eax,(%ebx) ; \
- addl $PAGE_SIZE,%eax ; /* increment physical address */ \
- addl $PTESIZE,%ebx ; /* next pte */ \
- loop 1b
-
-/*
- * fillkptphys(prot)
- * eax = physical address
- * ecx = how many pages to map
- * prot = protection bits
- */
-#define fillkptphys(prot) \
- movl %eax, %ebx ; \
- shrl $PAGE_SHIFT, %ebx ; \
- fillkpt(KPTphys, prot)
-
#define PING(a) \
- movb $(a),%bl; \
+ movq $(a),%rdi; \
call serial_putc
.text
/**********************************************************************
*
- * This is where the bootblocks start us, set the ball rolling...
+ * This is where the loader trampoline start us, set the ball rolling...
*
*/
NON_GPROF_ENTRY(btext)
-/* Tell the bios to warmboot next time */
+ /* Tell the bios to warmboot next time */
movw $0x1234,0x472
-/* Get onto a stack that we can trust and set up a real frame. */
- movq $HIDENAME(tmpstk),%rsp
- pushq %rbp
- movq %rsp, %rbp
-
-/* Don't trust what the BIOS gives for eflags. */
+ /* Don't trust what the loader gives for rflags. */
pushq $PSL_KERNEL
popfq
@@ -153,22 +107,41 @@
PING('!');
PING('\r');
PING('\n');
+
+ movq $str, %rdi
+ call serial_puts
+
+ movq $prf, %rdi
+ movl $0x12ab34ef, %esi
+ xorl %eax, %eax
+ call printf
+
+ /* Find the metadata pointers before we lose them */
+ movq 32(%rbp),%rax /* modulep */
+ movq %rax,modulep
+ movq 36(%rbp),%rax /* kernend */
+ movq %rax,KERNend
+
+ /* Get onto a stack that we can trust and set up a real frame. */
+ movq $HIDENAME(tmpstk),%rsp
+ pushq %rbp
+ movq %rsp, %rbp
+
hlt
+
+str:
+ .asciz "this is a string\n"
+prf:
+ .asciz "This is a number: %#x\n"
#if 0
- call recover_metadata
PING('i');
call identify_cpu
PING('T');
- call create_pagetables
-
PING('h');
PING('e');
PING('r');
PING('e');
- PING('0')
-paging:
- PING('1')
/* set up bootstrap stack */
movq proc0kstack,%rax /* location of in-kernel stack */
@@ -196,30 +169,7 @@
0: hlt
jmp 0b
-/**********************************************************************
- *
- * Recover the metadata passed to us from the boot program
- *
- */
-recover_metadata:
- /*
- * New uniform boot code:
- * (*btext)(howto, bootdev, 0, 0, 0, &bootinfo, modulep, kernend)
- * [return address != 0, and can be returned to]
- *
- * There may seem to be a lot of wasted arguments in here, but
- * that is so the newer boot code can still load very old kernels
- * and old boot code can load new kernels.
- */
-
- movq 32(%rbp),%rax /* modulep */
- movq %rax,modulep
- movq 36(%rbp),%rax /* kernend */
- movq %rax,KERNend
-
- ret
-
/**********************************************************************
*
* Identify the CPU and initialize anything special about it
@@ -241,120 +191,11 @@
movl %ebx,cpu_procinfo # store cpu_procinfo
movl %edx,cpu_feature # store cpu_feature
ret
+#endif
-/**********************************************************************
- *
- * Create the first page directory and its page tables.
- *
- */
-
-create_pagetables:
-
-/* We are told where the end of the kernel space is. */
- movl KERNend, %esi /* get end of kernel */
- movl %esi, physfree /* next free page is at end of kernel */
-
-/* Allocate Kernel Page Tables */
- ALLOCPAGES(NKPT)
- movl %esi, KPTphys
-
-/* Allocate Page Table Directory */
- ALLOCPAGES(1)
- movl %esi, IdlePML4
- ALLOCPAGES(1)
- movl %esi, IdlePDP
- ALLOCPAGES(NPGPTD)
- movl %esi, IdlePTD
-
-/* Allocate UPAGES */
- ALLOCPAGES(UAREA_PAGES)
- movl %esi, p0upa
- addl $KERNBASE, %esi
- movl %esi, proc0uarea
-
- ALLOCPAGES(KSTACK_PAGES)
- movl %esi, p0kpa
- addl $KERNBASE, %esi
- movl %esi, proc0kstack
-
-/* Map read-only from zero to the end of the kernel text section */
- xorl %eax, %eax
- xorl %edx,%edx
- movl $etext,%ecx
- addl $PAGE_MASK,%ecx
- shrl $PAGE_SHIFT,%ecx
- fillkptphys(%edx)
-
-/* Map read-write, data, bss and symbols */
- movl $etext, %eax
- addl $PAGE_MASK, %eax
- andl $~PAGE_MASK, %eax
- movl $PG_RW,%edx
- movl KERNend, %ecx
- subl %eax,%ecx
- shrl $PAGE_SHIFT,%ecx
- fillkptphys(%edx)
-
-/* Map page directory. */
- movl IdlePML4, %eax
- movl $1, %ecx
- fillkptphys($PG_RW)
+/***********************************************************************/
- movl IdlePDP, %eax
- movl $1, %ecx
- fillkptphys($PG_RW)
-
- movl IdlePTD, %eax
- movl $NPGPTD, %ecx
- fillkptphys($PG_RW)
-
-/* Map proc0's UPAGES in the physical way ... */
- movl p0upa, %eax
- movl $(UAREA_PAGES), %ecx
- fillkptphys($PG_RW)
-
-/* Map proc0's KSTACK in the physical way ... */
- movl p0kpa, %eax
- movl $(KSTACK_PAGES), %ecx
- fillkptphys($PG_RW)
-
-/* Map ISA hole */
- movl $ISA_HOLE_START, %eax
- movl $ISA_HOLE_LENGTH>>PAGE_SHIFT, %ecx
- fillkptphys($PG_RW)
-
-/* install a pde for temporary double map of bottom of VA */
- movl KPTphys, %eax
- xorl %ebx, %ebx
- movl $NKPT, %ecx
- fillkpt(IdlePTD, $PG_RW)
-
-/* install pde's for pt's */
- movl KPTphys, %eax
- movl $KPTDI, %ebx
- movl $NKPT, %ecx
- fillkpt(IdlePTD, $PG_RW)
-
-/* install a pde recursively mapping page directory as a page table */
- movl IdlePTD, %eax
- movl $PTDPTDI, %ebx
- movl $NPGPTD,%ecx
- fillkpt(IdlePTD, $PG_RW)
-
- movl IdlePTD, %eax
- xorl %ebx, %ebx
- movl $NPGPTD, %ecx
- fillkpt(IdlePDP, $0x0)
-
- movl IdlePDP, %eax
- xorl %ebx, %ebx
- movl $1, %ecx
- fillkpt(IdlePML4, $0x0)
-
- ret
-
-#endif
.bss
ALIGN_DATA /* just to be sure */
.globl HIDENAME(tmpstk)
@@ -389,7 +230,7 @@
testb $0x20, %al
je 1b # TX buffer not empty
- movb %bl, %al
+ movq %rdi, %rax
subl $5, %edx # TX output reg
outb %al, %dx # send this one
@@ -397,45 +238,6 @@
ret
/*
- * int serial_getc(void);
- * Read a character from port COMCONSOLE.
- */
- .globl serial_getc
- .type serial_getc at function
-serial_getc:
- mov $COMCONSOLE + 5, %edx # line status reg
-1:
- inb %dx, %al
- testb $0x01, %al
- je 1b # no rx char available
-
- xorl %eax, %eax
- subl $5, %edx # rx buffer reg
- inb %dx, %al # fetch (first) character
-
- andb $0x7F, %al # remove any parity bits we get
- cmpb $0x7F, %al # make DEL...
- jne 2f
- movb $0x08, %al # look like BS
-2:
- ret
-
-/*
- * int serial_ischar(void);
- * If there is a character in the input buffer of port COMCONSOLE,
- * return nonzero; otherwise return 0.
- */
-
- .globl serial_ischar
- .type serial_ischar at function
-serial_ischar:
- xorl %eax, %eax
- movl $COMCONSOLE + 5, %edx # line status reg
- inb %dx, %al
- andb $0x01, %al # rx char available?
- ret
-
-/*
* void init_serial(void);
* Initialize port COMCONSOLE to speed CONSPEED, line settings 8N1.
*/
More information about the p4-projects
mailing list