source: rtems/c/src/lib/libcpu/i386/cache.c @ 98a45c06

4.104.114.84.95
Last change on this file since 98a45c06 was 8358faa, checked in by Joel Sherrill <joel.sherrill@…>, on 06/13/00 at 22:25:28

Prototypes for cache manager support functions now agree.

  • Property mode set to 100644
File size: 2.0 KB
Line 
1/*
2 *  Cache Management Support Routines for the i386
3 *
4 *  $Id$
5 */
6
7#include <rtems.h>
8#include <libcpu/registers.h>
9#include "cache_.h"
10
11void _CPU_disable_cache() {
12  cr0 regCr0;
13
14  regCr0.i = i386_get_cr0();
15  regCr0.cr0.page_level_cache_disable = 1;
16  regCr0.cr0.no_write_through = 1;
17  i386_set_cr0( regCr0.i );
18  rtems_flush_entire_data_cache();
19}
20
21/*
22 * Enable the entire cache
23 */
24
25void _CPU_enable_cache() {
26  cr0 regCr0;
27
28  regCr0.i = i386_get_cr0();
29  regCr0.cr0.page_level_cache_disable = 0;
30  regCr0.cr0.no_write_through = 0;
31  i386_set_cr0( regCr0.i );
32  /*rtems_flush_entire_data_cache();*/
33}
34
35/*
36 * CACHE MANAGER: The following functions are CPU-specific.
37 * They provide the basic implementation for the rtems_* cache
38 * management routines. If a given function has no meaning for the CPU,
39 * it does nothing by default.
40 *
41 * FIXME: Definitions for I386_CACHE_ALIGNMENT are missing above for
42 *        each CPU. The routines below should be implemented per CPU,
43 *        to accomodate the capabilities of each.
44 */
45
46/* FIXME: I don't belong here. */
47#define I386_CACHE_ALIGNMENT 16
48
49#if defined(I386_CACHE_ALIGNMENT)
50#define _CPU_DATA_CACHE_ALIGNMENT I386_CACHE_ALIGNMENT
51#define _CPU_INST_CACHE_ALIGNEMNT I386_CACHE_ALIGNMENT
52
53void _CPU_flush_1_data_cache_line(const void *d_addr) {}
54void _CPU_invalidate_1_data_cache_line(const void *d_addr) {}
55void _CPU_freeze_data_cache(void) {}
56void _CPU_unfreeze_data_cache(void) {}
57void _CPU_invalidate_1_inst_cache_line ( const void *d_addr ) {}
58void _CPU_freeze_inst_cache(void) {}
59void _CPU_unfreeze_inst_cache(void) {}
60
61void _CPU_flush_entire_data_cache(void)
62{
63  asm volatile ("wbinvd");
64}
65void _CPU_invalidate_entire_data_cache(void)
66{
67  asm volatile ("invd");
68}
69
70void _CPU_enable_data_cache(void)
71{
72        _CPU_enable_cache();
73}
74
75void _CPU_disable_data_cache(void)
76{
77        _CPU_disable_cache();
78}
79
80void _CPU_invalidate_entire_inst_cache(void)
81{
82  asm volatile ("invd");
83}
84
85void _CPU_enable_inst_cache(void)
86{
87  _CPU_enable_cache();
88}
89
90void _CPU_disable_inst_cache( void )
91{
92  _CPU_disable_cache();
93}
94#endif
95
Note: See TracBrowser for help on using the repository browser.