コード例 #1
0
        private static void InitAta(BlockDevice.Ata.ControllerIdEnum aControllerID,
                                    BlockDevice.Ata.BusPositionEnum aBusPosition)
        {
            var xIO = aControllerID == BlockDevice.Ata.ControllerIdEnum.Primary
                ? Cosmos.Core.Global.BaseIOGroups.ATA1
                : Cosmos.Core.Global.BaseIOGroups.ATA2;
            var xATA = new BlockDevice.AtaPio(xIO, aControllerID, aBusPosition);

            if (xATA.DriveType == BlockDevice.AtaPio.SpecLevel.Null)
            {
                return;
            }
            if (xATA.DriveType == BlockDevice.AtaPio.SpecLevel.ATA)
            {
                BlockDevice.BlockDevice.Devices.Add(xATA);
                Ata.AtaDebugger.Send("ATA device with speclevel ATA found.");
            }
            else
            {
                Ata.AtaDebugger.Send("ATA device with spec level " + (int)xATA.DriveType +
                                     " found, which is not supported!");
                return;
            }
            var xMbrData = new byte[512];

            xATA.ReadBlock(0UL, 1U, xMbrData);
            var xMBR = new BlockDevice.MBR(xMbrData);

            if (xMBR.EBRLocation != 0)
            {
                //EBR Detected
                var xEbrData = new byte[512];
                xATA.ReadBlock(xMBR.EBRLocation, 1U, xEbrData);
                var xEBR = new BlockDevice.EBR(xEbrData);

                for (int i = 0; i < xEBR.Partitions.Count; i++)
                {
                    //var xPart = xEBR.Partitions[i];
                    //var xPartDevice = new BlockDevice.Partition(xATA, xPart.StartSector, xPart.SectorCount);
                    //BlockDevice.BlockDevice.Devices.Add(xPartDevice);
                }
            }

            // TODO Change this to foreach when foreach is supported
            Ata.AtaDebugger.Send("Number of MBR partitions found:  " + xMBR.Partitions.Count);
            for (int i = 0; i < xMBR.Partitions.Count; i++)
            {
                var xPart = xMBR.Partitions[i];
                if (xPart == null)
                {
                    Console.WriteLine("Null partition found at idx " + i);
                }
                else
                {
                    var xPartDevice = new BlockDevice.Partition(xATA, xPart.StartSector, xPart.SectorCount);
                    BlockDevice.BlockDevice.Devices.Add(xPartDevice);
                    Console.WriteLine("Found partition at idx " + i);
                }
            }
        }
コード例 #2
0
ファイル: Global.cs プロジェクト: fanoI/Cosmos
    private static void InitAta(Ata.ControllerIdEnum aControllerID,
        Ata.BusPositionEnum aBusPosition)
    {
      var xIO = aControllerID == Ata.ControllerIdEnum.Primary
          ? Core.Global.BaseIOGroups.ATA1
          : Core.Global.BaseIOGroups.ATA2;
      var xATA = new AtaPio(xIO, aControllerID, aBusPosition);
      if (xATA.DriveType == AtaPio.SpecLevel.Null)
      {
        return;
      }
      if (xATA.DriveType == AtaPio.SpecLevel.ATA)
      {
        BlockDevice.BlockDevice.Devices.Add(xATA);
        Ata.AtaDebugger.Send("ATA device with speclevel ATA found.");
      }
      else
      {
        //Ata.AtaDebugger.Send("ATA device with spec level " + (int)xATA.DriveType +
        //                     " found, which is not supported!");
        return;
      }
      var xMbrData = new byte[512];
      xATA.ReadBlock(0UL, 1U, xMbrData);
      var xMBR = new MBR(xMbrData);

      if (xMBR.EBRLocation != 0)
      {
        //EBR Detected
        var xEbrData = new byte[512];
        xATA.ReadBlock(xMBR.EBRLocation, 1U, xEbrData);
        var xEBR = new EBR(xEbrData);

        for (int i = 0; i < xEBR.Partitions.Count; i++)
        {
          //var xPart = xEBR.Partitions[i];
          //var xPartDevice = new BlockDevice.Partition(xATA, xPart.StartSector, xPart.SectorCount);
          //BlockDevice.BlockDevice.Devices.Add(xPartDevice);
        }
      }

      // TODO Change this to foreach when foreach is supported
      Ata.AtaDebugger.Send("Number of MBR partitions found:");
      Ata.AtaDebugger.SendNumber(xMBR.Partitions.Count);
      for (int i = 0; i < xMBR.Partitions.Count; i++)
      {
        var xPart = xMBR.Partitions[i];
        if (xPart == null)
        {
          Console.WriteLine("Null partition found at idx: " + i);
        }
        else
        {
          var xPartDevice = new Partition(xATA, xPart.StartSector, xPart.SectorCount);
          BlockDevice.BlockDevice.Devices.Add(xPartDevice);
          Console.WriteLine("Found partition at idx" + i);
        }
      }
    }
