cpufunc.h (181430) | cpufunc.h (187948) |
---|---|
1/*- 2 * Copyright (c) 2003 Peter Wemm. 3 * Copyright (c) 1993 The Regents of the University of California. 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 13 unchanged lines hidden (view full) --- 22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 * SUCH DAMAGE. 29 * | 1/*- 2 * Copyright (c) 2003 Peter Wemm. 3 * Copyright (c) 1993 The Regents of the University of California. 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 13 unchanged lines hidden (view full) --- 22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 * SUCH DAMAGE. 29 * |
30 * $FreeBSD: head/sys/amd64/include/cpufunc.h 181430 2008-08-08 16:26:53Z stas $ | 30 * $FreeBSD: head/sys/amd64/include/cpufunc.h 187948 2009-01-31 11:37:21Z obrien $ |
31 */ 32 33/* 34 * Functions to provide access to special i386 instructions. 35 * This in included in sys/systm.h, and that file should be 36 * used in preference to this. 37 */ 38 --- 438 unchanged lines hidden (view full) --- 477 478 __asm __volatile("invlpg %0" : : "m" (*(char *)addr) : "memory"); 479} 480 481static __inline u_int 482rfs(void) 483{ 484 u_int sel; | 31 */ 32 33/* 34 * Functions to provide access to special i386 instructions. 35 * This in included in sys/systm.h, and that file should be 36 * used in preference to this. 37 */ 38 --- 438 unchanged lines hidden (view full) --- 477 478 __asm __volatile("invlpg %0" : : "m" (*(char *)addr) : "memory"); 479} 480 481static __inline u_int 482rfs(void) 483{ 484 u_int sel; |
485 __asm __volatile("movl %%fs,%0" : "=rm" (sel)); | 485 __asm __volatile("mov %%fs,%0" : "=rm" (sel)); |
486 return (sel); 487} 488 489static __inline u_int 490rgs(void) 491{ 492 u_int sel; | 486 return (sel); 487} 488 489static __inline u_int 490rgs(void) 491{ 492 u_int sel; |
493 __asm __volatile("movl %%gs,%0" : "=rm" (sel)); | 493 __asm __volatile("mov %%gs,%0" : "=rm" (sel)); |
494 return (sel); 495} 496 497static __inline u_int 498rss(void) 499{ 500 u_int sel; | 494 return (sel); 495} 496 497static __inline u_int 498rss(void) 499{ 500 u_int sel; |
501 __asm __volatile("movl %%ss,%0" : "=rm" (sel)); | 501 __asm __volatile("mov %%ss,%0" : "=rm" (sel)); |
502 return (sel); 503} 504 505static __inline void 506load_ds(u_int sel) 507{ | 502 return (sel); 503} 504 505static __inline void 506load_ds(u_int sel) 507{ |
508 __asm __volatile("movl %0,%%ds" : : "rm" (sel)); | 508 __asm __volatile("mov %0,%%ds" : : "rm" (sel)); |
509} 510 511static __inline void 512load_es(u_int sel) 513{ | 509} 510 511static __inline void 512load_es(u_int sel) 513{ |
514 __asm __volatile("movl %0,%%es" : : "rm" (sel)); | 514 __asm __volatile("mov %0,%%es" : : "rm" (sel)); |
515} 516 517static inline void 518cpu_monitor(const void *addr, int extensions, int hints) 519{ 520 __asm __volatile("monitor;" 521 : :"a" (addr), "c" (extensions), "d"(hints)); 522} --- 11 unchanged lines hidden (view full) --- 534#endif 535static __inline void 536load_fs(u_int sel) 537{ 538 register u_int32_t fsbase __asm("ecx"); 539 540 /* Preserve the fsbase value across the selector load */ 541 fsbase = MSR_FSBASE; | 515} 516 517static inline void 518cpu_monitor(const void *addr, int extensions, int hints) 519{ 520 __asm __volatile("monitor;" 521 : :"a" (addr), "c" (extensions), "d"(hints)); 522} --- 11 unchanged lines hidden (view full) --- 534#endif 535static __inline void 536load_fs(u_int sel) 537{ 538 register u_int32_t fsbase __asm("ecx"); 539 540 /* Preserve the fsbase value across the selector load */ 541 fsbase = MSR_FSBASE; |
542 __asm __volatile("rdmsr; movl %0,%%fs; wrmsr" | 542 __asm __volatile("rdmsr; mov %0,%%fs; wrmsr" |
543 : : "rm" (sel), "c" (fsbase) : "eax", "edx"); 544} 545 546#ifndef MSR_GSBASE 547#define MSR_GSBASE 0xc0000101 548#endif 549static __inline void 550load_gs(u_int sel) 551{ 552 register u_int32_t gsbase __asm("ecx"); 553 554 /* 555 * Preserve the gsbase value across the selector load. 556 * Note that we have to disable interrupts because the gsbase 557 * being trashed happens to be the kernel gsbase at the time. 558 */ 559 gsbase = MSR_GSBASE; | 543 : : "rm" (sel), "c" (fsbase) : "eax", "edx"); 544} 545 546#ifndef MSR_GSBASE 547#define MSR_GSBASE 0xc0000101 548#endif 549static __inline void 550load_gs(u_int sel) 551{ 552 register u_int32_t gsbase __asm("ecx"); 553 554 /* 555 * Preserve the gsbase value across the selector load. 556 * Note that we have to disable interrupts because the gsbase 557 * being trashed happens to be the kernel gsbase at the time. 558 */ 559 gsbase = MSR_GSBASE; |
560 __asm __volatile("pushfq; cli; rdmsr; movl %0,%%gs; wrmsr; popfq" | 560 __asm __volatile("pushfq; cli; rdmsr; mov %0,%%gs; wrmsr; popfq" |
561 : : "rm" (sel), "c" (gsbase) : "eax", "edx"); 562} 563#else 564/* Usable by userland */ 565static __inline void 566load_fs(u_int sel) 567{ | 561 : : "rm" (sel), "c" (gsbase) : "eax", "edx"); 562} 563#else 564/* Usable by userland */ 565static __inline void 566load_fs(u_int sel) 567{ |
568 __asm __volatile("movl %0,%%fs" : : "rm" (sel)); | 568 __asm __volatile("mov %0,%%fs" : : "rm" (sel)); |
569} 570 571static __inline void 572load_gs(u_int sel) 573{ | 569} 570 571static __inline void 572load_gs(u_int sel) 573{ |
574 __asm __volatile("movl %0,%%gs" : : "rm" (sel)); | 574 __asm __volatile("mov %0,%%gs" : : "rm" (sel)); |
575} 576#endif 577 578static __inline void 579lidt(struct region_descriptor *addr) 580{ 581 __asm __volatile("lidt (%0)" : : "r" (addr)); 582} --- 216 unchanged lines hidden --- | 575} 576#endif 577 578static __inline void 579lidt(struct region_descriptor *addr) 580{ 581 __asm __volatile("lidt (%0)" : : "r" (addr)); 582} --- 216 unchanged lines hidden --- |