Browse Source

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
master
Chenming 10 years ago
committed by mengtianfang
parent
commit
2e77c5a954
  1. 52
      Targets/Bonito3a2h/Bonito/tgt_machdep.c
  2. 19
      Targets/Bonito3a780e/Bonito/tgt_machdep.c
  3. 39
      Targets/Bonito3aserver/Bonito/tgt_machdep.c
  4. 55
      Targets/Bonito3b780e/Bonito/tgt_machdep.c
  5. 65
      Targets/Bonito3c780e/Bonito/tgt_machdep.c
  6. 30
      Targets/Bonito3cserver/Bonito/tgt_machdep.c
  7. 1
      include/pmon.h
  8. 2
      pmon/cmds/cmd_main/cmd_main.c
  9. 47
      pmon/common/main.c

52
Targets/Bonito3a2h/Bonito/tgt_machdep.c

@ -429,56 +429,24 @@ initmips(unsigned long long raw_memsz)
int* io_addr; int* io_addr;
unsigned long long memsz; unsigned long long memsz;
tgt_fpuenable(); tgt_fpuenable();
#ifdef DEVBD2F_SM502 #ifdef DEVBD2F_SM502
{ {
/*set lio bus to 16 bit*/ /*set lio bus to 16 bit*/
volatile int *p=0xbfe00108; volatile int *p=0xbfe00108;
*p=((*p)&~(0x1f<<8))|(0x8<<8) |(1<<13); *p=((*p)&~(0x1f<<8))|(0x8<<8) |(1<<13);
} }
#endif #endif
/*enable float*/ /*enable float*/
tgt_fpuenable(); tgt_fpuenable();
//CPU_TLBClear(); //CPU_TLBClear();
#if PCI_IDSEL_CS5536 != 0 #if PCI_IDSEL_CS5536 != 0
superio_reinit(); superio_reinit();
#endif #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 get_memorysize(raw_memsz);
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
#if 0 /* whd : Disable gpu controller of MCP68 */ #if 0 /* whd : Disable gpu controller of MCP68 */
//*(unsigned int *)0xbfe809e8 = 0x122380; //*(unsigned int *)0xbfe809e8 = 0x122380;
//*(unsigned int *)0xbfe809e8 = 0x2280; //*(unsigned int *)0xbfe809e8 = 0x2280;

19
Targets/Bonito3a780e/Bonito/tgt_machdep.c

