[BACK]Return to locore.S CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / sys / arch / i386 / i386

Annotation of src/sys/arch/i386/i386/locore.S, Revision 1.50.2.1

1.50.2.1! yamt        1: /*     $NetBSD$        */
        !             2:
        !             3: /*
        !             4:  * Copyright-o-rama!
        !             5:  */
        !             6:
        !             7: /*
        !             8:  * Copyright (c) 2001 Wasabi Systems, Inc.
        !             9:  * All rights reserved.
        !            10:  *
        !            11:  * Written by Frank van der Linden for Wasabi Systems, Inc.
        !            12:  *
        !            13:  * Redistribution and use in source and binary forms, with or without
        !            14:  * modification, are permitted provided that the following conditions
        !            15:  * are met:
        !            16:  * 1. Redistributions of source code must retain the above copyright
        !            17:  *    notice, this list of conditions and the following disclaimer.
        !            18:  * 2. Redistributions in binary form must reproduce the above copyright
        !            19:  *    notice, this list of conditions and the following disclaimer in the
        !            20:  *    documentation and/or other materials provided with the distribution.
        !            21:  * 3. All advertising materials mentioning features or use of this software
        !            22:  *    must display the following acknowledgement:
        !            23:  *      This product includes software developed for the NetBSD Project by
        !            24:  *      Wasabi Systems, Inc.
        !            25:  * 4. The name of Wasabi Systems, Inc. may not be used to endorse
        !            26:  *    or promote products derived from this software without specific prior
        !            27:  *    written permission.
        !            28:  *
        !            29:  * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
        !            30:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
        !            31:  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
        !            32:  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL WASABI SYSTEMS, INC
        !            33:  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
        !            34:  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
        !            35:  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
        !            36:  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
        !            37:  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
        !            38:  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
        !            39:  * POSSIBILITY OF SUCH DAMAGE.
        !            40:  */
        !            41:
1.1       fvdl       42:
                     43: /*-
1.48      yamt       44:  * Copyright (c) 1998, 2000, 2004, 2006, 2007 The NetBSD Foundation, Inc.
1.1       fvdl       45:  * All rights reserved.
                     46:  *
                     47:  * This code is derived from software contributed to The NetBSD Foundation
                     48:  * by Charles M. Hannum.
                     49:  *
                     50:  * Redistribution and use in source and binary forms, with or without
                     51:  * modification, are permitted provided that the following conditions
                     52:  * are met:
                     53:  * 1. Redistributions of source code must retain the above copyright
                     54:  *    notice, this list of conditions and the following disclaimer.
                     55:  * 2. Redistributions in binary form must reproduce the above copyright
                     56:  *    notice, this list of conditions and the following disclaimer in the
                     57:  *    documentation and/or other materials provided with the distribution.
                     58:  * 3. All advertising materials mentioning features or use of this software
                     59:  *    must display the following acknowledgement:
                     60:  *        This product includes software developed by the NetBSD
                     61:  *        Foundation, Inc. and its contributors.
                     62:  * 4. Neither the name of The NetBSD Foundation nor the names of its
                     63:  *    contributors may be used to endorse or promote products derived
                     64:  *    from this software without specific prior written permission.
                     65:  *
                     66:  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
                     67:  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
                     68:  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
                     69:  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
                     70:  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
                     71:  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
                     72:  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
                     73:  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
                     74:  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
                     75:  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
                     76:  * POSSIBILITY OF SUCH DAMAGE.
                     77:  */
                     78:
                     79: /*-
                     80:  * Copyright (c) 1990 The Regents of the University of California.
                     81:  * All rights reserved.
                     82:  *
                     83:  * This code is derived from software contributed to Berkeley by
                     84:  * William Jolitz.
                     85:  *
                     86:  * Redistribution and use in source and binary forms, with or without
                     87:  * modification, are permitted provided that the following conditions
                     88:  * are met:
                     89:  * 1. Redistributions of source code must retain the above copyright
                     90:  *    notice, this list of conditions and the following disclaimer.
                     91:  * 2. Redistributions in binary form must reproduce the above copyright
                     92:  *    notice, this list of conditions and the following disclaimer in the
                     93:  *    documentation and/or other materials provided with the distribution.
1.12      agc        94:  * 3. Neither the name of the University nor the names of its contributors
1.1       fvdl       95:  *    may be used to endorse or promote products derived from this software
                     96:  *    without specific prior written permission.
                     97:  *
                     98:  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
                     99:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
                    100:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
                    101:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
                    102:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                    103:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
                    104:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                    105:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                    106:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                    107:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                    108:  * SUCH DAMAGE.
                    109:  *
                    110:  *     @(#)locore.s    7.3 (Berkeley) 5/13/91
                    111:  */
                    112:
1.18      christos  113: #include "opt_compat_oldboot.h"
1.1       fvdl      114: #include "opt_cputype.h"
                    115: #include "opt_ddb.h"
                    116: #include "opt_realmem.h"
1.18      christos  117: #include "opt_vm86.h"
1.1       fvdl      118:
                    119: #include "npx.h"
                    120: #include "assym.h"
                    121: #include "lapic.h"
                    122: #include "ioapic.h"
1.8       fvdl      123: #include "ksyms.h"
1.1       fvdl      124:
                    125: #include <sys/errno.h>
                    126: #include <sys/syscall.h>
                    127:
                    128: #include <machine/cputypes.h>
                    129: #include <machine/segments.h>
                    130: #include <machine/specialreg.h>
                    131: #include <machine/trap.h>
                    132: #include <machine/i82489reg.h>
1.37      jmmv      133: #include <machine/multiboot.h>
1.1       fvdl      134: #include <machine/asm.h>
1.48      yamt      135: #include <machine/frameasm.h>
                    136: #include <machine/i82489reg.h>
1.1       fvdl      137:
                    138: /* XXX temporary kluge; these should not be here */
                    139: /* Get definitions for IOM_BEGIN, IOM_END, and IOM_SIZE */
                    140: #include <dev/isa/isareg.h>
                    141:
                    142: /*
                    143:  * Initialization
                    144:  */
                    145:        .data
                    146:
                    147:        .globl  _C_LABEL(cpu)
