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

Advanced VFS #52

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion src/Compiler/Atomixilc/Lib/Memory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public static void Write8(uint aAddress, byte Value)

[NoException]
[Assembly(false)]
public static void FastCopy(uint aDest, uint aSrc, uint aLen)
public static void FastCopy(uint aDest, uint aSrc, int aLen)
{
new Mov { DestinationReg = Register.EAX, SourceReg = Register.ESP, SourceDisplacement = 0x4, SourceIndirect = true };
new Mov { DestinationReg = Register.ESI, SourceReg = Register.ESP, SourceDisplacement = 0x8, SourceIndirect = true };
Expand Down
2 changes: 1 addition & 1 deletion src/Compiler/Atomixilc/Lib/Plugs/String.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ internal static char[] ToCharArray(string aStr)
{
int len = aStr.Length;
var aArray = new char[len];
Memory.FastCopy(aArray.GetDataOffset(), aStr.GetDataOffset(), (uint)(len << 1));
Memory.FastCopy(aArray.GetDataOffset(), aStr.GetDataOffset(), (len << 1));

return aArray;
}
Expand Down
8 changes: 4 additions & 4 deletions src/Kernel/Atomix.Kernel_H/Arch/x86/Multiboot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ internal static unsafe class Multiboot
static Multiboot_Info* Mb_Info;
static bool aIsValid;
static uint Initrd;
static uint InitrdSize;
static int InitrdSize;

internal static bool IsValid
{ get { return aIsValid; } }
Expand All @@ -134,14 +134,14 @@ internal static uint RamDisk
get { return Initrd; }
}

internal static uint RamDiskSize
internal static int RamDiskSize
{
get { return InitrdSize; }
}

internal static uint RamDiskEnd
{
get { return Initrd + InitrdSize; }
get { return Initrd + (uint)InitrdSize; }
}

internal static unsafe void Setup(uint xSig, uint Address)
Expand All @@ -167,7 +167,7 @@ internal static unsafe void Setup(uint xSig, uint Address)
if (Mb_Info->mods_count > 0)
{
Initrd = modules[0];
InitrdSize = modules[1] - Initrd;
InitrdSize = (int)(modules[1] - Initrd);
Initrd += 0xC0000000;
Debug.Write(" RamDisk:%d\n", Initrd);
Debug.Write(" RamDisk-Size:%d\n", InitrdSize);
Expand Down
30 changes: 19 additions & 11 deletions src/Kernel/Atomix.Kernel_H/Atomix.Kernel_H.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -91,22 +91,30 @@
<Compile Include="Gui\GuiRequest.cs" />
<Compile Include="Gui\Programs\Explorer.cs" />
<Compile Include="Gui\Window.cs" />
<Compile Include="IO\FileSystem\FatFileSystem.cs" />
<Compile Include="IO\Directory.cs" />
<Compile Include="IO\File.cs" />
<Compile Include="IO\FileMode.cs" />
<Compile Include="IO\FileSystem\FAT\Entry.cs" />
<Compile Include="IO\FileSystem\FAT\FatDirectory.cs" />
<Compile Include="IO\FileSystem\FAT\FatFile.cs" />
<Compile Include="IO\FileSystem\FAT\FatFileSystem.cs" />
<Compile Include="IO\FileSystem\FAT\FatStream.cs" />
<Compile Include="IO\FileSystem\FAT\FileLocation.cs" />
<Compile Include="IO\FileSystem\FAT\Find\Any.cs" />
<Compile Include="IO\FileSystem\FAT\Find\ByCluster.cs" />
<Compile Include="IO\FileSystem\FAT\Find\Empty.cs" />
<Compile Include="IO\FileSystem\FAT\Find\WithName.cs" />
<Compile Include="IO\FileSystem\FAT\misc.cs" />
<Compile Include="IO\FileSystem\GenericFileSystem.cs" />
<Compile Include="IO\FileSystem\RamFileSystem.cs" />
<Compile Include="IO\FileSystem\RFS\FileStream.cs" />
<Compile Include="IO\FileSystem\FAT\FatType.cs" />
<Compile Include="IO\FileSystem\FAT\FatFileAttribute.cs" />
<Compile Include="IO\FileSystem\FAT\FileNameAttribute.cs" />
<Compile Include="IO\FileSystem\FAT\Comparison.cs" />
<Compile Include="IO\FileSystem\RFS\FileEntry.cs" />
<Compile Include="IO\FileSystem\RFS\RamFileSystem.cs" />
<Compile Include="IO\FileSystem\RFS\RamFile.cs" />
<Compile Include="IO\FileSystem\VirtualFileSystem.cs" />
<Compile Include="Drivers\Video\VBE.cs" />
<Compile Include="IO\FSObject.cs" />
<Compile Include="IO\FileSystem\GenericFileSystem.cs" />
<Compile Include="IO\MemoryStream.cs" />
<Compile Include="IO\Pipe.cs" />
<Compile Include="IO\FileSeek.cs" />
<Compile Include="IO\Stream.cs" />
<Compile Include="IO\VFN.cs" />
<Compile Include="IO\VirtualFileSystem.cs" />
<Compile Include="Lib\Cairo\ColorFormat.cs" />
<Compile Include="Lib\Cairo\Font.cs" />
<Compile Include="Lib\Cairo\Cairo.cs" />
Expand Down
15 changes: 6 additions & 9 deletions src/Kernel/Atomix.Kernel_H/Boot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
using System;

using Atomixilc.Lib;
using Atomix.Kernel_H.Lib.Cairo;
using Atomix.Kernel_H.IO;
using Atomix.Kernel_H.Gui;
using Atomix.Kernel_H.Core;
using Atomix.Kernel_H.Devices;
using Atomix.Kernel_H.Arch.x86;
using Atomix.Kernel_H.Lib.Cairo;
using Atomix.Kernel_H.Drivers.Video;
using Atomix.Kernel_H.IO.FileSystem;

Expand All @@ -35,9 +35,9 @@ internal unsafe static void Init()
#region InitRamDisk
if (Multiboot.RamDisk != 0)
{
var xFileSystem = new RamFileSystem(Multiboot.RamDisk, Multiboot.RamDiskSize);
if (xFileSystem.IsValid)
VirtualFileSystem.MountDevice(null, xFileSystem);
var xFileSystem = new RamFileSystem("disk0", new MemoryStream(Multiboot.RamDisk, Multiboot.RamDiskSize));
if (xFileSystem.Detect())
VirtualFileSystem.Mount(xFileSystem, "/");
else
throw new Exception("RamDisk Corrupted!");
}
Expand Down Expand Up @@ -231,8 +231,6 @@ private static unsafe void DrawTaskbar(GuiRequest* request, byte[] xData)
internal static void LoadIDE(bool IsPrimary, bool IsMaster)
{
var xIDE = new IDE(IsPrimary, IsMaster);

bool Clean = true;
if (xIDE.IsValid)
{
switch(xIDE.Device)
Expand All @@ -252,12 +250,11 @@ internal static void LoadIDE(bool IsPrimary, bool IsMaster)
/*
* Iterate over all FileSystem Drivers and check which is valid
*/
var xFileSystem = new FatFileSystem(xMBR.PartInfo[i]);
/*var xFileSystem = new FatFileSystem(xMBR.PartInfo[i]);
if (xFileSystem.IsValid)
{
VirtualFileSystem.MountDevice(null, xFileSystem);
Clean = false;
}
}*/
}
}
}
Expand Down
19 changes: 12 additions & 7 deletions src/Kernel/Atomix.Kernel_H/Core/Syscall.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@

using System;

using Atomixilc.Lib;

using Atomix.Kernel_H.IO;
using Atomix.Kernel_H.Arch.x86;
using Atomix.Kernel_H.IO.FileSystem;

namespace Atomix.Kernel_H.Core
{
Expand Down Expand Up @@ -99,7 +100,10 @@ private static unsafe int sys_read(int fd, byte* buffer, int count)
if (fd >= files.Count) return -1;

var stream = Process.Files[fd];
return stream.Read(buffer, count);
var data = new byte[count];
int status = stream.Read(data, count);
Memory.FastCopy((uint)buffer, data.GetDataOffset(), count);
return status;
}

private static int sys_seek(int fd, int offset, int origin)
Expand All @@ -113,7 +117,7 @@ private static int sys_seek(int fd, int offset, int origin)
if (origin > 2) return -1;

var stream = Process.Files[fd];
return stream.Seek(offset, (SEEK)origin);
return stream.Seek(offset, (FileSeek)origin);
}

private static int sys_close(int fd)
Expand All @@ -134,15 +138,16 @@ private static int sys_close(int fd)
return 0;
}

private static unsafe int sys_open(sbyte* file, int flags, int mode)
private static unsafe int sys_open(sbyte* name, int flags, int mode)
{
var filename = new string(file);
var stream = VirtualFileSystem.GetFile(filename);
var filename = new string(name);
var file = VirtualFileSystem.Open(filename);
Debug.Write("fopen: %s\n", filename);

if (stream == null)
if (file == null || !(file is File))
return -1;

var stream = ((File)file).Open(FileMode.Read);
var Process = Scheduler.RunningProcess;
var files = Process.Files;
int count = files.Count;
Expand Down
Loading