Git Product home page Git Product logo

amaneureka / atomos Goto Github PK

View Code? Open in Web Editor NEW
1.3K 1.3K 85.0 6.33 MB

A multitasking monolithic Kernel based x86 targeting Operating System written in C# from scratch aiming for high-level implementation of drivers in managed environment.

Home Page: http://www.atomixos.com

License: BSD 3-Clause "New" or "Revised" License

C# 98.50% Batchfile 0.32% Shell 0.84% Makefile 0.02% C 0.30% Assembly 0.02%
operating-system

atomos's People

Contributors

amaneureka avatar splittydev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

atomos's Issues

[Compiler] Implement a Garbage Collector

It is really hard to keep track of memory allocation with manual allocation and free mechanism; If a proper garbage collector is not implemented then It could lead to memory leaks.

[Compiler] Build Environment on Ubuntu

Right now it is not working on Ubuntu, Kernel Build Fails

System.Exception: ILOpCode=>Type    [0x028-0x02E] Constrained:     System.UInt32; System_Void__Atomix_Kernel_H_gui_Window__ctor_System_Int32_
  at Atomix.Compiler.ScanMethod (System.Reflection.MethodBase aMethod) <0x40fbb670 + 0x014c7> in <filename unknown>:0 
  at Atomix.Compiler.Start () <0x40fad080 + 0x002d7> in <filename unknown>:0 
  at Atomix.ILCompiler.Main (System.String[] args) <0x40fa8e70 + 0x00817> in <filename unknown>:0 

System.Exception: ILOpCode=>Type    [0x010-0x016] Constrained:     System.UInt32; System_String_Atomix_Kernel_H_io_FileSystem_VirtualFileSystem_GetDeviceLabel__
  at Atomix.Compiler.ScanMethod (System.Reflection.MethodBase aMethod) <0x4022e670 + 0x014c7> in <filename unknown>:0 
  at Atomix.Compiler.Start () <0x40220080 + 0x002d7> in <filename unknown>:0 
  at Atomix.ILCompiler.Main (System.String[] args) <0x4021be70 + 0x00817> in <filename unknown>:0

System.Exception: ILOpCode=>None    [0x175-0x177] Rethrow 359; System_Void_System_Array_Copy_System_Array__System_Int32__System_Array__System_Int32__System_Int32_
  at Atomix.Compiler.ScanMethod (System.Reflection.MethodBase aMethod) <0x41143670 + 0x014c7> in <filename unknown>:0 
  at Atomix.Compiler.Start () <0x41135080 + 0x002d7> in <filename unknown>:0 
  at Atomix.ILCompiler.Main (System.String[] args) <0x41130e70 + 0x00817> in <filename unknown>:0

[Stream] Pipe

Pipe should inherit stream class and can only be accessed through VirtualFileSystem.

[Kernel_H] Stack usage monitor

There is no way right now to monitor stack usage and hence It sometime introduce bugs. Also a fault should be thrown when stack overflows.

[Kernel_H] Return from thread

Return from thread should signal the parent process. Right now it throws a page fault because of invalid memory access execution.

basic code:

    new Thread(Parent, foo, Heap.kmalloc(0x1000) + 0x1000, 0x1000).Start();
    private static void foo()
    {
        return;
    }

Standard Library

Where is the standard library for C#? AFAIK compiling most C# projects requires a standard library / set of API's to do anything useful.

Kernel Debugger

A window application that could trace kernel actions would be helpful to debug kernel time to time.

[Compiler] Add Inline support to the methods

Compiling small method as inline function could save cpu time in fetching address and jumping to the label.
So, A Inline attribute that would tell the compiler that this method needs to be compiled inline. And also add inline feature to method processing engine of compiler.

Use LLVM

LLVM provides better optimizations in the backend. It already has GC support via statepoints.

[Graphics] Graphics Library for UI

We can either approach to Cairo which is really a good graphics library and widely used, Or we can either make any existing C# graphics library to work on Atomix Platform.

[Compiler]: structures not working

Ldobj MSIL not loading up structures properly after casting structure pointer.

       //Test code
        private static unsafe void structureTest()
        {
            var a = *(aman*)0x0;
            a.b = 0x2;
            a.u = 3;
            a.i = 0xDEAD;
            Debug.Write("Value: %d\n", a.i);
            Debug.Write("Value: %d\n", a.u);
            Debug.Write("Value: %d\n", a.b);
        }