1.38      jmmv      148:        .globl  _C_LABEL(esym)
                    149:        .globl  _C_LABEL(atdevbase)
1.40      yamt      150:        .globl  _C_LABEL(proc0uarea),_C_LABEL(PDPpaddr)
1.1       fvdl      151:        .globl  _C_LABEL(gdt)
                    152:        .globl  _C_LABEL(idt)
1.30      junyoung  153:        .globl  _C_LABEL(lapic_tpr)
                    154:
1.1       fvdl      155: #if NLAPIC > 0
                    156: #ifdef __ELF__
1.7       thorpej   157:        .align  PAGE_SIZE
1.1       fvdl      158: #else
                    159:        .align  12
                    160: #endif
                    161:        .globl _C_LABEL(local_apic), _C_LABEL(lapic_id)
                    162: _C_LABEL(local_apic):
                    163:        .space  LAPIC_ID
1.30      junyoung  164: _C_LABEL(lapic_id):
1.1       fvdl      165:        .long   0x00000000
                    166:        .space  LAPIC_TPRI-(LAPIC_ID+4)
1.30      junyoung  167: _C_LABEL(lapic_tpr):
1.1       fvdl      168:        .space  LAPIC_PPRI-LAPIC_TPRI
1.30      junyoung  169: _C_LABEL(lapic_ppr):
1.1       fvdl      170:        .space  LAPIC_ISR-LAPIC_PPRI
                    171: _C_LABEL(lapic_isr):
1.7       thorpej   172:        .space  PAGE_SIZE-LAPIC_ISR
1.1       fvdl      173: #else
1.30      junyoung  174: _C_LABEL(lapic_tpr):
1.1       fvdl      175:        .long 0
                    176: #endif
1.30      junyoung  177:
1.48      yamt      178: _C_LABEL(cpu):         .long   0       # are we 80486, Pentium, or..
1.1       fvdl      179: _C_LABEL(atdevbase):   .long   0       # location of start of iomem in virtual
1.40      yamt      180: _C_LABEL(proc0uarea):  .long   0
1.31      junyoung  181: _C_LABEL(PDPpaddr):    .long   0       # paddr of PDP, for libkvm
1.30      junyoung  182:
1.1       fvdl      183:        .space 512
                    184: tmpstk:
                    185:
                    186:
1.35      yamt      187: #define        _RELOC(x)       ((x) - KERNBASE)
1.1       fvdl      188: #define        RELOC(x)        _RELOC(_C_LABEL(x))
                    189:
                    190:        .text
                    191:        .globl  _C_LABEL(kernel_text)
                    192:        .set    _C_LABEL(kernel_text),KERNTEXTOFF
                    193:
                    194:        .globl  start
                    195: start: movw    $0x1234,0x472                   # warm boot
                    196:
1.37      jmmv      197: #if defined(MULTIBOOT)
                    198:        jmp     1f
                    199:
                    200:        .align  4
                    201:        .globl  Multiboot_Header
                    202: _C_LABEL(Multiboot_Header):
1.44      jmmv      203: #define MULTIBOOT_HEADER_FLAGS (MULTIBOOT_HEADER_WANT_MEMORY)
1.37      jmmv      204:        .long   MULTIBOOT_HEADER_MAGIC
                    205:        .long   MULTIBOOT_HEADER_FLAGS
                    206:        .long   -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS)
                    207:
                    208: 1:
                    209:        /* Check if we are being executed by a Multiboot-compliant boot
                    210:         * loader. */
                    211:        cmpl    $MULTIBOOT_INFO_MAGIC,%eax
                    212:        jne     1f
                    213:
1.43      mrg       214:        /*
                    215:         * Indeed, a multiboot-compliant boot loader executed us.  We copy
1.37      jmmv      216:         * the received Multiboot information structure into kernel's data
                    217:         * space to process it later -- after we are relocated.  It will
1.43      mrg       218:         * be safer to run complex C code than doing it at this point.
                    219:         */
1.37      jmmv      220:        pushl   %ebx            # Address of Multiboot information
                    221:        call    _C_LABEL(multiboot_pre_reloc)
                    222:        addl    $4,%esp
1.38      jmmv      223:        jmp     2f
1.37      jmmv      224: #endif
                    225:
                    226: 1:
1.1       fvdl      227:        /*
1.38      jmmv      228:         * At this point, we know that a NetBSD-specific boot loader
                    229:         * booted this kernel.  The stack carries the following parameters:
1.41      jmmv      230:         * (boothowto, [bootdev], bootinfo, esym, biosextmem, biosbasemem),
1.38      jmmv      231:         * 4 bytes each.
1.1       fvdl      232:         */
1.38      jmmv      233:        addl    $4,%esp         # Discard return address to boot loader
                    234:        call    _C_LABEL(native_loader)
                    235:        addl    $24,%esp
