Changeset 665285f in rtems


Ignore:
Timestamp:
May 21, 2010, 7:03:21 PM (9 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, master
Children:
121e5a7
Parents:
4a76be7
Message:

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

  • cache.c, page.c: Use masks and shift operations instead of bit-fields.
Location:
c/src/lib/libcpu/i386
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libcpu/i386/ChangeLog

    r4a76be7 r665285f  
     12010-05-21      Vinu Rajashekhar <vinutheraj@gmail.com>
     2
     3        * cache.c, page.c: Use masks and shift operations instead of
     4        bit-fields.
     5
    162010-04-15      Joel Sherrill <joel.sherrill@oarcorp.com>
    27
  • c/src/lib/libcpu/i386/cache.c

    r4a76be7 r665285f  
    1010
    1111void _CPU_disable_cache(void) {
    12   cr0 regCr0;
     12  unsigned int regCr0;
    1313
    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 );
     14  regCr0 = i386_get_cr0();
     15  regCr0 |= CR0_PAGE_LEVEL_CACHE_DISABLE;
     16  regCr0 |= CR0_NO_WRITE_THROUGH;
     17  i386_set_cr0( regCr0 );
    1818  rtems_cache_flush_entire_data();
    1919}
     
    2424
    2525void _CPU_enable_cache(void) {
    26   cr0 regCr0;
     26  unsigned int regCr0;
    2727
    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 );
     28  regCr0 = i386_get_cr0();
     29  regCr0 &= ~(CR0_PAGE_LEVEL_CACHE_DISABLE);
     30  regCr0 &= ~(CR0_NO_WRITE_THROUGH);
     31  i386_set_cr0( regCr0 );
    3232  /*rtems_cache_flush_entire_data();*/
    3333}
  • c/src/lib/libcpu/i386/page.c

    r4a76be7 r665285f  
    4444void _CPU_disable_paging(void)
    4545{
    46   cr0 regCr0;
     46  unsigned int regCr0;
    4747
    4848  rtems_cache_flush_entire_data();
    49   regCr0.i = i386_get_cr0();
    50   regCr0.cr0.paging = 0;
    51   i386_set_cr0( regCr0.i );
     49  regCr0 = i386_get_cr0();
     50  regCr0 &= ~(CR0_PAGING);
     51  i386_set_cr0( regCr0 );
    5252}
    5353
     
    5757void _CPU_enable_paging(void)
    5858{
    59   cr0 regCr0;
    60 
    61   regCr0.i = i386_get_cr0();
    62   regCr0.cr0.paging = 1;
    63   i386_set_cr0( regCr0.i );
     59  unsigned int regCr0;
     60
     61  regCr0 = i386_get_cr0();
     62  regCr0 |= CR0_PAGING;
     63  i386_set_cr0( regCr0 );
    6464  rtems_cache_flush_entire_data();
    6565}
     
    7575  int nbInitPages;
    7676  char *Tables;
    77   cr3 regCr3;
     77  unsigned int regCr3;
    7878  page_table *pageTable;
    7979  unsigned int physPage;
     
    136136  }
    137137
    138   regCr3.cr3.page_write_transparent = 0;
    139   regCr3.cr3.page_cache_disable     = 0;
    140   regCr3.cr3.page_directory_base    = (unsigned int)pageDirectory >> 12;
    141 
    142   i386_set_cr3( regCr3.i );
     138  regCr3 &= ~(CR3_PAGE_WRITE_THROUGH);
     139  regCr3 &= ~(CR3_PAGE_CACHE_DISABLE);
     140  /*regCr3.cr3.page_directory_base    = (unsigned int)pageDirectory >> 12;*/
     141  regCr3 = (unsigned int)pageDirectory & CR3_PAGE_DIRECTORY_MASK;
     142
     143  i386_set_cr3( regCr3 );
    143144
    144145  _CPU_enable_cache();
     
    153154int  _CPU_is_cache_enabled(void)
    154155{
    155   cr0 regCr0;
    156 
    157   regCr0.i = i386_get_cr0();
    158   return( ~(regCr0.cr0.page_level_cache_disable) );
     156  unsigned int regCr0;
     157
     158  regCr0 = i386_get_cr0();
     159  return( ~(regCr0 & CR0_PAGE_LEVEL_CACHE_DISABLE) );
    159160}
    160161
     
    164165int  _CPU_is_paging_enabled(void)
    165166{
    166   cr0 regCr0;
    167 
    168   regCr0.i = i386_get_cr0();
    169   return(regCr0.cr0.paging);
     167  unsigned int regCr0;
     168
     169  regCr0 = i386_get_cr0();
     170  return(regCr0 & CR0_PAGING);
    170171}
    171172
     
    455456{
    456457  unsigned int dirCount, pageCount;
    457   cr0 regCr0;
     458  unsigned int regCr0;
    458459  page_table *localPageTable;
    459460  unsigned int prevCache;
     
    462463  unsigned char pagingWasEnabled;
    463464
    464   regCr0.i = i386_get_cr0();
     465  regCr0 = i386_get_cr0();
    465466
    466467  printk("\n\n********* MEMORY CACHE CONFIGURATION *****\n");
    467468
    468   printk("CR0 -> paging           : %s\n",(regCr0.cr0.paging ? "ENABLE ":"DISABLE"));
    469   printk("       page-level cache : %s\n\n",(regCr0.cr0.page_level_cache_disable ? "DISABLE":"ENABLE"));
    470 
    471   if (regCr0.cr0.paging == 0)
     469  printk("CR0 -> paging           : %s\n",((regCr0 & CR0_PAGING) ? "ENABLE ":"DISABLE"));
     470  printk("       page-level cache : %s\n\n",((regCr0 & CR0_PAGE_LEVEL_CACHE_DISABLE) ? "DISABLE":"ENABLE"));
     471
     472  if ((regCr0 & CR0_PAGING) == 0)
    472473    return 0;
    473474
Note: See TracChangeset for help on using the changeset viewer.