Page MenuHomeFreeBSD

bhnd: Unify NVRAM/SPROM parsing, implement compact SPROM layout encoding

Authored by landonf on Nov 26 2016, 12:41 AM.


  • Defined an abstract NVRAM I/O API (bhnd_nvram_io), decoupling NVRAM/SPROM parsing from the actual underlying NVRAM data provider (e.g. CFE firmware devices).
  • Defined an abstract NVRAM data API (bhnd_nvram_data), decoupling higher-level NVRAM operations (indexed lookup, data conversion, etc) from the underlying NVRAM file format parsing/serialization.
  • Implemented a new high-level bhnd_nvram_store API, providing indexed variable lookup, pending write tracking, etc on top of an arbitrary bhnd_nvram_data instance.
  • Migrated all NVRAM device drivers to the common bhnd_nvram_store API.
  • Implemented a common bhnd_nvram_val API for parsing/encoding NVRAM variable values, including applying format-specific behavior when converting to/from the NVRAM string representations.
  • Dropped the now unnecessary bhnd_nvram driver, and moved the broadcom/mips-specific CFE NVRAM driver out into sys/mips/broadcom.
  • Implemented a new nvram_map file format:
    • Variable definitions are now defined separately from the SPROM layout information, allowing us to independently define SPROM layouts that reference the common variable definitions. Later, this should also allow us to define CIS tuple NVRAM mappings with the same common NVRAM variable definitions.
    • Variables can now be defined within arbitrary named groups.
    • Textual descriptions and help information can be defined inline for both variables and variable groups.
  • Implemented a new, compact encoding of SPROM image layout offsets:
    • The encoding is loosely modeled on Apple dyld compressed LINKEDIT symbol binding opcodes; it provides a compact state-machine encoding of the mapping between NVRAM variables and the SPROM image offset, mask, and shift instructions necessary to decode or encode the SPROM variable data.
    • The compact encoding reduces the size of the generated SPROM variable layout data from roughly 60KB to 3KB. The sequential nature SPROM layout opcode tables also simplify iteration of the SPROM variables, as it's no longer neccessary to iterate the full NVRAM variable definition table, but instead simply scan the SPROM revision's layout opcode table.
  • Added source-level (but not build system) support for building the NVRAM file format APIs (bhnd_nvram_io, bhnd_nvram_data, bhnd_nvram_store) as a userspace library.
Test Plan

Tested for bhnd(4)/bwn(4) regressions against:

  • BCM4321
  • BCM43225
  • BCM4331
  • Netgear WGT634U
  • Asus RT-N16
  • Asus RT-N53

Diff Detail

Lint OK
No Unit Test Coverage
Build Status
Buildable 6065
Build 6329: arc lint + arc unit

Event Timeline

landonf updated this revision to Diff 22520.Nov 26 2016, 12:41 AM
landonf updated this revision to Diff 22521.
landonf retitled this revision from to bhnd: Unify NVRAM/SPROM parsing, implement compact SPROM layout encoding.
landonf updated this object.
landonf edited the test plan for this revision. (Show Details)
landonf added reviewers: adrian, mizhka.

Fixed comment spelling errors.

adrian accepted this revision.Nov 26 2016, 4:29 AM
adrian edited edge metadata.

.. wow. :)

This revision is now accepted and ready to land.Nov 26 2016, 4:29 AM
mizhka accepted this revision.Nov 26 2016, 5:02 PM
mizhka edited edge metadata.
landonf closed this revision.Dec 12 2016, 8:04 PM