1.1       fvdl      236:
                    237: 2:
                    238:        /* First, reset the PSL. */
                    239:        pushl   $PSL_MBO
                    240:        popfl
                    241:
                    242:        /* Clear segment registers; always null in proc0. */
                    243:        xorl    %eax,%eax
                    244:        movw    %ax,%fs
                    245:        movw    %ax,%gs
                    246:        decl    %eax
                    247:        movl    %eax,RELOC(cpu_info_primary)+CPU_INFO_LEVEL
                    248:
                    249:        /* Find out our CPU type. */
                    250:
                    251: try386:        /* Try to toggle alignment check flag; does not exist on 386. */
                    252:        pushfl
                    253:        popl    %eax
                    254:        movl    %eax,%ecx
                    255:        orl     $PSL_AC,%eax
                    256:        pushl   %eax
                    257:        popfl
                    258:        pushfl
                    259:        popl    %eax
                    260:        xorl    %ecx,%eax
                    261:        andl    $PSL_AC,%eax
                    262:        pushl   %ecx
                    263:        popfl
                    264:
                    265:        testl   %eax,%eax
                    266:        jnz     try486
                    267:
                    268:        /*
                    269:         * Try the test of a NexGen CPU -- ZF will not change on a DIV
                    270:         * instruction on a NexGen, it will on an i386.  Documented in
                    271:         * Nx586 Processor Recognition Application Note, NexGen, Inc.
                    272:         */
                    273:        movl    $0x5555,%eax
                    274:        xorl    %edx,%edx
                    275:        movl    $2,%ecx
                    276:        divl    %ecx
                    277:        jnz     is386
                    278:
                    279: isnx586:
                    280:        /*
                    281:         * Don't try cpuid, as Nx586s reportedly don't support the
                    282:         * PSL_ID bit.
                    283:         */
                    284:        movl    $CPU_NX586,RELOC(cpu)
                    285:        jmp     2f
                    286:
                    287: is386:
                    288:        movl    $CPU_386,RELOC(cpu)
                    289:        jmp     2f
                    290:
                    291: try486:        /* Try to toggle identification flag; does not exist on early 486s. */
                    292:        pushfl
                    293:        popl    %eax
                    294:        movl    %eax,%ecx
                    295:        xorl    $PSL_ID,%eax
                    296:        pushl   %eax
                    297:        popfl
                    298:        pushfl
                    299:        popl    %eax
                    300:        xorl    %ecx,%eax
                    301:        andl    $PSL_ID,%eax
                    302:        pushl   %ecx
                    303:        popfl
                    304:
                    305:        testl   %eax,%eax
                    306:        jnz     try586
                    307: is486: movl    $CPU_486,RELOC(cpu)
                    308:        /*
                    309:         * Check Cyrix CPU
                    310:         * Cyrix CPUs do not change the undefined flags following
                    311:         * execution of the divide instruction which divides 5 by 2.
                    312:         *
                    313:         * Note: CPUID is enabled on M2, so it passes another way.
                    314:         */
                    315:        pushfl
                    316:        movl    $0x5555, %eax
                    317:        xorl    %edx, %edx
                    318:        movl    $2, %ecx
                    319:        clc
                    320:        divl    %ecx
                    321:        jnc     trycyrix486
                    322:        popfl
                    323:        jmp 2f
                    324: trycyrix486:
                    325:        movl    $CPU_6x86,RELOC(cpu)    # set CPU type
                    326:        /*
                    327:         * Check for Cyrix 486 CPU by seeing if the flags change during a
                    328:         * divide. This is documented in the Cx486SLC/e SMM Programmer's
                    329:         * Guide.
                    330:         */
                    331:        xorl    %edx,%edx
                    332:        cmpl    %edx,%edx               # set flags to known state
                    333:        pushfl
                    334:        popl    %ecx                    # store flags in ecx
                    335:        movl    $-1,%eax
                    336:        movl    $4,%ebx
                    337:        divl    %ebx                    # do a long division
                    338:        pushfl
                    339:        popl    %eax
                    340:        xorl    %ecx,%eax               # are the flags different?
                    341:        testl   $0x8d5,%eax             # only check C|PF|AF|Z|N|V
                    342:        jne     2f                      # yes; must be Cyrix 6x86 CPU
                    343:        movl    $CPU_486DLC,RELOC(cpu)  # set CPU type
                    344:
                    345: #ifndef CYRIX_CACHE_WORKS
                    346:        /* Disable caching of the ISA hole only. */
                    347:        invd
                    348:        movb    $CCR0,%al               # Configuration Register index (CCR0)
                    349:        outb    %al,$0x22
                    350:        inb     $0x23,%al
                    351:        orb     $(CCR0_NC1|CCR0_BARB),%al
                    352:        movb    %al,%ah
                    353:        movb    $CCR0,%al
                    354:        outb    %al,$0x22
                    355:        movb    %ah,%al
                    356:        outb    %al,$0x23
                    357:        invd
                    358: #else /* CYRIX_CACHE_WORKS */
                    359:        /* Set cache parameters */
                    360:        invd                            # Start with guaranteed clean cache
                    361:        movb    $CCR0,%al               # Configuration Register index (CCR0)
                    362:        outb    %al,$0x22
                    363:        inb     $0x23,%al
                    364:        andb    $~CCR0_NC0,%al
                    365: #ifndef CYRIX_CACHE_REALLY_WORKS
                    366:        orb     $(CCR0_NC1|CCR0_BARB),%al
                    367: #else
                    368:        orb     $CCR0_NC1,%al
                    369: #endif
                    370:        movb    %al,%ah
                    371:        movb    $CCR0,%al
                    372:        outb    %al,$0x22
                    373:        movb    %ah,%al
                    374:        outb    %al,$0x23
                    375:        /* clear non-cacheable region 1 */
                    376:        movb    $(NCR1+2),%al
                    377:        outb    %al,$0x22
                    378:        movb    $NCR_SIZE_0K,%al
                    379:        outb    %al,$0x23
                    380:        /* clear non-cacheable region 2 */
                    381:        movb    $(NCR2+2),%al
                    382:        outb    %al,$0x22
                    383:        movb    $NCR_SIZE_0K,%al
                    384:        outb    %al,$0x23
                    385:        /* clear non-cacheable region 3 */
                    386:        movb    $(NCR3+2),%al
                    387:        outb    %al,$0x22
                    388:        movb    $NCR_SIZE_0K,%al
                    389:        outb    %al,$0x23
                    390:        /* clear non-cacheable region 4 */
                    391:        movb    $(NCR4+2),%al
                    392:        outb    %al,$0x22
                    393:        movb    $NCR_SIZE_0K,%al
                    394:        outb    %al,$0x23
                    395:        /* enable caching in CR0 */
                    396:        movl    %cr0,%eax
                    397:        andl    $~(CR0_CD|CR0_NW),%eax
                    398:        movl    %eax,%cr0
                    399:        invd
                    400: #endif /* CYRIX_CACHE_WORKS */
                    401:
                    402:        jmp     2f
                    403:
                    404: try586:        /* Use the `cpuid' instruction. */
                    405:        xorl    %eax,%eax
                    406:        cpuid
                    407:        movl    %eax,RELOC(cpu_info_primary)+CPU_INFO_LEVEL
                    408:
                    409: 2:
                    410:        /*
                    411:         * Finished with old stack; load new %esp now instead of later so we
                    412:         * can trace this code without having to worry about the trace trap
                    413:         * clobbering the memory test or the zeroing of the bss+bootstrap page
                    414:         * tables.
                    415:         *
                    416:         * The boot program should check:
                    417:         *      text+data <= &stack_variable - more_space_for_stack
                    418:         *      text+data+bss+pad+space_for_page_tables <= end_of_memory
                    419:         * Oops, the gdt is in the carcass of the boot program so clearing
                    420:         * the rest of memory is still not possible.
                    421:         */
                    422:        movl    $_RELOC(tmpstk),%esp    # bootstrap stack end location
                    423:
                    424: /*
                    425:  * Virtual address space of kernel:
                    426:  *
1.30      junyoung  427:  * text | data | bss | [syms] | page dir | proc0 kstack
1.1       fvdl      428:  *                           0          1       2      3
                    429:  */
