github.com/hugelgupf/u-root@v0.0.0-20191023214958-4807c632154c/pkg/smbios/README.md (about) 1 # SMBIOS Information Library 2 3 TODO: godoc link 4 5 ## Adding a new type 6 7 Types are defined in [DMTF DSP0134](https://www.dmtf.org/dsp/DSP0134). As of July 2019, the most recent published version is 3.2.0. 8 9 Adding a type largely consists of copy-pasting a bunch of information from the doicument to define a Go struct and its string representation. 10 To make that easier, a set of tools is provided ina Gist [here](https://gist.github.com/rojer/4fa173442fb00e24dc7b9d120c2e30af). 11 These are Python scripts that take chunks of data copy-pasted from this document and produce a struct, anum or bit field declaration. 12 These are by no means perfect and do not handle all the cases of weird formatting in the document, 13 and may be broken completely by future formatting changes (but hopefully can be fixed if needed). 14 15 So, adding a type should looks omething like this: 16 * Create `typeXXX_new_information.go` with boilerplate from some other type (copyright, imports). 17 * Generate the struct: `tools/gen_struct.py NewInformation >> typeXXX_new_information.go`. 18 * Generate enums and bitfields if needed. 19 * Examine the generated code and tweak it manually if necessart. 20 * Run `gofmt` on it: `gofmt typeXXX_new_information.go`. 21 * Add new Type and a corresponding constant to [table_type.go](table_type.go). 22 * Implement the constructor function, `NewNewInformation` in this case. 23 * Most of the parsing can be done by reflection-based parser, see `parseStruct`. 24 * Add data validation and any additional custom parsing code necessary. 25 * Implement the `String()` method for `*NewInformation`. 26 * Add getter to the `Info` type, `GetNewInformation`.