2008-03-05 09:52:00 -05:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Microsoft Research Singularity
|
|
|
|
//
|
|
|
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
|
|
//
|
|
|
|
// File: Rsdt.cs
|
|
|
|
//
|
|
|
|
// Note:
|
|
|
|
// Page 93 of ACPI 3.0 Spec.
|
|
|
|
|
|
|
|
namespace Microsoft.Singularity.Hal.Acpi
|
|
|
|
{
|
|
|
|
using System;
|
|
|
|
using Microsoft.Singularity.Io;
|
|
|
|
public class Rsdt
|
|
|
|
{
|
2008-11-17 18:29:00 -05:00
|
|
|
protected IoMemory region;
|
2008-03-05 09:52:00 -05:00
|
|
|
private SystemTableHeader header;
|
|
|
|
|
2008-11-17 18:29:00 -05:00
|
|
|
protected Rsdt(IoMemory region, SystemTableHeader header)
|
2008-03-05 09:52:00 -05:00
|
|
|
{
|
|
|
|
this.region = region;
|
|
|
|
this.header = header;
|
|
|
|
}
|
|
|
|
|
2008-11-17 18:29:00 -05:00
|
|
|
public virtual int EntryCount { get { return region.Length / 4; } }
|
2008-03-05 09:52:00 -05:00
|
|
|
|
2008-11-17 18:29:00 -05:00
|
|
|
public virtual ulong GetEntry(int index)
|
2008-03-05 09:52:00 -05:00
|
|
|
{
|
|
|
|
index *= 4;
|
|
|
|
if (index > region.Length)
|
|
|
|
return 0;
|
|
|
|
return region.Read32(index);
|
|
|
|
}
|
|
|
|
|
|
|
|
public SystemTableHeader GetTableHeader(int index)
|
|
|
|
{
|
2008-11-17 18:29:00 -05:00
|
|
|
ulong address = GetEntry(index);
|
2008-03-05 09:52:00 -05:00
|
|
|
if (address == 0)
|
|
|
|
return null;
|
|
|
|
return SystemTableHeader.Create(address);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static Rsdt Create(SystemTableHeader header)
|
|
|
|
{
|
2008-11-17 18:29:00 -05:00
|
|
|
DebugStub.Assert(header.Signature == "RSDT");
|
2008-03-05 09:52:00 -05:00
|
|
|
return new Rsdt(
|
|
|
|
IoMemory.MapPhysicalMemory(
|
|
|
|
header.PostHeaderAddress, header.PostHeaderLength,
|
|
|
|
true, false
|
|
|
|
),
|
|
|
|
header
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2008-11-17 18:29:00 -05:00
|
|
|
|
|
|
|
public class Xsdt : Rsdt
|
|
|
|
{
|
|
|
|
private Xsdt(IoMemory region, SystemTableHeader header)
|
|
|
|
: base(region, header)
|
|
|
|
{
|
|
|
|
// Nothing to do
|
|
|
|
}
|
|
|
|
|
|
|
|
public override int EntryCount { get { return region.Length / 8; } }
|
|
|
|
|
|
|
|
public override ulong GetEntry(int index)
|
|
|
|
{
|
|
|
|
index *= 8;
|
|
|
|
if (index > region.Length)
|
|
|
|
return 0;
|
|
|
|
return region.Read64(index);
|
|
|
|
}
|
|
|
|
|
|
|
|
public new static Xsdt Create(SystemTableHeader header)
|
|
|
|
{
|
|
|
|
DebugStub.Assert(header.Signature == "XSDT");
|
|
|
|
return new Xsdt(
|
|
|
|
IoMemory.MapPhysicalMemory(
|
|
|
|
header.PostHeaderAddress, header.PostHeaderLength,
|
|
|
|
true, false
|
|
|
|
),
|
|
|
|
header
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2008-03-05 09:52:00 -05:00
|
|
|
}
|