1.50.2.1! yamt      430:
        !           431: #define        PROC0_PDIR_OFF  0
        !           432: #define        PROC0_STK_OFF   (PROC0_PDIR_OFF + PAGE_SIZE)
        !           433: #define        PROC0_PTP1_OFF  (PROC0_STK_OFF + UPAGES * PAGE_SIZE)
        !           434:
        !           435: #define        TABLESIZE       ((NKL2_KIMG_ENTRIES + 1 + UPAGES) * PAGE_SIZE)
        !           436:
        !           437: /*
        !           438:  * fillkpt
        !           439:  *     eax = pte (page frame | control | status)
        !           440:  *     ebx = page table address
        !           441:  *     ecx = number of pages to map
        !           442:  */
        !           443:
        !           444: #define fillkpt        \
        !           445: 1:     movl    %eax,(%ebx)     ;       /* store phys addr */ \
        !           446:        addl    $4,%ebx         ;       /* next pte/pde */ \
        !           447:        addl    $PAGE_SIZE,%eax ;       /* next phys page */ \
        !           448:        loop    1b              ;  \
        !           449:
1.1       fvdl      450:
                    451:        /* Find end of kernel image. */
                    452:        movl    $RELOC(end),%edi
1.8       fvdl      453: #if (NKSYMS || defined(DDB) || defined(LKM)) && !defined(SYMTAB_SPACE)
1.1       fvdl      454:        /* Save the symbols (if loaded). */
                    455:        movl    RELOC(esym),%eax
                    456:        testl   %eax,%eax
                    457:        jz      1f
1.35      yamt      458:        subl    $KERNBASE,%eax
1.1       fvdl      459:        movl    %eax,%edi
                    460: 1:
                    461: #endif
                    462:
1.50.2.1! yamt      463:        /* Clear tables */
1.1       fvdl      464:        movl    %edi,%esi                       # edi = esym ? esym : end
                    465:        addl    $PGOFSET,%esi                   # page align up
                    466:        andl    $~PGOFSET,%esi
                    467:
1.50.2.1! yamt      468:        movl    %esi,%edi
1.1       fvdl      469:        xorl    %eax,%eax
                    470:        cld
1.50.2.1! yamt      471:        movl    $TABLESIZE,%ecx
        !           472:        shrl    $2,%ecx
1.1       fvdl      473:        rep
                    474:        stosl
                    475:
1.50.2.1! yamt      476:        leal    (PROC0_PTP1_OFF)(%esi), %ebx
1.1       fvdl      477:
                    478: /*
                    479:  * Build initial page tables.
                    480:  */
1.50.2.1! yamt      481:        /*
        !           482:         * Compute etext - KERNBASE. This can't be > 4G, or we can't deal
        !           483:         * with it anyway, since we can't load it in 32 bit mode. So use
        !           484:         * the bottom 32 bits.
        !           485:         */
        !           486:        movl    $RELOC(etext),%edx
        !           487:        addl    $PGOFSET,%edx
1.1       fvdl      488:        andl    $~PGOFSET,%edx
1.30      junyoung  489:
1.50.2.1! yamt      490:        /*
        !           491:         * Skip the first MB.
        !           492:         */
1.1       fvdl      493:        movl    $_RELOC(KERNTEXTOFF),%eax
                    494:        movl    %eax,%ecx
1.50.2.1! yamt      495:        shrl    $(PGSHIFT-2),%ecx       /* ((n >> PGSHIFT) << 2) for # pdes */
        !           496:        addl    %ecx,%ebx
1.1       fvdl      497:
                    498:        /* Map the kernel text read-only. */
                    499:        movl    %edx,%ecx
                    500:        subl    %eax,%ecx
                    501:        shrl    $PGSHIFT,%ecx
                    502:        orl     $(PG_V|PG_KR),%eax
                    503:        fillkpt
                    504:
                    505:        /* Map the data, BSS, and bootstrap tables read-write. */
                    506:        leal    (PG_V|PG_KW)(%edx),%eax
1.50.2.1! yamt      507:        movl    $TABLESIZE,%ecx
1.1       fvdl      508:        addl    %esi,%ecx                               # end of tables
                    509:        subl    %edx,%ecx                               # subtract end of text
                    510:        shrl    $PGSHIFT,%ecx
                    511:        fillkpt
                    512:
1.50.2.1! yamt      513:        /* Map ISA I/O mem (later atdevbase) */
1.1       fvdl      514:        movl    $(IOM_BEGIN|PG_V|PG_KW/*|PG_N*/),%eax   # having these bits set
                    515:        movl    $(IOM_SIZE>>PGSHIFT),%ecx               # for this many pte s,
                    516:        fillkpt
                    517:
                    518: /*
                    519:  * Construct a page table directory.
                    520:  */
1.50.2.1! yamt      521:        /* Set up top level entries for identity mapping */
        !           522:        leal    (PROC0_PDIR_OFF)(%esi),%ebx
        !           523:        leal    (PROC0_PTP1_OFF)(%esi),%eax
        !           524:        orl     $(PG_V|PG_KW), %eax
        !           525:        movl    $NKL2_KIMG_ENTRIES,%ecx
1.1       fvdl      526:        fillkpt
                    527:
1.50.2.1! yamt      528:        /* Set up top level entries for actual kernel mapping */
        !           529:        leal    (PROC0_PDIR_OFF + L2_SLOT_KERNBASE*4)(%esi),%ebx
        !           530:        leal    (PROC0_PTP1_OFF)(%esi),%eax
        !           531:        orl     $(PG_V|PG_KW), %eax
        !           532:        movl    $NKL2_KIMG_ENTRIES,%ecx
