Line data Source code
1 0 : /*
2 : * Copyright (c) 2019 Intel Corporation
3 : * Copyright (c) 2019 Stephanos Ioannidis <root@stephanos.io>
4 : *
5 : * SPDX-License-Identifier: Apache-2.0
6 : */
7 :
8 : #ifndef ZEPHYR_INCLUDE_ARCH_X86_ARCH_INLINES_H_
9 : #define ZEPHYR_INCLUDE_ARCH_X86_ARCH_INLINES_H_
10 :
11 : #ifndef _ASMLANGUAGE
12 :
13 : #include <zephyr/arch/x86/x86_acpi.h>
14 :
15 : #if defined(CONFIG_X86_64)
16 :
17 : #include <zephyr/arch/x86/intel64/thread.h>
18 : #include <zephyr/kernel_structs.h>
19 :
20 : static inline struct _cpu *arch_curr_cpu(void)
21 : {
22 : struct _cpu *cpu;
23 :
24 : __asm__ volatile("movq %%gs:(%c1), %0"
25 : : "=r" (cpu)
26 : : "i" (offsetof(x86_tss64_t, cpu)));
27 :
28 : return cpu;
29 : }
30 :
31 : static ALWAYS_INLINE uint32_t arch_proc_id(void)
32 : {
33 : /*
34 : * Placeholder implementation to be replaced with an architecture
35 : * specific call to get processor ID
36 : */
37 : return arch_curr_cpu()->id;
38 : }
39 :
40 : #endif /* CONFIG_X86_64 */
41 :
42 0 : static ALWAYS_INLINE unsigned int arch_num_cpus(void)
43 : {
44 : return CONFIG_MP_MAX_NUM_CPUS;
45 : }
46 :
47 : #endif /* !_ASMLANGUAGE */
48 :
49 : #endif /* ZEPHYR_INCLUDE_ARCH_X86_ARCH_INLINES_H_ */
|