util: Add support to spd_tools for fixed id

For boards that have already assigned memory ids, there needs to be a
way to fix parts to a specific id. After assigning all the fixed ids the
tool still attempts to minimize the SPDs entries. Since a fixed ID could
be anywhere, gaps can be created in the list. So an empty SPD entry is
created to fill the gaps in the list until they are used.

BUG=b:162939176
TEST=Generate various outputs

Signed-off-by: Rob Barnes <robbarnes@google.com>
Change-Id: I1f8ea1ff4f33a97ab28ba94896a1054e89189576
Reviewed-on: https://review.coreboot.org/c/coreboot/+/44463
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Furquan Shaikh <furquan@google.com>
Reviewed-by: Nick Vaccaro <nvaccaro@google.com>
This commit is contained in:
Rob Barnes
2020-08-14 09:40:04 -06:00
committed by Aaron Durbin
parent e905753afd
commit a662648a7f
3 changed files with 155 additions and 31 deletions

View File

@ -968,7 +968,10 @@ func createSPD(memAttribs *memAttributes) string {
var s string
for i := 0; i < 512; i++ {
b := getSPDByte(i, memAttribs)
var b byte = 0
if memAttribs != nil {
b = getSPDByte(i, memAttribs)
}
if (i + 1) % 16 == 0 {
s += fmt.Sprintf("%02X\n", b)
@ -997,6 +1000,13 @@ func generateSPD(memPart *memPart, SPDId int, SPDDirName string) {
ioutil.WriteFile(filepath.Join(SPDDirName, memPart.SPDFileName), []byte(s), 0644)
}
func generateEmptySPD(SPDDirName string) {
s := createSPD(nil)
SPDFileName := "ddr4-spd-empty.hex"
ioutil.WriteFile(filepath.Join(SPDDirName, SPDFileName), []byte(s), 0644)
}
func readMemoryParts(memParts *memParts, memPartsFileName string) error {
databytes, err := ioutil.ReadFile(memPartsFileName)
if err != nil {
@ -1396,6 +1406,8 @@ func main() {
}
}
generateEmptySPD(SPDDir)
if err := writeSPDManifest(&memParts, SPDDir); err != nil {
log.Fatal(err)
}