1.1       fvdl      533:        fillkpt
                    534:
                    535:        /* Install a PDE recursively mapping page directory as a page table! */
1.50.2.1! yamt      536:        leal    (PROC0_PDIR_OFF + PDIR_SLOT_PTE*4)(%esi),%ebx
        !           537:        leal    (PROC0_PDIR_OFF)(%esi),%eax
        !           538:        orl     $(PG_V|PG_KW),%eax
        !           539:        movl    %eax,(%ebx)
        !           540:
1.1       fvdl      541:
1.31      junyoung  542:        /* Save phys. addr of PDP, for libkvm. */
                    543:        movl    %esi,RELOC(PDPpaddr)
1.1       fvdl      544:
1.50.2.1! yamt      545:        /*
        !           546:         * Startup checklist:
        !           547:         * 1. Load %cr3 with pointer to PDIR.
        !           548:         */
1.1       fvdl      549:        movl    %esi,%eax               # phys address of ptd in proc 0
                    550:        movl    %eax,%cr3               # load ptd addr into mmu
1.50.2.1! yamt      551:
        !           552:        /*
        !           553:         * 2. Enable paging and the rest of it.
        !           554:         */
1.1       fvdl      555:        movl    %cr0,%eax               # get control word
                    556:                                        # enable paging & NPX emulation
                    557:        orl     $(CR0_PE|CR0_PG|CR0_NE|CR0_TS|CR0_EM|CR0_MP),%eax
                    558:        movl    %eax,%cr0               # and let's page NOW!
                    559:
                    560:        pushl   $begin                  # jump to high mem
                    561:        ret
                    562:
                    563: begin:
1.50.2.1! yamt      564:        /*
        !           565:         * We have arrived.
        !           566:         * There's no need anymore for the identity mapping in low
        !           567:         * memory, remove it.
        !           568:         */
        !           569:        movl    $NKL2_KIMG_ENTRIES,%ecx
        !           570:        leal    (PROC0_PDIR_OFF)(%esi),%ebx     # old, phys  address of PDIR
        !           571:        addl    $(KERNBASE), %ebx       # new, virtual address of PDIR
1.1       fvdl      572: 1:     movl    $0,(%ebx)
1.50.2.1! yamt      573:        addl    $4,%ebx
1.1       fvdl      574:        loop    1b
                    575:
                    576:        /* Relocate atdevbase. */
1.50.2.1! yamt      577:        movl    $(TABLESIZE+KERNBASE),%edx
1.1       fvdl      578:        addl    %esi,%edx
                    579:        movl    %edx,_C_LABEL(atdevbase)
                    580:
                    581:        /* Set up bootstrap stack. */
1.50.2.1! yamt      582:        leal    (PROC0_STK_OFF+KERNBASE)(%esi),%eax
1.40      yamt      583:        movl    %eax,_C_LABEL(proc0uarea)
                    584:        leal    (KSTACK_SIZE-FRAMESIZE)(%eax),%esp
                    585:        movl    %esi,(KSTACK_SIZE+PCB_CR3)(%eax)        # pcb->pcb_cr3
1.1       fvdl      586:        xorl    %ebp,%ebp               # mark end of frames
                    587:
1.37      jmmv      588: #if defined(MULTIBOOT)
                    589:        /* It is now safe to parse the Multiboot information structure
                    590:         * we saved before from C code.  Note that we cannot delay its
                    591:         * parsing any more because initgdt (called below) needs to make
                    592:         * use of this information. */
                    593:        call    _C_LABEL(multiboot_post_reloc)
                    594: #endif
                    595:
1.1       fvdl      596:        subl    $NGDT*8, %esp           # space for temporary gdt
                    597:        pushl   %esp
                    598:        call    _C_LABEL(initgdt)
                    599:        addl    $4,%esp
1.30      junyoung  600:
1.50.2.1! yamt      601:        movl    $TABLESIZE,%eax
1.1       fvdl      602:        addl    %esi,%eax               # skip past stack and page tables
                    603:
                    604:        pushl   %eax
                    605:        call    _C_LABEL(init386)       # wire 386 chip for unix operation
                    606:        addl    $4+NGDT*8,%esp          # pop temporary gdt
                    607:
                    608: #ifdef SAFARI_FIFO_HACK
                    609:        movb    $5,%al
                    610:        movw    $0x37b,%dx
                    611:        outb    %al,%dx
                    612:        movw    $0x37f,%dx
                    613:        inb     %dx,%al
                    614:        movb    %al,%cl
                    615:
                    616:        orb     $1,%cl
                    617:
                    618:        movb    $5,%al
                    619:        movw    $0x37b,%dx
                    620:        outb    %al,%dx
                    621:        movw    $0x37f,%dx
                    622:        movb    %cl,%al
                    623:        outb    %al,%dx
                    624: #endif /* SAFARI_FIFO_HACK */
                    625:
                    626:        call    _C_LABEL(main)
                    627:
                    628: /*
1.48      yamt      629:  * void lwp_trampoline(void);
                    630:  *
1.1       fvdl      631:  * This is a trampoline function pushed onto the stack of a newly created
                    632:  * process in order to do some additional setup.  The trampoline is entered by
                    633:  * cpu_switch()ing to the process, so we abuse the callee-saved registers used
                    634:  * by cpu_switch() to store the information about the stub to call.
                    635:  * NOTE: This function does not have a normal calling sequence!
                    636:  */
1.48      yamt      637: NENTRY(lwp_trampoline)
                    638:        pushl   %ebp
                    639:        xorl    %ebp,%ebp
                    640:        pushl   %eax
                    641:        call    _C_LABEL(lwp_startup)
                    642:        addl    $8,%esp
1.1       fvdl      643:        pushl   %ebx
                    644:        call    *%esi
                    645:        addl    $4,%esp
