singrdk/base/Kernel/Singularity.Hal.Acpi/AcpiChecksum.cs

36 lines
874 B
C#
Raw Permalink Normal View History

2008-03-05 09:52:00 -05:00
///////////////////////////////////////////////////////////////////////////////
//
// Microsoft Research Singularity
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// File: AcpiChecksum.cs
//
// Note:
// Based on ACPI 3.0 Spec.
namespace Microsoft.Singularity.Hal.Acpi
{
using System;
using Microsoft.Singularity.Io;
internal class AcpiChecksum
{
public static byte Compute(IoMemory region)
{
return Compute(region, 0, (uint) region.Length);
}
public static byte Compute(IoMemory region, uint offset, uint length)
{
byte sum = 0;
uint stop = offset + length;
2008-11-17 18:29:00 -05:00
for (uint i = offset; i < stop; i++) {
2008-03-05 09:52:00 -05:00
sum += region.Read8((int) i);
}
return sum;
}
}
}