@ -218,6 +218,10 @@ unsigned long _filebase;
extern unsigned long long memorysize; extern unsigned long long memorysize;
extern unsigned long long memorysize_high; 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[]; extern char MipsException[], MipsExceptionEnd[];
@ -225,6 +229,7 @@ unsigned char hwethadr[6];
void initmips(unsigned long long raw_memsz); void initmips(unsigned long long raw_memsz);
//extern void get_memorysize(unsigned long long raw_memsz);
void addr_tst1(void); void addr_tst1(void);
void addr_tst2(void); void addr_tst2(void);
void movinv1(int iter, ulong p1, ulong p2); void movinv1(int iter, ulong p1, ulong p2);
@ -237,20 +242,10 @@ initmips(unsigned long long raw_memsz)
{ {
int i; int i;
int* io_addr; int* io_addr;
unsigned long long memsz;
tgt_fpuenable(); tgt_fpuenable();
memsz = raw_memsz & 0xff; get_memorysize(raw_memsz);
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;
/* /*
* Probe clock frequencys so delays will work properly. * Probe clock frequencys so delays will work properly.
*/ */

39
Targets/Bonito3aserver/Bonito/tgt_machdep.c

@ -432,7 +432,6 @@ initmips(unsigned int raw_memsz)
{ {
int i; int i;
int* io_addr; int* io_addr;
unsigned long long memsz;
tgt_fpuenable(); tgt_fpuenable();
#ifdef DEVBD2F_SM502 #ifdef DEVBD2F_SM502
{ {
@ -449,43 +448,7 @@ initmips(unsigned int raw_memsz)
#if PCI_IDSEL_CS5536 != 0 #if PCI_IDSEL_CS5536 != 0
superio_reinit(); superio_reinit();
#endif #endif
memsz = raw_memsz & 0xff; get_memorysize(raw_memsz);
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
#if 0 /* whd : Disable gpu controller of MCP68 */ #if 0 /* whd : Disable gpu controller of MCP68 */
//*(unsigned int *)0xbfe809e8 = 0x122380; //*(unsigned int *)0xbfe809e8 = 0x122380;

55
Targets/Bonito3b780e/Bonito/tgt_machdep.c

@ -422,57 +422,24 @@ initmips(unsigned int raw_memsz)
int i; int i;
int* io_addr; int* io_addr;
unsigned long long memsz; unsigned long long memsz;
tgt_fpuenable(); tgt_fpuenable();
#ifdef DEVBD2F_SM502 #ifdef DEVBD2F_SM502
{ {
/*set lio bus to 16 bit*/ /*set lio bus to 16 bit*/
volatile int *p=0xbfe00108; volatile int *p=0xbfe00108;
*p=((*p)&~(0x1f<<8))|(0x8<<8) |(1<<13); *p=((*p)&~(0x1f<<8))|(0x8<<8) |(1<<13);
} }
#endif #endif
/*enable float*/ /*enable float*/
tgt_fpuenable(); tgt_fpuenable();
//CPU_TLBClear(); //CPU_TLBClear();
#if PCI_IDSEL_CS5536 != 0 #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 > 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 #endif
get_memorysize(raw_memsz);
#if 0 /* whd : Disable gpu controller of MCP68 */ #if 0 /* whd : Disable gpu controller of MCP68 */
//*(unsigned int *)0xbfe809e8 = 0x122380; //*(unsigned int *)0xbfe809e8 = 0x122380;
//*(unsigned int *)0xbfe809e8 = 0x2280; //*(unsigned int *)0xbfe809e8 = 0x2280;

65
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); pcireg_t _pci_allocate_io(struct pci_device *dev, vm_size_t size);
static void superio_reinit(); static void superio_reinit();
extern unsigned long long memorysize_total; //extern unsigned long long memorysize_total;
void void
initmips(unsigned long long raw_memsz) initmips(unsigned long long raw_memsz)
@ -427,68 +427,23 @@ initmips(unsigned long long raw_memsz)
int i; int i;
int* io_addr; int* io_addr;
unsigned long long memsz; unsigned long long memsz;
tgt_fpuenable(); tgt_fpuenable();
#ifdef DEVBD2F_SM502 #ifdef DEVBD2F_SM502
{ {
/*set lio bus to 16 bit*/ /*set lio bus to 16 bit*/
volatile int *p=0xbfe00108; volatile int *p=0xbfe00108;
*p=((*p)&~(0x1f<<8))|(0x8<<8) |(1<<13); *p=((*p)&~(0x1f<<8))|(0x8<<8) |(1<<13);
} }
#endif #endif
/*enable float*/ /*enable float*/
tgt_fpuenable(); tgt_fpuenable();
//CPU_TLBClear(); //CPU_TLBClear();
#if PCI_IDSEL_CS5536 != 0 #if PCI_IDSEL_CS5536 != 0
superio_reinit(); superio_reinit();
#endif #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; get_memorysize(raw_memsz);
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
#if 0 /* whd : Disable gpu controller of MCP68 */ #if 0 /* whd : Disable gpu controller of MCP68 */
//*(unsigned int *)0xbfe809e8 = 0x122380; //*(unsigned int *)0xbfe809e8 = 0x122380;

30
Targets/Bonito3cserver/Bonito/tgt_machdep.c

@ -424,35 +424,7 @@ initmips(unsigned long long raw_memsz)
unsigned long long memsz; unsigned long long memsz;
tgt_fpuenable(); tgt_fpuenable();
memsz = raw_memsz & 0xff; get_memorysize(raw_memsz);
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;
/* /*
* Probe clock frequencys so delays will work properly. * Probe clock frequencys so delays will work properly.
*/ */

1
include/pmon.h

@ -206,6 +206,7 @@ int do_cmd __P((char *));
int no_cmd __P((int, char *[])); int no_cmd __P((int, char *[]));
void closelst __P((int)); void closelst __P((int));
void console_state(int); void console_state(int);
void get_memorysize(unsigned long long);
extern unsigned long long memorysize; extern unsigned long long memorysize;
extern int repeating_cmd; extern int repeating_cmd;

2
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); sprintf(line,"CPU Type: %s @ %d MHz",md_cpuname(),tgt_pipefreq()/1000000);
w_text(3,7,WA_LEFT,line); w_text(3,7,WA_LEFT,line);
/* Display Memory size */ /* Display Memory size */
sprintf(line, "Memory size: %dMB", memorysize_total); sprintf(line, "Memory size: %lldMB", memorysize_total);
w_bigtext(3,8,40,2,line); 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 #if LOONGSON_3ASINGLE /* below code only used for ls3a/3b/3c 780e board with rte0, other card not support

47
pmon/common/main.c

@ -89,8 +89,10 @@ register_t initial_sr;
unsigned long long memorysize = 0; unsigned long long memorysize = 0;
unsigned long long memorysize_high = 0; unsigned long long memorysize_high = 0;
unsigned long long memorysize_high_n1 = 0; unsigned long long memorysize_high_n1 = 0;
#ifdef MULTI_CHIP
unsigned long long memorysize_high_n2 = 0; unsigned long long memorysize_high_n2 = 0;
unsigned long long memorysize_high_n3 = 0; unsigned long long memorysize_high_n3 = 0;
#endif
unsigned long long memorysize_total = 0; unsigned long long memorysize_total = 0;
char prnbuf[LINESZ + 8]; /* commonly used print buffer */ char prnbuf[LINESZ + 8]; /* commonly used print buffer */
@ -866,6 +868,7 @@ dbginit (char *adr)
else else
printf("/ Bus @ 33 MHz\n"); printf("/ Bus @ 33 MHz\n");
#endif #endif
/*
memorysize_total = ((memsize + memorysize_high + (16 << 20)) >> 20); memorysize_total = ((memsize + memorysize_high + (16 << 20)) >> 20);
#ifdef MULTI_CHIP #ifdef MULTI_CHIP
if(memorysize_high_n1 == 0) if(memorysize_high_n1 == 0)
@ -881,7 +884,10 @@ dbginit (char *adr)
else if(memorysize_high_n2 !=0 && memorysize_high_n3 != 0) else if(memorysize_high_n2 !=0 && memorysize_high_n3 != 0)
memorysize_total += ((memorysize_high_n2 + (256 << 20) + memorysize_high_n3 + (256 << 20)) >> 20); memorysize_total += ((memorysize_high_n2 + (256 << 20) + memorysize_high_n3 + (256 << 20)) >> 20);
#endif #endif
*/
printf ("Memory size %lld MB .\n", memorysize_total); printf ("Memory size %lld MB .\n", memorysize_total);
tgt_memprint(); tgt_memprint();
#if defined(SMP) #if defined(SMP)
tgt_smpstartup(); tgt_smpstartup();
@ -1116,3 +1122,44 @@ initstack (ac, av, addenv)
*/ */
md_setlr(NULL, (register_t)_exit); 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
}

Loading…
Cancel
Save