PcdValueCommon.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779
  1. /** @file
  2. This file contains the PcdValue structure definition.
  3. Copyright (c) 2017 - 2018, Intel Corporation. All rights reserved.<BR>
  4. SPDX-License-Identifier: BSD-2-Clause-Patent
  5. **/
  6. #include <stdio.h>
  7. #include <string.h>
  8. #include <stdlib.h>
  9. #include "CommonLib.h"
  10. #include "PcdValueCommon.h"
  11. typedef enum {
  12. PcdDataTypeBoolean,
  13. PcdDataTypeUint8,
  14. PcdDataTypeUint16,
  15. PcdDataTypeUint32,
  16. PcdDataTypeUint64,
  17. PcdDataTypePointer
  18. } PCD_DATA_TYPE;
  19. typedef struct {
  20. CHAR8 *SkuName;
  21. CHAR8 *DefaultValueName;
  22. CHAR8 *TokenSpaceGuidName;
  23. CHAR8 *TokenName;
  24. CHAR8 *DataType;
  25. CHAR8 *Value;
  26. PCD_DATA_TYPE PcdDataType;
  27. } PCD_ENTRY;
  28. PCD_ENTRY *PcdList;
  29. UINT32 PcdListLength;
  30. VOID
  31. STATIC
  32. RecordToken (
  33. UINT8 *FileBuffer,
  34. UINT32 PcdIndex,
  35. UINT32 TokenIndex,
  36. UINT32 TokenStart,
  37. UINT32 TokenEnd
  38. )
  39. /*++
  40. Routine Description:
  41. Record new token information
  42. Arguments:
  43. FileBuffer File Buffer to be record
  44. PcdIndex Index of PCD in database
  45. TokenIndex Index of Token
  46. TokenStart Start of Token
  47. TokenEnd End of Token
  48. Returns:
  49. None
  50. --*/
  51. {
  52. CHAR8 *Token;
  53. Token = malloc (TokenEnd - TokenStart + 1);
  54. if (Token == NULL) {
  55. return;
  56. }
  57. memcpy (Token, &FileBuffer[TokenStart], TokenEnd - TokenStart);
  58. Token[TokenEnd - TokenStart] = 0;
  59. switch (TokenIndex) {
  60. case 0:
  61. PcdList[PcdIndex].SkuName = Token;
  62. break;
  63. case 1:
  64. PcdList[PcdIndex].DefaultValueName = Token;
  65. break;
  66. case 2:
  67. PcdList[PcdIndex].TokenSpaceGuidName = Token;
  68. break;
  69. case 3:
  70. PcdList[PcdIndex].TokenName = Token;
  71. break;
  72. case 4:
  73. PcdList[PcdIndex].DataType = Token;
  74. if (strcmp (Token, "BOOLEAN") == 0) {
  75. PcdList[PcdIndex].PcdDataType = PcdDataTypeBoolean;
  76. } else if (strcmp (Token, "UINT8") == 0) {
  77. PcdList[PcdIndex].PcdDataType = PcdDataTypeUint8;
  78. } else if (strcmp (Token, "UINT16") == 0) {
  79. PcdList[PcdIndex].PcdDataType = PcdDataTypeUint16;
  80. } else if (strcmp (Token, "UINT32") == 0) {
  81. PcdList[PcdIndex].PcdDataType = PcdDataTypeUint32;
  82. } else if (strcmp (Token, "UINT64") == 0) {
  83. PcdList[PcdIndex].PcdDataType = PcdDataTypeUint64;
  84. } else {
  85. PcdList[PcdIndex].PcdDataType = PcdDataTypePointer;
  86. }
  87. break;
  88. case 5:
  89. PcdList[PcdIndex].Value = Token;
  90. break;
  91. default:
  92. free (Token);
  93. break;
  94. }
  95. }
  96. int
  97. STATIC
  98. LookupPcdIndex (
  99. CHAR8 *SkuName OPTIONAL,
  100. CHAR8 *DefaultValueName OPTIONAL,
  101. CHAR8 *TokenSpaceGuidName,
  102. CHAR8 *TokenName
  103. )
  104. /*++
  105. Routine Description:
  106. Get PCD index in Pcd database
  107. Arguments:
  108. SkuName SkuName String
  109. DefaultValueName DefaultValueName String
  110. TokenSpaceGuidName TokenSpaceGuidName String
  111. TokenName TokenName String
  112. Returns:
  113. Index of PCD in Pcd database
  114. --*/
  115. {
  116. UINT32 Index;
  117. if (SkuName == NULL) {
  118. SkuName = "DEFAULT";
  119. }
  120. if (DefaultValueName == NULL) {
  121. DefaultValueName = "DEFAULT";
  122. }
  123. for (Index = 0; Index < PcdListLength; Index++) {
  124. if (strcmp(PcdList[Index].TokenSpaceGuidName, TokenSpaceGuidName) != 0) {
  125. continue;
  126. }
  127. if (strcmp(PcdList[Index].TokenName, TokenName) != 0) {
  128. continue;
  129. }
  130. if (strcmp(PcdList[Index].SkuName, SkuName) != 0) {
  131. continue;
  132. }
  133. if (strcmp(PcdList[Index].DefaultValueName, DefaultValueName) != 0) {
  134. continue;
  135. }
  136. return Index;
  137. }
  138. return -1;
  139. }
  140. UINT64
  141. __PcdGet (
  142. CHAR8 *SkuName OPTIONAL,
  143. CHAR8 *DefaultValueName OPTIONAL,
  144. CHAR8 *TokenSpaceGuidName,
  145. CHAR8 *TokenName
  146. )
  147. /*++
  148. Routine Description:
  149. Get PCD value
  150. Arguments:
  151. SkuName SkuName String
  152. DefaultValueName DefaultValueName String
  153. TokenSpaceGuidName TokenSpaceGuidName String
  154. TokenName TokenName String
  155. Returns:
  156. PCD value
  157. --*/
  158. {
  159. int Index;
  160. CHAR8 *End;
  161. Index = LookupPcdIndex (SkuName, DefaultValueName, TokenSpaceGuidName, TokenName);
  162. if (Index < 0) {
  163. fprintf (stderr, "PCD %s.%s.%s.%s is not in database\n", SkuName, DefaultValueName, TokenSpaceGuidName, TokenName);
  164. exit (EXIT_FAILURE);
  165. }
  166. switch (PcdList[Index].PcdDataType) {
  167. case PcdDataTypeBoolean:
  168. case PcdDataTypeUint8:
  169. case PcdDataTypeUint16:
  170. case PcdDataTypeUint32:
  171. return (UINT64)strtoul(PcdList[Index].Value, &End, 16);
  172. break;
  173. case PcdDataTypeUint64:
  174. return (UINT64)strtoul(PcdList[Index].Value, &End, 16);
  175. break;
  176. case PcdDataTypePointer:
  177. fprintf (stderr, "PCD %s.%s.%s.%s is structure. Use PcdGetPtr()\n", SkuName, DefaultValueName, TokenSpaceGuidName, TokenName);
  178. exit (EXIT_FAILURE);
  179. break;
  180. }
  181. return 0;
  182. }
  183. VOID
  184. __PcdSet (
  185. CHAR8 *SkuName OPTIONAL,
  186. CHAR8 *DefaultValueName OPTIONAL,
  187. CHAR8 *TokenSpaceGuidName,
  188. CHAR8 *TokenName,
  189. UINT64 Value
  190. )
  191. /*++
  192. Routine Description:
  193. Set PCD value
  194. Arguments:
  195. SkuName SkuName String
  196. DefaultValueName DefaultValueName String
  197. TokenSpaceGuidName TokenSpaceGuidName String
  198. TokenName TokenName String
  199. Value PCD value to be set
  200. Returns:
  201. None
  202. --*/
  203. {
  204. int Index;
  205. Index = LookupPcdIndex (SkuName, DefaultValueName, TokenSpaceGuidName, TokenName);
  206. if (Index < 0) {
  207. fprintf (stderr, "PCD %s.%s.%s.%s is not in database\n", SkuName, DefaultValueName, TokenSpaceGuidName, TokenName);
  208. exit (EXIT_FAILURE);
  209. }
  210. free(PcdList[Index].Value);
  211. PcdList[Index].Value = malloc(20);
  212. switch (PcdList[Index].PcdDataType) {
  213. case PcdDataTypeBoolean:
  214. if (Value == 0) {
  215. strcpy (PcdList[Index].Value, "0x00");
  216. } else {
  217. strcpy (PcdList[Index].Value, "0x01");
  218. }
  219. break;
  220. case PcdDataTypeUint8:
  221. sprintf(PcdList[Index].Value, "0x%02x", (UINT8)(Value & 0xff));
  222. break;
  223. case PcdDataTypeUint16:
  224. sprintf(PcdList[Index].Value, "0x%04x", (UINT16)(Value & 0xffff));
  225. break;
  226. case PcdDataTypeUint32:
  227. sprintf(PcdList[Index].Value, "0x%08x", (UINT32)(Value & 0xffffffff));
  228. break;
  229. case PcdDataTypeUint64:
  230. sprintf(PcdList[Index].Value, "0x%016llx", (unsigned long long)Value);
  231. break;
  232. case PcdDataTypePointer:
  233. fprintf (stderr, "PCD %s.%s.%s.%s is structure. Use PcdSetPtr()\n", SkuName, DefaultValueName, TokenSpaceGuidName, TokenName);
  234. exit (EXIT_FAILURE);
  235. break;
  236. }
  237. }
  238. VOID *
  239. __PcdGetPtr (
  240. CHAR8 *SkuName OPTIONAL,
  241. CHAR8 *DefaultValueName OPTIONAL,
  242. CHAR8 *TokenSpaceGuidName,
  243. CHAR8 *TokenName,
  244. UINT32 *Size
  245. )
  246. /*++
  247. Routine Description:
  248. Get PCD value buffer
  249. Arguments:
  250. SkuName SkuName String
  251. DefaultValueName DefaultValueName String
  252. TokenSpaceGuidName TokenSpaceGuidName String
  253. TokenName TokenName String
  254. Size Size of PCD value buffer
  255. Returns:
  256. PCD value buffer
  257. --*/
  258. {
  259. int Index;
  260. CHAR8 *Value;
  261. UINT8 *Buffer;
  262. CHAR8 *End;
  263. Index = LookupPcdIndex (SkuName, DefaultValueName, TokenSpaceGuidName, TokenName);
  264. if (Index < 0) {
  265. fprintf (stderr, "PCD %s.%s.%s.%s is not in database\n", SkuName, DefaultValueName, TokenSpaceGuidName, TokenName);
  266. exit (EXIT_FAILURE);
  267. }
  268. switch (PcdList[Index].PcdDataType) {
  269. case PcdDataTypeBoolean:
  270. case PcdDataTypeUint8:
  271. case PcdDataTypeUint16:
  272. case PcdDataTypeUint32:
  273. case PcdDataTypeUint64:
  274. fprintf (stderr, "PCD %s.%s.%s.%s is a value. Use PcdGet()\n", SkuName, DefaultValueName, TokenSpaceGuidName, TokenName);
  275. exit (EXIT_FAILURE);
  276. break;
  277. case PcdDataTypePointer:
  278. Value = &PcdList[Index].Value[1];
  279. for (*Size = 0, strtoul(Value, &End, 16); Value != End; strtoul(Value, &End, 16), *Size = *Size + 1) {
  280. Value = End + 1;
  281. }
  282. Buffer = malloc(*Size + 1);
  283. if (Buffer == NULL) {
  284. *Size = 0;
  285. return NULL;
  286. }
  287. Value = &PcdList[Index].Value[1];
  288. for (*Size = 0, Buffer[*Size] = (UINT8) strtoul(Value, &End, 16); Value != End; *Size = *Size + 1, Buffer[*Size] = (UINT8) strtoul(Value, &End, 16)) {
  289. Value = End + 1;
  290. }
  291. return Buffer;
  292. }
  293. *Size = 0;
  294. return 0;
  295. }
  296. VOID
  297. __PcdSetPtr (
  298. CHAR8 *SkuName OPTIONAL,
  299. CHAR8 *DefaultValueName OPTIONAL,
  300. CHAR8 *TokenSpaceGuidName,
  301. CHAR8 *TokenName,
  302. UINT32 Size,
  303. UINT8 *Value
  304. )
  305. /*++
  306. Routine Description:
  307. Set PCD value buffer
  308. Arguments:
  309. SkuName SkuName String
  310. DefaultValueName DefaultValueName String
  311. TokenSpaceGuidName TokenSpaceGuidName String
  312. TokenName TokenName String
  313. Size Size of PCD value
  314. Value Pointer to the updated PCD value buffer
  315. Returns:
  316. None
  317. --*/
  318. {
  319. int Index;
  320. UINT32 ValueIndex;
  321. Index = LookupPcdIndex (SkuName, DefaultValueName, TokenSpaceGuidName, TokenName);
  322. if (Index < 0) {
  323. fprintf (stderr, "PCD %s.%s.%s.%s is not in database\n", SkuName, DefaultValueName, TokenSpaceGuidName, TokenName);
  324. exit (EXIT_FAILURE);
  325. }
  326. switch (PcdList[Index].PcdDataType) {
  327. case PcdDataTypeBoolean:
  328. case PcdDataTypeUint8:
  329. case PcdDataTypeUint16:
  330. case PcdDataTypeUint32:
  331. case PcdDataTypeUint64:
  332. fprintf (stderr, "PCD %s.%s.%s.%s is a value. Use PcdGet()\n", SkuName, DefaultValueName, TokenSpaceGuidName, TokenName);
  333. exit (EXIT_FAILURE);
  334. break;
  335. case PcdDataTypePointer:
  336. free(PcdList[Index].Value);
  337. PcdList[Index].Value = malloc(Size * 5 + 3);
  338. PcdList[Index].Value[0] = '{';
  339. for (ValueIndex = 0; ValueIndex < Size; ValueIndex++) {
  340. sprintf(&PcdList[Index].Value[1 + ValueIndex * 5], "0x%02x,", Value[ValueIndex]);
  341. }
  342. PcdList[Index].Value[1 + Size * 5 - 1] = '}';
  343. PcdList[Index].Value[1 + Size * 5 ] = 0;
  344. break;
  345. }
  346. }
  347. VOID
  348. STATIC
  349. ReadInputFile (
  350. CHAR8 *InputFileName,
  351. UINT8 **FileBuffer,
  352. UINT32 *FileSize
  353. )
  354. /*++
  355. Routine Description:
  356. Read the file buffer from the input file.
  357. Arguments:
  358. InputFileName Point to the input file name.
  359. FileBuffer Point to the input file buffer.
  360. FileSize Size of the file buffer.
  361. Returns:
  362. None
  363. --*/
  364. {
  365. FILE *InputFile;
  366. UINT32 BytesRead;
  367. //
  368. // Open Input file and read file data.
  369. //
  370. InputFile = fopen (InputFileName, "rb");
  371. if (InputFile == NULL) {
  372. fprintf (stderr, "Error opening file %s\n", InputFileName);
  373. exit (EXIT_FAILURE);
  374. }
  375. //
  376. // Go to the end so that we can determine the file size
  377. //
  378. if (fseek (InputFile, 0, SEEK_END)) {
  379. fprintf (stderr, "Error reading input file %s\n", InputFileName);
  380. fclose (InputFile);
  381. exit (EXIT_FAILURE);
  382. }
  383. //
  384. // Get the file size
  385. //
  386. *FileSize = ftell (InputFile);
  387. if (*FileSize == -1) {
  388. fprintf (stderr, "Error parsing the input file %s\n", InputFileName);
  389. fclose (InputFile);
  390. exit (EXIT_FAILURE);
  391. }
  392. //
  393. // Allocate a buffer
  394. //
  395. *FileBuffer = malloc (*FileSize);
  396. if (*FileBuffer == NULL) {
  397. fprintf (stderr, "Can not allocate buffer for input input file %s\n", InputFileName);
  398. fclose (InputFile);
  399. exit (EXIT_FAILURE);
  400. }
  401. //
  402. // Reset to the beginning of the file
  403. //
  404. if (fseek (InputFile, 0, SEEK_SET)) {
  405. fprintf (stderr, "Error reading the input file %s\n", InputFileName);
  406. fclose (InputFile);
  407. free (*FileBuffer);
  408. exit (EXIT_FAILURE);
  409. }
  410. //
  411. // Read all of the file contents.
  412. //
  413. BytesRead = fread (*FileBuffer, sizeof (UINT8), *FileSize, InputFile);
  414. if (BytesRead != *FileSize * sizeof (UINT8)) {
  415. fprintf (stderr, "Error reading the input file %s\n", InputFileName);
  416. fclose (InputFile);
  417. free (*FileBuffer);
  418. exit (EXIT_FAILURE);
  419. }
  420. //
  421. // Close the file
  422. //
  423. fclose (InputFile);
  424. }
  425. VOID
  426. STATIC
  427. ParseFile (
  428. UINT8 *FileBuffer,
  429. UINT32 FileSize
  430. )
  431. /*++
  432. Routine Description:
  433. Read the initial PCD value from the input file buffer.
  434. Arguments:
  435. FileBuffer Point to the input file buffer.
  436. FileSize Size of the file buffer.
  437. Returns:
  438. None
  439. --*/
  440. {
  441. UINT32 Index;
  442. UINT32 NumLines;
  443. UINT32 TokenIndex;
  444. UINT32 TokenStart;
  445. for (Index = 0, NumLines = 0; Index < FileSize; Index++) {
  446. if (FileBuffer[Index] == '\n') {
  447. NumLines++;
  448. }
  449. }
  450. PcdList = malloc((NumLines + 1) * sizeof(PcdList[0]));
  451. for (Index = 0, TokenIndex = 0, PcdListLength = 0, TokenStart = 0; Index < FileSize; Index++) {
  452. if (FileBuffer[Index] == ' ') {
  453. continue;
  454. }
  455. if (FileBuffer[Index] == '|' || FileBuffer[Index] == '.' || FileBuffer[Index] == '\n' || FileBuffer[Index] == '\r') {
  456. RecordToken (FileBuffer, PcdListLength, TokenIndex, TokenStart, Index);
  457. if (FileBuffer[Index] == '\n' || FileBuffer[Index] == '\r') {
  458. if (TokenIndex != 0) {
  459. PcdListLength++;
  460. TokenIndex = 0;
  461. }
  462. } else {
  463. TokenIndex++;
  464. }
  465. TokenStart = Index + 1;
  466. continue;
  467. }
  468. }
  469. if (Index > TokenStart) {
  470. RecordToken (FileBuffer, PcdListLength, TokenIndex, TokenStart, Index);
  471. if (TokenIndex != 0) {
  472. PcdListLength++;
  473. }
  474. }
  475. }
  476. VOID
  477. STATIC
  478. WriteOutputFile (
  479. CHAR8 *OutputFileName
  480. )
  481. /*++
  482. Routine Description:
  483. Write the updated PCD value into the output file name.
  484. Arguments:
  485. OutputFileName Point to the output file name.
  486. Returns:
  487. None
  488. --*/
  489. {
  490. FILE *OutputFile;
  491. UINT32 Index;
  492. //
  493. // Open output file
  494. //
  495. OutputFile = fopen (OutputFileName, "wb");
  496. if (OutputFile == NULL) {
  497. fprintf (stderr, "Error opening file %s\n", OutputFileName);
  498. exit (EXIT_FAILURE);
  499. }
  500. for (Index = 0; Index < PcdListLength; Index++) {
  501. fprintf (
  502. OutputFile,
  503. "%s.%s.%s.%s|%s|%s\n",
  504. PcdList[Index].SkuName,
  505. PcdList[Index].DefaultValueName,
  506. PcdList[Index].TokenSpaceGuidName,
  507. PcdList[Index].TokenName,
  508. PcdList[Index].DataType,
  509. PcdList[Index].Value
  510. );
  511. }
  512. //
  513. // Done, write output file.
  514. //
  515. if (OutputFile != NULL) {
  516. fclose (OutputFile);
  517. }
  518. }
  519. VOID
  520. STATIC
  521. Usage (
  522. VOID
  523. )
  524. /*++
  525. Routine Description:
  526. Displays the utility usage syntax to STDOUT
  527. Arguments:
  528. None
  529. Returns:
  530. None
  531. --*/
  532. {
  533. fprintf (stdout, "Usage: -i <input_file> -o <output_file>\n\n");
  534. fprintf (stdout, "optional arguments:\n");
  535. fprintf (stdout, " -h, --help Show this help message and exit\n");
  536. fprintf (stdout, " -i INPUT_FILENAME, --input INPUT_FILENAME\n\
  537. PCD Database Input file name\n");
  538. fprintf (stdout, " -o OUTPUT_FILENAME, --output OUTPUT_FILENAME\n\
  539. PCD Database Output file name\n");
  540. }
  541. VOID
  542. STATIC
  543. ParseArguments (
  544. int argc,
  545. char *argv[],
  546. CHAR8 **InputFileName,
  547. CHAR8 **OutputFileName
  548. )
  549. /*++
  550. Routine Description:
  551. Parse the input parameters to get the input/output file name.
  552. Arguments:
  553. argc Number of command line parameters.
  554. argv Array of pointers to parameter strings.
  555. InputFileName Point to the input file name.
  556. OutputFileName Point to the output file name.
  557. Returns:
  558. None
  559. --*/
  560. {
  561. if (argc == 1) {
  562. fprintf (stderr, "Missing options\n");
  563. exit (EXIT_FAILURE);
  564. }
  565. //
  566. // Parse command line
  567. //
  568. argc--;
  569. argv++;
  570. if ((stricmp (argv[0], "-h") == 0) || (stricmp (argv[0], "--help") == 0)) {
  571. Usage ();
  572. exit (EXIT_SUCCESS);
  573. }
  574. while (argc > 0) {
  575. if ((stricmp (argv[0], "-i") == 0) || (stricmp (argv[0], "--input") == 0)) {
  576. if (argv[1] == NULL || argv[1][0] == '-') {
  577. fprintf (stderr, "Invalid option value. Input File name is missing for -i option\n");
  578. exit (EXIT_FAILURE);
  579. }
  580. *InputFileName = argv[1];
  581. argc -= 2;
  582. argv += 2;
  583. continue;
  584. }
  585. if ((stricmp (argv[0], "-o") == 0) || (stricmp (argv[0], "--output") == 0)) {
  586. if (argv[1] == NULL || argv[1][0] == '-') {
  587. fprintf (stderr, "Invalid option value. Output File name is missing for -i option\n");
  588. exit (EXIT_FAILURE);
  589. }
  590. *OutputFileName = argv[1];
  591. argc -= 2;
  592. argv += 2;
  593. continue;
  594. }
  595. if (argv[0][0] == '-') {
  596. fprintf (stderr, "Unknown option %s\n", argv[0]);
  597. exit (EXIT_FAILURE);
  598. }
  599. argc --;
  600. argv ++;
  601. }
  602. //
  603. // Check Input parameters
  604. //
  605. if (*InputFileName == NULL) {
  606. fprintf (stderr, "Missing option. Input files is not specified\n");
  607. exit (EXIT_FAILURE);
  608. }
  609. if (*OutputFileName == NULL) {
  610. fprintf (stderr, "Missing option. Output file is not specified\n");
  611. exit (EXIT_FAILURE);
  612. }
  613. }
  614. int
  615. PcdValueMain (
  616. int argc,
  617. char *argv[]
  618. )
  619. /*++
  620. Routine Description:
  621. Main function updates PCD values.
  622. Arguments:
  623. argc Number of command line parameters.
  624. argv Array of pointers to parameter strings.
  625. Returns:
  626. EXIT_SUCCESS
  627. --*/
  628. {
  629. CHAR8 *InputFileName;
  630. CHAR8 *OutputFileName;
  631. UINT8 *FileBuffer;
  632. UINT32 FileSize;
  633. InputFileName = NULL;
  634. OutputFileName = NULL;
  635. //
  636. // Parse the input arguments
  637. //
  638. ParseArguments (argc, argv, &InputFileName, &OutputFileName);
  639. //
  640. // Open Input file and read file data.
  641. //
  642. ReadInputFile (InputFileName, &FileBuffer, &FileSize);
  643. //
  644. // Read the initial Pcd value
  645. //
  646. ParseFile (FileBuffer, FileSize);
  647. //
  648. // Customize PCD values in the PCD Database
  649. //
  650. PcdEntryPoint ();
  651. //
  652. // Save the updated PCD value
  653. //
  654. WriteOutputFile (OutputFileName);
  655. exit (EXIT_SUCCESS);
  656. }