diff options
author | Mike Larkin <mlarkin@cvs.openbsd.org> | 2013-06-01 17:16:52 +0000 |
---|---|---|
committer | Mike Larkin <mlarkin@cvs.openbsd.org> | 2013-06-01 17:16:52 +0000 |
commit | e4cca411bb39a0db04a89ce79cce2f15266c3e4f (patch) | |
tree | 5e91785825468c15f23a523f4f959f05063f791b /sys | |
parent | b1a0ee253d61f2170cd68b59d708048553691206 (diff) |
Add code to drop a CPU from long mode back to real mode, will be used to
park CPUs back to a known state in preparation for re-INIT/SIPIing them
later in the hibernate resume cycle.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/amd64/amd64/acpi_wakecode.S | 43 |
1 files changed, 42 insertions, 1 deletions
diff --git a/sys/arch/amd64/amd64/acpi_wakecode.S b/sys/arch/amd64/amd64/acpi_wakecode.S index 466535dd8f8..30e413f340f 100644 --- a/sys/arch/amd64/amd64/acpi_wakecode.S +++ b/sys/arch/amd64/amd64/acpi_wakecode.S @@ -1,4 +1,4 @@ -/* $OpenBSD: acpi_wakecode.S,v 1.16 2013/01/17 00:54:48 mlarkin Exp $ */ +/* $OpenBSD: acpi_wakecode.S,v 1.17 2013/06/01 17:16:51 mlarkin Exp $ */ /* * Copyright (c) 2001 Takanori Watanabe <takawata@jp.freebsd.org> * Copyright (c) 2001 Mitsuru IWASAKI <iwasaki@jp.freebsd.org> @@ -421,6 +421,47 @@ _ACPI_TRMP_LABEL(hibernate_resume_vector_3) /* Jump to the S3 resume vector */ ljmp $0x0400, $acpi_s3_vector_real +NENTRY(hibernate_drop_to_real_mode) + .code64 + cli + /* Jump to the identity mapped version of ourself */ + mov $hibernate_resume_vector_2b, %rax + jmp *%rax +_ACPI_TRMP_LABEL(hibernate_resume_vector_2b) + + /* Get out of 64 bit CS */ + lgdtq tmp_gdt6416 + + rex64 ljmp *(hibernate_indirect_16b) +_ACPI_TRMP_LABEL(hibernate_indirect_16b) + .quad hibernate_resume_vector_3b + .word 0x18 + +_ACPI_TRMP_LABEL(hibernate_resume_vector_3b) + .code16 + + movl %cr0, %eax + /* Disable CR0.PG - no paging */ + andl $(~CR0_PG), %eax + /* Disable CR0.PE - real mode */ + andl $(~CR0_PE), %eax + movl %eax, %cr0 + + /* Set up real mode segment selectors */ + movw $0x0400, %ax + movw %ax, %ds + movw %ax, %es + movw %ax, %fs + movw %ax, %gs + movl $0x0FFE, %esp + lidtl clean_idt + + ljmp $0x0400, $hib_hlt_real + +_ACPI_TRMP_LABEL(hib_hlt_real) + hlt + ljmp $0x0400, $hib_hlt_real + .code64 /* Switch to hibernate resume pagetable */ NENTRY(hibernate_activate_resume_pt_machdep) |