コード例 #3
0
        internal static void ScanAndInitPartitions(BlockDevice device)
        {
            if (GPT.IsGPTPartition(device))
            {
                var xGPT = new GPT(device);

                Ata.AtaDebugger.Send("Number of GPT partitions found:");
                Ata.AtaDebugger.SendNumber(xGPT.Partitions.Count);
                int i = 0;
                foreach (var part in xGPT.Partitions)
                {
                    Partition.Partitions.Add(new Partition(device, part.StartSector, part.SectorCount));
                    i++;
                }
            }
            else
            {
                var mbr = new MBR(device);

                if (mbr.EBRLocation != 0)
                {
                    //EBR Detected
                    var xEbrData = new byte[512];
                    device.ReadBlock(mbr.EBRLocation, 1U, ref xEbrData);
                    var xEBR = new EBR(xEbrData);

                    for (int i = 0; i < xEBR.Partitions.Count; i++)
                    {
                        //var xPart = xEBR.Partitions[i];
                        //var xPartDevice = new BlockDevice.Partition(xATA, xPart.StartSector, xPart.SectorCount);
                        //Partition.Partitions.Add(xATA, xPartDevice);
                    }
                }
                int c = 0;
                foreach (var part in mbr.Partitions)
                {
                    Partition.Partitions.Add(new Partition(device, part.StartSector, part.SectorCount));
                    c++;
                }
            }
        }
コード例 #4
0
ファイル: IDE.cs プロジェクト: ThomasBeHappy/Cosmos
        private static void Initialize(Ata.ControllerIdEnum aControllerID, Ata.BusPositionEnum aBusPosition)
        {
            var xIO  = aControllerID == Ata.ControllerIdEnum.Primary ? Core.Global.BaseIOGroups.ATA1 : Core.Global.BaseIOGroups.ATA2;
            var xATA = new ATA_PIO(xIO, aControllerID, aBusPosition);

            if (xATA.DriveType == ATA_PIO.SpecLevel.Null)
            {
                return;
            }
            else if (xATA.DriveType == ATA_PIO.SpecLevel.ATA)
            {
                BlockDevice.Devices.Add(xATA);
                Ata.AtaDebugger.Send("ATA device with speclevel ATA found.");
            }
            else if (xATA.DriveType == ATA_PIO.SpecLevel.ATAPI)
            {
                var atapi = new ATAPI(xATA);

                //TODO: Replace 1000000 with proper size once ATAPI driver implements it
                //Add the atapi device to an array so we reorder them to be last
                ATAPIPartions.Add(new Partition(atapi, 0, 1000000));
                Ata.AtaDebugger.Send("ATA device with speclevel ATAPI found");
                return;
            }

            if (GPT.IsGPTPartition(xATA))
            {
                var xGPT = new GPT(xATA);

                Ata.AtaDebugger.Send("Number of GPT partitions found:");
                Ata.AtaDebugger.SendNumber(xGPT.Partitions.Count);
                for (int i = 0; i < xGPT.Partitions.Count; i++)
                {
                    var xPart = xGPT.Partitions[i];
                    if (xPart == null)
                    {
                        Console.WriteLine("Null partition found at idx: " + i);
                    }
                    else
                    {
                        var xPartDevice = new Partition(xATA, xPart.StartSector, xPart.SectorCount);
                        BlockDevice.Devices.Add(xPartDevice);
                        Console.WriteLine("Found partition at idx: " + i);
                    }
                }
            }
            else
            {
                var xMbrData = new byte[512];
                xATA.ReadBlock(0UL, 1U, ref xMbrData);
                var xMBR = new MBR(xMbrData);

                if (xMBR.EBRLocation != 0)
                {
                    //EBR Detected
                    var xEbrData = new byte[512];
                    xATA.ReadBlock(xMBR.EBRLocation, 1U, ref xEbrData);
                    var xEBR = new EBR(xEbrData);

                    for (int i = 0; i < xEBR.Partitions.Count; i++)
                    {
                        //var xPart = xEBR.Partitions[i];
                        //var xPartDevice = new BlockDevice.Partition(xATA, xPart.StartSector, xPart.SectorCount);
                        //BlockDevice.BlockDevice.Devices.Add(xPartDevice);
                    }
                }
                Ata.AtaDebugger.Send("Number of MBR partitions found:");
                Ata.AtaDebugger.SendNumber(xMBR.Partitions.Count);
                int partNumb = 0;
                foreach (var part in xMBR.Partitions)
                {
                    if (part == null)
                    {
                        Console.WriteLine("Null partition found at idx: " + partNumb);
                    }
                    else
                    {
                        var xPartDevice = new Partition(xATA, part.StartSector, part.SectorCount);
                        BlockDevice.Devices.Add(xPartDevice);
                        Console.WriteLine("Found partition at idx: " + partNumb);
                    }
                    partNumb++;
                }
            }
        }