From 2e77c5a95413e4fdb07496d8db1bcfced01e4c5a Mon Sep 17 00:00:00 2001 From: Chenming Date: Fri, 22 Aug 2014 19:51:02 +0800 Subject: [PATCH] modify codes to get correct memory_size before read. It displays in three plays:pmon bios, before pmon command line, `sysinfo mem` command. Now all of them are right. Change-Id: I6eaf42f3df83a2603decf32cfea131a84f773374 --- Targets/Bonito3a2h/Bonito/tgt_machdep.c | 52 ++++------------- Targets/Bonito3a780e/Bonito/tgt_machdep.c | 19 +++--- Targets/Bonito3aserver/Bonito/tgt_machdep.c | 39 +------------ Targets/Bonito3b780e/Bonito/tgt_machdep.c | 55 ++++------------- Targets/Bonito3c780e/Bonito/tgt_machdep.c | 65 ++++----------------- Targets/Bonito3cserver/Bonito/tgt_machdep.c | 30 +--------- include/pmon.h | 1 + pmon/cmds/cmd_main/cmd_main.c | 2 +- pmon/common/main.c | 47 +++++++++++++++ 9 files changed, 89 insertions(+), 221 deletions(-) diff --git a/Targets/Bonito3a2h/Bonito/tgt_machdep.c b/Targets/Bonito3a2h/Bonito/tgt_machdep.c index f879ed22..bfdab50e 100644 --- a/Targets/Bonito3a2h/Bonito/tgt_machdep.c +++ b/Targets/Bonito3a2h/Bonito/tgt_machdep.c @@ -429,56 +429,24 @@ initmips(unsigned long long raw_memsz) int* io_addr; unsigned long long memsz; -tgt_fpuenable(); + tgt_fpuenable(); #ifdef DEVBD2F_SM502 { -/*set lio bus to 16 bit*/ -volatile int *p=0xbfe00108; -*p=((*p)&~(0x1f<<8))|(0x8<<8) |(1<<13); + /*set lio bus to 16 bit*/ + volatile int *p=0xbfe00108; + *p=((*p)&~(0x1f<<8))|(0x8<<8) |(1<<13); } #endif -/*enable float*/ -tgt_fpuenable(); -//CPU_TLBClear(); + /*enable float*/ + tgt_fpuenable(); + //CPU_TLBClear(); #if PCI_IDSEL_CS5536 != 0 -superio_reinit(); + superio_reinit(); #endif - memsz = raw_memsz & 0xff; - memsz = memsz << 29; - memsz = memsz - 0x1000000; - memsz = memsz >> 20; - /* - * Set up memory address decoders to map entire memory. - * But first move away bootrom map to high memory. - */ -#if 0 - GT_WRITE(BOOTCS_LOW_DECODE_ADDRESS, BOOT_BASE >> 20); - GT_WRITE(BOOTCS_HIGH_DECODE_ADDRESS, (BOOT_BASE - 1 + BOOT_SIZE) >> 20); -#endif - memorysize = memsz > 240 ? 240 << 20 : memsz << 20; - memorysize_high = memsz > 240 ? (((unsigned long long)memsz) - 240) << 20 : 0; - mem_size = memsz; -#ifdef MULTI_CHIP - memsz = raw_memsz & 0xff00; - memsz = memsz >> 8; - memsz = memsz << 29; - memorysize_n1 = memsz; - memsz = raw_memsz & 0xff0000; - memsz = memsz >> 16; - memsz = memsz << 29; - memorysize_n2 = memsz; - memsz = raw_memsz & 0xff000000; - memsz = memsz >> 24; - memsz = memsz << 29; - memorysize_n3 = memsz; -#if 1 - tgt_printf("memorysize_n1 0x%llx\n", memorysize_n1); - tgt_printf("memorysize_n2 0x%llx\n", memorysize_n2); - tgt_printf("memorysize_n3 0x%llx\n", memorysize_n3); -#endif -#endif + get_memorysize(raw_memsz); + #if 0 /* whd : Disable gpu controller of MCP68 */ //*(unsigned int *)0xbfe809e8 = 0x122380; //*(unsigned int *)0xbfe809e8 = 0x2280; diff --git a/Targets/Bonito3a780e/Bonito/tgt_machdep.c b/Targets/Bonito3a780e/Bonito/tgt_machdep.c index 14728317..c692fe94 100644 --- a/Targets/Bonito3a780e/Bonito/tgt_machdep.c +++ b/Targets/Bonito3a780e/Bonito/tgt_machdep.c @@ -218,6 +218,10 @@ unsigned long _filebase; extern unsigned long long memorysize; extern unsigned long long memorysize_high; +extern unsigned long long memorysize_high_n1; +extern unsigned long long memorysize_high_n2; +extern unsigned long long memorysize_high_n3; +extern unsigned long long memorysize_total; extern char MipsException[], MipsExceptionEnd[]; @@ -225,6 +229,7 @@ unsigned char hwethadr[6]; void initmips(unsigned long long raw_memsz); +//extern void get_memorysize(unsigned long long raw_memsz); void addr_tst1(void); void addr_tst2(void); void movinv1(int iter, ulong p1, ulong p2); @@ -237,20 +242,10 @@ initmips(unsigned long long raw_memsz) { int i; int* io_addr; - unsigned long long memsz; tgt_fpuenable(); - memsz = raw_memsz & 0xff; - memsz = memsz << 29; - memsz = memsz - 0x1000000; - memsz = memsz >> 20; - /* - * Set up memory address decoders to map entire memory. - * But first move away bootrom map to high memory. - */ - memorysize = memsz > 240 ? 240 << 20 : memsz << 20; - memorysize_high = memsz > 240 ? (((unsigned long long)memsz) - 240) << 20 : 0; - mem_size = memsz; + get_memorysize(raw_memsz); + /* * Probe clock frequencys so delays will work properly. */ diff --git a/Targets/Bonito3aserver/Bonito/tgt_machdep.c b/Targets/Bonito3aserver/Bonito/tgt_machdep.c index ce43f025..f25adbd3 100644 --- a/Targets/Bonito3aserver/Bonito/tgt_machdep.c +++ b/Targets/Bonito3aserver/Bonito/tgt_machdep.c @@ -432,7 +432,6 @@ initmips(unsigned int raw_memsz) { int i; int* io_addr; - unsigned long long memsz; tgt_fpuenable(); #ifdef DEVBD2F_SM502 { @@ -449,43 +448,7 @@ initmips(unsigned int raw_memsz) #if PCI_IDSEL_CS5536 != 0 superio_reinit(); #endif - memsz = raw_memsz & 0xff; - memsz = memsz << 29; - memsz = memsz - 0x1000000; - memsz = memsz >> 20; - /* - * Set up memory address decoders to map entire memory. - * But first move away bootrom map to high memory. - */ -#if 0 - GT_WRITE(BOOTCS_LOW_DECODE_ADDRESS, BOOT_BASE >> 20); - GT_WRITE(BOOTCS_HIGH_DECODE_ADDRESS, (BOOT_BASE - 1 + BOOT_SIZE) >> 20); -#endif - //memorysize = memsz > 256 ? 256 << 20 : memsz << 20; - //memorysize_high = memsz > 256 ? (memsz - 256) << 20 : 0; - memorysize = memsz > 240 ? 240 << 20 : memsz << 20; - memorysize_high = memsz > 240 ? (((unsigned long long)memsz) - 240) << 20 : 0; - mem_size = memsz; - -#ifdef MULTI_CHIP - memsz = raw_memsz & 0xff00; - memsz = memsz >> 8; - memsz = memsz << 29; - memorysize_high_n1 = (memsz == 0) ? 0 : (memsz - (256 << 20)); - tgt_printf("memorysize_high_n1 0x%llx\n", memorysize_high_n1); -#endif -#ifdef DUAL_3B - memsz = raw_memsz & 0xff0000; - memsz = memsz >> 16; - memsz = memsz << 29; - memorysize_high_n2 = (memsz == 0) ? 0 : (memsz - (256 << 20)); - memsz = raw_memsz & 0xff000000; - memsz = memsz >> 24; - memsz = memsz << 29; - memorysize_high_n3 = (memsz == 0) ? 0 : (memsz - (256 << 20)); - tgt_printf("memorysize_high_n2 0x%llx\n", memorysize_high_n2); - tgt_printf("memorysize_high_n3 0x%llx\n", memorysize_high_n3); -#endif + get_memorysize(raw_memsz); #if 0 /* whd : Disable gpu controller of MCP68 */ //*(unsigned int *)0xbfe809e8 = 0x122380; diff --git a/Targets/Bonito3b780e/Bonito/tgt_machdep.c b/Targets/Bonito3b780e/Bonito/tgt_machdep.c index 1a553965..caf69cdd 100644 --- a/Targets/Bonito3b780e/Bonito/tgt_machdep.c +++ b/Targets/Bonito3b780e/Bonito/tgt_machdep.c @@ -422,57 +422,24 @@ initmips(unsigned int raw_memsz) int i; int* io_addr; unsigned long long memsz; -tgt_fpuenable(); + tgt_fpuenable(); #ifdef DEVBD2F_SM502 { -/*set lio bus to 16 bit*/ -volatile int *p=0xbfe00108; -*p=((*p)&~(0x1f<<8))|(0x8<<8) |(1<<13); + /*set lio bus to 16 bit*/ + volatile int *p=0xbfe00108; + *p=((*p)&~(0x1f<<8))|(0x8<<8) |(1<<13); } #endif -/*enable float*/ -tgt_fpuenable(); -//CPU_TLBClear(); + /*enable float*/ + tgt_fpuenable(); + //CPU_TLBClear(); #if PCI_IDSEL_CS5536 != 0 -superio_reinit(); -#endif - memsz = raw_memsz & 0xff; - memsz = memsz << 29; - memsz = memsz - 0x1000000; - memsz = memsz >> 20; - /* - * Set up memory address decoders to map entire memory. - * But first move away bootrom map to high memory. - */ -#if 0 - GT_WRITE(BOOTCS_LOW_DECODE_ADDRESS, BOOT_BASE >> 20); - GT_WRITE(BOOTCS_HIGH_DECODE_ADDRESS, (BOOT_BASE - 1 + BOOT_SIZE) >> 20); -#endif - //memorysize = memsz > 256 ? 256 << 20 : memsz << 20; - //memorysize_high = memsz > 256 ? (memsz - 256) << 20 : 0; - memorysize = memsz > 240 ? 240 << 20 : memsz << 20; - memorysize_high = memsz > 240 ? (((unsigned long long)memsz) - 240) << 20 : 0; - mem_size = memsz; -#ifdef MULTI_CHIP - memsz = raw_memsz & 0xff00; - memsz = memsz >> 8; - memsz = memsz << 29; - memorysize_high_n1 = (memsz == 0) ? 0 : (memsz - (256 << 20)); - tgt_printf("memorysize_high_n1 0x%llx\n", memorysize_high_n1); -#endif -#ifdef DUAL_3B - memsz = raw_memsz & 0xff0000; - memsz = memsz >> 16; - memsz = memsz << 29; - memorysize_high_n2 = (memsz == 0) ? 0 : (memsz - (256 << 20)); - memsz = raw_memsz & 0xff000000; - memsz = memsz >> 24; - memsz = memsz << 29; - memorysize_high_n3 = (memsz == 0) ? 0 : (memsz - (256 << 20)); - tgt_printf("memorysize_high_n2 0x%llx\n", memorysize_high_n2); - tgt_printf("memorysize_high_n3 0x%llx\n", memorysize_high_n3); + superio_reinit(); #endif + + get_memorysize(raw_memsz); + #if 0 /* whd : Disable gpu controller of MCP68 */ //*(unsigned int *)0xbfe809e8 = 0x122380; //*(unsigned int *)0xbfe809e8 = 0x2280; diff --git a/Targets/Bonito3c780e/Bonito/tgt_machdep.c b/Targets/Bonito3c780e/Bonito/tgt_machdep.c index 2edf622e..3516cbd3 100644 --- a/Targets/Bonito3c780e/Bonito/tgt_machdep.c +++ b/Targets/Bonito3c780e/Bonito/tgt_machdep.c @@ -419,7 +419,7 @@ void movinv1(int iter, ulong p1, ulong p2); pcireg_t _pci_allocate_io(struct pci_device *dev, vm_size_t size); static void superio_reinit(); -extern unsigned long long memorysize_total; +//extern unsigned long long memorysize_total; void initmips(unsigned long long raw_memsz) @@ -427,68 +427,23 @@ initmips(unsigned long long raw_memsz) int i; int* io_addr; unsigned long long memsz; -tgt_fpuenable(); + tgt_fpuenable(); #ifdef DEVBD2F_SM502 { -/*set lio bus to 16 bit*/ -volatile int *p=0xbfe00108; -*p=((*p)&~(0x1f<<8))|(0x8<<8) |(1<<13); + /*set lio bus to 16 bit*/ + volatile int *p=0xbfe00108; + *p=((*p)&~(0x1f<<8))|(0x8<<8) |(1<<13); } #endif -/*enable float*/ -tgt_fpuenable(); -//CPU_TLBClear(); + /*enable float*/ + tgt_fpuenable(); + //CPU_TLBClear(); #if PCI_IDSEL_CS5536 != 0 -superio_reinit(); + superio_reinit(); #endif - memsz = raw_memsz & 0xff; - memsz = memsz << 29; - memsz = memsz - 0x1000000; - memsz = memsz >> 20; - /* - * Set up memory address decoders to map entire memory. - * But first move away bootrom map to high memory. - */ -#if 0 - GT_WRITE(BOOTCS_LOW_DECODE_ADDRESS, BOOT_BASE >> 20); - GT_WRITE(BOOTCS_HIGH_DECODE_ADDRESS, (BOOT_BASE - 1 + BOOT_SIZE) >> 20); -#endif - memorysize = memsz > 240 ? 240 << 20 : memsz << 20; - memorysize_high = memsz > 240 ? (((unsigned long long)memsz) - 240) << 20 : 0; - mem_size = memsz; - memsz = raw_memsz & 0xff00; - memsz = memsz >> 8; - memsz = memsz << 29; - memorysize_high_n1 = (memsz == 0) ? 0 : (memsz - (256 << 20)); -#ifdef MULTI_CHIP - memsz = raw_memsz & 0xff0000; - memsz = memsz >> 16; - memsz = memsz << 29; - memorysize_high_n2 = (memsz == 0) ? 0 : (memsz - (256 << 20)); - memsz = raw_memsz & 0xff000000; - memsz = memsz >> 24; - memsz = memsz << 29; - memorysize_high_n3 = (memsz == 0) ? 0 : (memsz - (256 << 20)); -#endif - memorysize_total = ((memorysize + memorysize_high + memsz) >> 20) + 16; -//cm: calculate the correct Memory Size in BIOS SETUP -#ifdef MULTI_CHIP - if(memorysize_high_n1 == 0) - memorysize_total += (memorysize_high_n1 >> 20); - else - memorysize_total += ((memorysize_high_n1 + (256 << 20)) >> 20); -#endif -#ifdef DUAL_3B - if(memorysize_high_n2 != 0 && memorysize_high_n3 == 0) - memorysize_total += ((memorysize_high_n2 + (256 << 20)) >> 20); - else if(memorysize_high_n2 == 0 && memorysize_high_n3 != 0) - memorysize_total += ((memorysize_high_n3 + (256 << 20)) >> 20); - else if(memorysize_high_n2 !=0 && memorysize_high_n3 != 0) - memorysize_total += ((memorysize_high_n2 + (256 << 20) + memorysize_high_n3 + (256 << 20)) >> 20); -#endif -//cm: end + get_memorysize(raw_memsz); #if 0 /* whd : Disable gpu controller of MCP68 */ //*(unsigned int *)0xbfe809e8 = 0x122380; diff --git a/Targets/Bonito3cserver/Bonito/tgt_machdep.c b/Targets/Bonito3cserver/Bonito/tgt_machdep.c index 94141658..1ac56948 100644 --- a/Targets/Bonito3cserver/Bonito/tgt_machdep.c +++ b/Targets/Bonito3cserver/Bonito/tgt_machdep.c @@ -424,35 +424,7 @@ initmips(unsigned long long raw_memsz) unsigned long long memsz; tgt_fpuenable(); - memsz = raw_memsz & 0xff; - memsz = memsz << 29; - memsz = memsz - 0x1000000; - memsz = memsz >> 20; - /* - * Set up memory address decoders to map entire memory. - * But first move away bootrom map to high memory. - */ - memorysize = memsz > 240 ? 240 << 20 : memsz << 20; - memorysize_high = memsz > 240 ? (((unsigned long long)memsz) - 240) << 20 : 0; - mem_size = memsz; - - memsz = raw_memsz & 0xff00; - memsz = memsz >> 8; - memsz = memsz << 29; - memorysize_high_n1 = (memsz == 0) ? 0 : (memsz - (256 << 20)); -#if 1 - //#ifdef MULTI_CHIP - memsz = raw_memsz & 0xff0000; - memsz = memsz >> 16; - memsz = memsz << 29; - memorysize_high_n2 = (memsz == 0) ? 0 : (memsz - (256 << 20)); - memsz = raw_memsz & 0xff000000; - memsz = memsz >> 24; - memsz = memsz << 29; - memorysize_high_n3 = (memsz == 0) ? 0 : (memsz - (256 << 20)); -#endif - memorysize_total = ((memorysize + memorysize_high + memsz) >> 20) + 16; - + get_memorysize(raw_memsz); /* * Probe clock frequencys so delays will work properly. */ diff --git a/include/pmon.h b/include/pmon.h index b5963ab4..12f0ce24 100644 --- a/include/pmon.h +++ b/include/pmon.h @@ -206,6 +206,7 @@ int do_cmd __P((char *)); int no_cmd __P((int, char *[])); void closelst __P((int)); void console_state(int); +void get_memorysize(unsigned long long); extern unsigned long long memorysize; extern int repeating_cmd; diff --git a/pmon/cmds/cmd_main/cmd_main.c b/pmon/cmds/cmd_main/cmd_main.c index a80a2974..9fa7379e 100644 --- a/pmon/cmds/cmd_main/cmd_main.c +++ b/pmon/cmds/cmd_main/cmd_main.c @@ -992,7 +992,7 @@ int paint_childwindow(char **hint,char *diskdev_name[],char *netdev_name[],int e sprintf(line,"CPU Type: %s @ %d MHz",md_cpuname(),tgt_pipefreq()/1000000); w_text(3,7,WA_LEFT,line); /* Display Memory size */ - sprintf(line, "Memory size: %dMB", memorysize_total); + sprintf(line, "Memory size: %lldMB", memorysize_total); w_bigtext(3,8,40,2,line); #if LOONGSON_3ASINGLE /* below code only used for ls3a/3b/3c 780e board with rte0, other card not support diff --git a/pmon/common/main.c b/pmon/common/main.c index 4c2d5d3e..25db8f5e 100644 --- a/pmon/common/main.c +++ b/pmon/common/main.c @@ -89,8 +89,10 @@ register_t initial_sr; unsigned long long memorysize = 0; unsigned long long memorysize_high = 0; unsigned long long memorysize_high_n1 = 0; +#ifdef MULTI_CHIP unsigned long long memorysize_high_n2 = 0; unsigned long long memorysize_high_n3 = 0; +#endif unsigned long long memorysize_total = 0; char prnbuf[LINESZ + 8]; /* commonly used print buffer */ @@ -866,6 +868,7 @@ dbginit (char *adr) else printf("/ Bus @ 33 MHz\n"); #endif + /* memorysize_total = ((memsize + memorysize_high + (16 << 20)) >> 20); #ifdef MULTI_CHIP if(memorysize_high_n1 == 0) @@ -881,7 +884,10 @@ dbginit (char *adr) else if(memorysize_high_n2 !=0 && memorysize_high_n3 != 0) memorysize_total += ((memorysize_high_n2 + (256 << 20) + memorysize_high_n3 + (256 << 20)) >> 20); #endif +*/ + printf ("Memory size %lld MB .\n", memorysize_total); + tgt_memprint(); #if defined(SMP) tgt_smpstartup(); @@ -1116,3 +1122,44 @@ initstack (ac, av, addenv) */ md_setlr(NULL, (register_t)_exit); } + +void get_memorysize(unsigned long long raw_memsz) { + unsigned long long memsz,mem_size; + memsz = raw_memsz & 0xff; + memsz = memsz << 29; + memsz = memsz - 0x1000000; + memsz = memsz >> 20; + /* + * Set up memory address decoders to map entire memory. + * But first move away bootrom map to high memory. + */ + memorysize = memsz > 240 ? 240 << 20 : memsz << 20; + memorysize_high = memsz > 240 ? (((unsigned long long)memsz) - 240) << 20 : 0; + mem_size = memsz; + + memsz = raw_memsz & 0xff00; + memsz = memsz >> 8; + memsz = memsz << 29; + memorysize_high_n1 = (memsz == 0) ? 0 : (memsz - (256 << 20)); + +#ifdef MULTI_CHIP + memsz = raw_memsz & 0xff0000; + memsz = memsz >> 16; + memsz = memsz << 29; + memorysize_high_n2 = (memsz == 0) ? 0 : (memsz - (256 << 20)); + + memsz = raw_memsz & 0xff000000; + memsz = memsz >> 24; + memsz = memsz << 29; + memorysize_high_n3 = (memsz == 0) ? 0 : (memsz - (256 << 20)); +#endif + memorysize_total = ((memorysize + memorysize_high) >> 20) + 16; + if(memorysize_high_n1 != 0) + memorysize_total += ((memorysize_high_n1 + (256 << 20)) >> 20); +#ifdef MULTI_CHIP + if(memorysize_high_n2 != 0) + memorysize_total += ((memorysize_high_n2 + (256 << 20)) >> 20); + if(memorysize_high_n3 != 0) + memorysize_total += ((memorysize_high_n3 + (256 << 20)) >> 20); +#endif +}