Print this page
de-linting of .s files
m

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/i86pc/ml/fb_swtch_src.s
          +++ new/usr/src/uts/i86pc/ml/fb_swtch_src.s
↓ open down ↓ 18 lines elided ↑ open up ↑
  19   19   * CDDL HEADER END
  20   20   */
  21   21  
  22   22  /*
  23   23   * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
  24   24   * Use is subject to license terms.
  25   25   * Copyright 2018 Joyent, Inc.
  26   26   */
  27   27  
  28   28  
  29      -#if defined(__lint)
  30      -
  31      -int fb_swtch_silence_lint = 0;
  32      -
  33      -#else
  34      -
  35   29  #include <sys/asm_linkage.h>
  36   30  #include <sys/segments.h>
  37   31  #include <sys/controlregs.h>
  38   32  #include <sys/machparam.h>
  39   33  #include <sys/multiboot.h>
  40   34  #include <sys/fastboot.h>
  41   35  #include "assym.h"
  42   36  
  43   37  /*
  44   38   * This code is to switch from 64-bit or 32-bit to protected mode.
↓ open down ↓ 44 lines elided ↑ open up ↑
  89   83          dec     snum;                           \
  90   84          jnz     1b
  91   85  
  92   86  
  93   87          .globl  _start
  94   88  _start:
  95   89  
  96   90          /* Disable interrupts */
  97   91          cli
  98   92  
  99      -#if defined(__amd64)
 100   93          /* Switch to a low memory stack */
 101   94          movq    $_start, %rsp
 102   95          addq    $FASTBOOT_STACK_OFFSET, %rsp
 103   96  
 104   97          /*
 105   98           * Copy from old stack to new stack
 106   99           * If the content before fi_valid gets bigger than 0x200 bytes,
 107  100           * the reserved stack size above will need to be changed.
 108  101           */
 109  102          movq    %rdi, %rsi      /* source from old stack */
 110  103          movq    %rsp, %rdi      /* destination on the new stack */
 111  104          movq    $FI_VALID, %rcx /* size to copy */
 112  105          rep
 113  106            smovb
 114  107  
 115      -#elif defined(__i386)
 116      -        movl    0x4(%esp), %esi /* address of fastboot info struct */
 117      -
 118      -        /* Switch to a low memory stack */
 119      -        movl    $_start, %esp
 120      -        addl    $FASTBOOT_STACK_OFFSET, %esp
 121      -
 122      -        /* Copy struct to stack */
 123      -        movl    %esp, %edi      /* destination on the new stack */
 124      -        movl    $FI_VALID, %ecx /* size to copy */
 125      -        rep
 126      -          smovb
 127      -
 128      -#endif
 129      -
 130      -#if defined(__amd64)
 131      -
 132  108          xorl    %eax, %eax
 133  109          xorl    %edx, %edx
 134  110  
 135  111          movl    $MSR_AMD_FSBASE, %ecx
 136  112          wrmsr
 137  113  
 138  114          movl    $MSR_AMD_GSBASE, %ecx
 139  115          wrmsr
 140  116  
 141  117          movl    $MSR_AMD_KGSBASE, %ecx
 142  118          wrmsr
 143  119  
 144      -#endif
 145  120          /*
 146  121           * zero out all the registers to make sure they're 16 bit clean
 147  122           */
 148      -#if defined(__amd64)
 149  123          xorq    %r8, %r8
 150  124          xorq    %r9, %r9
 151  125          xorq    %r10, %r10
 152  126          xorq    %r11, %r11
 153  127          xorq    %r12, %r12
 154  128          xorq    %r13, %r13
 155  129          xorq    %r14, %r14
 156  130          xorq    %r15, %r15
 157      -#endif
 158  131          xorl    %eax, %eax
 159  132          xorl    %ebx, %ebx
 160  133          xorl    %ecx, %ecx
 161  134          xorl    %edx, %edx
 162  135          xorl    %ebp, %ebp
 163  136  
 164      -#if defined(__amd64)
 165  137          /*
 166  138           * Load our own GDT
 167  139           */
 168  140          lgdt    gdt_info
 169      -#endif
 170  141          /*
 171  142           * Load our own IDT
 172  143           */
 173  144          lidt    idt_info
 174  145  
 175      -#if defined(__amd64)
 176  146          /*
 177  147           * Invalidate all TLB entries.
 178  148           * Load temporary pagetables to copy kernel and boot-archive
 179  149           */
 180  150          movq    %cr4, %rax
 181  151          andq    $_BITNOT(CR4_PGE), %rax
 182  152          movq    %rax, %cr4
 183  153          movq    FI_PAGETABLE_PA(%rsp), %rax
 184  154          movq    %rax, %cr3
 185  155  
