Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ISO9660 support #2843

Merged
merged 1 commit into from
Dec 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions source/Cosmos.Build.Tasks/MakeIso.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,14 @@ protected override string GenerateCommandLineCommands()
xBuilder.AppendSwitch("-J");
xBuilder.AppendSwitch("-R");
xBuilder.AppendSwitch("-l");
xBuilder.AppendSwitch("-allow-lowercase");
xBuilder.AppendSwitchIfNotNull("-o ", OutputFile);
xBuilder.AppendSwitch(" -b boot/limine-bios-cd.bin");
xBuilder.AppendSwitch("-no-emul-boot");
xBuilder.AppendSwitch("-boot-load-size 4");
xBuilder.AppendSwitch("-boot-info-table");
xBuilder.AppendSwitch("--efi-boot boot/limine-uefi-cd.bin");
xBuilder.AppendSwitch("-efi-boot-part");
xBuilder.AppendSwitch("-boot-info-table");
xBuilder.AppendSwitch("--efi-boot boot/limine-uefi-cd.bin");
xBuilder.AppendSwitch("-efi-boot-part");
xBuilder.AppendSwitch("--efi-boot-image");
xBuilder.AppendFileNameIfNotNull(IsoDirectory.TrimEnd('\\', '/'));

Expand Down
6 changes: 3 additions & 3 deletions source/Cosmos.HAL2/BlockDevice/ATAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public override void ReadBlock(ulong SectorNum, ulong SectorCount, ref byte[] aD
throw new NotImplementedException("Reading more than one sectors is not supported. SectorCount: " + SectorCount);
}

ataDebugger.Send("ATAPI: Reading block. Sector: " + SectorNum + " SectorCount: " + SectorCount);
ataDebugger.SendInternal("ATAPI: Reading block. Sector: " + SectorNum + " SectorCount: " + SectorCount);


byte[] packet = new byte[12];
Expand Down Expand Up @@ -182,10 +182,10 @@ private void SendCmd(byte[] AtapiPacket, int size, ref ushort[] outputData)

//Send ATAPI packet command
device.SendCmd(Cmd.Packet);
ataDebugger.Send("ATAPI: Polling");
ataDebugger.SendInternal("ATAPI: Polling");

Poll(true);
ataDebugger.Send("ATAPI: Polling complete");
ataDebugger.SendInternal("ATAPI: Polling complete");

//Send the command as words
for (int i = 0; i < AtapiPacket.Length; i++)
Expand Down
14 changes: 11 additions & 3 deletions source/Cosmos.System2/FileSystem/Disk.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@

using System;
using System.Collections.Generic;
using System.ComponentModel.Design.Serialization;
using System.Net.Mime;
using System.Text;
using Cosmos.HAL.BlockDevice;
using Cosmos.System.FileSystem.FAT;
using Cosmos.System.FileSystem.ISO9660;
using Cosmos.System.FileSystem.VFS;

namespace Cosmos.System.FileSystem
Expand All @@ -26,9 +30,8 @@ public List<ManagedPartition> Partitions
{
List<ManagedPartition> converted = new();

if(Host.Type == BlockDeviceType.RemovableCD) {
// we dont actually have a partition table in CDs
ManagedPartition part = new(new Partition(Host, 0, Host.BlockCount / 4)); // BlockSize is 512, SectorSize of ISO9660 usually is 2 2048
if (Host.Type == BlockDeviceType.RemovableCD) {
ManagedPartition part = new(new Partition(Host, 0, 1000000000), nameof(ISO9660FileSystemFactory)); // For some reason, BlockCount is always 0, so just put a large value here.

if (mountedPartitions[0] != null) {
var data = mountedPartitions[0];
Expand Down Expand Up @@ -296,6 +299,11 @@ public void MountPartition(int index)

foreach (var item in FileSystemManager.RegisteredFileSystems)
{
if(part.LimitFS != null && item.GetType().Name != part.LimitFS) {
Kernel.PrintDebug("Did not mount partition " + index + " as " + item.GetType().Name + " because the partition has been limited to being a " + part.LimitFS);
continue;
}

if (item.IsType(part.Host))
{
Kernel.PrintDebug("Mounted partition.");
Expand Down
6 changes: 4 additions & 2 deletions source/Cosmos.System2/FileSystem/ManagedPartition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ public class ManagedPartition
/// </summary>
public bool HasFileSystem => MountedFS != null;

public ManagedPartition(Partition host)
{
public string LimitFS = null;

public ManagedPartition(Partition host, string limitFS = null) {
Host = host;
LimitFS = limitFS;
}

/// <summary>
Expand Down