Cosmos.Compiler.x86 METHOD NOT FOUND!

Topics: Using Cosmos (Developing your own OS, projects, etc)
Aug 26, 2012 at 3:17 AM

Hello, I am attempting to write an executable loader for my OS. I am executing the instructions 

mov dword eax, 0xB8000
mov byte [eax],65
hlt 
ret
 To test my loader. Currently my OS just loads raw binary data.  The code to execute it is:
        public static unsafe void LoadAndRun(byte* instructions)
        {
            byte** address = &instructions;
            uint ptr = (uint)address;
            Terminal.WriteInfo("Perparing to began execution at: " + ((int)ptr).ToString());
            new CPUx86.Call { DestinationValue = ptr};
        }
 When I run my OS I get an error Type 0x00000007 , MethodIndex = 0x000000384 NOT FOUND!. Am I missing something???

Coordinator
Aug 26, 2012 at 5:18 PM
You're trying to use assembler code (new CPUx86.Call) in runtime code. you're mixing kernel and compiler..
The compiler runs in windows, while the kernel runs in bar metal hardware..


On Sun, Aug 26, 2012 at 5:40 PM, GruntXProductions <notifications@codeplex.com> wrote:

From: GruntXProductions

Hello, I am attempting to write an executable loader for my OS. I am executing the instructions

mov dword eax, 0xB8000
mov byte [eax],65
hlt 
ret
To test my loader. Currently my OS just loads raw binary data. The code to execute it is:
        public static unsafe void LoadAndRun(byte* instructions)
        {
            byte** address = &instructions;
            uint ptr = (uint)address;
            Terminal.WriteInfo("Perparing to began execution at: " + ((int)ptr).ToString());
            new CPUx86.Call { DestinationValue = ptr};
        }
When I run my OS I get an error Type 0x00000007 , MethodIndex = 0x000000384 NOT FOUND!. Am I missing something???

Read the full discussion online.

To add a post to this discussion, reply to this email (Cosmos@discussions.codeplex.com)

To start a new discussion for this project, email Cosmos@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com


Aug 26, 2012 at 6:08 PM
Edited Aug 26, 2012 at 6:10 PM

I get this error too. I am using Userkit 92560 and compiled the Devkit of the same version and referenced its Assembler libraries. How do we use assembly in our OS's then?

Aug 26, 2012 at 6:54 PM
mterwoord wrote:
You're trying to use assembler code (new CPUx86.Call) in runtime code. you're mixing kernel and compiler..
The compiler runs in windows, while the kernel runs in bar metal hardware..


On Sun, Aug 26, 2012 at 5:40 PM, GruntXProductions <notifications@codeplex.com> wrote:

From: GruntXProductions

Hello, I am attempting to write an executable loader for my OS. I am executing the instructions

mov dword eax, 0xB8000
mov byte [eax],65
hlt 
ret
To test my loader. Currently my OS just loads raw binary data. The code to execute it is:
        public static unsafe void LoadAndRun(byte* instructions)
        {
            byte** address = &instructions;
            uint ptr = (uint)address;
            Terminal.WriteInfo("Perparing to began execution at: " + ((int)ptr).ToString());
            new CPUx86.Call { DestinationValue = ptr};
        }
When I run my OS I get an error Type 0x00000007 , MethodIndex = 0x000000384 NOT FOUND!. Am I missing something???

 

Read the full discussion online.

To add a post to this discussion, reply to this email (Cosmos@discussions.codeplex.com)

To start a new discussion for this project, email Cosmos@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com


I am such an idiot, yeah I just figured that out. 

Coordinator
Aug 26, 2012 at 6:54 PM

A kernel shouldn't use the compiler/assembler libraries unless you're writing plugs.

Op 26 aug. 2012 19:08 schreef "gungan37" <notifications@codeplex.com> het volgende:

From: gungan37

I get this error too! I am using Userkit 92560 and compiled the Devkit of the same version and referenced its Assembler libraries. Maybe Kudzu could shed some light on this?

Read the full discussion online.

To add a post to this discussion, reply to this email (Cosmos@discussions.codeplex.com)

To start a new discussion for this project, email Cosmos@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com

Aug 27, 2012 at 1:25 AM

Ahh... my mistake. So if something is attributed as a plug, it will be compile into its respective x86 Assembly code at compile time and run without error?

Coordinator
Aug 27, 2012 at 7:54 AM
if all things are done appropriately, yes..


On Mon, Aug 27, 2012 at 2:25 AM, gungan37 <notifications@codeplex.com> wrote:

From: gungan37

Ahh... my mistake. So if something is attributed as a plug, it will be compile into its respective x86 Assembly code at compile time and run without error?

Read the full discussion online.

To add a post to this discussion, reply to this email (Cosmos@discussions.codeplex.com)

To start a new discussion for this project, email Cosmos@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com


Aug 28, 2012 at 1:14 AM

Why is it not possible to use load some assembly into memory, make sure the last instruction jumps back to the previous line of kernel code, then continue execution?  

Aug 28, 2012 at 1:50 AM
LukeTerry wrote:

Why is it not possible to use load some assembly into memory, make sure the last instruction jumps back to the previous line of kernel code, then continue execution?  

Because you need to call the assembly code to actually execute it and you can not call memory addresses in c#

Aug 28, 2012 at 2:26 AM

