I am trying to write so code to find the amount of memory available in a device. It can either have 2,4,8, or 16 meg's. The memory starts at
0x00000000. What is the best way to find how much is their. Here is what I am trying now but is their a better (prettier) way.#define DRAM_BASE 0x00000000 #define DRAM_END_2MB 0x001FFFFF #define DRAM_END_4MB 0x003FFFFF #define DRAM_END_8MB 0x007FFFFF #define DRAM_END_16MB 0x00FFFFFF unsigned int probe_dram(void){ char tmp; volatile unsigned char *dram;
dram = (volatile unsigned char *) DRAM_BASE; tmp = dram[0]; printk("0mb\n"); dram = (volatile unsigned char *) DRAM_END_2MB; tmp = dram[0]; printk("2mb\n"); dram = (volatile unsigned char *) DRAM_END_4MB; tmp = dram[0]; printk("4mb\n"); dram = (volatile unsigned char *) DRAM_END_8MB; tmp = dram[0]; printk("8mb\n"); dram = (volatile unsigned char *) DRAM_END_16MB; tmp = dram[0]; printk("16mb\n"); return 0; }
-kyle