github.com/system-transparency/u-root@v6.0.1-0.20190919065413-ed07a650de4c+incompatible/pkg/acpi/ssdt.go (about)

     1  // Copyright 2019 the u-root Authors. All rights reserved
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package acpi
     6  
     7  import "bytes"
     8  
     9  // genssdt generates an ssdt header for an existing []byte.
    10  // We are unlikely to ever need this, and may remove it. It is from an
    11  // early iteration of this package.
    12  // It is only useful if the slice contains AML, not a table, so we don't actually
    13  // use it currently. It turns out that it's easisest just to do it programatically
    14  // with a function call, rather than create a magic struct and serializing it out, due to
    15  // the need to create a checksum once it's all assembled.
    16  // From the Big Bad Book of ACPI:
    17  // SSDT
    18  // Signature 4 0 ‘SSDT’ Signature for the Secondary System Description Table.
    19  // Length 4 4 Length, in bytes, of the entire SSDT (including the header).
    20  // Revision 1 8 2
    21  // Checksum 1 9 Entire table must sum to zero.
    22  // OEMID 6 10 OEM ID
    23  // OEM Table ID 8 16 The manufacture model ID.
    24  // OEM Revision 4 24 OEM revision of DSDT for supplied OEM Table ID.
    25  // Creator ID 4 28 Vendor ID for the ASL Compiler.
    26  // Creator Revision 4 32 Revision number of the ASL Compiler.
    27  func genssdt(b []byte) []byte {
    28  	var (
    29  		ssdt = &bytes.Buffer{}
    30  		csum uint8
    31  	)
    32  
    33  	l := uint32(HeaderLength + len(b))
    34  	w(ssdt, 1, []byte("SSDT"), l, uint8(0), csum, []byte("ACPIXX"), []byte("GOXR00LZ"), uint32(0), []byte("VEND"), uint32(0xdecafbad), b)
    35  	csum = gencsum(ssdt.Bytes())
    36  	Debug("CSUM is %#x", csum)
    37  	s := ssdt.Bytes()
    38  	s[CSUMOffset] = csum
    39  	return s
    40  }