Advertisement
Guest User

intel1155_ecc_check2.c

a guest
Jun 24th, 2014
761
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 3.17 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <sys/types.h>
  4. #include <sys/stat.h>
  5. #include <unistd.h>
  6. #include <fcntl.h>
  7. #include <sys/mman.h>
  8. #include <stdint.h>
  9.  
  10. /*
  11. Interpretation of Register based on Intel documentation:
  12. http://www.intel.in/content/dam/www/public/us/en/documents/datasheets/xeon-core-communication-infrastructure-datasheet-vol-1.pdf
  13. Chapter 11.9 "MAD_DIMM_CH0 - Address Decode Channel 0"
  14. Page 158 ff.
  15. */
  16.  
  17.  
  18. #define MEM_START       0xFED10000
  19. #define FILESIZE        32*1024
  20.  
  21.  
  22. int decode_channel(char* mem_mad_dimm_chx)
  23.     {
  24.     uint32_t mad_dimm_chx= *( (uint32_t *) mem_mad_dimm_chx);
  25.  
  26.     // DIMM A is allways the larger one, is it because of that swapped
  27.     // Bit 16
  28.     printf("  DIMM A&B swapped: %u\n", (mad_dimm_chx & (1<<16)) > 0 );
  29.    
  30.     // Size of DIMM 256 MB multiples
  31.     // DIMM A: Bits 7:0
  32.     printf("  DIMM A Size:      %u MB\n", ((mad_dimm_chx & (255<<0))>>0) * 256 );
  33.     // DIMM B: Bits 15:8
  34.     printf("  DIMM B Size:      %u MB\n", ((mad_dimm_chx & (255<<8))>>8) * 256 );
  35.  
  36.     // Number of ranks (0 = single, 1 = dual)
  37.     // DIMM A: bit 17
  38.     printf("  DIMM A dual rank: %u\n", (mad_dimm_chx & (1<<17)) > 0 );
  39.     // DIMM B: bit 18
  40.     printf("  DIMM B dual rank: %u\n", (mad_dimm_chx & (1<<18)) > 0 );
  41.  
  42.     // DIMM DDR width (DBW) (0 = X8 Chips, 1 = X16 Chips)
  43.     // DIMM A: bit 19
  44.     printf("  DIMM A DDR width: %u\n", 8+((mad_dimm_chx & (1<<19))>>19)*8 );
  45.     // DIMM B: bit 20
  46.     printf("  DIMM B DDR width: %u\n", 8+((mad_dimm_chx & (1<<20))>>20)*8 );
  47.  
  48.     // Rank interleave (RI), bit 21
  49.     printf("  Rank Interleave:  %u\n", (mad_dimm_chx & (1<<21)) > 0 );
  50.  
  51.     // Enhanced Interleave mode (Enh_Interleave), bit 22
  52.     printf("  Enh. Interleave:  %u\n", (mad_dimm_chx & (1<<22)) > 0 );
  53.  
  54.     // ECC-Mode per Channel in Bit 25:24
  55.     printf("  ECC in IO:        %u\n", (mad_dimm_chx & (1<<25)) > 0 );
  56.     printf("  ECC in Logic:     %u\n", (mad_dimm_chx & (1<<24)) > 0 );
  57.  
  58.     }//decode_channel()
  59.  
  60.  
  61. int main(int argc, char *argv[])
  62.     {
  63.     int i;
  64.     int fd = -1;
  65.     unsigned long pagesize;
  66.     unsigned char *map;
  67.     unsigned char *mem;
  68.  
  69.     fd = open("/dev/mem", O_RDONLY|O_SYNC);
  70.     if (fd == -1) {
  71.         perror("Error opening /dev/mem for reading");
  72.         exit(EXIT_FAILURE);
  73.         }
  74.      
  75.     map = mmap(0, FILESIZE, PROT_READ, MAP_SHARED, fd, MEM_START);
  76.     if (map == MAP_FAILED) {
  77.         close(fd);
  78.         perror("Error mmapping the file");
  79.         exit(EXIT_FAILURE);
  80.         }
  81.        
  82.     // Get RAM info
  83.     printf("5004-5007h: ");
  84.     for (i = 0x5004; i < 0x5004+4; i++) {
  85.         printf("%lx ", map[i]);
  86.         }
  87.     printf("\n");
  88.      
  89.     printf("5008-500Bh: ");
  90.     for (i = 0x5008; i < 0x5008+4; i++) {
  91.         printf("%lx ", map[i]);
  92.         }
  93.     printf("\n\n");
  94.            
  95.     printf("Interpretation:\n");
  96.     printf("------------------\n");
  97.     printf("Channel 0:\n");
  98.     decode_channel(&map[0x5004]);
  99.  
  100.     printf("Channel 1:\n");
  101.     decode_channel(&map[0x5008]);
  102.      
  103.     // Unmap the file
  104.     if (munmap(map, FILESIZE) == -1) {
  105.         perror("Error un-mmapping the file");
  106.         }
  107.      
  108.     close(fd);
  109.     return 0;
  110.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement