RDFU  1.0
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros
Conf.c File Reference

Reading configuration file (adding bad addrs to list) More...

Include dependency graph for Conf.c:

Go to the source code of this file.

Macros

#define MAX_CONF_DATA   512*10
 

Functions

VOID ParseConfiguration (CHAR8 *ConfData, UINTN ConfDataSize)
 
EFI_STATUS ReadConfiguration (CHAR16 *ConfPath)
 

Detailed Description

Reading configuration file (adding bad addrs to list)

Author
Piotr Bania
Date
Feb 2013 Reading configuration file (adding bad addrs to list)

Definition in file Conf.c.

Macro Definition Documentation

#define MAX_CONF_DATA   512*10

Referenced by ReadConfiguration().

Function Documentation

VOID ParseConfiguration ( CHAR8 *  ConfData,
UINTN  ConfDataSize 
)

Function parses the data from the configuration file.

Parameters
ConfDataPointer to configuration data
ConfDataSizeNumber of bytes in the configuration data

Definition at line 23 of file Conf.c.

References _policy::BadAddrs, _bad_addr_entry::EndAddr, gEfiScannerPolicy, LogFullAscii(), MAX_BAD_ADDRS, MemCopy(), _policy::NumOfBadAddrs, and _bad_addr_entry::StartAddr.

Referenced by ReadConfiguration().

24 {
25  UINTN i;
26  ULONG32 Cmd;
27  CHAR8 *p;
28 
29  CHAR8 AddrAscii[17], AddrAscii2[17];
30  UINT64 Addr, Addr2;
31 
32  AddrAscii[16] = 0;
33  AddrAscii2[16] = 0;
34 
35  i = 0;
36  while (1)
37  {
38  p = (CHAR8*)(ConfData + i);
39  Cmd = *(ULONG32*)p;
40 
41  switch (Cmd)
42  {
43  // unknown command
44  default:
45  break;
46 
47  // dump command
48  //case 'pmud':
49  // break;
50 
51  // badd <addr_start> <addr_end>
52  case 'ddab':
53  p += sizeof(ULONG32);
54 
55  MemCopy(AddrAscii, (p + 1), 16);
56  MemCopy(AddrAscii2, (p + 1 + 16 + 1), 16);
57  Addr = AsciiStrHexToUint64(AddrAscii);
58  Addr2 = AsciiStrHexToUint64(AddrAscii2);
59 
60 #if DEBUG_ON == 1
61  LogFullAscii("%a: badd command at i = %08x bad_index=%d addr1=%a(%lx) addr2=%a(%lx)\r\n",
62  __FUNCTION__, i, gEfiScannerPolicy.NumOfBadAddrs, AddrAscii, Addr, AddrAscii2, Addr2);
63 #endif
64 
66  {
70  }
71  break;
72  }
73 
74  // scan until new line is found or end of file
75  while (ConfData[i] != '\n')
76  {
77  if (i >= ConfDataSize)
78  return;
79  i++;
80  }
81 
82  i++;
83  }
84 }

Here is the call graph for this function:

Here is the caller graph for this function:

EFI_STATUS ReadConfiguration ( CHAR16 *  ConfPath)

Function reads the configuration file. Currently the configuration file is only used for the bad addr filtering (not needed by vmware).

Parameters
ConfPathPath to the configuration path (unicode)
Return values
EFI_SUCCESSOn success
EFI_ERROR*On error

Definition at line 102 of file Conf.c.

References EFI_STATUS(), LogFileAscii(), LogFullAscii(), MAX_CONF_DATA, MemAllocate(), MemFree(), OpenFile(), and ParseConfiguration().

Referenced by EfiScannerEntryPoint().

103 {
104  EFI_STATUS Status;
105  EFI_FILE_PROTOCOL *File;
106  UINTN ConfSize;
107 
108  CHAR8 *ConfData;
109 #define MAX_CONF_DATA 512*10
110 
111 
112  // read the configuration file
113  Status = OpenFile(ConfPath, EFI_FILE_MODE_READ, &File);
114 
115  if (EFI_ERROR(Status))
116  {
117 
118 #if DEBUG_ON == 1
119  LogFullAscii("%a: unable to open configuration file, status = %08x\r\n",
120  __FUNCTION__, Status);
121 #endif
122 
123  return Status;
124  }
125 
126  ConfData = (CHAR8*)MemAllocate(MAX_CONF_DATA + 32);
127  if (!ConfData)
128  {
129  LogFileAscii("%a: MemAllocate returned error!\r\n", __FUNCTION__);
130  File->Close(File);
131  return EFI_NOT_FOUND;
132  }
133 
134  ConfSize = MAX_CONF_DATA;
135  Status = File->Read(File, &ConfSize, ConfData);
136  File->Close(File);
137 
138  ParseConfiguration(ConfData, ConfSize);
139 
140  MemFree(ConfData);
141  return EFI_SUCCESS;
142 }

Here is the call graph for this function:

Here is the caller graph for this function: