Annotation of src/sys/arch/i386/i386/cpufunc.S, Revision 1.2.10.2
1.2.10.2! yamt 1: /* $NetBSD$ */
! 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: cld
! 350: rep
! 351: insb
! 352: popl %edi
! 353: ret
! 354:
! 355: ENTRY(inw)
! 356: movl 4(%esp), %edx
! 357: xorl %eax, %eax
! 358: inw %dx, %ax
! 359: ret
! 360:
! 361: ENTRY(insw)
! 362: pushl %edi
! 363: movl 8(%esp), %edx
! 364: movl 12(%esp), %edi
! 365: movl 16(%esp), %ecx
! 366: cld
! 367: rep
! 368: insw
! 369: popl %edi
! 370: ret
! 371:
! 372: ENTRY(inl)
! 373: movl 4(%esp), %edx
! 374: inl %dx, %eax
! 375: ret
! 376:
! 377: ENTRY(insl)
! 378: pushl %edi
! 379: movl 8(%esp), %edx
! 380: movl 12(%esp), %edi
! 381: movl 16(%esp), %ecx
! 382: cld
! 383: rep
! 384: insl
! 385: popl %edi
! 386: ret
! 387:
! 388: ENTRY(outb)
! 389: movl 4(%esp), %edx
! 390: movl 8(%esp), %eax
! 391: outb %al, %dx
! 392: ret
! 393:
! 394: ENTRY(outsb)
! 395: pushl %esi
! 396: movl 8(%esp), %edx
! 397: movl 12(%esp), %esi
! 398: movl 16(%esp), %ecx
! 399: cld
! 400: rep
! 401: outsb
! 402: popl %esi
! 403: ret
! 404:
! 405: ENTRY(outw)
! 406: movl 4(%esp), %edx
! 407: movl 8(%esp), %eax
! 408: outw %ax, %dx
! 409: ret
! 410:
! 411: ENTRY(outsw)
! 412: pushl %esi
! 413: movl 8(%esp), %edx
! 414: movl 12(%esp), %esi
! 415: movl 16(%esp), %ecx
! 416: cld
! 417: rep
! 418: outsw
! 419: popl %esi
! 420: ret
! 421:
! 422: ENTRY(outl)
! 423: movl 4(%esp), %edx
! 424: movl 8(%esp), %eax
! 425: outl %eax, %dx
! 426: ret
! 427:
! 428: ENTRY(outsl)
! 429: pushl %esi
! 430: movl 8(%esp), %edx
! 431: movl 12(%esp), %esi
! 432: movl 16(%esp), %ecx
! 433: cld
! 434: rep
! 435: outsl
! 436: popl %esi
! 437: ret
CVSweb <webmaster@jp.NetBSD.org>