Author: kib
Date: Wed Sep 21 10:10:36 2016
New Revision: 306088
URL: https://svnweb.freebsd.org/changeset/base/306088

Log:
  Add amd64 functions to load/store GDT register, store IDT and TR registers.
  
  Note that lgdt() name is already used for function which, besides
  loading GDT, also reloads segment descriptors cache, thus new function
  is named bare_lgdt().
  
  Sponsored by: The FreeBSD Foundation
  MFC after:    1 week

Modified:
  head/sys/amd64/include/cpufunc.h

Modified: head/sys/amd64/include/cpufunc.h
==============================================================================
--- head/sys/amd64/include/cpufunc.h    Wed Sep 21 10:05:51 2016        
(r306087)
+++ head/sys/amd64/include/cpufunc.h    Wed Sep 21 10:10:36 2016        
(r306088)
@@ -645,12 +645,36 @@ load_gs(u_short sel)
 #endif
 
 static __inline void
+bare_lgdt(struct region_descriptor *addr)
+{
+       __asm __volatile("lgdt (%0)" : : "r" (addr));
+}
+
+static __inline void
+sgdt(struct region_descriptor *addr)
+{
+       char *loc;
+
+       loc = (char *)addr;
+       __asm __volatile("sgdt %0" : "=m" (*loc) : : "memory");
+}
+
+static __inline void
 lidt(struct region_descriptor *addr)
 {
        __asm __volatile("lidt (%0)" : : "r" (addr));
 }
 
 static __inline void
+sidt(struct region_descriptor *addr)
+{
+       char *loc;
+
+       loc = (char *)addr;
+       __asm __volatile("sidt %0" : "=m" (*loc) : : "memory");
+}
+
+static __inline void
 lldt(u_short sel)
 {
        __asm __volatile("lldt %0" : : "r" (sel));
@@ -662,6 +686,15 @@ ltr(u_short sel)
        __asm __volatile("ltr %0" : : "r" (sel));
 }
 
+static __inline uint32_t
+read_tr(void)
+{
+       u_short sel;
+
+       __asm __volatile("str %0" : "=r" (sel));
+       return (sel);
+}
+
 static __inline uint64_t
 rdr0(void)
 {
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to