↓ open down ↓ 36 lines elided ↑ open up ↑
 222  192          movw    %ax, %fs
 223  193          movw    %ax, %gs
 224  194  
 225  195          /*
 226  196           * Disable long mode by:
 227  197           * - shutting down paging (bit 31 of cr0).  This will flush the
 228  198           *   TLBs.
 229  199           * - turning off PCID in cr4
 230  200           * - disabling LME (long mode enable) in EFER (extended feature reg)
 231  201           */
 232      -#endif
 233  202          DISABLE_PAGING          /* clobbers %eax */
 234  203  
 235      -#if defined(__amd64)
 236  204          ljmp    $B32CODE_SEL, $1f
 237  205  1:
 238      -#endif
 239  206  
 240  207          /*
 241  208           * Clear PGE, PAE and PSE flags as dboot expects them to be
 242  209           * cleared.
 243  210           */
 244  211          movl    %cr4, %eax
 245  212          andl    $_BITNOT(CR4_PGE | CR4_PAE | CR4_PSE), %eax
 246  213          movl    %eax, %cr4
 247  214  
 248      -#if defined(__amd64)
 249  215          movl    $MSR_AMD_EFER, %ecx     /* Extended Feature Enable */
 250  216          rdmsr
 251  217          btcl    $8, %eax                /* bit 8 Long Mode Enable bit */
 252  218          wrmsr
 253  219  
 254      -#elif defined(__i386)
 255      -        /*
 256      -         * If fi_has_pae is set, re-enable paging with PAE.
 257      -         */
 258      -        leal    FI_FILES(%esp), %ebx    /* offset to the files */
 259      -        movl    FI_HAS_PAE(%esp), %edi  /* need to enable paging or not */
 260      -        cmpl    $0, %edi
 261      -        je      paging_on               /* no need to enable paging */
 262      -
 263      -        movl    FI_LAST_TABLE_PA(%esp), %esi    /* page table PA */
 264      -
 265      -        /*
 266      -         * Turn on PAE
 267      -         */
 268      -        movl    %cr4, %eax
 269      -        orl     $CR4_PAE, %eax
 270      -        movl    %eax, %cr4
 271      -
 272      -        /*
 273      -         * Load top pagetable base address into cr3
 274      -         */
 275      -        movl    FI_PAGETABLE_PA(%esp), %eax
 276      -        movl    %eax, %cr3
 277      -
 278      -        movl    %cr0, %eax
 279      -        orl     $_CONST(CR0_PG | CR0_WP | CR0_AM), %eax
 280      -        andl    $_BITNOT(CR0_NW | CR0_CD), %eax
 281      -        movl    %eax, %cr0
 282      -        jmp     paging_on
 283      -paging_on:
 284      -
 285      -        /* copy unix to final destination */
 286      -        leal    _MUL(FASTBOOT_UNIX, FI_FILES_INCR)(%ebx), %edx
 287      -        call    map_copy
 288      -
 289      -        /* copy boot archive to final destination */
 290      -        leal    _MUL(FASTBOOT_BOOTARCHIVE, FI_FILES_INCR)(%ebx), %edx
 291      -        call    map_copy
 292      -
 293      -        /* Disable paging one more time */
 294      -        DISABLE_PAGING
 295      -
 296      -        /* Copy sections if there are any */ 
 297      -        leal    _MUL(FASTBOOT_UNIX, FI_FILES_INCR)(%ebx), %edx
 298      -        movl    FB_SECTCNT(%edx), %eax
 299      -        cmpl    $0, %eax
 300      -        je      1f
 301      -        call    copy_sections
 302      -1:
 303      -
 304      -        /* Whatever flags we turn on we need to turn off */
 305      -        movl    %cr4, %eax
 306      -        andl    $_BITNOT(CR4_PAE), %eax
 307      -        movl    %eax, %cr4
 308      -#endif  /* __i386 */
 309      -
 310  220  dboot_jump:
 311  221          /* Jump to dboot */
 312  222          movl    $DBOOT_ENTRY_ADDRESS, %edi
 313  223          movl    FI_NEW_MBI_PA(%esp), %ebx
 314  224          movl    $MB_BOOTLOADER_MAGIC, %eax
 315  225          jmp     *%edi
 316  226  
 317      -#if defined(__amd64)
 318      -
 319  227          .code64
 320  228          ENTRY_NP(copy_sections)
 321  229          /*
 322  230           * On entry
 323  231           *      %rdi points to the fboot_file_t
 324  232           *      %rsi contains number of sections
 325  233           */
 326  234          movq    %rdi, %rdx
 327  235          movq    %rsi, %r9
 328  236  
