Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/amd64/amd64 clarify



details:   https://anonhg.NetBSD.org/src/rev/07b020bbcded
branches:  trunk
changeset: 345091:07b020bbcded
user:      maxv <maxv%NetBSD.org@localhost>
date:      Sat May 07 11:49:21 2016 +0000

description:
clarify

diffstat:

 sys/arch/amd64/amd64/locore.S |  275 +++++++++++++++++++++++------------------
 1 files changed, 151 insertions(+), 124 deletions(-)

diffs (truncated from 642 to 300 lines):

diff -r 400715622166 -r 07b020bbcded sys/arch/amd64/amd64/locore.S
--- a/sys/arch/amd64/amd64/locore.S     Sat May 07 08:52:10 2016 +0000
+++ b/sys/arch/amd64/amd64/locore.S     Sat May 07 11:49:21 2016 +0000
@@ -1,10 +1,39 @@
-/*     $NetBSD: locore.S,v 1.83 2015/11/25 16:00:09 maxv Exp $ */
+/*     $NetBSD: locore.S,v 1.84 2016/05/07 11:49:21 maxv Exp $ */
 
 /*
  * Copyright-o-rama!
  */
 
 /*
+ * Copyright (c) 1998, 2000, 2007, 2008, 2016 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Charles M. Hannum and Maxime Villard.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
  * Copyright (c) 2007 Manuel Bouyer.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -80,36 +109,6 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
-
-/*-
- * Copyright (c) 1998, 2000, 2007, 2008 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Charles M. Hannum.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
  * All rights reserved.
@@ -144,9 +143,7 @@
  *     @(#)locore.s    7.3 (Berkeley) 5/13/91
  */
 
-/*
- * override user-land alignment before including asm.h
- */
+/* Override user-land alignment before including asm.h */
 #define        ALIGN_DATA      .align  8
 #define ALIGN_TEXT     .align 16,0x90
 #define _ALIGN_TEXT    ALIGN_TEXT
@@ -184,7 +181,6 @@
 #include <machine/i82489reg.h>
 #endif
 
-/* XXX temporary kluge; these should not be here */
 /* Get definitions for IOM_BEGIN, IOM_END, and IOM_SIZE */
 #include <dev/isa/isareg.h>
 
@@ -204,7 +200,7 @@
 #endif
 
 #define PROC0_PML4_OFF 0
-#define PROC0_STK_OFF  (PROC0_PML4_OFF + PAGE_SIZE)
+#define PROC0_STK_OFF  (PROC0_PML4_OFF + 1 * PAGE_SIZE)
 #define PROC0_PTP3_OFF (PROC0_STK_OFF + UPAGES * PAGE_SIZE)
 #define PROC0_PTP2_OFF (PROC0_PTP3_OFF + NKL4_KIMG_ENTRIES * PAGE_SIZE)
 #define PROC0_PTP1_OFF (PROC0_PTP2_OFF + TABLE_L3_ENTRIES * PAGE_SIZE)
@@ -222,20 +218,27 @@
  */
 #define fillkpt        \
 1:     movl    %eax,(%ebx)             ;       /* store phys addr */   \
-       movl    $0,(PDE_SIZE-4)(%ebx)   ;       /* upper 32 bits 0 */   \
+       movl    $0,(PDE_SIZE-4)(%ebx)   ;       /* upper 32 bits: 0 */  \
        addl    $PDE_SIZE,%ebx          ;       /* next PTE/PDE */      \
        addl    $PAGE_SIZE,%eax         ;       /* next phys page */    \
        loop    1b                      ;
 
+/*
+ * killkpt - Destroy a kernel page table (long mode)
+ *     rbx = page table address
+ *     rcx = number of pages to destroy
+ */
+#define killkpt \
+1:     movq    $0,(%rbx)       ; \
+       addq    $PDE_SIZE,%rbx  ; \
+       loop    1b              ;
+
 
 #ifdef XEN
-
 /*
  * Xen guest identifier and loader selection
  */
-
 .section __xen_guest
-
        .ascii  "GUEST_OS=NetBSD,GUEST_VER=4.99"
        .ascii  ",XEN_VER=xen-3.0"
        .ascii  ",LOADER=generic"
@@ -247,7 +250,6 @@
        .ascii  ",BSD_SYMTAB=yes"
 #endif
        .byte   0
-
 #endif /* XEN */
 
 /*
@@ -257,9 +259,9 @@
 
 #if NLAPIC > 0
        .align  PAGE_SIZE
-       .globl _C_LABEL(local_apic)
-       .globl _C_LABEL(lapic_id)
-       .globl _C_LABEL(lapic_tpr)
+       .globl  _C_LABEL(local_apic)
+       .globl  _C_LABEL(lapic_id)
+       .globl  _C_LABEL(lapic_tpr)
 
        .type   _C_LABEL(local_apic), @object
 LABEL(local_apic)
@@ -282,7 +284,7 @@
 _C_LABEL(lapic_isr):
        .space  PAGE_SIZE-LAPIC_ISR
 END(lapic_isr)
-#endif
+#endif /* NLAPIC > 0 */
 
        .globl  _C_LABEL(cpuid_level)
        .globl  _C_LABEL(esym)
