Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * purgatory:  setup code
0004  *
0005  * Copyright (C) 2003,2004  Eric Biederman (ebiederm@xmission.com)
0006  * Copyright (C) 2014 Red Hat Inc.
0007  *
0008  * This code has been taken from kexec-tools.
0009  */
0010 #include <linux/linkage.h>
0011 #include <asm/purgatory.h>
0012 
0013     .text
0014     .balign 16
0015     .code64
0016 
0017 SYM_CODE_START(purgatory_start)
0018     /* Load a gdt so I know what the segment registers are */
0019     lgdt    gdt(%rip)
0020 
0021     /* load the data segments */
0022     movl    $0x18, %eax /* data segment */
0023     movl    %eax, %ds
0024     movl    %eax, %es
0025     movl    %eax, %ss
0026     movl    %eax, %fs
0027     movl    %eax, %gs
0028 
0029     /* Setup a stack */
0030     leaq    lstack_end(%rip), %rsp
0031 
0032     /* Call the C code */
0033     call purgatory
0034     jmp entry64
0035 SYM_CODE_END(purgatory_start)
0036 
0037     .section ".rodata"
0038     .balign 16
0039 SYM_DATA_START_LOCAL(gdt)
0040     /* 0x00 unusable segment
0041      * 0x08 unused
0042      * so use them as the gdt ptr
0043      */
0044     .word   gdt_end - gdt - 1
0045     .quad   gdt
0046     .word   0, 0, 0
0047 
0048     /* 0x10 4GB flat code segment */
0049     .word   0xFFFF, 0x0000, 0x9A00, 0x00AF
0050 
0051     /* 0x18 4GB flat data segment */
0052     .word   0xFFFF, 0x0000, 0x9200, 0x00CF
0053 SYM_DATA_END_LABEL(gdt, SYM_L_LOCAL, gdt_end)
0054 
0055     .bss
0056     .balign 4096
0057 SYM_DATA_START_LOCAL(lstack)
0058     .skip 4096
0059 SYM_DATA_END_LABEL(lstack, SYM_L_LOCAL, lstack_end)