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

4.115
Last change on this file since a3579d3b was 665285f, checked in by Joel Sherrill <joel.sherrill@…>, on 05/21/10 at 19:03:21

2010-05-21 Vinu Rajashekhar <vinutheraj@…>

  • cache.c, page.c: Use masks and shift operations instead of bit-fields.
  • Property mode set to 100644
File size: 1.8 KB
Line 
1/*
2 *  Cache Management Support Routines for the i386
3 *
4 *  $Id$
5 */
6
7#include <rtems.h>
8#include <rtems/score/registers.h>
9#include "cache_.h"
10
11void _CPU_disable_cache(void) {
12  unsigned int regCr0;
13
14  regCr0 = i386_get_cr0();
15  regCr0 |= CR0_PAGE_LEVEL_CACHE_DISABLE;
16  regCr0 |= CR0_NO_WRITE_THROUGH;
17  i386_set_cr0( regCr0 );
18  rtems_cache_flush_entire_data();
19}
20
21/*
22 * Enable the entire cache
23 */
24
25void _CPU_enable_cache(void) {
26  unsigned int regCr0;
27
28  regCr0 = i386_get_cr0();
29  regCr0 &= ~(CR0_PAGE_LEVEL_CACHE_DISABLE);
30  regCr0 &= ~(CR0_NO_WRITE_THROUGH);
31  i386_set_cr0( regCr0 );
32  /*rtems_cache_flush_entire_data();*/
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: The routines below should be implemented per CPU,
42 *        to accomodate the capabilities of each.
43 */
44
45#if defined(I386_CACHE_ALIGNMENT)
46void _CPU_cache_flush_1_data_line(const void *d_addr) {}
47void _CPU_cache_invalidate_1_data_line(const void *d_addr) {}
48void _CPU_cache_freeze_data(void) {}
49void _CPU_cache_unfreeze_data(void) {}
50void _CPU_cache_invalidate_1_instruction_line ( const void *d_addr ) {}
51void _CPU_cache_freeze_instruction(void) {}
52void _CPU_cache_unfreeze_instruction(void) {}
53
54void _CPU_cache_flush_entire_data(void)
55{
56  asm volatile ("wbinvd");
57}
58void _CPU_cache_invalidate_entire_data(void)
59{
60  asm volatile ("invd");
61}
62
63void _CPU_cache_enable_data(void)
64{
65        _CPU_enable_cache();
66}
67
68void _CPU_cache_disable_data(void)
69{
70        _CPU_disable_cache();
71}
72
73void _CPU_cache_invalidate_entire_instruction(void)
74{
75  asm volatile ("invd");
76}
77
78void _CPU_cache_enable_instruction(void)
79{
80  _CPU_enable_cache();
81}
82
83void _CPU_cache_disable_instruction( void )
84{
85  _CPU_disable_cache();
86}
87#endif
Note: See TracBrowser for help on using the repository browser.