Skip to content

Commit 5e4e029

Browse files
Tomasz Bursztykanashif
authored andcommitted
arch/x86: Generalize cache manipulation functions
We assume that all x86 CPUs do have clflush instructions. And the cache line size is now provided through DTS. So detecting clflush instruction as well as the cache line size is no longer required at runtime and thus removed. Signed-off-by: Tomasz Bursztyka <[email protected]>
1 parent 16c4b65 commit 5e4e029

File tree

9 files changed

+3
-168
lines changed

9 files changed

+3
-168
lines changed

arch/x86/core/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ zephyr_library_sources_ifdef(CONFIG_MULTIBOOT multiboot.c)
2020
zephyr_library_sources_ifdef(CONFIG_ACPI acpi.c)
2121
zephyr_library_sources_ifdef(CONFIG_X86_MMU x86_mmu.c)
2222
zephyr_library_sources_ifdef(CONFIG_USERSPACE userspace.c)
23+
zephyr_library_sources_ifdef(CONFIG_CACHE_MANAGEMENT cache.c)
2324

2425
zephyr_library_sources_ifdef(CONFIG_X86_VERY_EARLY_CONSOLE early_serial.c)
2526

arch/x86/core/Kconfig.ia32

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -144,34 +144,6 @@ config X86_FP_USE_SOFT_FLOAT
144144

145145
endmenu
146146

147-
config DCACHE_LINE_SIZE
148-
default 64 if CPU_ATOM
149-
150-
config CLFLUSH_INSTRUCTION_SUPPORTED
151-
bool "CLFLUSH instruction supported"
152-
depends on !CLFLUSH_DETECT && CACHE_MANAGEMENT
153-
help
154-
An implementation of sys_cache_flush() that uses CLFLUSH is made
155-
available, instead of the one using WBINVD.
156-
157-
This option should only be enabled if it is known in advance that the
158-
CPU supports the CLFLUSH instruction. It disables runtime detection of
159-
CLFLUSH support thereby reducing both memory footprint and boot time.
160-
161-
config CLFLUSH_DETECT
162-
bool "Detect support of CLFLUSH instruction at runtime"
163-
depends on CACHE_MANAGEMENT
164-
help
165-
This option should be enabled if it is not known in advance whether the
166-
CPU supports the CLFLUSH instruction or not.
167-
168-
The CPU is queried at boot time to determine which of the multiple
169-
implementations of sys_cache_flush() linked into the image is the
170-
correct one to use.
171-
172-
If the CPU's support (or lack thereof) of CLFLUSH is known in advance, then
173-
disable this option and set CLFLUSH_INSTRUCTION_SUPPORTED as appropriate.
174-
175147
config X86_DYNAMIC_IRQ_STUBS
176148
int "Number of dynamic interrupt stubs"
177149
depends on DYNAMIC_INTERRUPTS
Lines changed: 2 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
22
* Copyright (c) 2013-2014 Wind River Systems, Inc.
3+
* Copyright (c) 2021 Intel Corporation
34
*
45
* SPDX-License-Identifier: Apache-2.0
56
*/
@@ -16,37 +17,18 @@
1617
#include <toolchain.h>
1718
#include <cache.h>
1819
#include <stdbool.h>
19-
#include <cache.h>
20-
21-
/*
22-
* these functions are defined in cache_s.S
23-
*/
24-
25-
extern int z_is_clflush_available(void);
26-
extern void z_cache_flush_wbinvd(vaddr_t addr, size_t len);
27-
extern size_t z_cache_line_size_get(void);
28-
29-
#if defined(CONFIG_DCACHE_LINE_SIZE_DETECT)
30-
size_t sys_cache_line_size;
31-
#endif
32-
33-
#if defined(CONFIG_CLFLUSH_INSTRUCTION_SUPPORTED) || \
34-
defined(CONFIG_CLFLUSH_DETECT)
3520

3621
/**
37-
*
3822
* @brief Flush cache lines to main memory
3923
*
4024
* No alignment is required for either <virt> or <size>, but since
4125
* sys_cache_flush() iterates on the cache lines, a cache line alignment for
4226
* both is optimal.
4327
*
44-
* The cache line size is specified either via the CONFIG_DCACHE_LINE_SIZE
45-
* kconfig option or it is detected at runtime.
28+
* The cache line size is specified via the d-cache-line-size DTS property.
4629
*
4730
* @return N/A
4831
*/
49-
5032
static void arch_dcache_flush(void *start_addr, size_t size)
5133
{
5234
size_t line_size = sys_dcache_line_size_get();
@@ -76,31 +58,3 @@ int arch_dcache_range(void *addr, size_t size, int op)
7658

7759
return -ENOTSUP;
7860
}
79-
80-
#endif /* CONFIG_CLFLUSH_INSTRUCTION_SUPPORTED || CLFLUSH_DETECT */
81-
82-
#include <init.h>
83-
84-
#if defined(CONFIG_DCACHE_LINE_SIZE_DETECT)
85-
static void init_cache_line_size(void)
86-
{
87-
sys_cache_line_size = z_cache_line_size_get();
88-
}
89-
90-
size_t arch_cache_line_size_get(void)
91-
{
92-
return sys_cache_line_size;
93-
}
94-
#endif
95-
96-
static int init_dcache(const struct device *unused)
97-
{
98-
ARG_UNUSED(unused);
99-
100-
#if defined(CONFIG_DCACHE_LINE_SIZE_DETECT)
101-
init_cache_line_size();
102-
#endif
103-
return 0;
104-
}
105-
106-
SYS_INIT(init_dcache, PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT);

arch/x86/core/ia32.cmake

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ elseif(CMAKE_C_COMPILER_ID STREQUAL "GNU")
99
endif()
1010

1111
zephyr_library_sources(
12-
ia32/cache.c
13-
ia32/cache_s.S
1412
ia32/crt0.S
1513
ia32/excstub.S
1614
ia32/intstub.S

arch/x86/core/ia32/cache_s.S

Lines changed: 0 additions & 78 deletions
This file was deleted.

soc/x86/apollo_lake/Kconfig.defconfig

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,6 @@ endif # APIC_TIMER_TSC
4141

4242
endif # APIC_TIMER
4343

44-
config CLFLUSH_DETECT
45-
default y if CACHE_MANAGEMENT
46-
4744
config X86_DYNAMIC_IRQ_STUBS
4845
default 16
4946
depends on DYNAMIC_INTERRUPTS

soc/x86/atom/Kconfig.defconfig

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ config SOC
1111
config SYS_CLOCK_HW_CYCLES_PER_SEC
1212
default 25000000 if HPET_TIMER
1313

14-
config CLFLUSH_DETECT
15-
default y if CACHE_MANAGEMENT
16-
1714
if BT_UART
1815

1916
config UART_PIPE_ON_DEV_NAME

soc/x86/elkhart_lake/Kconfig.defconfig

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,6 @@ endif # APIC_TIMER_TSC
4141

4242
endif # APIC_TIMER
4343

44-
config CLFLUSH_DETECT
45-
default y if CACHE_MANAGEMENT
46-
4744
config X86_DYNAMIC_IRQ_STUBS
4845
default 16
4946
depends on DYNAMIC_INTERRUPTS

soc/x86/ia32/Kconfig.defconfig

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,4 @@ config SOC
1111
config SYS_CLOCK_HW_CYCLES_PER_SEC
1212
default 25000000 if HPET_TIMER
1313

14-
config CLFLUSH_DETECT
15-
default y if CACHE_MANAGEMENT
16-
1714
endif

0 commit comments

Comments
 (0)