Always generate absolute address for SMBIOS tables (follow the spec).

This is a big re-factoring, which is a following CL after 1243
In CL 1243, Hungte mentioned the case C & D are annoying and suggested to
remove. This CL is going to removed that. So that, when reading file, the vpd
will try 3 ways to get the 'eps_base' value:

  1. try to parse fmap structure and get the offset of VPD partition.
  2. try to search "_SM_" signature in file.
  3. try to load content from BIOS to learn the eps_base.

Alternatively, user can use -E to force the eps_base value.

For the backward-compatible, we keep the ability to read case B. Once a
write is happening on case B, the offset will be corrected to absolute.
Which means following the SMBIOS spec.

Also did some re-factoring to make code more readable and easy to maintain.

TEST=Tested all commands in CL 1243, and the following commands:
  rm -f /tmp/zero ; touch /tmp/zero
  vpd -f /tmp/zero -l  # loadFile() error
  vpd -f /tmp/zero -O  # got a 1537-byte file, the eps_base is 0x1f0000.
  rm -f /tmp/zero ; touch /tmp/zero
  vpd -f /tmp/zero -E 0x230000 -O  # a 1537-byte file, and eps_base is 0x230000.
  In addition, I write a testing script that runs combinations and corner cases.
  I have run that script on K and Z models and passed.

Reviewed-by: Yung-Chieh Lo <>
Tested-by: Yung-Chieh Lo <>

(cherry picked from commit edca624b92638efb06933a3ab0eb8b38201815ec)

Change-Id: I0704ec32b4d34e00ef038c2cec52603e3f8a36ba
Reviewed-by: Hung-Te Lin <>
Reviewed-by: Yung-Chieh Lo <>
Tested-by: Yung-Chieh Lo <>
6 files changed
tree: 87d60fd4f08f40d2390946a6643afef790063460
  1. include/
  2. lib/
  3. util/
  5. Makefile
  7. vpd.c