Print this page
de-linting of .s files
first


   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  */
  25 




  26 #include <sys/asm_linkage.h>
  27 #include <sys/asm_misc.h>
  28 #include <sys/regset.h>
  29 #include <sys/panic.h>
  30 #include <sys/ontrap.h>
  31 #include <sys/privregs.h>
  32 #include <sys/segments.h>
  33 #include <sys/trap.h>
  34 
  35 #if defined(__lint)
  36 #include <sys/types.h>
  37 #include <sys/systm.h>
  38 #include <sys/thread.h>
  39 #include <sys/archsystm.h>
  40 #include <sys/byteorder.h>
  41 #include <sys/dtrace.h>
  42 #include <sys/x86_archext.h>
  43 #else   /* __lint */
  44 #include "assym.h"
  45 #endif  /* __lint */
  46 
  47 #if defined(__lint)
  48 
  49 /*ARGSUSED*/
  50 void
  51 rd_idtr(desctbr_t *idtr)
  52 {}
  53 
  54 /*ARGSUSED*/
  55 void
  56 wr_idtr(desctbr_t *idtr)
  57 {}
  58 
  59 #else   /* __lint */
  60 
  61 #if defined(__amd64)
  62 
  63         ENTRY_NP(rd_idtr)
  64         sidt    (%rdi)
  65         ret
  66         SET_SIZE(rd_idtr)
  67 
  68         ENTRY_NP(wr_idtr)
  69         lidt    (%rdi)
  70         ret
  71         SET_SIZE(wr_idtr)
  72 
  73 #elif defined(__i386)
  74 
  75         ENTRY_NP(rd_idtr)
  76         pushl   %ebp
  77         movl    %esp, %ebp
  78         movl    8(%ebp), %edx
  79         sidt    (%edx)
  80         leave
  81         ret
  82         SET_SIZE(rd_idtr)
  83 
  84         ENTRY_NP(wr_idtr)
  85         pushl   %ebp
  86         movl    %esp, %ebp
  87         movl    8(%ebp), %edx
  88         lidt    (%edx)
  89         leave
  90         ret
  91         SET_SIZE(wr_idtr)
  92 
  93 #endif  /* __i386 */
  94 #endif  /* __lint */
  95 
  96 #if defined(__lint)
  97 
  98 /*ARGSUSED*/
  99 void
 100 rd_gdtr(desctbr_t *gdtr)
 101 {}
 102 
 103 /*ARGSUSED*/
 104 void
 105 wr_gdtr(desctbr_t *gdtr)
 106 {}
 107 
 108 #else   /* __lint */
 109 
 110 #if defined(__amd64)
 111 
 112         ENTRY_NP(rd_gdtr)
 113         pushq   %rbp
 114         movq    %rsp, %rbp
 115         sgdt    (%rdi)
 116         leave
 117         ret
 118         SET_SIZE(rd_gdtr)
 119 
 120         ENTRY_NP(wr_gdtr)
 121         pushq   %rbp
 122         movq    %rsp, %rbp
 123         lgdt    (%rdi)
 124         jmp     1f
 125         nop
 126 1:
 127         leave
 128         ret
 129         SET_SIZE(wr_gdtr)
 130 
 131 #elif defined(__i386)
 132 
 133         ENTRY_NP(rd_gdtr)
 134         pushl   %ebp
 135         movl    %esp, %ebp
 136         movl    8(%ebp), %edx
 137         sgdt    (%edx)
 138         leave
 139         ret
 140         SET_SIZE(rd_gdtr)
 141 
 142         ENTRY_NP(wr_gdtr)
 143         pushl   %ebp
 144         movl    %esp, %ebp
 145         movl    8(%ebp), %edx
 146         lgdt    (%edx)
 147         jmp     1f
 148         nop
 149 1:
 150         leave
 151         ret
 152         SET_SIZE(wr_gdtr)
 153 
 154 #endif  /* __i386 */
 155 #endif  /* __lint */
 156 
 157 #if defined(__amd64)
 158 #if defined(__lint)
 159 
 160 /*ARGSUSED*/
 161 void
 162 load_segment_registers(selector_t cs, selector_t fs, selector_t gs,
 163     selector_t ss)
 164 {}
 165 
 166 selector_t
 167 get_cs_register()
 168 { return (0); }
 169 
 170 #else   /* __lint */
 171 
 172         /*
 173          * loads zero selector for ds and es.
 174          */
 175         ENTRY_NP(load_segment_registers)
 176         pushq   %rbp
 177         movq    %rsp, %rbp
 178         pushq   %rdi
 179         pushq   $.newcs
 180         lretq
 181 .newcs:
 182         /*
 183          * zero %ds and %es - they're ignored anyway
 184          */
 185         xorl    %eax, %eax
 186         movw    %ax, %ds
 187         movw    %ax, %es
 188         movl    %esi, %eax
 189         movw    %ax, %fs
 190         movl    %edx, %eax
 191         movw    %ax, %gs
 192         movl    %ecx, %eax
 193         movw    %ax, %ss
 194         leave
 195         ret
 196         SET_SIZE(load_segment_registers)
 197 
 198         ENTRY_NP(get_cs_register)
 199         movq    %cs, %rax
 200         ret
 201         SET_SIZE(get_cs_register)
 202 
 203 #endif  /* __lint */
 204 #elif defined(__i386)
 205 
 206 #if defined(__lint)
 207 
 208 /*ARGSUSED*/
 209 void
 210 load_segment_registers(
 211     selector_t cs, selector_t ds, selector_t es,
 212     selector_t fs, selector_t gs, selector_t ss)
 213 {}
 214 
 215 selector_t
 216 get_cs_register()
 217 { return ((selector_t) 0); }
 218 
 219 #else   /* __lint */
 220 
 221         ENTRY_NP(load_segment_registers)
 222         pushl   %ebp
 223         movl    %esp, %ebp
 224 
 225         pushl   0x8(%ebp)
 226         pushl   $.newcs
 227         lret
 228 .newcs:
 229         movw    0xc(%ebp), %ax
 230         movw    %ax, %ds
 231         movw    0x10(%ebp), %ax
 232         movw    %ax, %es
 233         movw    0x14(%ebp), %ax
 234         movw    %ax, %fs
 235         movw    0x18(%ebp), %ax
 236         movw    %ax, %gs
 237         movw    0x1c(%ebp), %ax
 238         movw    %ax, %ss
 239         leave
 240         ret
 241         SET_SIZE(load_segment_registers)
 242 
 243         ENTRY_NP(get_cs_register)
 244         movl    $0, %eax
 245         movw    %cs, %ax
 246         ret
 247         SET_SIZE(get_cs_register)
 248 
 249 #endif  /* __lint */
 250 #endif  /* __i386 */
 251 
 252 #if defined(__lint)
 253 
 254 /*ARGSUSED*/
 255 void
 256 wr_ldtr(selector_t ldtsel)
 257 {}
 258 
 259 selector_t
 260 rd_ldtr(void)
 261 { return (0); }
 262 
 263 #else   /* __lint */
 264 
 265 #if defined(__amd64)
 266 
 267         ENTRY_NP(wr_ldtr)
 268         movq    %rdi, %rax
 269         lldt    %ax
 270         ret
 271         SET_SIZE(wr_ldtr)
 272 
 273         ENTRY_NP(rd_ldtr)
 274         xorl    %eax, %eax
 275         sldt    %ax
 276         ret
 277         SET_SIZE(rd_ldtr)
 278 
 279 #elif defined(__i386)
 280 
 281         ENTRY_NP(wr_ldtr)
 282         movw    4(%esp), %ax
 283         lldt    %ax
 284         ret
 285         SET_SIZE(wr_ldtr)
 286 
 287         ENTRY_NP(rd_ldtr)
 288         xorl    %eax, %eax
 289         sldt    %ax
 290         ret
 291         SET_SIZE(rd_ldtr)
 292 
 293 #endif  /* __i386 */
 294 #endif  /* __lint */
 295 
 296 #if defined(__lint)
 297 
 298 /*ARGSUSED*/
 299 void
 300 wr_tsr(selector_t tsssel)
 301 {}
 302 
 303 #else   /* __lint */
 304 
 305 #if defined(__amd64)
 306 
 307         ENTRY_NP(wr_tsr)
 308         movq    %rdi, %rax
 309         ltr     %ax
 310         ret
 311         SET_SIZE(wr_tsr)
 312 
 313 #elif defined(__i386)
 314 
 315         ENTRY_NP(wr_tsr)
 316         movw    4(%esp), %ax
 317         ltr     %ax
 318         ret
 319         SET_SIZE(wr_tsr)
 320 
 321 #endif  /* __i386 */
 322 #endif  /* __lint */


   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  */
  25 
  26 /*
  27  * Copyright 2019 Joyent, Inc.
  28  */
  29 
  30 #include <sys/asm_linkage.h>
  31 #include <sys/asm_misc.h>
  32 #include <sys/regset.h>
  33 #include <sys/panic.h>
  34 #include <sys/ontrap.h>
  35 #include <sys/privregs.h>
  36 #include <sys/segments.h>
  37 #include <sys/trap.h>
  38 









  39 #include "assym.h"

  40 
















  41         ENTRY_NP(rd_idtr)
  42         sidt    (%rdi)
  43         ret
  44         SET_SIZE(rd_idtr)
  45 
  46         ENTRY_NP(wr_idtr)
  47         lidt    (%rdi)
  48         ret
  49         SET_SIZE(wr_idtr)
  50 







































  51         ENTRY_NP(rd_gdtr)
  52         pushq   %rbp
  53         movq    %rsp, %rbp
  54         sgdt    (%rdi)
  55         leave
  56         ret
  57         SET_SIZE(rd_gdtr)
  58 
  59         ENTRY_NP(wr_gdtr)
  60         pushq   %rbp
  61         movq    %rsp, %rbp
  62         lgdt    (%rdi)
  63         jmp     1f
  64         nop
  65 1:
  66         leave
  67         ret
  68         SET_SIZE(wr_gdtr)
  69 









































  70         /*
  71          * loads zero selector for ds and es.
  72          */
  73         ENTRY_NP(load_segment_registers)
  74         pushq   %rbp
  75         movq    %rsp, %rbp
  76         pushq   %rdi
  77         pushq   $.newcs
  78         lretq
  79 .newcs:
  80         /*
  81          * zero %ds and %es - they're ignored anyway
  82          */
  83         xorl    %eax, %eax
  84         movw    %ax, %ds
  85         movw    %ax, %es
  86         movl    %esi, %eax
  87         movw    %ax, %fs
  88         movl    %edx, %eax
  89         movw    %ax, %gs
  90         movl    %ecx, %eax
  91         movw    %ax, %ss
  92         leave
  93         ret
  94         SET_SIZE(load_segment_registers)
  95 
  96         ENTRY_NP(get_cs_register)
  97         movq    %cs, %rax
  98         ret
  99         SET_SIZE(get_cs_register)
 100 
































































 101         ENTRY_NP(wr_ldtr)
 102         movq    %rdi, %rax
 103         lldt    %ax
 104         ret
 105         SET_SIZE(wr_ldtr)
 106 
 107         ENTRY_NP(rd_ldtr)
 108         xorl    %eax, %eax
 109         sldt    %ax
 110         ret
 111         SET_SIZE(rd_ldtr)
 112 




























 113         ENTRY_NP(wr_tsr)
 114         movq    %rdi, %rax
 115         ltr     %ax
 116         ret
 117         SET_SIZE(wr_tsr)
 118