gitee.com/mirrors_u-root/u-root@v7.0.0+incompatible/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 8 July 2019, the most recent published version is 3.2.0. 9 10 Adding a type largely consists of copy-pasting a bunch of information from the 11 doicument to define a Go struct and its string representation. To make that 12 easier, a set of tools is provided ina Gist 13 [here](https://gist.github.com/rojer/4fa173442fb00e24dc7b9d120c2e30af). These 14 are Python scripts that take chunks of data copy-pasted from this document and 15 produce a struct, anum or bit field declaration. These are by no means perfect 16 and do not handle all the cases of weird formatting in the document, and may be 17 broken completely by future formatting changes (but hopefully can be fixed if 18 needed). 19 20 So, adding a type should look something like this: 21 22 * Create `typeXXX_new_information.go` with boilerplate from some other type 23 (copyright, imports). 24 25 * Generate the struct: `tools/gen_struct.py NewInformation >> 26 typeXXX_new_information.go`. 27 28 * Generate enums and bitfields if needed. 29 30 * Examine the generated code and tweak it manually if necessart. 31 32 * Run `gofmt` on it: `gofmt typeXXX_new_information.go`. 33 34 * Add new Type and a corresponding constant to [table_type.go](table_type.go). 35 36 * Implement the constructor function, `NewNewInformation` in this case. 37 38 * Most of the parsing can be done by reflection-based parser, see 39 `parseStruct`. 40 41 * Add data validation and any additional custom parsing code necessary. 42 43 * Implement the `String()` method for `*NewInformation`. 44 45 * Add getter to the `Info` type, `GetNewInformation`.