GUI: Fix Tomato RAF theme for all builds. Compilation typo.
[tomato.git] / release / src-rt-6.x.4708 / cfe / cfe / arch / mips / board / bcm9635x / src / bcm635x_board.c
blob68559665db5fbf32c73296aa0b6bf7ead754780d
1 /* *********************************************************************
2 * Broadcom Common Firmware Environment (CFE)
3 *
4 * bcm635x_board.c utility functions for bcm635X board
5 *
6 * Created on : 09/25/2002 seanl
8 *********************************************************************
10 <:copyright-broadcom
12 Copyright (c) 2002 Broadcom Corporation
13 All Rights Reserved
14 No portions of this material may be reproduced in any form without the
15 written permission of:
16 Broadcom Corporation
17 16215 Alton Parkway
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)
34 return 0;
35 else
36 return 1;
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)
44 return 0;
45 else
46 return 1;
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},
60 {NULL}
64 // getBoardParam: convert the board param data and put them in the gBoardParam struct
66 void getBoardParam(void)
68 int memType;
70 if (nvramData.szBoardId[0] != (char)0xff)
71 memcpy(gBoardParam[0].parameter, nvramData.szBoardId, NVRAM_BOARD_ID_STRING_LEN);
72 else
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);
86 else
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)
101 int bChange = FALSE;
102 int count = 0;
103 PPARAMETER_SETTING tmpPtr = gBoardParam;
104 int memType;
106 while (tmpPtr->promptName != NULL)
108 count++;
109 tmpPtr++;
112 getBoardParam();
114 while (1)
116 bChange = processPrompt(gBoardParam, count);
117 if (strlen(gBoardParam[3].parameter) != 0)
118 break;
119 printf("Base Mac address is not entered. Try it again!\n");
122 if (bChange)
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);
140 if (yesno())
142 nvramData.ulPsiSize = NVRAM_PSI_DEFAULT_635X;
143 sprintf(gBoardParam[1].parameter, "%d", nvramData.ulPsiSize);
144 return 0;
147 // save the buf to nvram
148 writeNvramData();
150 printf("Press any key to reset the board: \n");
151 while (1)
152 if (console_status())
153 kerSysMipsSoftReset();
156 return 0;
158 } // setBoardParam
161 void displayBoardParam(void)
163 PPARAMETER_SETTING tmpPtr = gBoardParam;
164 int count = 0;
165 int i;
166 int memType;
167 char memoryStr[] = "Memory size :";
168 char megaByte[30];
170 while (tmpPtr->promptName != NULL)
172 count++;
173 tmpPtr++;
176 getBoardParam();
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();
181 switch (memType)
183 case MEMORY_635X_16MB_1_CHIP:
184 strcpy(megaByte, "16MB");
185 break;
186 case MEMORY_635X_32MB_2_CHIP:
187 strcpy(megaByte, "32MB");
188 break;
189 case MEMORY_635X_64MB_2_CHIP:
190 strcpy(megaByte, "64MB");
191 break;
192 default:
193 strcpy(megaByte, "***Not defined?***");
194 break;
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);
205 writeNvramData();
206 readNvramData();
207 convertBootInfo();