mirror of
https://github.com/danbulant/Cosmos
synced 2026-05-19 20:39:01 +00:00
added initial filesystem objects for review added the ability to use a file as a disk (see filesystem test project) clead up some redundant fs stuff
92 lines
No EOL
2.7 KiB
C#
92 lines
No EOL
2.7 KiB
C#
using System;
|
|
using Cosmos.Build.Windows;
|
|
using Cosmos.Hardware.PC.Bus;
|
|
using Cosmos.FileSystem;
|
|
using Cosmos.Hardware;
|
|
using System.Diagnostics;
|
|
|
|
namespace SteveKernel
|
|
{
|
|
class Program
|
|
{
|
|
#region Cosmos Builder logic
|
|
// Most users wont touch this. This will call the Cosmos Build tool
|
|
[STAThread]
|
|
static void Main(string[] args) {
|
|
BuildUI.Run();
|
|
}
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
// Main entry point of the kernel
|
|
public static void Init()
|
|
{
|
|
Cosmos.Sys.Boot.Default();
|
|
Console.WriteLine("Done booting");
|
|
|
|
|
|
Console.WriteLine("looking for devices");
|
|
Debugger.Break();
|
|
Cosmos.Hardware.Storage.ATA2.ATA.Initialize(Cosmos.Hardware.Global.Sleep);
|
|
|
|
Console.WriteLine("looking for mbr");
|
|
|
|
for (int i = 0; i < Cosmos.Hardware.Device.Devices.Count; i++)
|
|
{
|
|
Device dev = Cosmos.Hardware.Device.Devices[i];
|
|
|
|
|
|
if (dev is Disk)
|
|
{
|
|
Disk bd = dev as Disk;
|
|
MBR mbr = new MBR(bd);
|
|
|
|
Console.WriteLine("WARNING: ABOUT TO REWRITE MBR OF " + bd.Name);
|
|
Console.ReadLine();
|
|
|
|
mbr.DiskSignature = 0x12345678;
|
|
mbr.Partition[0].StartLBA = 1;
|
|
mbr.Partition[0].EndLBA = (uint)(bd.BlockCount - 2);
|
|
mbr.Partition[0].PartitionType = 0x0c;
|
|
mbr.Partition[0].Bootable = true;
|
|
|
|
mbr.Save();
|
|
|
|
Console.WriteLine("wrote a fat partition of size + " + ((mbr.Partition[0].EndLBA - mbr.Partition[0].StartLBA)) * 512); ;
|
|
|
|
|
|
Console.ReadLine();
|
|
}
|
|
else
|
|
{
|
|
|
|
Console.WriteLine("skipping " +dev.Name);
|
|
}
|
|
}
|
|
|
|
|
|
System.Diagnostics.Debugger.Break();
|
|
Cosmos.Hardware.PC.Bus.PCIBus.DebugLSPCI();
|
|
|
|
|
|
PCIDeviceNormal rtlpci = PCIBus.GetPCIDevice(0, 3, 0) as PCIDeviceNormal;
|
|
if (rtlpci != null)
|
|
Console.WriteLine("got rtl pci");
|
|
|
|
Cosmos.Kernel.MemoryAddressSpace mas = rtlpci.GetAddressSpace(1) as Cosmos.Kernel.MemoryAddressSpace;
|
|
if (mas != null)
|
|
Console.WriteLine("got mas");
|
|
|
|
Console.WriteLine("dumping memory space:");
|
|
|
|
for (uint i = 0; i < mas.Size; i++)
|
|
Console.Write(PCIBus.ToHex(mas.Read8Unchecked(i),2) +" ");
|
|
|
|
|
|
while (true)
|
|
;
|
|
}
|
|
}
|
|
} |