1.24      yamt      646:        DO_DEFERRED_SWITCH(%eax)
1.1       fvdl      647:        INTRFASTEXIT
                    648:        /* NOTREACHED */
                    649:
                    650: /*
1.48      yamt      651:  * sigcode()
                    652:  *
                    653:  * Signal trampoline; copied to top of user stack.  Used only for
                    654:  * compatibility with old releases of NetBSD.
1.1       fvdl      655:  */
                    656: NENTRY(sigcode)
                    657:        /*
                    658:         * Handler has returned here as if we called it.  The sigcontext
                    659:         * is on the stack after the 3 args "we" pushed.
                    660:         */
                    661:        leal    12(%esp),%eax           # get pointer to sigcontext
                    662:        movl    %eax,4(%esp)            # put it in the argument slot
                    663:                                        # fake return address already there
1.17      christos  664:        movl    $SYS_compat_16___sigreturn14,%eax
1.1       fvdl      665:        int     $0x80                   # enter kernel with args on stack
                    666:        movl    $SYS_exit,%eax
                    667:        int     $0x80                   # exit if sigreturn fails
                    668:        .globl  _C_LABEL(esigcode)
                    669: _C_LABEL(esigcode):
                    670:
                    671: /*
                    672:  * void lgdt(struct region_descriptor *rdp);
1.48      yamt      673:  *
1.1       fvdl      674:  * Load a new GDT pointer (and do any necessary cleanup).
                    675:  * XXX It's somewhat questionable whether reloading all the segment registers
                    676:  * is necessary, since the actual descriptor data is not changed except by
                    677:  * process creation and exit, both of which clean up via task switches.  OTOH,
                    678:  * this only happens at run time when the GDT is resized.
                    679:  */
                    680: NENTRY(lgdt)
                    681:        /* Reload the descriptor table. */
                    682:        movl    4(%esp),%eax
                    683:        lgdt    (%eax)
                    684:        /* Flush the prefetch queue. */
                    685:        jmp     1f
                    686:        nop
                    687: 1:     /* Reload "stale" selectors. */
                    688:        movl    $GSEL(GDATA_SEL, SEL_KPL),%eax
                    689:        movw    %ax,%ds
                    690:        movw    %ax,%es
                    691:        movw    %ax,%gs
                    692:        movw    %ax,%ss
                    693:        movl    $GSEL(GCPU_SEL, SEL_KPL),%eax
                    694:        movw    %ax,%fs
                    695:        /* Reload code selector by doing intersegment return. */
                    696:        popl    %eax
                    697:        pushl   $GSEL(GCODE_SEL, SEL_KPL)
                    698:        pushl   %eax
                    699:        lret
                    700:
1.48      yamt      701: /*
                    702:  * void x86_flush()
                    703:  *
                    704:  * Flush instruction pipelines by doing an intersegment (far) return.
                    705:  */
1.45      ad        706: NENTRY(x86_flush)
                    707:        popl    %eax
                    708:        pushl   $GSEL(GCODE_SEL, SEL_KPL)
                    709:        pushl   %eax
                    710:        lret
                    711:
1.1       fvdl      712: /*
1.48      yamt      713:  * int setjmp(label_t *)
                    714:  *
                    715:  * Used primarily by DDB.
1.1       fvdl      716:  */
                    717: ENTRY(setjmp)
                    718:        movl    4(%esp),%eax
                    719:        movl    %ebx,(%eax)             # save ebx
                    720:        movl    %esp,4(%eax)            # save esp
                    721:        movl    %ebp,8(%eax)            # save ebp
                    722:        movl    %esi,12(%eax)           # save esi
                    723:        movl    %edi,16(%eax)           # save edi
                    724:        movl    (%esp),%edx             # get rta
                    725:        movl    %edx,20(%eax)           # save eip
1.48      yamt      726:        xorl    %eax,%eax               # return 0
1.1       fvdl      727:        ret
                    728:
1.48      yamt      729: /*
                    730:  * int longjmp(label_t *)
                    731:  *
                    732:  * Used primarily by DDB.
                    733:  */
1.1       fvdl      734: ENTRY(longjmp)
                    735:        movl    4(%esp),%eax
                    736:        movl    (%eax),%ebx             # restore ebx
                    737:        movl    4(%eax),%esp            # restore esp
                    738:        movl    8(%eax),%ebp            # restore ebp
                    739:        movl    12(%eax),%esi           # restore esi
                    740:        movl    16(%eax),%edi           # restore edi
                    741:        movl    20(%eax),%edx           # get rta
                    742:        movl    %edx,(%esp)             # put in return frame
1.48      yamt      743:        movl    $1,%eax                 # return 1
1.1       fvdl      744:        ret
                    745:
                    746: /*
1.48      yamt      747:  * struct lwp *cpu_switchto(struct lwp *oldlwp, struct newlwp)
1.30      junyoung  748:  *
1.48      yamt      749:  *     1. if (oldlwp != NULL), save its context.
                    750:  *     2. then, restore context of newlwp.
                    751:  *
                    752:  * Note that the stack frame layout is known to "struct switchframe" in
                    753:  * <machine/frame.h> and to the code in cpu_lwp_fork() which initializes
1.5       thorpej   754:  * it for a new lwp.
1.1       fvdl      755:  */
1.48      yamt      756: ENTRY(cpu_switchto)
1.1       fvdl      757:        pushl   %ebx
                    758:        pushl   %esi
                    759:        pushl   %edi
                    760:
1.48      yamt      761:        movl    16(%esp),%esi           # oldlwp
                    762:        movl    20(%esp),%edi           # newlwp
                    763:        testl   %esi,%esi
                    764:        jz      1f
1.1       fvdl      765:
1.48      yamt      766:        /* Save old context. */
                    767:        movl    L_ADDR(%esi),%eax
                    768:        movl    %esp,PCB_ESP(%eax)
                    769:        movl    %ebp,PCB_EBP(%eax)
                    770:
                    771:        /* Switch to newlwp's stack. */
                    772: 1:     movl    L_ADDR(%edi),%ebx
                    773:        movl    PCB_EBP(%ebx),%ebp
                    774:        movl    PCB_ESP(%ebx),%esp
1.1       fvdl      775:
1.48      yamt      776:        /* Switch TSS.  Reset "task busy" flag before loading. */
1.26      yamt      777:        movl    %cr3,%eax
1.48      yamt      778:        movl    %eax,PCB_CR3(%ebx)      # for TSS gates
1.1       fvdl      779:        movl    CPUVAR(GDT),%eax
1.48      yamt      780:        movl    L_MD_TSS_SEL(%edi),%edx
                    781:        andl    $~0x0200,4(%eax,%edx, 1)
