Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <unistd.h>
- #include <fcntl.h>
- #include <sys/mman.h>
- #include <stdint.h>
- /*
- Interpretation of Register based on Intel documentation:
- http://www.intel.in/content/dam/www/public/us/en/documents/datasheets/xeon-core-communication-infrastructure-datasheet-vol-1.pdf
- Chapter 11.9 "MAD_DIMM_CH0 - Address Decode Channel 0"
- Page 158 ff.
- */
- #define MEM_START 0xFED10000
- #define FILESIZE 32*1024
- int decode_channel(char* mem_mad_dimm_chx)
- {
- uint32_t mad_dimm_chx= *( (uint32_t *) mem_mad_dimm_chx);
- // DIMM A is allways the larger one, is it because of that swapped
- // Bit 16
- printf(" DIMM A&B swapped: %u\n", (mad_dimm_chx & (1<<16)) > 0 );
- // Size of DIMM 256 MB multiples
- // DIMM A: Bits 7:0
- printf(" DIMM A Size: %u MB\n", ((mad_dimm_chx & (255<<0))>>0) * 256 );
- // DIMM B: Bits 15:8
- printf(" DIMM B Size: %u MB\n", ((mad_dimm_chx & (255<<8))>>8) * 256 );
- // Number of ranks (0 = single, 1 = dual)
- // DIMM A: bit 17
- printf(" DIMM A dual rank: %u\n", (mad_dimm_chx & (1<<17)) > 0 );
- // DIMM B: bit 18
- printf(" DIMM B dual rank: %u\n", (mad_dimm_chx & (1<<18)) > 0 );
- // DIMM DDR width (DBW) (0 = X8 Chips, 1 = X16 Chips)
- // DIMM A: bit 19
- printf(" DIMM A DDR width: %u\n", 8+((mad_dimm_chx & (1<<19))>>19)*8 );
- // DIMM B: bit 20
- printf(" DIMM B DDR width: %u\n", 8+((mad_dimm_chx & (1<<20))>>20)*8 );
- // Rank interleave (RI), bit 21
- printf(" Rank Interleave: %u\n", (mad_dimm_chx & (1<<21)) > 0 );
- // Enhanced Interleave mode (Enh_Interleave), bit 22
- printf(" Enh. Interleave: %u\n", (mad_dimm_chx & (1<<22)) > 0 );
- // ECC-Mode per Channel in Bit 25:24
- printf(" ECC in IO: %u\n", (mad_dimm_chx & (1<<25)) > 0 );
- printf(" ECC in Logic: %u\n", (mad_dimm_chx & (1<<24)) > 0 );
- }//decode_channel()
- int main(int argc, char *argv[])
- {
- int i;
- int fd = -1;
- unsigned long pagesize;
- unsigned char *map;
- unsigned char *mem;
- fd = open("/dev/mem", O_RDONLY|O_SYNC);
- if (fd == -1) {
- perror("Error opening /dev/mem for reading");
- exit(EXIT_FAILURE);
- }
- map = mmap(0, FILESIZE, PROT_READ, MAP_SHARED, fd, MEM_START);
- if (map == MAP_FAILED) {
- close(fd);
- perror("Error mmapping the file");
- exit(EXIT_FAILURE);
- }
- // Get RAM info
- printf("5004-5007h: ");
- for (i = 0x5004; i < 0x5004+4; i++) {
- printf("%lx ", map[i]);
- }
- printf("\n");
- printf("5008-500Bh: ");
- for (i = 0x5008; i < 0x5008+4; i++) {
- printf("%lx ", map[i]);
- }
- printf("\n\n");
- printf("Interpretation:\n");
- printf("------------------\n");
- printf("Channel 0:\n");
- decode_channel(&map[0x5004]);
- printf("Channel 1:\n");
- decode_channel(&map[0x5008]);
- // Unmap the file
- if (munmap(map, FILESIZE) == -1) {
- perror("Error un-mmapping the file");
- }
- close(fd);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement