1 | /* |
---|
2 | * Cache Management Support Routines for the i386 |
---|
3 | */ |
---|
4 | |
---|
5 | #include <rtems.h> |
---|
6 | #include <rtems/score/registers.h> |
---|
7 | #include "cache_.h" |
---|
8 | |
---|
9 | void _CPU_disable_cache(void) { |
---|
10 | unsigned int regCr0; |
---|
11 | |
---|
12 | regCr0 = i386_get_cr0(); |
---|
13 | regCr0 |= CR0_PAGE_LEVEL_CACHE_DISABLE; |
---|
14 | regCr0 |= CR0_NO_WRITE_THROUGH; |
---|
15 | i386_set_cr0( regCr0 ); |
---|
16 | rtems_cache_flush_entire_data(); |
---|
17 | } |
---|
18 | |
---|
19 | /* |
---|
20 | * Enable the entire cache |
---|
21 | */ |
---|
22 | |
---|
23 | void _CPU_enable_cache(void) { |
---|
24 | unsigned int regCr0; |
---|
25 | |
---|
26 | regCr0 = i386_get_cr0(); |
---|
27 | regCr0 &= ~(CR0_PAGE_LEVEL_CACHE_DISABLE); |
---|
28 | regCr0 &= ~(CR0_NO_WRITE_THROUGH); |
---|
29 | i386_set_cr0( regCr0 ); |
---|
30 | /*rtems_cache_flush_entire_data();*/ |
---|
31 | } |
---|
32 | |
---|
33 | /* |
---|
34 | * CACHE MANAGER: The following functions are CPU-specific. |
---|
35 | * They provide the basic implementation for the rtems_* cache |
---|
36 | * management routines. If a given function has no meaning for the CPU, |
---|
37 | * it does nothing by default. |
---|
38 | * |
---|
39 | * FIXME: The routines below should be implemented per CPU, |
---|
40 | * to accomodate the capabilities of each. |
---|
41 | */ |
---|
42 | |
---|
43 | #if defined(I386_CACHE_ALIGNMENT) |
---|
44 | void _CPU_cache_flush_1_data_line(const void *d_addr) {} |
---|
45 | void _CPU_cache_invalidate_1_data_line(const void *d_addr) {} |
---|
46 | void _CPU_cache_freeze_data(void) {} |
---|
47 | void _CPU_cache_unfreeze_data(void) {} |
---|
48 | void _CPU_cache_invalidate_1_instruction_line ( const void *d_addr ) {} |
---|
49 | void _CPU_cache_freeze_instruction(void) {} |
---|
50 | void _CPU_cache_unfreeze_instruction(void) {} |
---|
51 | |
---|
52 | void _CPU_cache_flush_entire_data(void) |
---|
53 | { |
---|
54 | __asm__ volatile ("wbinvd"); |
---|
55 | } |
---|
56 | void _CPU_cache_invalidate_entire_data(void) |
---|
57 | { |
---|
58 | __asm__ volatile ("invd"); |
---|
59 | } |
---|
60 | |
---|
61 | void _CPU_cache_enable_data(void) |
---|
62 | { |
---|
63 | _CPU_enable_cache(); |
---|
64 | } |
---|
65 | |
---|
66 | void _CPU_cache_disable_data(void) |
---|
67 | { |
---|
68 | _CPU_disable_cache(); |
---|
69 | } |
---|
70 | |
---|
71 | void _CPU_cache_invalidate_entire_instruction(void) |
---|
72 | { |
---|
73 | __asm__ volatile ("invd"); |
---|
74 | } |
---|
75 | |
---|
76 | void _CPU_cache_enable_instruction(void) |
---|
77 | { |
---|
78 | _CPU_enable_cache(); |
---|
79 | } |
---|
80 | |
---|
81 | void _CPU_cache_disable_instruction( void ) |
---|
82 | { |
---|
83 | _CPU_disable_cache(); |
---|
84 | } |
---|
85 | #endif |
---|