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

Annotation of src/sys/arch/i386/i386/cpufunc.S, Revision 1.2.2.3

1.2.2.3 ! joerg       1: /*     $NetBSD: cpufunc.S,v 1.2.2.2 2007/10/02 18:27:15 joerg Exp $    */
1.2.2.2   joerg       2:
                      3: /*-
                      4:  * Copyright (c) 1998, 2007 The NetBSD Foundation, Inc.
                      5:  * All rights reserved.
                      6:  *
                      7:  * This code is derived from software contributed to The NetBSD Foundation
                      8:  * by Charles M. Hannum, and by Andrew Doran.
                      9:  *
                     10:  * Redistribution and use in source and binary forms, with or without
                     11:  * modification, are permitted provided that the following conditions
                     12:  * are met:
                     13:  * 1. Redistributions of source code must retain the above copyright
                     14:  *    notice, this list of conditions and the following disclaimer.
                     15:  * 2. Redistributions in binary form must reproduce the above copyright
                     16:  *    notice, this list of conditions and the following disclaimer in the
                     17:  *    documentation and/or other materials provided with the distribution.
                     18:  * 3. All advertising materials mentioning features or use of this software
                     19:  *    must display the following acknowledgement:
                     20:  *        This product includes software developed by the NetBSD
                     21:  *        Foundation, Inc. and its contributors.
                     22:  * 4. Neither the name of The NetBSD Foundation nor the names of its
                     23:  *    contributors may be used to endorse or promote products derived
                     24:  *    from this software without specific prior written permission.
                     25:  *
                     26:  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
                     27:  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
                     28:  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
                     29:  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
                     30:  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
                     31:  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
                     32:  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
                     33:  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
                     34:  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
                     35:  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
                     36:  * POSSIBILITY OF SUCH DAMAGE.
                     37:  */
                     38:
                     39: /*
                     40:  * Functions to provide access to i386-specific instructions.
                     41:  *
                     42:  * These are shared with NetBSD/xen.
                     43:  */
                     44:
                     45: #include "opt_xen.h"
                     46:
                     47: #include <machine/asm.h>
                     48: #include <machine/specialreg.h>
                     49: #include <machine/segments.h>
                     50:
                     51: #include "assym.h"
                     52:
                     53: /* Small and slow, so align less. */
                     54: #undef _ALIGN_TEXT
                     55: #define        _ALIGN_TEXT     .align 8
                     56:
                     57: ENTRY(x86_lfence)
                     58:        lock
                     59:        addl    $0, -4(%esp)
                     60:        ret
                     61:
                     62: ENTRY(x86_sfence)
                     63:        lock
                     64:        addl    $0, -4(%esp)
                     65:        ret
                     66:
                     67: ENTRY(x86_mfence)
                     68:        lock
                     69:        addl    $0, -4(%esp)
                     70:        ret
                     71:
                     72: ENTRY(lidt)
                     73:        movl    4(%esp), %eax
                     74:        lidt    (%eax)
                     75:        ret
                     76:
                     77: ENTRY(rcr3)
                     78:        movl    %cr3, %eax
                     79:        ret
                     80:
                     81: ENTRY(lcr4)
                     82:        movl    4(%esp), %eax
                     83:        movl    %eax, %cr4
                     84:        ret
                     85:
                     86: ENTRY(rcr4)
                     87:        movl    %cr4, %eax
                     88:        ret
                     89:
                     90: NENTRY(x86_read_flags)
                     91:        pushfl
                     92:        popl    %eax
                     93:        ret
                     94:
                     95: NENTRY(x86_write_flags)
                     96:        movl    4(%esp), %eax
                     97:        pushl   %eax
                     98:        popfl
                     99:        ret
                    100:
                    101: #ifndef XEN
                    102: STRONG_ALIAS(x86_write_psl,x86_write_flags)
                    103: STRONG_ALIAS(x86_read_psl,x86_read_flags)
                    104: #endif /* XEN */
                    105:
                    106: ENTRY(rdmsr)
                    107:        movl    4(%esp), %ecx
                    108:        rdmsr
                    109:        ret
                    110:
                    111: ENTRY(wrmsr)
                    112:        movl    4(%esp), %ecx
                    113:        movl    8(%esp), %eax
                    114:        movl    12(%esp), %edx
                    115:        wrmsr
                    116:        ret
                    117:
                    118: ENTRY(rdmsr_locked)
                    119:        movl    4(%esp), %ecx
                    120:        pushl   %edi
                    121:        movl    $OPTERON_MSR_PASSCODE, %edi
                    122:        rdmsr
                    123:        popl    %edi
                    124:        ret
                    125:
                    126: ENTRY(wrmsr_locked)
                    127:        movl    4(%esp), %ecx
                    128:        movl    8(%esp), %eax
                    129:        movl    12(%esp), %edx
                    130:        pushl   %edi
                    131:        movl    $OPTERON_MSR_PASSCODE, %edi
                    132:        wrmsr
                    133:        popl    %edi
                    134:        ret
                    135:
                    136: ENTRY(rdtsc)
                    137:        rdtsc
                    138:        ret
                    139:
                    140: ENTRY(rdpmc)
                    141:        movl    4(%esp), %ecx
                    142:        rdpmc
                    143:        ret
                    144:
                    145: NENTRY(breakpoint)
                    146:        int     $0x03           /* paranoid, not 'int3' */
                    147:        ret
                    148:
                    149: NENTRY(x86_atomic_testset_ul)
                    150:        movl    4(%esp), %ecx
                    151:        movl    8(%esp), %eax
                    152:        xchgl   %eax, (%ecx)
                    153:        ret
                    154:
                    155: NENTRY(x86_atomic_testset_i)
                    156:        movl    4(%esp), %ecx
                    157:        movl    8(%esp), %eax
                    158:        xchgl   %eax, (%ecx)
                    159:        ret
                    160:
                    161: NENTRY(x86_atomic_testset_b)
                    162:        movl    4(%esp), %ecx
                    163:        movl    8(%esp), %eax
                    164:        xchgb   %al, (%ecx)
                    165:        andl    $0xff, %eax
                    166:        ret
                    167:
                    168: NENTRY(x86_atomic_setbits_l)
                    169:        movl    4(%esp), %ecx
                    170:        movl    8(%esp), %eax
                    171:        lock
                    172:        orl     %eax, (%ecx)
                    173:        ret
                    174:
                    175: NENTRY(x86_atomic_clearbits_l)
                    176:        movl    4(%esp), %ecx
                    177:        movl    8(%esp), %eax
                    178:        notl    %eax
                    179:        lock
                    180:        andl    %eax, (%ecx)
                    181:        ret
                    182:
                    183: NENTRY(x86_curcpu)
                    184:        movl    %fs:(CPU_INFO_SELF), %eax
                    185:        ret
                    186:
                    187: NENTRY(x86_curlwp)
                    188:        movl    %fs:(CPU_INFO_CURLWP), %eax
                    189:        ret
                    190:
                    191: ENTRY(__byte_swap_u32_variable)
                    192:        movl    4(%esp), %eax
                    193:        bswapl  %eax
                    194:        ret
                    195:
                    196: ENTRY(__byte_swap_u16_variable)
                    197:        movl    4(%esp), %eax
                    198:        xchgb   %al, %ah
                    199:        ret
                    200:
                    201: /*
                    202:  * void x86_flush()
                    203:  *
                    204:  * Flush instruction pipelines by doing an intersegment (far) return.
                    205:  */
                    206: NENTRY(x86_flush)
                    207:        popl    %eax
                    208:        pushl   $GSEL(GCODE_SEL, SEL_KPL)
                    209:        pushl   %eax
                    210:        lret
                    211:
                    212: /* Waits - set up stack frame. */
                    213: NENTRY(x86_hlt)
                    214:        pushl   %ebp
                    215:        movl    %esp, %ebp
                    216:        hlt
                    217:        leave
                    218:        ret
                    219:
                    220: /* Waits - set up stack frame. */
                    221: NENTRY(x86_stihlt)
                    222:        pushl   %ebp
                    223:        movl    %esp, %ebp
                    224:        sti
                    225:        hlt
                    226:        leave
                    227:        ret
                    228:
                    229: NENTRY(x86_monitor)
                    230:        movl    4(%esp), %eax
                    231:        movl    8(%esp), %ecx
                    232:        movl    12(%esp), %edx
                    233:        monitor %eax, %ecx, %edx
                    234:        ret
                    235:
                    236: /* Waits - set up stack frame. */
                    237: NENTRY(x86_mwait)
                    238:        pushl   %ebp
                    239:        movl    %esp, %ebp
                    240:        movl    8(%ebp), %eax
                    241:        movl    12(%ebp), %ecx
                    242:        mwait   %eax, %ecx
                    243:        leave
                    244:        ret
                    245:
                    246: NENTRY(x86_pause)
                    247:        pause
                    248:        ret
                    249:
                    250: ENTRY(x86_cpuid)
                    251:        pushl   %ebx
                    252:        pushl   %edi
                    253:        movl    12(%esp), %eax
                    254:        movl    16(%esp), %edi
                    255:        cpuid
                    256:        movl    %eax, 0(%edi)
                    257:        movl    %ebx, 4(%edi)
                    258:        movl    %ecx, 8(%edi)
                    259:        movl    %edx, 12(%edi)
                    260:        popl    %edi
                    261:        popl    %ebx
                    262:        ret
                    263:
                    264: ENTRY(x86_getss)
                    265:        movl    %ss, %eax
                    266:        ret
                    267:
                    268: ENTRY(fldcw)
                    269:        movl    4(%esp), %eax
                    270:        fldcw   (%eax)
                    271:        ret
                    272:
                    273: ENTRY(fnclex)
                    274:        fnclex
                    275:        ret
                    276:
                    277: ENTRY(fninit)
                    278:        fninit
                    279:        ret
                    280:
                    281: ENTRY(fnsave)
                    282:        movl    4(%esp), %eax
                    283:        fnsave  (%eax)
                    284:        ret
                    285:
                    286: ENTRY(fnstcw)
                    287:        movl    4(%esp), %eax
                    288:        fnstcw  (%eax)
                    289:        ret
                    290:
                    291: ENTRY(fnstsw)
                    292:        movl    4(%esp), %eax
                    293:        fnstsw  (%eax)
                    294:        ret
                    295:
                    296: ENTRY(fp_divide_by_0)
                    297:        fldz
                    298:        fld1
                    299:        fdiv    %st, %st(1)
                    300:        fwait
                    301:        ret
                    302:
                    303: ENTRY(frstor)
                    304:        movl    4(%esp), %eax
                    305:        frstor  (%eax)
                    306:        ret
                    307:
                    308: ENTRY(fwait)
                    309:        fwait
                    310:        ret
                    311:
                    312: NENTRY(clts)
                    313:        clts
                    314:        ret
                    315:
                    316: NENTRY(stts)
                    317:        movl    %cr0, %eax
                    318:        orl     $CR0_TS, %eax
                    319:        movl    %eax, %cr0
                    320:        ret
                    321:
                    322: ENTRY(fxsave)
                    323:        movl    4(%esp), %eax
                    324:        fxsave  (%eax)
                    325:        ret
                    326:
                    327: ENTRY(fxrstor)
                    328:        movl    4(%esp), %eax
                    329:        fxrstor (%eax)
                    330:        ret
                    331:
                    332: ENTRY(fldummy)
                    333:        movl    4(%esp), %eax
                    334:        ffree   %st(7)
                    335:        fld     (%eax)
                    336:        ret
                    337:
                    338: ENTRY(inb)
                    339:        movl    4(%esp), %edx
                    340:        xorl    %eax, %eax
                    341:        inb     %dx, %al
                    342:        ret
                    343:
                    344: ENTRY(insb)
                    345:        pushl   %edi
                    346:        movl    8(%esp), %edx
                    347:        movl    12(%esp), %edi
                    348:        movl    16(%esp), %ecx
                    349:        rep
                    350:        insb
                    351:        popl    %edi
                    352:        ret
                    353:
                    354: ENTRY(inw)
                    355:        movl    4(%esp), %edx
                    356:        xorl    %eax, %eax
                    357:        inw     %dx, %ax
                    358:        ret
                    359:
                    360: ENTRY(insw)
                    361:        pushl   %edi
                    362:        movl    8(%esp), %edx
                    363:        movl    12(%esp), %edi
                    364:        movl    16(%esp), %ecx
                    365:        rep
                    366:        insw
                    367:        popl    %edi
                    368:        ret
                    369:
                    370: ENTRY(inl)
                    371:        movl    4(%esp), %edx
                    372:        inl     %dx, %eax
                    373:        ret
                    374:
                    375: ENTRY(insl)
                    376:        pushl   %edi
                    377:        movl    8(%esp), %edx
                    378:        movl    12(%esp), %edi
                    379:        movl    16(%esp), %ecx
                    380:        rep
                    381:        insl
                    382:        popl    %edi
                    383:        ret
                    384:
                    385: ENTRY(outb)
                    386:        movl    4(%esp), %edx
                    387:        movl    8(%esp), %eax
                    388:        outb    %al, %dx
                    389:        ret
                    390:
                    391: ENTRY(outsb)
                    392:        pushl   %esi
                    393:        movl    8(%esp), %edx
                    394:        movl    12(%esp), %esi
                    395:        movl    16(%esp), %ecx
                    396:        rep
                    397:        outsb
                    398:        popl    %esi
                    399:        ret
                    400:
                    401: ENTRY(outw)
                    402:        movl    4(%esp), %edx
                    403:        movl    8(%esp), %eax
                    404:        outw    %ax, %dx
                    405:        ret
                    406:
                    407: ENTRY(outsw)
                    408:        pushl   %esi
                    409:        movl    8(%esp), %edx
                    410:        movl    12(%esp), %esi
                    411:        movl    16(%esp), %ecx
                    412:        rep
                    413:        outsw
                    414:        popl    %esi
                    415:        ret
                    416:
                    417: ENTRY(outl)
                    418:        movl    4(%esp), %edx
                    419:        movl    8(%esp), %eax
                    420:        outl    %eax, %dx
                    421:        ret
                    422:
                    423: ENTRY(outsl)
                    424:        pushl   %esi
                    425:        movl    8(%esp), %edx
                    426:        movl    12(%esp), %esi
                    427:        movl    16(%esp), %ecx
                    428:        rep
                    429:        outsl
                    430:        popl    %esi
                    431:        ret

CVSweb <webmaster@jp.NetBSD.org>