AtomOS contains Cosmos Code?

Cosmos code from 2010 (BSD-3-Clause?):

https://github.com/CosmosOS/Cosmos/blob/474c16ecd89bde238925910083307141cd20cc23/source2/IL2PCU/Cosmos.IL2CPU/ILReader.cs#L62

      int xPos = 0;
      while (xPos < xIL.Length) {
          ExceptionHandlingClause xCurrentHandler = null;
          #region Determine current handler
          // todo: add support for nested handlers using a stack or so..
          foreach (ExceptionHandlingClause xHandler in xBody.ExceptionHandlingClauses)
          {
              if (xHandler.TryOffset > 0)
              {
                  if (xHandler.TryOffset <= xPos && (xHandler.TryLength + xHandler.TryOffset + 1) > xPos) // + 1 because index should be less than the try
                  {
                      if (xCurrentHandler == null)
                      {
                          xCurrentHandler = xHandler;
                          continue;
                      }
                      else if (xHandler.TryOffset > xCurrentHandler.TryOffset && (xHandler.TryLength + xHandler.TryOffset) < (xCurrentHandler.TryLength + xCurrentHandler.TryOffset))
                      {
                          // only replace if the current found handler is narrower
                          xCurrentHandler = xHandler;
                          continue;
                      }
                  }
              }

AtomOS code from 2014:

https://github.com/amaneureka/AtomOS/blob/master/src/Compiler/OpCodes.cs#L79

            int xPos = 0;
            while (xPos < msIL.Length)
            {
                /* Calculate Exception handling label for current IL
                 * It just do check if this IL is inside try catch, if yes than set xCurrentHandler else null
                 */
                ExceptionHandlingClause xCurrentHandler = null;
                #region Exception
                foreach (ExceptionHandlingClause xHandler in xBody.ExceptionHandlingClauses)
                {
                    //We can have Try in the beginning so it can be equals to zero :)
                    if (xHandler.TryOffset >= 0)
                    {
                        if (xHandler.TryOffset <= xPos && (xHandler.TryLength + xHandler.TryOffset + 1) > xPos) // + 1 because index should be less than the try
                        {
                            if (xCurrentHandler == null)
                            {
                                xCurrentHandler = xHandler;
                                continue;
                            }
                            else if (xHandler.TryOffset > xCurrentHandler.TryOffset && (xHandler.TryLength + xHandler.TryOffset) < (xCurrentHandler.TryLength + xCurrentHandler.TryOffset))
                            {
                                xCurrentHandler = xHandler;
                                continue;
                            }
                        }
                    }

Code seems pretty similar. I assume this is an accident and not out of malice (and the projects are both 3-Clause BSD anyway) but I think it'd definitely be a great gesture to give the Cosmos project (github.com/CosmosOS/) some love in the README even if the projects have diverged significantly.

[Styling] File License Header and CodeStyle

Add License Header and Description of each file to the following project

  • Atomix.Core
  • Atomix.Shell
  • Atomix.Assembler
  • Atomix.CompilerExt
  • Atomix.ILCompiler
  • Atomix.ILOptimizer
  • Atomix.Kernel_H
  • Atomix.mscorlib
  • Kernel_alpha
  • Atomix.Debugger
  • Atomix.RamFS

[ELF] replace Heap with SHM allocate

ELF is allocating memory through Kernel Memory Manager but it should do that with SHM allocate.

//File: Atomix.Kernel_H.exec.ELF.cs
...
var Mem = Heap.kmalloc(section->sh_size);
...
var des = Heap.kmalloc(section->sh_size);
...

[Compiler] Address to a method symbol

Right now we use a very pitty idea to get address of a method symbol.
It follows by setting a Int32 field in same type with name prefix by p followed by method name.

static uint pHelloWorld;
void HelloWorld() { }

pHelloWorld will contain address of HelloWorld. It should be made more reliable.

[Build] Setup.sh --newlib fails when automake is above v1.12

Newlib will fail to build when automake is below version 1.12, when doing the autoreconf command it will fail with the error:
configure.in:5: error: support for Cygnus-style trees has been removed
Maybe have some kind of warning, as by default automake 1.14 is installed on ubuntu 14.04, and automake 1.15 is install on ubuntu 16.04. It can be fixed by removing the default package and installing the package automake1.1

Build failed. Please check the logs above to see what went wrong.

My PC:
http://pastebin.com/q7HGfYti

All I did is:
sudo apt-get install build-essential texinfo flex bison
than check packages, seems all needed already installed
chown +x Setup.sh from src/Build/ and run with sudo

some last lines from my terminal:
AtomOS/src/Build/Temp/newlib-1.19.0/newlib/doc/makedoc.c:1349:15: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
isp[0] = *(int *)(isp[0]);
^
i386-atomos-ar: creating libnosys.a
~/AtomOS/src/Build/Bin ~/AtomOS/src/Build
./Setup.sh: line 178: nasm: command not found
Build failed. Please check the logs above to see what went wrong.

Setup.log download:
http://www.mediafire.com/file/8dte5x3ohzw56n4/Setup.log

[SHM] memory out of run exception

Handle the case when we are running out of memory

//File: Atomix.Kernel_H.arch.x86.SHM.cs
private static void CreateNew(string aID, int Size)
{
    int NumberOfFrames = (Size / 0x1000) + (Size % 0x1000 == 0 ? 0 : 1);

    var NewChunk = new shm_chunk();
    NewChunk.RefCount = 0;
    NewChunk.Frames = new uint[NumberOfFrames];

    for (int index = 0; index < NumberOfFrames; index++)
    {
        //Allocate New Frame to this guy!
        uint NewFrame = Paging.FirstFreeFrame();
        Paging.SetFrame(NewFrame);
#warning Check If we are not out of run of memory
        NewChunk.Frames[index] = NewFrame;
        //Debug.Write(0x0);
    }
    Nodes.Add(aID, NewChunk);
}

Crash on GenerateNewHashID()

The OS crashes with seg fault. After trying to copy the string that is generated by this function.
The Kernel.asm shows the function isn't complete.
I narrowed the issue down to .ToString() not seem to be working
Mono 4.8.0.0
Code:
System_String_Atomix_Kernel_H_Gui_Window_GenerateNewHashID__:
push dword EBP
mov dword EBP, ESP
sub dword ESP, 0x8
; [Ldsflda] : OpField [0x0000-0x0005] System.UInt32 TicksFromStart => 0
push dword static_Field__System_UInt32_Atomix_Kernel_H_Devices_Timer_TicksFromStart
; Unimplemented ILCode 'Constrained'

This would result in the length of the string being > 4GB hence seg fault.
Fix for this was to change to Convert.ToString(Timer.TicksFromStart)
Kernel.txt
GenerateNewHashID is in Window.cs in Gui

I think this is related to issue #4 and #5

Crashes with C_String and Cairo

OS crashes for me after loading up and displaying the window. After commenting out lines which call
C_String in DrawWindow and DrawTaskbar it no longer crashes. Although the text obviously is no longer displayed. Testing the C_String function separately seems to work fine and the data is accessible.
However, when combined with Cairo.ShowText or Cairo.SelectFontFace it seems to crash.

EIP is 3222279488
Kernel.txt
kernel_map.txt

[FileSystem] FAT 32 write support progress

This issue is for tracking the progress of fat 32 write support which was earlier implemented by @sandeepiliger in previous version of Kernel (test kernel).
We need to copy code from previous version of kernel to newer version and link it to I/O abstraction classes.

[Kernel_alpha] Build Fix

A lot of changes are made to the compiler and It is needed to check & fix build for test Kernel project "Kernel_alpha"

Licensing

Is the whole project licensed under BSD 3-clause, or some parts are just shared-source? (like Atomix.Core, Atomix.Shell, etc.)

Please make this clear.
Thanks.

Hyper-V support?

I see there is VMware specific code in there. But will it run under Hyper-V as well? The thing is if you have the latter enabled you can't easily switch to the former and the other way round.

[GC] Minimize Global Search Space

Right now GC search for objects in complete global search space and this can be made more efficient by making some changes in Compiler. like searching in IsClass type fields only.

[Compiler] vStack not good

Compiler Internal virtual stack is not working properly. Though this is fine now. But may inject some serious issue in future.

[Travis] Cron Job

  • Toolchain Building
  • Libraries Building
  • Solution Compilation
  • Kernel Compilation

[Kernel_H] Verify Array.Copy Implementation

It has been used in many place. And never updated after making important changes in compiler. So it is necessary to verify it's working in order to avoid any bug in near future.

[Kernel_H] Switch task

switch task function should be independent calling function. And should be isolated from timer interrupt

[Compiler] ELF output for Kernel Project

Compiler assumes and output flat binary for Kernel Project, which could affect loading time of Kernel by Bootloader.
It need to changed to ELF output.

  • This will reduce output binary size.
  • Decrease Kernel loading time.

[Wiki] Documentations

This issue will track all things that we need to list/document out in GitHub wiki page regarding Atom.

  • Coding Guidelines
  • Setup Build Environment?
  • Building Kernel
  • C# Compiler Assumptions/Conventions
  • Attributes
  • Assembly
  • Kernel Documentation

Build error: cfns.gperf:101:1

Tried to build AtomOS, got a failure:

cfns.gperf:101:1 error: 'const char* libc_name_p(const char*, unsigned int)' redeclared inline with 'gnu_inline' attribute

Installer ISO

How to install this OS and is it supporting .NET binaries?

[Build] Setup Build Environment

A shell script which would check/setup build environment for Atom. Like building up necessary library (i386-elf) or fetching/downloading necessary binaries (nasm).
It should target both windows and linux.

sbrk is deprecated on MacOS

When I tried the first building step using sudo ./Setup.sh --setup on MacOS on Sierra. (Btw, I had to install the packages using homebrew instead of apt-get and build-install isn't available so I did it without it...)

/Users/USER/Desktop/AtomOS/AtomOS/src/Build/Temp/binutils-2.26/gas/as.c:1013:24: error: 
      'sbrk' is deprecated [-Werror,-Wdeprecated-declarations]
  char *lim = (char *) sbrk (0);
                       ^
/usr/include/unistd.h:587:7: note: 'sbrk' has been explicitly marked
      deprecated here
void    *sbrk(int);
         ^
/Users/USER/Desktop/AtomOS/AtomOS/src/Build/Temp/binutils-2.26/gas/as.c:1156:25: error: 
      'sbrk' is deprecated [-Werror,-Wdeprecated-declarations]
  start_sbrk = (char *) sbrk (0);
                        ^
/usr/include/unistd.h:587:7: note: 'sbrk' has been explicitly marked
      deprecated here
void    *sbrk(int);
         ^
2 errors generated.
make[4]: *** [as.o] Error 1
make[4]: *** Waiting for unfinished jobs....
make[3]: *** [all-recursive] Error 1
make[2]: *** [all] Error 2
make[1]: *** [all-gas] Error 2
make: *** [all] Error 2
Build failed. Please check the logs above to see what went wrong.

Error in building cairo

I've built the other libraries inside libs folder but cairo.

./Build-cairo.sh is returning fatal error for "fontconfig/fontconfig.h" : no such file or directory.

[VBE] Graphics 4MB memory limit

Buffer can be more 4 MB or very much less than 4 MB so we have to take care of size before updating the main buffer.

//File: Atomix.Kernel_H.drivers.video.VBE.cs
public static void Update()
{
#warning *4MB* is not good size
    //Copy 4MB of data from Secondary Buffer to Virtual Frame Buffer    
    Core.AssemblerCode.Add(new Mov { DestinationReg = Registers.ESI, SourceRef = "static_Field__System_Byte__Atomix_Kernel_H_drivers_video_VBE_SecondaryBuffer", SourceIndirect = true });
    Core.AssemblerCode.Add(new Mov { DestinationReg = Registers.EDI, SourceRef = "static_Field__System_Byte__Atomix_Kernel_H_drivers_video_VBE_VirtualFrameBuffer", SourceIndirect = true });
    Core.AssemblerCode.Add(new Mov { DestinationReg = Registers.ECX, SourceRef = "0x100000" });
    Core.AssemblerCode.Add(new Cli());
    Core.AssemblerCode.Add(new Literal("rep movsd"));
    Core.AssemblerCode.Add(new Sti());
}

[Compiler] Calling Convention

New Compiler is based on __stdcall calling convention except for the fact that arguments are pushed from left to right (order) while __stdcall suggests doing it from right to left. It has to be fixed!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.