-/* $OpenBSD: acpi_wakecode.S,v 1.47 2021/09/04 22:15:33 bluhm Exp $ */
+/* $OpenBSD: acpi_wakecode.S,v 1.48 2022/11/29 02:19:29 guenther Exp $ */
/*
* Copyright (c) 2001 Takanori Watanabe <takawata@jp.freebsd.org>
* Copyright (c) 2001 Mitsuru IWASAKI <iwasaki@jp.freebsd.org>
* 3. Reenable paging
* 4. Enter long mode
* 5. Restore saved CPU registers
+ *
+ * Initial copy of this code gets placed in .rodata, kernel makes
+ * RX copy of it in the ACPI trampoline page.
*/
- .text
+ .section .rodata
.code16
.align 4, 0xcc
- .global _C_LABEL(acpi_real_mode_resume)
- .global _C_LABEL(acpi_protected_mode_resume)
- .global _C_LABEL(acpi_long_mode_resume)
.global _C_LABEL(acpi_resume_end)
.global _C_LABEL(acpi_pdirpa)
.global _C_LABEL(acpi_tramp_data_start)
.global _C_LABEL(acpi_tramp_data_end)
-_C_LABEL(acpi_real_mode_resume):
+GENTRY(acpi_real_mode_resume)
_ACPI_TRMP_OFFSET(.Lacpi_s3_vector_real)
nop
cli
.code32
.align 16, 0xcc
_ACPI_TRMP_LABEL(.Lacpi_protected_mode_trampoline)
-_C_LABEL(acpi_protected_mode_resume):
+ /* acpi_protected_mode_resume: */
nop
/*
.code64
.align 16, 0xcc
_ACPI_TRMP_LABEL(.Lacpi_long_mode_trampoline)
-_C_LABEL(acpi_long_mode_resume):
/* Reset stack */
movq $(ACPI_TRAMP_DATA + 0x0FF8), %rsp
/* Jump to the identity mapped version of ourself */
mov $.Lhibernate_resume_vector_2, %rax
jmp *%rax
+END(hibernate_resume_machdep)
+
+ .section .rodata
_ACPI_TRMP_LABEL(.Lhibernate_resume_vector_2)
/* Get out of 64 bit CS */
/* Jump to the identity mapped version of ourself */
mov $.Lhibernate_resume_vector_2b, %rax
jmp *%rax
+END(hibernate_drop_to_real_mode)
+
+ .section .rodata
_ACPI_TRMP_LABEL(.Lhibernate_resume_vector_2b)
/* Get out of 64 bit CS */
1: RETGUARD_CHECK(hibernate_activate_resume_pt_machdep, r11)
ret
lfence
+END(hibernate_activate_resume_pt_machdep)
/*
* Switch to the private resume-time hibernate stack
RETGUARD_CHECK(hibernate_switch_stack_machdep, r11)
ret
lfence
+END(hibernate_switch_stack_machdep)
NENTRY(hibernate_flush)
RETGUARD_SETUP(hibernate_flush, r11)
RETGUARD_CHECK(hibernate_flush, r11)
ret
lfence
+END(hibernate_flush)
#endif /* HIBERNATE */
/*
* End of resume code (code copied to ACPI_TRAMPOLINE)
*/
+ .section .rodata
+ .type acpi_resume_end,@object
_C_LABEL(acpi_resume_end):
+END(acpi_real_mode_resume)
/*
* Initial copy of this data gets placed in .rodata, kernel makes
* RW copy of it in the tramp data page.
*/
.section .rodata
+ .type acpi_tramp_data_start,@object
_C_LABEL(acpi_tramp_data_start):
_ACPI_TRMP_DATA_OFFSET(.Ltmp_gdt)
.word .Ltmp_gdt_end - .Ltmp_gdtable
#endif
.align 4, 0xcc
+ .type acpi_pdirpa,@object
_ACPI_TRMP_DATA_LABEL(acpi_pdirpa)
.long 0
+ .size acpi_pdirpa, 4
#ifdef HIBERNATE
_ACPI_TRMP_DATA_LABEL(.Lhibernate_indirect_16)
.long .Lhibernate_resume_vector_3
.word 0x18
#endif /* HIBERNATE */
+ .type acpi_tramp_data_end,@object
_C_LABEL(acpi_tramp_data_end):
+END(acpi_tramp_data_start)
/*
* acpi_savecpu saves the processor's registers and flags
RETGUARD_CHECK(acpi_savecpu, r11)
ret
lfence
+END(acpi_savecpu)
-/* $OpenBSD: mptramp.S,v 1.20 2019/10/08 16:58:09 mlarkin Exp $ */
+/* $OpenBSD: mptramp.S,v 1.21 2022/11/29 02:19:29 guenther Exp $ */
/* $NetBSD: mptramp.S,v 1.1 2003/04/26 18:39:30 fvdl Exp $ */
/*-
MP_TRAMP_DATA
#define _TRMP_DATA_OFFSET(a) a = . - _C_LABEL(mp_tramp_data_start)
- .global _C_LABEL(cpu_spinup_trampoline)
.global _C_LABEL(cpu_spinup_trampoline_end)
- .global _C_LABEL(cpu_hatch)
- .global _C_LABEL(local_apic)
- .global _C_LABEL(mp_pdirpa)
.global _C_LABEL(mp_tramp_data_start)
.global _C_LABEL(mp_tramp_data_end)
- .text
+ /*
+ * Initial copy of this code gets placed in .rodata, kernel
+ * makes RX copy of it in the MP trampoline page.
+ */
+ .section .rodata
.align 4, 0xcc
.code16
-_C_LABEL(cpu_spinup_trampoline):
+GENTRY(cpu_spinup_trampoline)
cli
movw $(MP_TRAMP_DATA >> 4), %ax
movw %ax, %ds
_TRMP_LABEL(.Lmptramp_longmode)
.code64
- movabsq $_C_LABEL(cpu_spinup_trampoline_end),%rax
+ movabsq $cpu_spinup_finish,%rax
jmp *%rax
-
+ .type cpu_spinup_trampoline_end,@object
_C_LABEL(cpu_spinup_trampoline_end): #end of code copied to MP_TRAMPOLINE
- .globl _C_LABEL(x2apic_enabled)
+END(cpu_spinup_trampoline)
+
+ .text
+GENTRY(cpu_spinup_finish)
movl x2apic_enabled,%eax
testl %eax,%eax
jz 1f
movl $CR0_DEFAULT,%eax
movq %rax,%cr0
call _C_LABEL(cpu_hatch)
+END(cpu_spinup_finish)
/* NOTREACHED */
.section .rodata
+ .type mp_tramp_data_start,@object
_C_LABEL(mp_tramp_data_start):
_TRMP_DATA_LABEL(.Lmptramp_jmp64)
.long .Lmptramp_longmode
.word GSEL(GCODE_SEL, SEL_KPL)
.global mp_pdirpa
+ .type mp_pdirpa,@object
_TRMP_DATA_LABEL(mp_pdirpa)
.long 0
+ .size mp_pdirpa,4
_TRMP_DATA_LABEL(.Lmptramp_gdt32)
_TRMP_DATA_LABEL(.Lmptramp_gdt64_desc)
.word 0x17
.long .Lmptramp_gdt64
+
+ .type mp_tramp_data_end,@object
_C_LABEL(mp_tramp_data_end):
+END(mp_tramp_data_start)