1 /* *********************************************************************
2 * Broadcom Common Firmware Environment (CFE)
4 * bcm635x_board.c utility functions for bcm635X board
6 * Created on : 09/25/2002 seanl
8 *********************************************************************
12 Copyright (c) 2002 Broadcom Corporation
14 No portions of this material may be reproduced in any form without the
15 written permission of:
18 Irvine, California 92619
19 All information contained in this document is Broadcom Corporation
20 company private, proprietary, and trade secret.
25 #include "bcm63xx_util.h"
26 extern NVRAM_DATA nvramData
;
27 extern int readNvramData(void);
29 static int parsePsiSize(char *psiStr
)
31 int psiSize
= atoi(psiStr
);
33 if (psiSize
>= 1 && psiSize
<= NVRAM_PSI_MAX_SIZE
)
39 static int parseMemConfig(char *memSizeStr
)
41 int memSize
= atoi(memSizeStr
);
43 if (memSize
>= MEMORY_635X_16MB_1_CHIP
&& memSize
<= MEMORY_635X_64MB_2_CHIP
)
49 static PARAMETER_SETTING gBoardParam
[] =
51 // prompt name Error Prompt Define Param Validation function
52 {"Board Id String(max 16 char) :", BOARDID_STR_PROMPT
, "", "", parseBoardIdStr
},
53 {"Psi size in KB (default:127) :", PSI_SIZE_PROMPT
, "", "", parsePsiSize
},
54 {"Number of MAC Addresses(1-32):", MAC_CT_PROMPT
, "", "", parseMacAddrCount
},
55 {"Base MAC Address :", MAC_ADDR_PROMPT
, "", "", parseMacAddr
},
56 {"Memory size: Range 0-2\n\
57 16MB (1 chip) ------- 0\n\
58 32MB (2 chips) ------- 1\n\
59 64MB (2 chips) ------- 2 :", MEM_CONFIG_PROMPT
, "", "", parseMemConfig
},
64 // getBoardParam: convert the board param data and put them in the gBoardParam struct
66 void getBoardParam(void)
70 if (nvramData
.szBoardId
[0] != (char)0xff)
71 memcpy(gBoardParam
[0].parameter
, nvramData
.szBoardId
, NVRAM_BOARD_ID_STRING_LEN
);
73 memset(gBoardParam
[0].parameter
, 0, NVRAM_BOARD_ID_STRING_LEN
);
75 if (nvramData
.ulPsiSize
== 0xffffffff)
76 nvramData
.ulPsiSize
= NVRAM_PSI_DEFAULT_635X
;
77 sprintf(gBoardParam
[1].parameter
, "%d", nvramData
.ulPsiSize
);
79 if (nvramData
.ulNumMacAddrs
== 0xffffffff)
80 nvramData
.ulNumMacAddrs
= NVRAM_MAC_COUNT_DEFAULT_635X
;
81 sprintf(gBoardParam
[2].parameter
, "%d", nvramData
.ulNumMacAddrs
);
83 if (nvramData
.ucaBaseMacAddr
[0] == 0xff && nvramData
.ucaBaseMacAddr
[1] == 0xff &&
84 nvramData
.ucaBaseMacAddr
[2] == 0xff && nvramData
.ucaBaseMacAddr
[3] == 0xff)
85 memset(gBoardParam
[3].parameter
, 0, NVRAM_MAC_ADDRESS_LEN
);
87 macNumToStr(nvramData
.ucaBaseMacAddr
, gBoardParam
[3].parameter
);
89 memType
= kerSysMemoryTypeGet();
91 if (!(memType
>= MEMORY_635X_16MB_1_CHIP
&& memType
<= MEMORY_635X_64MB_2_CHIP
))
92 memType
= MEMORY_635X_16MB_1_CHIP
;
93 sprintf(gBoardParam
[4].parameter
, "%d", memType
);
97 // setBoardParam: Set the board Id string, mac addresses, psi size, etc...
99 int setBoardParam(void)
103 PPARAMETER_SETTING tmpPtr
= gBoardParam
;
106 while (tmpPtr
->promptName
!= NULL
)
116 bChange
= processPrompt(gBoardParam
, count
);
117 if (strlen(gBoardParam
[3].parameter
) != 0)
119 printf("Base Mac address is not entered. Try it again!\n");
124 // fill in board id string, psi and mac count
125 nvramData
.ulVersion
= NVRAM_VERSION_NUMBER
;
126 nvramData
.ulEnetModeFlag
= 0xffffffff; // all ffs for enet mode flag
127 memset(nvramData
.szBoardId
, 0, NVRAM_BOARD_ID_STRING_LEN
);
128 memcpy(nvramData
.szBoardId
, gBoardParam
[0].parameter
, NVRAM_BOARD_ID_STRING_LEN
);
129 nvramData
.ulPsiSize
= atoi(gBoardParam
[1].parameter
);
130 nvramData
.ulNumMacAddrs
= atoi(gBoardParam
[2].parameter
);
131 parsehwaddr(gBoardParam
[3].parameter
, nvramData
.ucaBaseMacAddr
);
133 // set memory type thing
134 memType
= atoi(gBoardParam
[4].parameter
);
135 kerSysMemoryTypeSet((int) FLASH63XX_ADDR_BOOT_ROM
, (char *)&memType
, sizeof(int));
137 if (nvramData
.ulPsiSize
!= NVRAM_PSI_DEFAULT_635X
)
139 printf("Are you REALLY sure persistent storage size is %d?", nvramData
.ulPsiSize
);
142 nvramData
.ulPsiSize
= NVRAM_PSI_DEFAULT_635X
;
143 sprintf(gBoardParam
[1].parameter
, "%d", nvramData
.ulPsiSize
);
147 // save the buf to nvram
150 printf("Press any key to reset the board: \n");
152 if (console_status())
153 kerSysMipsSoftReset();
161 void displayBoardParam(void)
163 PPARAMETER_SETTING tmpPtr
= gBoardParam
;
167 char memoryStr
[] = "Memory size :";
170 while (tmpPtr
->promptName
!= NULL
)
177 for (i
= 0; i
< (count
-1); i
++)
178 printf("%s %s \n", gBoardParam
[i
].promptName
, gBoardParam
[i
].parameter
);
179 // print last memory type seperately
180 memType
= kerSysMemoryTypeGet();
183 case MEMORY_635X_16MB_1_CHIP
:
184 strcpy(megaByte
, "16MB");
186 case MEMORY_635X_32MB_2_CHIP
:
187 strcpy(megaByte
, "32MB");
189 case MEMORY_635X_64MB_2_CHIP
:
190 strcpy(megaByte
, "64MB");
193 strcpy(megaByte
, "***Not defined?***");
196 printf("%s %s\n\n", memoryStr
, megaByte
);
200 void setDefaultBootline(void)
202 memset(nvramData
.szBootline
, 0, NVRAM_BOOTLINE_LEN
);
203 strncpy(nvramData
.szBootline
, DEFAULT_BOOTLINE_635X
, strlen(DEFAULT_BOOTLINE_635X
));
204 printf("Use default boot line parameters: %s\n", DEFAULT_BOOTLINE_635X
);