1 /*
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 #if defined(CONFIG_X86_64)
14 
15 #include <zephyr/arch/x86/intel64/thread.h>
16 #include <zephyr/kernel_structs.h>
17 
arch_curr_cpu(void)18 static inline struct _cpu *arch_curr_cpu(void)
19 {
20 	struct _cpu *cpu;
21 
22 	__asm__ volatile("movq %%gs:(%c1), %0"
23 			 : "=r" (cpu)
24 			 : "i" (offsetof(x86_tss64_t, cpu)));
25 
26 	return cpu;
27 }
28 
arch_proc_id(void)29 static ALWAYS_INLINE uint32_t arch_proc_id(void)
30 {
31 	/*
32 	 * Placeholder implementation to be replaced with an architecture
33 	 * specific call to get processor ID
34 	 */
35 	return arch_curr_cpu()->id;
36 }
37 
38 #endif /* CONFIG_X86_64 */
39 
arch_num_cpus(void)40 static ALWAYS_INLINE unsigned int arch_num_cpus(void)
41 {
42 	return CONFIG_MP_MAX_NUM_CPUS;
43 }
44 
45 #endif /* !_ASMLANGUAGE */
46 
47 #endif /* ZEPHYR_INCLUDE_ARCH_X86_ARCH_INLINES_H_ */
48