singrdk/base/Kernel/Singularity/Io/Resources.cs

87 lines
2.6 KiB
C#
Raw Normal View History

2008-03-05 09:52:00 -05:00
///////////////////////////////////////////////////////////////////////////////
//
// Microsoft Research Singularity
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// File: Resources.cs
//
using System;
2008-11-17 18:29:00 -05:00
using System.Collections;
using System.Runtime.CompilerServices;
2008-03-05 09:52:00 -05:00
using System.Threading;
using Microsoft.Singularity.Loader;
2008-11-17 18:29:00 -05:00
using Microsoft.Singularity.Memory;
using Microsoft.Singularity.Hal;
2008-03-05 09:52:00 -05:00
namespace Microsoft.Singularity.Io
{
[CLSCompliant(false)]
2008-11-17 18:29:00 -05:00
[AccessedByRuntime("referenced in halkd.cpp")]
2008-03-05 09:52:00 -05:00
public class Resources
{
static public int GetWarmBootCount()
{
2008-11-17 18:29:00 -05:00
return Platform.ThePlatform.BootCount;
2008-03-05 09:52:00 -05:00
}
public struct PnpBiosInfo
{
public IoMemory pnpRegion;
public IoPort isaReadPort;
public uint isaCsns;
}
static public PnpBiosInfo GetPnpBiosInfo()
{
2008-11-17 18:29:00 -05:00
Platform bi = Platform.ThePlatform;
2008-03-05 09:52:00 -05:00
PnpBiosInfo pbi = new PnpBiosInfo();
if (bi.PnpNodesAddr32 != UIntPtr.Zero) {
Tracing.Log(Tracing.Debug, "PnpBiosRegion {0:x8}..{1:x8}",
bi.PnpNodesAddr32, bi.PnpNodesAddr32 + bi.PnpNodesSize32);
pbi.pnpRegion = IoMemory.MapPhysicalMemory(
bi.PnpNodesAddr32, bi.PnpNodesSize32, true, false);
}
pbi.isaReadPort = new IoPort((ushort)bi.IsaReadPort, 1, Access.Read);;
pbi.isaCsns = bi.IsaCsns;
return pbi;
}
static public uint GetPciNumberOfBuses()
{
2008-11-17 18:29:00 -05:00
Platform bi = Platform.ThePlatform;
2008-03-05 09:52:00 -05:00
return (uint)bi.PciBiosCX + 1;
}
static private unsafe FileImage GetLoadedFileImage(int image)
{
2008-11-17 18:29:00 -05:00
Platform bi = Platform.ThePlatform;
if (image < bi.FileImageTableEntries) {
2008-03-05 09:52:00 -05:00
FileImage* fi = (FileImage*) bi.FileImageTableBase32; //.ToPointer();
return *(fi + image);
}
return new FileImage(UIntPtr.Zero, 0);
}
static public IoMemory GetLoadedImageMemory(int image)
{
FileImage fileImage = GetLoadedFileImage(image);
2008-11-17 18:29:00 -05:00
if (fileImage.Address != UIntPtr.Zero) {
2008-03-05 09:52:00 -05:00
return IoMemory.MapPhysicalMemory(fileImage.Address, fileImage.Size,
true, false);
}
return null;
}
2008-11-17 18:29:00 -05:00
public static IoMemory GetSystemManifest()
{
return Resources.GetLoadedImageMemory(1);
}
2008-03-05 09:52:00 -05:00
}
}