@@ -297,34 +299,33 @@
        .globl  _C_LABEL(cputype)
 
        .type   _C_LABEL(cputype), @object
-LABEL(cputype)         .long   0       # are we 80486, Pentium, or..
+LABEL(cputype)         .long   0       /* are we 80486, Pentium, or.. */
 END(cputype)
        .type   _C_LABEL(cpuid_level), @object
-LABEL(cpuid_level)     .long   -1      # max. level accepted by 'cpuid'
-                                       #   instruction
+LABEL(cpuid_level)     .long   -1      /* max. level accepted by cpuid instr */
 END(cpuid_level)
        .type   _C_LABEL(esym), @object
-LABEL(esym)            .quad   0       # ptr to end of syms
+LABEL(esym)            .quad   0       /* ptr to end of syms */
 END(esym)
        .type   _C_LABEL(eblob), @object
-LABEL(eblob)           .quad   0       # ptr to end of modules
+LABEL(eblob)           .quad   0       /* ptr to end of modules */
 END(eblob)
        .type   _C_LABEL(atdevbase), @object
-LABEL(atdevbase)       .quad   0       # location of start of iomem in virtual
+LABEL(atdevbase)       .quad   0       /* location of start of iomem in virt */
 END(atdevbase)
        .type   _C_LABEL(PDPpaddr), @object
-LABEL(PDPpaddr)                .quad   0       # paddr of PTD, for libkvm
+LABEL(PDPpaddr)                .quad   0       /* paddr of PTD, for libkvm */
 END(PDPpaddr)
        .type   _C_LABEL(biosbasemem), @object
 #ifndef REALBASEMEM
-LABEL(biosbasemem)     .long   0       # base memory reported by BIOS
+LABEL(biosbasemem)     .long   0       /* base memory reported by BIOS */
 #else
 LABEL(biosbasemem)     .long   REALBASEMEM
 #endif
 END(biosbasemem)
        .type   _C_LABEL(biosextmem), @object
 #ifndef REALEXTMEM
-LABEL(biosextmem)      .long   0       # extended memory reported by BIOS
+LABEL(biosextmem)      .long   0       /* extended memory reported by BIOS */
 #else
 LABEL(biosextmem)      .long   REALEXTMEM
 #endif
@@ -335,7 +336,6 @@
        .globl  gdt64_hi
 
 #define GDT64_LIMIT gdt64_end-gdt64_start-1
-
 /* Temporary gdt64, with base address in low memory */
        .type   _C_LABEL(gdt64_lo), @object
 LABEL(gdt64_lo)
@@ -351,7 +351,6 @@
        .quad   gdt64_start
 END(gdt64_hi)
 .align 64
-
 #undef GDT64_LIMIT
 
        .type   _C_LABEL(gdt64_start), @object
@@ -367,11 +366,12 @@
        .long   _RELOC(longmode)
        .word   GSEL(GCODE_SEL, SEL_KPL)
 END(farjmp64)
-       
+
 #endif /* !XEN */
 
+       /* Space for the temporary stack */
        .size   tmpstk, tmpstk - .
-       .space 512
+       .space  512
 tmpstk:
 
        .globl _C_LABEL(cpu_private)
@@ -394,7 +394,7 @@
        movw    $0x1234,0x472
 
        /*
-        * Load parameters from the stack (32 bits):   
+        * Load parameters from the stack (32 bits):
         *     boothowto, [bootdev], bootinfo, esym, biosbasemem, biosextmem
         * We are not interested in 'bootdev'.
         */
@@ -425,7 +425,7 @@
        pushl   %esi
        pushl   %eax
 
-       movl    (%ecx),%eax             /* size of entry */
+       movl    (%ecx),%eax             /* btinfo_common::len (size of entry) */
        movl    %edx,%edi
        addl    (%ecx),%edx             /* update dest pointer */
        cmpl    %ebp,%edx               /* beyond bootinfo+BOOTINFO_MAXSIZE? */
@@ -438,10 +438,10 @@
         * If any modules were loaded, record where they end.  We'll need to
         * skip over them.
         */
-       cmpl    $BTINFO_MODULELIST,4(%esi)
+       cmpl    $BTINFO_MODULELIST,4(%esi) /* btinfo_common::type */
        jne     0f
 
-       pushl   12(%esi)                /* endpa */
+       pushl   12(%esi)                /* btinfo_modulelist::endpa */
        popl    RELOC(eblob)
        addl    $KERNBASE_LO,RELOC(eblob)
        adcl    $KERNBASE_HI,RELOC(eblob)+4
@@ -501,8 +501,10 @@
 
 biosbasemem_finished:
        /*
-        * Done with the parameters. First, reset the PSL.
+        * Done with the parameters!
         */
+
+       /* First, reset the PSL. */
        pushl   $PSL_MBO
        popfl
 
@@ -519,23 +521,39 @@
         * The boot program should check:
         *      text+data <= &stack_variable - more_space_for_stack
         *      text+data+bss+pad+space_for_page_tables <= end_of_memory
-        * Oops, the gdt is in the carcass of the boot program so clearing
+        * 
+        * XXX: the gdt is in the carcass of the boot program so clearing
         * the rest of memory is still not possible.
         */
        movl    $RELOC(tmpstk),%esp
 
 /*



Home | Main Index | Thread Index | Old Index