Thanks, mterwoord, you have really helped clear up this issue! Luke and Grunt, why not just plug a call method (good plugs tutorial: http://www.codeproject.com/Articles/220076/Csharp-Open-Source-Managed-Operating-System-Intro) in C# with X# / Inline x86 assembly then use the memory write routines to load the file, then call the plugged call method?

Aug 28, 2012 at 10:39 AM
GruntXProductions wrote:
LukeTerry wrote:

Why is it not possible to use load some assembly into memory, make sure the last instruction jumps back to the previous line of kernel code, then continue execution?  

Because you need to call the assembly code to actually execute it and you can not call memory addresses in c#

But you can in assembly, and that's what COSMOS compiles to, and uses in some places, so it shouldn't be such a hard thing to do. I guess gungan37 is right though, writing a plug in X# for some oddball method would be useful.

Aug 28, 2012 at 10:43 PM

It isn't really that hard. All you have to do is designate the section of code as an Assembly Plug, then make an empty C# / VB / F# method for it to plug. This is just so the compiler compiles it into assembly rather than trying to convert the IL compilation to real-time code (since assembly must be pre-compiled, this will not work). Plugging is a good route to go, but remember that if COSMOS supports additional architectures in the future, your plug won't work.

Aug 28, 2012 at 10:59 PM
Edited Aug 28, 2012 at 11:00 PM

Here is the code I wrote (C#) to call an address.  First, I made a blank C# method and then plugged it using the old-fashioned plugging method (rather than X# since I am more used to the old method):

 

using Cosmos.IL2CPU.Plugs;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Assembler = Cosmos.Assembler.Assembler;
using CPUAll = Cosmos.Assembler;
using CPUx86 = Cosmos.Assembler.x86;
using Cosmos.Assembler.x86;

namespace CosmosKernel1.Plugs
{
    public static class Call
    {
        public static void CallAddress(uint Address) { }
    }

    [Plug(Target = typeof(CosmosKernel1.Plugs.Call))]
    static class PluggedCall
    {
        [Inline]
        private static void CallAddress(uint Address)
        {
            new CPUx86.Call { DestinationValue = Address };
        }
    }
}

I haven't tested it, so correct me if I did something wrong. This code will be going into the OS I am currently writing, so please give me (gungan37) credit if you decide to use it in yours =).

Coordinator
Aug 29, 2012 at 7:54 AM
Would you be interested in joining the project as one of the developers? ie work on cosmos core stuff?



On Tue, Aug 28, 2012 at 11:59 PM, gungan37 <notifications@codeplex.com> wrote:

From: gungan37

Here is the code I wrote (C#) to call an address. First, I made a blank C# method and then plugged it using the old-fashioned plugging method (rather than X# since I am more used to the old method):

using Cosmos.IL2CPU.Plugs;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Assembler = Cosmos.Assembler.Assembler;
using CPUAll = Cosmos.Assembler;
using CPUx86 = Cosmos.Assembler.x86;
using Cosmos.Assembler.x86;

namespace CosmosKernel1.Plugs
{
    public static class Call
    {
        public static void CallAddress(uint Address) { }
    }

    [Plug(Target = typeof(CosmosKernel1.Plugs.Call))]
    static class PluggedCall
    {
        [Inline]
        private static void CallAddress(uint Address)
        {
            new CPUx86.Call { DestinationValue = Address };
        }
    }
}

Read the full discussion online.

To add a post to this discussion, reply to this email (Cosmos@discussions.codeplex.com)

To start a new discussion for this project, email Cosmos@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com


Aug 30, 2012 at 12:27 AM

I just sent a request, thanks for the idea! I will be pretty busy with high school but could certainly write some code on weeknights and weekends. 

Aug 30, 2012 at 2:01 AM
gungan37 wrote:

Here is the code I wrote (C#) to call an address.  First, I made a blank C# method and then plugged it using the old-fashioned plugging method (rather than X# since I am more used to the old method):

 

using Cosmos.IL2CPU.Plugs;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Assembler = Cosmos.Assembler.Assembler;
using CPUAll = Cosmos.Assembler;
using CPUx86 = Cosmos.Assembler.x86;
using Cosmos.Assembler.x86;

namespace CosmosKernel1.Plugs
{
    public static class Call
    {
        public static void CallAddress(uint Address) { }
    }

    [Plug(Target = typeof(CosmosKernel1.Plugs.Call))]
    static class PluggedCall
    {
        [Inline]
        private static void CallAddress(uint Address)
        {
            new CPUx86.Call { DestinationValue = Address };
        }
    }
}

I haven't tested it, so correct me if I did something wrong. This code will be going into the OS I am currently writing, so please give me (gungan37) credit if you decide to use it in yours =).

Thanks but I no longer need it. I wrote a tool that lets me mix real assembly and cosmos.

Aug 30, 2012 at 11:11 PM

Oh, awesome! If you wouldn't mind, could you please email me a copy of that tool (gungan37 at gmail dot com). Thanks!

Sep 1, 2012 at 1:43 AM
gungan37 wrote:

Oh, awesome! If you wouldn't mind, could you please email me a copy of that tool (gungan37 at gmail dot com). Thanks!

It is kind of made just for my OS. It isnt that hard to make something like that though. Basically it replaces the NASM.exe inside the cosmos folder and adds extra assembly to the input file before passing it on to the real NASM. Quite simple , but it works and is easy to implement. 

Sep 2, 2012 at 5:34 AM

Oh, okay I understand. Thanks for the steps on how you did it, I will likely do the same =)