1.1       fvdl      782:        ltr     %dx
                    783:
1.48      yamt      784:        /* Set curlwp. */
                    785:        movl    %edi,CPUVAR(CURLWP)
1.1       fvdl      786:
                    787:        /* Don't bother with the rest if switching to a system process. */
1.48      yamt      788:        testl   $LW_SYSTEM,L_FLAG(%edi)
                    789:        jnz     4f
1.1       fvdl      790:
1.48      yamt      791:        /* Is this process using RAS (restartable atomic sequences)? */
                    792:        movl    L_PROC(%edi),%eax
                    793:        cmpl    $0,P_RASLIST(%eax)
                    794:        jne     5f
                    795:
                    796:        /*
                    797:         * Restore cr0 (including FPU state).  Raise the IPL to IPL_IPI.
                    798:         * FPU IPIs can alter the LWP's saved cr0.  Dropping the priority
                    799:         * is deferred until mi_switch(), when cpu_switchto() returns.
                    800:         */
                    801: 2:     movl    $IPL_IPI,CPUVAR(ILEVEL)
                    802:        movl    PCB_CR0(%ebx),%ecx
                    803:        movl    %cr0,%edx
1.1       fvdl      804:
1.30      junyoung  805:        /*
1.22      wiz       806:         * If our floating point registers are on a different CPU,
1.48      yamt      807:         * set CR0_TS so we'll trap rather than reuse bogus state.
1.1       fvdl      808:         */
1.48      yamt      809:        movl    PCB_FPCPU(%ebx),%eax
                    810:        cmpl    CPUVAR(SELF),%eax
                    811:        je      3f
1.1       fvdl      812:        orl     $CR0_TS,%ecx
1.48      yamt      813:
                    814:        /* Reloading CR0 is very expensive - avoid if possible. */
                    815: 3:     cmpl    %edx,%ecx
                    816:        je      4f
1.1       fvdl      817:        movl    %ecx,%cr0
                    818:
1.48      yamt      819:        /* Return to the new LWP, returning 'oldlwp' in %eax. */
                    820: 4:     movl    %esi,%eax
1.1       fvdl      821:        popl    %edi
                    822:        popl    %esi
                    823:        popl    %ebx
                    824:        ret
1.20      dsl       825:
1.48      yamt      826:        /* Check for restartable atomic sequences (RAS). */
                    827: 5:     movl    L_MD_REGS(%edi),%ecx
                    828:        pushl   TF_EIP(%ecx)
1.20      dsl       829:        pushl   %eax
                    830:        call    _C_LABEL(ras_lookup)
                    831:        addl    $8,%esp
                    832:        cmpl    $-1,%eax
1.48      yamt      833:        je      2b
1.49      ad        834:        movl    L_MD_REGS(%edi),%ecx
                    835:        movl    %eax,TF_EIP(%ecx)
1.48      yamt      836:        jmp     2b
1.1       fvdl      837:
                    838: /*
                    839:  * void savectx(struct pcb *pcb);
1.48      yamt      840:  *
1.1       fvdl      841:  * Update pcb, saving current processor state.
                    842:  */
                    843: ENTRY(savectx)
1.47      skrll     844:        movl    4(%esp),%edx            # edx = pcb
1.1       fvdl      845:        movl    %esp,PCB_ESP(%edx)
                    846:        movl    %ebp,PCB_EBP(%edx)
                    847:        ret
                    848:
                    849: /*
1.48      yamt      850:  * osyscall()
                    851:  *
1.1       fvdl      852:  * Old call gate entry for syscall
                    853:  */
                    854: IDTVEC(osyscall)
1.48      yamt      855:        pushfl                  # set eflags in trap frame
1.1       fvdl      856:        popl    8(%esp)
                    857:        pushl   $7              # size of instruction for restart
                    858:        jmp     syscall1
                    859:
                    860: /*
1.48      yamt      861:  * syscall()
                    862:  *
1.1       fvdl      863:  * Trap gate entry for syscall
                    864:  */
                    865: IDTVEC(syscall)
                    866:        pushl   $2              # size of instruction for restart
                    867: syscall1:
                    868:        pushl   $T_ASTFLT       # trap # for doing ASTs
                    869:        INTRENTRY
                    870:
                    871: #ifdef DIAGNOSTIC
1.24      yamt      872:        cmpl    $0, CPUVAR(WANT_PMAPLOAD)
                    873:        jz      1f
                    874:        pushl   $6f
                    875:        call    _C_LABEL(printf)
                    876:        addl    $4, %esp
                    877: 1:
1.1       fvdl      878:        movl    CPUVAR(ILEVEL),%ebx
                    879:        testl   %ebx,%ebx
                    880:        jz      1f
                    881:        pushl   $5f
                    882:        call    _C_LABEL(printf)
                    883:        addl    $4,%esp
                    884: #ifdef DDB
                    885:        int     $3
                    886: #endif
1.30      junyoung  887: 1:
1.1       fvdl      888: #endif /* DIAGNOSTIC */
1.5       thorpej   889:        movl    CPUVAR(CURLWP),%edx
                    890:        movl    %esp,L_MD_REGS(%edx)    # save pointer to frame
                    891:        movl    L_PROC(%edx),%edx
1.15      fvdl      892:        pushl   %esp
1.1       fvdl      893:        call    *P_MD_SYSCALL(%edx)     # get pointer to syscall() function
1.15      fvdl      894:        addl    $4,%esp
1.27      yamt      895: .Lsyscall_checkast:
1.24      yamt      896:        /* Check for ASTs on exit to user mode. */
1.1       fvdl      897:        cli
1.5       thorpej   898:        CHECK_ASTPENDING(%eax)
1.1       fvdl      899:        je      1f
                    900:        /* Always returning to user mode here. */
1.5       thorpej   901:        CLEAR_ASTPENDING(%eax)
1.1       fvdl      902:        sti
                    903:        /* Pushed T_ASTFLT into tf_trapno on entry. */
