2019-07-05 02:27:20 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2019 Intel Corp.
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
|
|
|
|
2019-07-06 03:02:49 +08:00
|
|
|
#ifndef ZEPHYR_INCLUDE_ARCH_X86_INTEL64_ARCH_H_
|
|
|
|
#define ZEPHYR_INCLUDE_ARCH_X86_INTEL64_ARCH_H_
|
|
|
|
|
|
|
|
#include <kernel_arch_thread.h>
|
|
|
|
|
2019-07-05 11:17:14 +08:00
|
|
|
#define STACK_ALIGN 16
|
|
|
|
#define STACK_SIZE_ALIGN 16
|
|
|
|
|
2019-09-19 00:01:18 +08:00
|
|
|
#if CONFIG_ISR_STACK_SIZE != (CONFIG_ISR_SUBSTACK_SIZE * CONFIG_ISR_DEPTH)
|
|
|
|
#error "Check ISR stack configuration (CONFIG_ISR_*)"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if CONFIG_ISR_SUBSTACK_SIZE % STACK_ALIGN
|
|
|
|
#error "CONFIG_ISR_SUBSTACK_SIZE must be a multiple of 16"
|
|
|
|
#endif
|
|
|
|
|
2019-07-06 03:02:49 +08:00
|
|
|
#ifndef _ASMLANGUAGE
|
|
|
|
|
2019-07-24 02:05:42 +08:00
|
|
|
#define Z_ARCH_THREAD_STACK_LEN(size) (ROUND_UP((size), STACK_SIZE_ALIGN))
|
|
|
|
|
2019-07-05 11:17:14 +08:00
|
|
|
#define Z_ARCH_THREAD_STACK_DEFINE(sym, size) \
|
|
|
|
struct _k_thread_stack_element __noinit \
|
|
|
|
__aligned(STACK_ALIGN) \
|
2019-07-24 02:05:42 +08:00
|
|
|
sym[Z_ARCH_THREAD_STACK_LEN(size)]
|
2019-07-05 11:17:14 +08:00
|
|
|
|
|
|
|
#define Z_ARCH_THREAD_STACK_ARRAY_DEFINE(sym, nmemb, size) \
|
|
|
|
struct _k_thread_stack_element __noinit \
|
|
|
|
__aligned(STACK_ALIGN) \
|
2019-07-24 02:05:42 +08:00
|
|
|
sym[nmemb][Z_ARCH_THREAD_STACK_LEN(size)]
|
2019-07-05 11:17:14 +08:00
|
|
|
|
2019-10-01 02:51:42 +08:00
|
|
|
#define Z_ARCH_THREAD_STACK_MEMBER(sym, size) \
|
|
|
|
struct _k_thread_stack_element __aligned(STACK_ALIGN) \
|
|
|
|
sym[Z_ARCH_THREAD_STACK_LEN(size)]
|
|
|
|
|
2019-07-05 11:17:14 +08:00
|
|
|
#define Z_ARCH_THREAD_STACK_SIZEOF(sym) sizeof(sym)
|
|
|
|
#define Z_ARCH_THREAD_STACK_BUFFER(sym) ((char *) sym)
|
|
|
|
|
2019-07-06 03:02:49 +08:00
|
|
|
static ALWAYS_INLINE unsigned int z_arch_irq_lock(void)
|
|
|
|
{
|
|
|
|
unsigned long key;
|
|
|
|
|
2019-07-27 00:53:17 +08:00
|
|
|
__asm__ volatile ("pushfq; cli; popq %0" : "=g" (key) : : "memory");
|
2019-07-06 03:02:49 +08:00
|
|
|
|
|
|
|
return (unsigned int) key;
|
|
|
|
}
|
|
|
|
|
2019-07-05 04:49:06 +08:00
|
|
|
/*
|
2019-07-16 04:18:36 +08:00
|
|
|
* the exception stack frame
|
2019-07-05 04:49:06 +08:00
|
|
|
*/
|
|
|
|
|
2019-07-05 11:17:14 +08:00
|
|
|
struct x86_esf {
|
2019-07-16 04:18:36 +08:00
|
|
|
unsigned long rax;
|
|
|
|
unsigned long rbx;
|
|
|
|
unsigned long rcx;
|
|
|
|
unsigned long rdx;
|
|
|
|
unsigned long rbp;
|
|
|
|
unsigned long rsi;
|
|
|
|
unsigned long rdi;
|
|
|
|
unsigned long r8;
|
|
|
|
unsigned long r9;
|
|
|
|
unsigned long r10;
|
|
|
|
unsigned long r11;
|
|
|
|
unsigned long r12;
|
|
|
|
unsigned long r13;
|
|
|
|
unsigned long r14;
|
|
|
|
unsigned long r15;
|
|
|
|
unsigned long vector;
|
|
|
|
unsigned long code;
|
|
|
|
unsigned long rip;
|
|
|
|
unsigned long cs;
|
|
|
|
unsigned long rflags;
|
|
|
|
unsigned long rsp;
|
|
|
|
unsigned long ss;
|
2019-07-05 11:17:14 +08:00
|
|
|
};
|
2019-07-05 04:49:06 +08:00
|
|
|
|
2019-07-05 11:17:14 +08:00
|
|
|
typedef struct x86_esf z_arch_esf_t;
|
2019-07-05 04:49:06 +08:00
|
|
|
|
2019-07-05 11:17:14 +08:00
|
|
|
#endif /* _ASMLANGUAGE */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* All Intel64 interrupts are dynamically connected.
|
|
|
|
*/
|
2019-07-05 04:49:06 +08:00
|
|
|
|
2019-07-05 11:17:14 +08:00
|
|
|
#define Z_ARCH_IRQ_CONNECT z_arch_irq_connect_dynamic
|
2019-07-05 04:49:06 +08:00
|
|
|
|
2019-07-05 02:27:20 +08:00
|
|
|
#endif /* ZEPHYR_INCLUDE_ARCH_X86_INTEL64_ARCH_H_ */
|