Zephyr API Documentation
2.7.0-rc2
A Scalable Open Source RTOS
arch.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2019 Intel Corp.
3
* SPDX-License-Identifier: Apache-2.0
4
*/
5
6
#ifndef ZEPHYR_INCLUDE_ARCH_X86_INTEL64_ARCH_H_
7
#define ZEPHYR_INCLUDE_ARCH_X86_INTEL64_ARCH_H_
8
9
#include <
arch/x86/intel64/thread.h
>
10
#include <
arch/x86/thread_stack.h
>
11
12
#if CONFIG_ISR_STACK_SIZE != (CONFIG_ISR_SUBSTACK_SIZE * CONFIG_ISR_DEPTH)
13
#error "Check ISR stack configuration (CONFIG_ISR_*)"
14
#endif
15
16
#if CONFIG_ISR_SUBSTACK_SIZE % ARCH_STACK_PTR_ALIGN
17
#error "CONFIG_ISR_SUBSTACK_SIZE must be a multiple of 16"
18
#endif
19
20
#ifndef _ASMLANGUAGE
21
22
static
ALWAYS_INLINE
void
sys_write64
(
uint64_t
data
,
mm_reg_t
addr)
23
{
24
__asm__
volatile
(
"movq %0, %1"
25
:
26
:
"r"
(
data
),
"m"
(*(
volatile
uint64_t
*)
27
(
uintptr_t
) addr)
28
:
"memory"
);
29
}
30
31
static
ALWAYS_INLINE
uint64_t
sys_read64
(
mm_reg_t
addr)
32
{
33
uint64_t
ret
;
34
35
__asm__
volatile
(
"movq %1, %0"
36
:
"=r"
(
ret
)
37
:
"m"
(*(
volatile
uint64_t
*)(
uintptr_t
) addr)
38
:
"memory"
);
39
40
return
ret
;
41
}
42
43
static
ALWAYS_INLINE
unsigned
int
arch_irq_lock
(
void
)
44
{
45
unsigned
long
key
;
46
47
__asm__
volatile
(
"pushfq; cli; popq %0"
:
"=g"
(
key
) : :
"memory"
);
48
49
return
(
unsigned
int
)
key
;
50
}
51
52
/*
53
* the exception stack frame
54
*/
55
56
struct
x86_esf
{
57
#ifdef CONFIG_EXCEPTION_DEBUG
58
/* callee-saved */
59
unsigned
long
rbx;
60
unsigned
long
r12;
61
unsigned
long
r13;
62
unsigned
long
r14;
63
unsigned
long
r15;
64
#endif
/* CONFIG_EXCEPTION_DEBUG */
65
unsigned
long
rbp
;
66
67
/* Caller-saved regs */
68
unsigned
long
rax
;
69
unsigned
long
rcx
;
70
unsigned
long
rdx
;
71
unsigned
long
rsi
;
72
unsigned
long
rdi
;
73
unsigned
long
r8
;
74
unsigned
long
r9
;
75
unsigned
long
r10
;
76
/* Must be aligned 16 bytes from the end of this struct due to
77
* requirements of 'fxsave (%rsp)'
78
*/
79
char
fxsave
[
X86_FXSAVE_SIZE
];
80
unsigned
long
r11
;
81
82
/* Pushed by CPU or assembly stub */
83
unsigned
long
vector
;
84
unsigned
long
code
;
85
unsigned
long
rip
;
86
unsigned
long
cs
;
87
unsigned
long
rflags
;
88
unsigned
long
rsp
;
89
unsigned
long
ss
;
90
};
91
92
typedef
struct
x86_esf
z_arch_esf_t;
93
94
struct
x86_ssf
{
95
unsigned
long
rip
;
96
unsigned
long
rflags
;
97
unsigned
long
r10
;
98
unsigned
long
r9
;
99
unsigned
long
r8
;
100
unsigned
long
rdx
;
101
unsigned
long
rsi
;
102
char
fxsave
[
X86_FXSAVE_SIZE
];
103
unsigned
long
rdi
;
104
unsigned
long
rsp
;
105
};
106
107
#define ARCH_EXCEPT(reason_p) do { \
108
__asm__ volatile( \
109
"movq %[reason], %%rax\n\t"
\
110
"int $32\n\t" \
111
: \
112
: [reason] "i" (reason_p)); \
113
CODE_UNREACHABLE;
/* LCOV_EXCL_LINE */
\
114
} while (false)
115
116
#endif
/* _ASMLANGUAGE */
117
118
#ifdef CONFIG_PCIE
119
#define X86_RESERVE_IRQ(irq_p, name) \
120
static Z_DECL_ALIGN(uint8_t) name \
121
__in_section(_irq_alloc, static, name) __used = irq_p
122
#else
123
#define X86_RESERVE_IRQ(irq_p, name)
124
#endif
125
126
/*
127
* All Intel64 interrupts are dynamically connected.
128
*/
129
130
#define ARCH_IRQ_CONNECT(irq_p, priority_p, isr_p, isr_param_p, flags_p) \
131
X86_RESERVE_IRQ(irq_p, _CONCAT(_irq_alloc_fixed, __COUNTER__)); \
132
arch_irq_connect_dynamic(irq_p, priority_p, \
133
(void (*)(const void *))isr_p, \
134
isr_param_p, flags_p)
135
136
/*
137
* Thread object needs to be 16-byte aligned.
138
*/
139
#define ARCH_DYMANIC_OBJ_K_THREAD_ALIGNMENT 16
140
141
#endif
/* ZEPHYR_INCLUDE_ARCH_X86_INTEL64_ARCH_H_ */
thread.h
X86_FXSAVE_SIZE
#define X86_FXSAVE_SIZE
Definition:
thread.h:37
thread_stack.h
ALWAYS_INLINE
#define ALWAYS_INLINE
Definition:
common.h:116
ret
static ZTEST_BMEM volatile int ret
Definition:
k_float_disable.c:28
key
static k_spinlock_key_t key
Definition:
spinlock_error_case.c:14
uint64_t
__UINT64_TYPE__ uint64_t
Definition:
stdint.h:61
uintptr_t
__UINTPTR_TYPE__ uintptr_t
Definition:
stdint.h:75
x86_esf
Definition:
arch.h:56
x86_esf::rsp
unsigned long rsp
Definition:
arch.h:88
x86_esf::r11
unsigned long r11
Definition:
arch.h:80
x86_esf::vector
unsigned long vector
Definition:
arch.h:83
x86_esf::cs
unsigned long cs
Definition:
arch.h:86
x86_esf::rip
unsigned long rip
Definition:
arch.h:85
x86_esf::ss
unsigned long ss
Definition:
arch.h:89
x86_esf::r8
unsigned long r8
Definition:
arch.h:73
x86_esf::rbp
unsigned long rbp
Definition:
arch.h:65
x86_esf::r10
unsigned long r10
Definition:
arch.h:75
x86_esf::rcx
unsigned long rcx
Definition:
arch.h:69
x86_esf::code
unsigned long code
Definition:
arch.h:84
x86_esf::r9
unsigned long r9
Definition:
arch.h:74
x86_esf::rdx
unsigned long rdx
Definition:
arch.h:70
x86_esf::rsi
unsigned long rsi
Definition:
arch.h:71
x86_esf::rdi
unsigned long rdi
Definition:
arch.h:72
x86_esf::rax
unsigned long rax
Definition:
arch.h:68
x86_esf::fxsave
char fxsave[X86_FXSAVE_SIZE]
Definition:
arch.h:79
x86_esf::rflags
unsigned long rflags
Definition:
arch.h:87
x86_ssf
Definition:
arch.h:94
x86_ssf::rsp
unsigned long rsp
Definition:
arch.h:104
x86_ssf::r8
unsigned long r8
Definition:
arch.h:99
x86_ssf::r9
unsigned long r9
Definition:
arch.h:98
x86_ssf::r10
unsigned long r10
Definition:
arch.h:97
x86_ssf::rdx
unsigned long rdx
Definition:
arch.h:100
x86_ssf::rflags
unsigned long rflags
Definition:
arch.h:96
x86_ssf::fxsave
char fxsave[X86_FXSAVE_SIZE]
Definition:
arch.h:102
x86_ssf::rdi
unsigned long rdi
Definition:
arch.h:103
x86_ssf::rip
unsigned long rip
Definition:
arch.h:95
x86_ssf::rsi
unsigned long rsi
Definition:
arch.h:101
mm_reg_t
uintptr_t mm_reg_t
Definition:
sys_io.h:20
data
static fdata_t data[2]
Definition:
test_fifo_contexts.c:15
arch_irq_lock
static ALWAYS_INLINE unsigned int arch_irq_lock(void)
Definition:
arch.h:43
sys_read64
static ALWAYS_INLINE uint64_t sys_read64(mm_reg_t addr)
Definition:
arch.h:31
sys_write64
static ALWAYS_INLINE void sys_write64(uint64_t data, mm_reg_t addr)
Definition:
arch.h:22
include
arch
x86
intel64
arch.h
Generated on Sun Oct 9 2022 09:21:56 for Zephyr API Documentation by
1.9.4