↓ open down ↓ 25 lines elided ↑ open up ↑
 354  262          movq    $PAGESIZE, %rcx
 355  263          shrq    $3, %rcx                /* 8-byte at a time */
 356  264          rep
 357  265            smovq
 358  266          addq    $8, %rax                /* Go to next PTE */
 359  267          jmp     2b
 360  268  1:
 361  269          ret
 362  270          SET_SIZE(map_copy)      
 363  271  
 364      -#elif defined(__i386)
 365      -
 366      -        ENTRY_NP(copy_sections)
 367      -        /*
 368      -         * On entry
 369      -         *      %edx points to the fboot_file_t
 370      -         *      %eax contains the number of sections
 371      -         */
 372      -        pushl   %ebp
 373      -        pushl   %ebx
 374      -        pushl   %esi
 375      -        pushl   %edi
 376      -
 377      -        movl    %eax, %ebp
 378      -
 379      -        COPY_SECT(%edx, %ebx, %ebp)
 380      -
 381      -        popl    %edi
 382      -        popl    %esi
 383      -        popl    %ebx
 384      -        popl    %ebp
 385      -        ret
 386      -        SET_SIZE(copy_sections) 
 387      -
 388      -        ENTRY_NP(map_copy)
 389      -        /*
 390      -         * On entry
 391      -         *      %edx points to the fboot_file_t
 392      -         *      %edi has FB_HAS_PAE(%esp)
 393      -         *      %esi has FI_LAST_TABLE_PA(%esp)
 394      -         */
 395      -        pushl   %eax
 396      -        pushl   %ebx
 397      -        pushl   %ecx
 398      -        pushl   %edx
 399      -        pushl   %ebp
 400      -        pushl   %esi
 401      -        pushl   %edi
 402      -        movl    %esi, %ebp      /* Save page table PA in %ebp */
 403      -
 404      -        movl    FB_PTE_LIST_PA(%edx), %eax      /* PA list of the source */
 405      -        movl    FB_DEST_PA(%edx), %ebx          /* PA of the destination */
 406      -
 407      -loop:
 408      -        movl    (%eax), %esi                    /* Are we done? */
 409      -        cmpl    $FASTBOOT_TERMINATE, %esi
 410      -        je      done
 411      -
 412      -        cmpl    $1, (%esp)                      /* Is paging on? */
 413      -        jne     no_paging                       /* Nope */
 414      -
 415      -        movl    %ebp, %edi                      /* Page table PA */
 416      -        movl    %esi, (%edi)                    /* Program low 32-bit */
 417      -        movl    4(%eax), %esi                   /* high bits of the table */
 418      -        movl    %esi, 4(%edi)                   /* Program high 32-bit */
 419      -        movl    %cr3, %esi                      /* Reload cr3 */
 420      -        movl    %esi, %cr3
 421      -        movl    FB_VA(%edx), %esi               /* Load from VA */
 422      -        jmp     do_copy
 423      -no_paging:
 424      -        andl    $_BITNOT(MMU_PAGEOFFSET), %esi  /* clear lower 12-bit */
 425      -do_copy:
 426      -        movl    %ebx, %edi
 427      -        movl    $PAGESIZE, %ecx
 428      -        shrl    $2, %ecx        /* 4-byte at a time */
 429      -        rep
 430      -          smovl
 431      -        addl    $8, %eax /* We built the PTEs as 8-byte entries */
 432      -        addl    $PAGESIZE, %ebx
 433      -        jmp     loop
 434      -done:
 435      -        popl    %edi
 436      -        popl    %esi
 437      -        popl    %ebp
 438      -        popl    %edx
 439      -        popl    %ecx
 440      -        popl    %ebx
 441      -        popl    %eax
 442      -        ret
 443      -        SET_SIZE(map_copy)      
 444      -#endif  /* __i386 */
 445      -
 446      -
 447  272  idt_info:
 448  273          .value  0x3ff
 449  274          .quad   0
 450  275  
 451  276  /*
 452  277   * We need to trampoline thru a gdt we have in low memory.
 453  278   */
 454  279  #include "../boot/boot_gdt.s"
 455      -#endif /* __lint */
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX