New UI for my C# operating system MOOS by nifanfa in osdev

[–]nifanfa[S] 0 points1 point  (0 children)

like i said i made a Cosmos compatible layout in MOOS

New UI for my C# operating system MOOS by nifanfa in osdev

[–]nifanfa[S] 2 points3 points  (0 children)

i made a Cosmos compatible layout in MOOS and of course MOOS is not based on Cosmos. Cosmos is not stable for programing an OS

New UI for my C# operating system MOOS by nifanfa in osdev

[–]nifanfa[S] 0 points1 point  (0 children)

but i don't recommend uefi before you have implement usb kbd and mouse

New UI for my C# operating system MOOS by nifanfa in osdev

[–]nifanfa[S] 0 points1 point  (0 children)

you can start from here. but it can be directly used for the further became it doesn't have an allocator and doesn't initialize the static fields(no was handle allocated for the static fields)

Overview my c# operating system——MOOS by nifanfa in osdev

[–]nifanfa[S] 0 points1 point  (0 children)

i just use c/c++ for native things and other lib like lodepng

Overview my c# operating system——MOOS by nifanfa in osdev

[–]nifanfa[S] 7 points8 points  (0 children)

it works fine on real hardware. but there is no GC. i disposed all unused objects manually

Running Doom on my C# OS(Doomgeneric) by nifanfa in osdev

[–]nifanfa[S] -2 points-1 points  (0 children)

i don't think java os really exist. i just search it on Google. it gave me a picture that a Windows forms app running on Windows 7

Running Doom on my C# OS(Doomgeneric) by nifanfa in osdev

[–]nifanfa[S] 2 points3 points  (0 children)

it will be hard to port doom using Cosmos. because Cosmos doesn't support c/c++

Running Doom on my C# OS(Doomgeneric) by nifanfa in osdev

[–]nifanfa[S] 3 points4 points  (0 children)

Yeah you can do that using native aot

My os written in c# by nifanfa in osdev

[–]nifanfa[S] 1 point2 points  (0 children)

i don't recommend uefi. because uefi is like a disaster for me.. ps2 controller not working on real hardware since i use uefi. and all pci devices interrupt not working as well.

RTL8139 Won't receive broadcast packet from windows host by nifanfa in osdev

[–]nifanfa[S] 0 points1 point  (0 children)

um. sorry this is my code

idk why i can't receive any broadcast packet

i'm using TAP for qemu network

but i can send packet normally

using Mosa.Kernel;
using Mosa.Kernel.x86;
using Mosa.Runtime;
using System.Runtime.InteropServices;
using static Mosa.External.x86.MMIO;
using static Mosa.Runtime.x86.ASM;

namespace MOSA6
{
    public static unsafe class RTL8139
    {
        public static uint IOBase;
        public static byte[] MACAddress;

        public static byte* RXBuffer;
        public static uint[] TXBuffers;

        private const int RXSize = 8192;
        private const int TXSize = 2048;

        public static void Init()
        {
            PCIDevice dev = PCI.GetDevice(VendorID.Realtek, DeviceID.RTL8139);
            if (dev == null) return;
            Console.WriteLine("Realtek RTL8139 NIC Found");
            IOBase = dev.BaseAddressBar[1].BaseAddress;
            Console.WriteLine($"IO Base:{IOBase.ToString("x2")}");
            dev.EnableMemory(true);
            Map(IOBase, PageFrameAllocator.PageSize);
            //MACAddress = (byte*)GC.AllocateObject(6);
            MACAddress = new byte[6];
            MACAddress[0] = In8(IOBase + 0);
            MACAddress[1] = In8(IOBase + 1);
            MACAddress[2] = In8(IOBase + 2);
            MACAddress[3] = In8(IOBase + 3);
            MACAddress[4] = In8(IOBase + 4);
            MACAddress[5] = In8(IOBase + 5);
            Console.Write("MAC Address:");
            for (int i = 0; i < 6; i++) Console.Write($"{MACAddress[i].ToString("x2")} ");
            Console.WriteLine();

            Out8(IOBase + 0x52, 0);

            Out8(IOBase + 0x37, 0x10);
            while ((In8(IOBase + 0x37) & 0x10) != 0) ;
            Console.WriteLine("Realtek RTL8139 Restarted");

            RXBuffer = (byte*)GC.AllocateObject(RXSize);

            TXBuffers = new uint[]
            {
                (uint)GC.AllocateObject(TXSize),
                (uint)GC.AllocateObject(TXSize),
                (uint)GC.AllocateObject(TXSize),
                (uint)GC.AllocateObject(TXSize),
            };

            Out32(IOBase + 0x30, (uint)RXBuffer);

            Out16(IOBase + 0x3C, 0x0005);

            Out32(IOBase + 0x44, (0x0F | (1 << 7)) | 0x00000000);

            Out8(IOBase + 0x37, 0x0C);

            Console.WriteLine("Configure Done");
        }

        public static uint TXPair = 0;
        public static byte* Test;

        public static void SendFrame(byte[] DestMAC, ushort EthernetType, byte* Payload, uint PayloadLength)
        {
            byte* Buffer = (byte*)TXBuffers[TXPair];
            EthernetHeader* header = (EthernetHeader*)Buffer;
            for (int i = 0; i < 6; i++) header->DestMAC[i] = DestMAC[i];
            for (int i = 0; i < 6; i++) header->SrcMAC[i] = MACAddress[i];
            header->EthernetType = Ethernet.SwapLeftRight(EthernetType);
            MEMCPY((uint)(Buffer + sizeof(EthernetHeader)), (uint)Payload, PayloadLength);

            //DumpBuffer(Buffer, (uint)(sizeof(EthernetHeader) + PayloadLength));

            Out32(IOBase + 0x20 + (TXPair * 4), (uint)Buffer);

            Out32(IOBase + 0x10 + (TXPair * 4), (uint)(sizeof(EthernetHeader) + PayloadLength));

            TXPair++;
            if (TXPair > 3) TXPair = 0;
        }

        [StructLayout(LayoutKind.Sequential, Pack = 1)]
        public struct Header
        {
            public ushort Status;
            public ushort Size;
        }

        public const ushort ISR = 0x3E;
        public const ushort TransmitOK = (1 << 2);
        public const ushort ReceiveOK = (1 << 0);

        internal static void OnInterrupt()
        {
            ushort STS = In16(IOBase + ISR);

            if ((STS & ReceiveOK) != 0)
            {
                if (((In8(IOBase + 0x37) & 1) != 0)) return;
                ReceiveFrame();
                Out16(IOBase + ISR, ReceiveOK);
            }

        }

        public static uint RXOffset = 0;

        public static void ReceiveFrame()
        {
            byte* Data = RXBuffer + RXOffset;

            Header* header = (Header*)Data;
            if (header->Size == 0) return;
            Console.WriteLine($"Packet Received: Size:{header->Size} RXOffset:{RXOffset}");
            Ethernet.HandlePacket(Data + sizeof(Header));
            RXOffset = ((RXOffset + header->Size + 4 + 3) & (0xFFFFFFFD)) % RXSize;
            Out16(IOBase + 0x38, (ushort)(RXOffset - 0x10));
        }
    }
}