Custom Interrupt handler not working?

Topics: Off Topic, Other, Using Cosmos (Developing your own OS, projects, etc)
Aug 30, 2012 at 4:43 PM

Hello, I am using this code to write a custom software interrupt to the IDT. The code I am using is

Cosmos.Core.INTs.SetIntHandler(32, HandleTestInt);

The code for HandleTestInt is

 

unsafe void HandleTestInt(ref Cosmos.Core.INTs.IRQContext info)
        {
            Terminal.WriteLine("Hello World!");
            Terminal.ReadLine();
        }

Now when called from an external program in assembly nothing appears to happen. Is custom interrupt handling not implemented yet or is there something wrong with my code. 

Coordinator
Aug 30, 2012 at 5:00 PM
On 8/30/2012 12:43 PM, Grunt wrote:
> Cosmos.Core.INTs.SetIntHandler(32, HandleTestInt);
>
> The code for HandleTestInt is
>
> unsafe void HandleTestInt(ref Cosmos.Core.INTs.IRQContext info)
> {
> Terminal.WriteLine("Hello World!");
> Terminal.ReadLine();
> }
>
> Now when called from an external program in assembly nothing appears to
> happen. Is custom interrupt handling not implemented yet or is there
> something wrong with my code.

Interrupts are currently disabled.
Coordinator
Aug 30, 2012 at 5:02 PM
So how is keyboard input then handled?


On Thu, Aug 30, 2012 at 7:00 PM, kudzu <notifications@codeplex.com> wrote:

From: kudzu

On 8/30/2012 12:43 PM, Grunt wrote:
> Cosmos.Core.INTs.SetIntHandler(32, HandleTestInt);
>
> The code for HandleTestInt is
>
> unsafe void HandleTestInt(ref Cosmos.Core.INTs.IRQContext info)
> {
> Terminal.WriteLine("Hello World!");
> Terminal.ReadLine();
> }
>
> Now when called from an external program in assembly nothing appears to
> happen. Is custom interrupt handling not implemented yet or is there
> something wrong with my code.

Interrupts are currently disabled.

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


Coordinator
Aug 30, 2012 at 5:04 PM
On 8/30/2012 1:02 PM, mterwoord wrote:
> So how is keyboard input then handled?

I dont remember. :)
Aug 30, 2012 at 5:06 PM
kudzu wrote:
On 8/30/2012 1:02 PM, mterwoord wrote:
> So how is keyboard input then handled?

I dont remember. :)

Isn't the keyboard handled by int 0x21 , I can attach a handler to that one just fine but it gets called every time I press a key.

Coordinator
Aug 30, 2012 at 5:31 PM
SOmething like that sounds right..
It may be that the PIC blocks all other interrupts?


On Thu, Aug 30, 2012 at 7:06 PM, Grunt <notifications@codeplex.com> wrote:

From: Grunt

kudzu wrote:
On 8/30/2012 1:02 PM, mterwoord wrote:
> So how is keyboard input then handled?

I dont remember. :)

Isn't the keyboard handled by int 0x21 , I can attach a handler to that one just fine but it gets called every time I press a key.

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


Sep 2, 2012 at 4:38 AM

What you can do Grunt, is go into the Cosmos.Core folder and modify the INTs.cs file. The part in which the ***CPU EXCEPTION: 0xXX*** is written to the screen, get the interrupt vector from ctx.Interrupt, then use a series of if statements for the current interrupt, then write your custom routines, compile and then reference Cosmos.Core.dll in your OS. A bit hacky, but I have done it and it works =)

Sep 2, 2012 at 4:38 AM
Edited Sep 2, 2012 at 4:49 AM

Also, please remember that interrupts don't interrupt the OS until the next keystroke (as far as I know).

Sep 2, 2012 at 5:55 AM
gungan37 wrote:

What you can do Grunt, is go into the Cosmos.Core folder and modify the INTs.cs file. The part in which the ***CPU EXCEPTION: 0xXX*** is written to the screen, get the interrupt vector from ctx.Interrupt, then use a series of if statements for the current interrupt, then write your custom routines, compile and then reference Cosmos.Core.dll in your OS. A bit hacky, but I have done it and it works =)

Yeah that could probably work but again I did some modifications to get it working ( http://www.youtube.com/watch?v=FxJvNTGLSzo ). That also though is a bit more hacky though. Now my only problem is getting IRQ0 to work properly , but  I think I am almost there too

Sep 2, 2012 at 3:54 PM

Awesome! Sorry to bug you, but how did you get the reboot code working (the plugged call doesn't work for me)?

Sep 2, 2012 at 6:04 PM
gungan37 wrote:

Awesome! Sorry to bug you, but how did you get the reboot code working (the plugged call doesn't work for me)?

yeah the plug doesn't work. I had to rewrite it.

public static void Reboot()
    {
        byte good = 0x02;
        while ((good & 0x02) != 0)
            good = GruntyOS.IO.Ports.Inb(0x64);
        GruntyOS.IO.Ports.Outb(0x64, 0xFE);
        GruntyOS.Assembly.CLI();
	GruntyOS.Assembly.HLT();
    }
Replace the CLI and HLT with 

Cosmos.Core.Global.CPU.Halt();

 The code for inb and outb is

	static Cosmos.Core.IOPort io = new Cosmos.Core.IOPort(0);
        static int PP = 0, D = 0;
        public static void Outb(ushort port, byte data)
        {
            if(io.Port != port)
                io = new Cosmos.Core.IOPort(port);
            io.Byte = data;
            PP = port;
            D = data;
            
        }
        public static byte Inb(ushort port)
        {
            if (io.Port != port)
                io = new Cosmos.Core.IOPort(port);
            return io.Byte;

        }
 

Sep 3, 2012 at 2:13 AM

Thank you! Works very well! I appreciate it.