1.15      fvdl      904:        pushl   %esp
1.1       fvdl      905:        call    _C_LABEL(trap)
1.15      fvdl      906:        addl    $4,%esp
1.27      yamt      907:        jmp     .Lsyscall_checkast      /* re-check ASTs */
1.24      yamt      908: 1:     CHECK_DEFERRED_SWITCH(%eax)
                    909:        jnz     9f
1.1       fvdl      910: #ifndef DIAGNOSTIC
1.24      yamt      911:        INTRFASTEXIT
1.1       fvdl      912: #else /* DIAGNOSTIC */
1.24      yamt      913:        cmpl    $IPL_NONE,CPUVAR(ILEVEL)
1.1       fvdl      914:        jne     3f
                    915:        INTRFASTEXIT
                    916: 3:     sti
                    917:        pushl   $4f
                    918:        call    _C_LABEL(printf)
                    919:        addl    $4,%esp
                    920: #ifdef DDB
                    921:        int     $3
                    922: #endif /* DDB */
                    923:        movl    $IPL_NONE,CPUVAR(ILEVEL)
                    924:        jmp     2b
                    925: 4:     .asciz  "WARNING: SPL NOT LOWERED ON SYSCALL EXIT\n"
1.30      junyoung  926: 5:     .asciz  "WARNING: SPL NOT ZERO ON SYSCALL ENTRY\n"
                    927: 6:     .asciz  "WARNING: WANT PMAPLOAD ON SYSCALL ENTRY\n"
1.1       fvdl      928: #endif /* DIAGNOSTIC */
1.24      yamt      929: 9:     sti
                    930:        call    _C_LABEL(pmap_load)
1.27      yamt      931:        jmp     .Lsyscall_checkast      /* re-check ASTs */
1.1       fvdl      932:
                    933: #if NNPX > 0
                    934: /*
                    935:  * Special interrupt handlers.  Someday intr0-intr15 will be used to count
                    936:  * interrupts.  We'll still need a special exception 16 handler.  The busy
                    937:  * latch stuff in probintr() can be moved to npxprobe().
                    938:  */
                    939:
1.48      yamt      940: /*
                    941:  * void probeintr(void)
                    942:  */
1.1       fvdl      943: NENTRY(probeintr)
                    944:        ss
                    945:        incl    _C_LABEL(npx_intrs_while_probing)
                    946:        pushl   %eax
                    947:        movb    $0x20,%al       # EOI (asm in strings loses cpp features)
                    948:        outb    %al,$0xa0       # IO_ICU2
                    949:        outb    %al,$0x20       # IO_ICU1
                    950:        movb    $0,%al
                    951:        outb    %al,$0xf0       # clear BUSY# latch
                    952:        popl    %eax
                    953:        iret
                    954:
1.48      yamt      955: /*
                    956:  * void probetrap(void)
                    957:  */
1.1       fvdl      958: NENTRY(probetrap)
                    959:        ss
                    960:        incl    _C_LABEL(npx_traps_while_probing)
                    961:        fnclex
                    962:        iret
                    963:
1.48      yamt      964: /*
                    965:  * int npx586bug1(int a, int b)
                    966:  */
1.1       fvdl      967: NENTRY(npx586bug1)
                    968:        fildl   4(%esp)         # x
                    969:        fildl   8(%esp)         # y
                    970:        fld     %st(1)
                    971:        fdiv    %st(1),%st      # x/y
                    972:        fmulp   %st,%st(1)      # (x/y)*y
                    973:        fsubrp  %st,%st(1)      # x-(x/y)*y
                    974:        pushl   $0
                    975:        fistpl  (%esp)
                    976:        popl    %eax
                    977:        ret
                    978: #endif /* NNPX > 0 */
1.50      ad        979:
                    980: /*
                    981:  * void sse2_zero_page(void *pg)
                    982:  *
                    983:  * Zero a page without polluting the cache.
                    984:  */
                    985: ENTRY(sse2_zero_page)
                    986:        pushl   %ebp
                    987:        movl    %esp,%ebp
                    988:        movl    8(%esp), %edx
                    989:        movl    $PAGE_SIZE, %ecx
                    990:        xorl    %eax, %eax
                    991:        .align  16
                    992: 1:
                    993:        movnti  %eax, 0(%edx)
                    994:        movnti  %eax, 4(%edx)
                    995:        movnti  %eax, 8(%edx)
                    996:        movnti  %eax, 12(%edx)
                    997:        movnti  %eax, 16(%edx)
                    998:        movnti  %eax, 20(%edx)
                    999:        movnti  %eax, 24(%edx)
                   1000:        movnti  %eax, 28(%edx)
                   1001:        subl    $32, %ecx
                   1002:        leal    32(%edx), %edx
                   1003:        jnz     1b
                   1004:        sfence
                   1005:        pop     %ebp
                   1006:        ret
                   1007:
                   1008: /*
                   1009:  * void sse2_copy_page(void *src, void *dst)
                   1010:  *
                   1011:  * Copy a page without polluting the cache.
                   1012:  */
                   1013: ENTRY(sse2_copy_page)
                   1014:        pushl   %ebp
                   1015:        pushl   %ebx
                   1016:        pushl   %esi
                   1017:        pushl   %edi
                   1018:        movl    20(%esp), %esi
                   1019:        movl    24(%esp), %edi
                   1020:        movl    $PAGE_SIZE, %ebp
                   1021:        .align  16
                   1022: 1:
                   1023:        movl    0(%esi), %eax
                   1024:        movl    4(%esi), %ebx
                   1025:        movl    8(%esi), %ecx
                   1026:        movl    12(%esi), %edx
                   1027:        movnti  %eax, 0(%edi)
                   1028:        movnti  %ebx, 4(%edi)
                   1029:        movnti  %ecx, 8(%edi)
                   1030:        movnti  %edx, 12(%edi)
                   1031:        subl    $16, %ebp
                   1032:        leal    16(%esi), %esi
                   1033:        leal    16(%edi), %edi
                   1034:        jnz     1b
                   1035:        sfence
                   1036:        popl    %edi
                   1037:        popl    %esi
                   1038:        popl    %ebx
                   1039:        popl    %ebp
                   1040:        ret

CVSweb <webmaster@jp.NetBSD.org>