summaryrefslogtreecommitdiff
path: root/src/arch/x86/acpi_s3.c
blob: ec1fafcd3cf7d201d804d9dd3b4f0945028fe4e5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/* SPDX-License-Identifier: GPL-2.0-only */

#include <console/console.h>
#include <string.h>
#include <acpi/acpi.h>
#include <arch/cpu.h>
#include <commonlib/helpers.h>
#include <fallback.h>
#include <timestamp.h>

#define WAKEUP_BASE 0x600

asmlinkage void (*acpi_do_wakeup)(uintptr_t vector) = (void *)WAKEUP_BASE;

extern unsigned char __wakeup;
extern unsigned int __wakeup_size;

void __noreturn acpi_resume(void *wake_vec)
{
	/* Call mainboard resume handler first, if defined. */
	mainboard_suspend_resume();

	/* Copy wakeup trampoline in place. */
	memcpy((void *)WAKEUP_BASE, &__wakeup, __wakeup_size);

	set_boot_successful();

	timestamp_add_now(TS_ACPI_WAKE_JUMP);

	post_code(POST_OS_RESUME);
	acpi_do_wakeup((uintptr_t)wake_vec);

	die("Failed the jump to wakeup vector\n");
}