source: rtems/bsps/i386/shared/cache/cache.c @ bb6eeabf

5
Last change on this file since bb6eeabf was bb6eeabf, checked in by Joel Sherrill <joel@…>, on 08/21/18 at 15:35:26

bsps/i386/shared/cache/cache.c: Fix warnings

  • Property mode set to 100644
File size: 1.7 KB
RevLine 
[cf1f72e]1/*
2 *  Cache Management Support Routines for the i386
3 */
4
5#include <rtems.h>
[328bd35]6#include <rtems/score/cpu.h>
7#include <libcpu/page.h>
[cf1f72e]8
[4cf93658]9#define I386_CACHE_ALIGNMENT 16
10#define CPU_DATA_CACHE_ALIGNMENT I386_CACHE_ALIGNMENT
11#define CPU_INSTRUCTION_CACHE_ALIGNEMNT I386_CACHE_ALIGNMENT
12
[e6e63f8]13void _CPU_disable_cache(void)
14{
[665285f]15  unsigned int regCr0;
[cf1f72e]16
[665285f]17  regCr0 = i386_get_cr0();
18  regCr0 |= CR0_PAGE_LEVEL_CACHE_DISABLE;
19  regCr0 |= CR0_NO_WRITE_THROUGH;
20  i386_set_cr0( regCr0 );
[5e77d129]21  rtems_cache_flush_entire_data();
[cf1f72e]22}
23
24/*
25 * Enable the entire cache
26 */
27
[e6e63f8]28void _CPU_enable_cache(void)
29{
[665285f]30  unsigned int regCr0;
[cf1f72e]31
[665285f]32  regCr0 = i386_get_cr0();
33  regCr0 &= ~(CR0_PAGE_LEVEL_CACHE_DISABLE);
34  regCr0 &= ~(CR0_NO_WRITE_THROUGH);
35  i386_set_cr0( regCr0 );
[5e77d129]36  /*rtems_cache_flush_entire_data();*/
[cf1f72e]37}
38
39/*
40 * CACHE MANAGER: The following functions are CPU-specific.
41 * They provide the basic implementation for the rtems_* cache
42 * management routines. If a given function has no meaning for the CPU,
43 * it does nothing by default.
44 *
[5e77d129]45 * FIXME: The routines below should be implemented per CPU,
[cf1f72e]46 *        to accomodate the capabilities of each.
47 */
48
49#if defined(I386_CACHE_ALIGNMENT)
[4cf93658]50static void _CPU_cache_flush_1_data_line(const void *d_addr) {}
51static void _CPU_cache_invalidate_1_data_line(const void *d_addr) {}
52static void _CPU_cache_freeze_data(void) {}
53static void _CPU_cache_unfreeze_data(void) {}
54static void _CPU_cache_flush_entire_data(void)
[cf1f72e]55{
[550c1b23]56  __asm__ volatile ("wbinvd");
[cf1f72e]57}
[4cf93658]58static void _CPU_cache_invalidate_entire_data(void)
[cf1f72e]59{
[550c1b23]60  __asm__ volatile ("invd");
[cf1f72e]61}
62
[4cf93658]63static void _CPU_cache_enable_data(void)
[cf1f72e]64{
65  _CPU_enable_cache();
66}
67
[bb6eeabf]68static void _CPU_cache_disable_data(void)
[cf1f72e]69{
70  _CPU_disable_cache();
71}
[bb6eeabf]72
[cf1f72e]73#endif
[4cf93658]74
75#include "../../../shared/cache/cacheimpl.h"
Note: See TracBrowser for help on using the repository browser.