checksum.bend checks
raw source on the hub · import bend-osdev-acpi@0.1.1.0/checksum.bend as Checksum
bend-osdev-acpi, checksum.bend: the ACPI checksum (ACPI 6.5, section 5.2.6, and 5.2.5.3 for the RSDP). A table is valid when all its bytes, its checksum byte included, sum to zero modulo 256.
2 imports
import Base import bend-osdev-bytes@0.1.1.0/bytes.bend as B
Definitions
def ck.sum.go source · line 8 · raw
@xs:List<&2, U32> -> @acc:U32 -> U32
the sum of the bytes, modulo 2^32 (tail-recursive)
def AcpiChecksum.sum source · line 16 · raw
@o:0xe0217e1ab38629fddf738452c1f2a82e/bytes.Octets -> U32
the sum of the bytes, modulo 256
def AcpiChecksum.ok source · line 20 · raw
@o:0xe0217e1ab38629fddf738452c1f2a82e/bytes.Octets -> Bool
the bytes sum to zero modulo 256
def AcpiChecksum.byte_for source · line 25 · raw
@+i:Nat -> @+o:0xe0217e1ab38629fddf738452c1f2a82e/bytes.Octets -> U32
the byte that, put at offset i of o (whose byte there is ignored), makes o sum to zero modulo 256
def ck.fix.pick source · line 29 · raw
@fits:Bool -> @+i:Nat -> @+o:0xe0217e1ab38629fddf738452c1f2a82e/bytes.Octets -> 0xe0217e1ab38629fddf738452c1f2a82e/bytes.Octets
def AcpiChecksum.fix source · line 38 · raw
@+i:Nat -> @+o:0xe0217e1ab38629fddf738452c1f2a82e/bytes.Octets -> 0xe0217e1ab38629fddf738452c1f2a82e/bytes.Octets
o with its byte at offset i replaced by the checksum byte (o unchanged if it has no byte i)