How can i remap IRQ1? [SOLVED: Stop replying.]

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
NunoLava1998
Member
Member
Posts: 273
Joined: Sun Oct 09, 2016 4:38 am
Libera.chat IRC: NunoLava1998

How can i remap IRQ1? [SOLVED: Stop replying.]

Post by NunoLava1998 »

For my keyboard handler, i need to remap IRQ1. However, i find barely any code on this, and the code that is provided doesn't work.
I tried doing the following:

Code: Select all

void PIC_remap(void) {
	asm(".intel_syntax noprefix");
	asm("mov al, 0x11");
	asm("out 0x20, al");
	asm("out 0xA0, al");
	asm("mov al, 0x20");
	asm("out 0x21, al");
	asm("mov al, 0x28");
	asm("out 0xA1, al");
	asm("mov al, 0x04");
	asm("out 0x21, al");
	asm("mov al, 0x02");
	asm("out 0xA1, al");
	asm("mov al, 0x01");
	asm("out 0x21, al");
	asm("out 0xA1, al");
}
However, this gives out this during my build.bat (i'm in windows so instead of using a makefile i will use a batch file):

Code: Select all

C:\Users\Nuno\AppData\Local\Temp\ccyCmahd.s: Assembler messages:
C:\Users\Nuno\AppData\Local\Temp\ccyCmahd.s:330: Error: no such instruction: `subl $4,%esp'
C:\Users\Nuno\AppData\Local\Temp\ccyCmahd.s:334: Error: operand size mismatch for `in'
C:\Users\Nuno\AppData\Local\Temp\ccyCmahd.s:337: Error: operand type mismatch for `movzbl'
C:\Users\Nuno\AppData\Local\Temp\ccyCmahd.s:338: Error: junk `(%eax)' after expression
C:\Users\Nuno\AppData\Local\Temp\ccyCmahd.s:339: Error: no such instruction: `movl %eax,(%esp)'
C:\Users\Nuno\AppData\Local\Temp\ccyCmahd.s:341: Error: no such instruction: `addl $4,%esp'
C:\Users\Nuno\AppData\Local\Temp\ccyCmahd.s:355: Error: operand size mismatch for `in'
C:\Users\Nuno\AppData\Local\Temp\ccyCmahd.s:363: Error: no such instruction: `subl $4,%esp'
C:\Users\Nuno\AppData\Local\Temp\ccyCmahd.s:367: Error: operand size mismatch for `in'
C:\Users\Nuno\AppData\Local\Temp\ccyCmahd.s:370: Error: operand type mismatch for `movzbl'
C:\Users\Nuno\AppData\Local\Temp\ccyCmahd.s:371: Error: junk `(%eax)' after expression
C:\Users\Nuno\AppData\Local\Temp\ccyCmahd.s:372: Error: no such instruction: `movl %eax,(%esp)'
C:\Users\Nuno\AppData\Local\Temp\ccyCmahd.s:374: Error: no such instruction: `addl $4,%esp'
i686-elf-gcc: error: kernel.o: No such file or directory
How do i successfully remap IRQ1? (I only need IRQ1, as i don't find a use for IRQ2 and what i need relies on IRQ1 anyway).

My keyboard handler is complete, it only needs a working IRQ remapper. And yes, i did write most of the additional code that was needed in order for it to stop spamming 7's ("7 "'s if nulls are not ignored in putchar) when the mouse was moved and filled the screen with whatever character was pressed.
Last edited by NunoLava1998 on Tue Dec 20, 2016 6:26 am, edited 1 time in total.
Developing TRIODIUM OS. Or call it Dixium if you want. It doesn't matter.

https://github.com/NunoLava1998/DixiumOS
Octocontrabass
Member
Member
Posts: 5587
Joined: Mon Mar 25, 2013 7:01 pm

Re: How can i remap IRQ1?

Post by Octocontrabass »

The example code is only an example, not something you can copy and paste. You must understand what it does, and translate it into a format usable in your OS - in your case specifically, you would rewrite it in C using outb().

By the way, every single one of your asm() statements is wrong. Writing correct inline assembly for GCC is extremely difficult and should be avoided whenever possible.
NunoLava1998
Member
Member
Posts: 273
Joined: Sun Oct 09, 2016 4:38 am
Libera.chat IRC: NunoLava1998

Re: How can i remap IRQ1?

Post by NunoLava1998 »

Octocontrabass wrote:The example code is only an example, not something you can copy and paste. You must understand what it does, and translate it into a format usable in your OS - in your case specifically, you would rewrite it in C using outb().

By the way, every single one of your asm() statements is wrong. Writing correct inline assembly for GCC is extremely difficult and should be avoided whenever possible.
I am not trying to point out that. I am trying to find a alternative way, nothing else. I need this for my keyboard controller to work properly (so it doesn't do weird things, for some reason it writes 7's and a null at a random position every time the mouse moves a bit.).
Developing TRIODIUM OS. Or call it Dixium if you want. It doesn't matter.

https://github.com/NunoLava1998/DixiumOS
User avatar
sleephacker
Member
Member
Posts: 97
Joined: Thu Aug 06, 2015 6:41 am
Location: Netherlands

Re: How can i remap IRQ1?

Post by sleephacker »

NunoLava1998 wrote:for some reason it writes 7's and a null at a random position every time the mouse moves a bit
Do you happen to have a (emulated) PS/2 mouse?
Octocontrabass
Member
Member
Posts: 5587
Joined: Mon Mar 25, 2013 7:01 pm

Re: How can i remap IRQ1?

Post by Octocontrabass »

NunoLava1998 wrote:I am trying to find a alternative way, nothing else.
Do you understand what the example code does?
NunoLava1998 wrote:I need this for my keyboard controller to work properly (so it doesn't do weird things, for some reason it writes 7's and a null at a random position every time the mouse moves a bit.).
The PS/2 controller does more than just provide keyboard input. You'll need to initialize it to get it to behave in a predictable way, although you might be able to just disable the mouse port until you're ready to completely initialize it.
NunoLava1998
Member
Member
Posts: 273
Joined: Sun Oct 09, 2016 4:38 am
Libera.chat IRC: NunoLava1998

Re: How can i remap IRQ1?

Post by NunoLava1998 »

sleephacker wrote:
NunoLava1998 wrote:for some reason it writes 7's and a null at a random position every time the mouse moves a bit
Do you happen to have a (emulated) PS/2 mouse?
I was running this on QEMU, and my mouse is PS/2.

If putchar ignores nulls, it's only "7".
If it doesn't, it's "7" plus a null character (0x00).
Developing TRIODIUM OS. Or call it Dixium if you want. It doesn't matter.

https://github.com/NunoLava1998/DixiumOS
NunoLava1998
Member
Member
Posts: 273
Joined: Sun Oct 09, 2016 4:38 am
Libera.chat IRC: NunoLava1998

Re: How can i remap IRQ1?

Post by NunoLava1998 »

I think i remapped, however it seems to be ignoring that the only way to get into the keyboard handler is an IRQ 1, however it's of course ignoring that.

EDIT:
Horray! Done! The only thing i need to fix is to somehow make my emulator NOT restart when i press a key. I still get 7's, but i can fix that later.
Developing TRIODIUM OS. Or call it Dixium if you want. It doesn't matter.

https://github.com/NunoLava1998/DixiumOS
User avatar
iansjack
Member
Member
Posts: 4706
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: How can i remap IRQ1?

Post by iansjack »

"I think...."

"It seems...."

You really ought to try to work with facts rather than conjectures. What makes you believe either of these statements? Rest assured that your computer isn't capable of independent thoughts; it only does what you tell it to, and only ignores what you tell it to ignore.

It would be useful if you gave a more coherent account of what you have done and what the result is.
User avatar
bauen1
Member
Member
Posts: 29
Joined: Sun Dec 11, 2016 3:31 am
Libera.chat IRC: bauen1
Location: In your computer
Contact:

Re: How can i remap IRQ1?

Post by bauen1 »

(you shouldn't copy past and shouldn't put .c files in a directory called include but i'm gonna answer this anyway)
When you add a

Code: Select all

asm(".intel_syntax noprefix");
gcc switches the syntax used in asm statements to intel syntax without prefix, however you don't change the syntax back to the normal one used so gas will error because the next asm seems like "garbage" under the current settings => you need to switch the syntax back to what it was

(google how to do this its not hard and maybe you will learn something in the process)
myunix (version 3) (name suggestions are welcome!)
GPG Key fingerprint: 5ED6 D826 ACD4 3F8E D9D4 FBB2 FF0A AF5E 0812 BA9C
NunoLava1998
Member
Member
Posts: 273
Joined: Sun Oct 09, 2016 4:38 am
Libera.chat IRC: NunoLava1998

Re: How can i remap IRQ1?

Post by NunoLava1998 »

bauen1 wrote:(you shouldn't copy past and shouldn't put .c files in a directory called include but i'm gonna answer this anyway)
When you add a

Code: Select all

asm(".intel_syntax noprefix");
gcc switches the syntax used in asm statements to intel syntax without prefix, however you don't change the syntax back to the normal one used so gas will error because the next asm seems like "garbage" under the current settings => you need to switch the syntax back to what it was

(google how to do this its not hard and maybe you will learn something in the process)

I already fixed the issue, i simply had to use the OSDev original with some definitions.
Worked perfectly.
I just need to find out how to do some more stuff for IRQ1 to not triple-fault (as i somehow was intelligent enough to not load the IDT)
Last edited by NunoLava1998 on Tue Dec 20, 2016 7:32 am, edited 1 time in total.
Developing TRIODIUM OS. Or call it Dixium if you want. It doesn't matter.

https://github.com/NunoLava1998/DixiumOS
User avatar
iansjack
Member
Member
Posts: 4706
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: How can i remap IRQ1?

Post by iansjack »

I'm glad to hear that you have solved your problem (though some nit-pickers might say that triple-faulting when a key is pressed falls a little short of "working perfectly").
NunoLava1998
Member
Member
Posts: 273
Joined: Sun Oct 09, 2016 4:38 am
Libera.chat IRC: NunoLava1998

Re: How can i remap IRQ1?

Post by NunoLava1998 »

iansjack wrote:I'm glad to hear that you have solved your problem (though some nit-pickers might say that triple-faulting when a key is pressed falls a little short of "working perfectly").
Yep. However, triple faulting is actually fault of IRQ1's, but they're actually doing fine, it's the fact i didn't load the IDT. Which has no code that i know, only prerequisite code.
Again, i'm absolutely not into interrupt stuff. I know how they work, but loading interrupts? Uh.. absolutely not.
Developing TRIODIUM OS. Or call it Dixium if you want. It doesn't matter.

https://github.com/NunoLava1998/DixiumOS
User avatar
iansjack
Member
Member
Posts: 4706
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: How can i remap IRQ1?

Post by iansjack »

Oh dear! :(
User avatar
sleephacker
Member
Member
Posts: 97
Joined: Thu Aug 06, 2015 6:41 am
Location: Netherlands

Re: How can i remap IRQ1?

Post by sleephacker »

NunoLava1998 wrote:loading interrupts? Uh.. absolutely not.
You do realise that x86 is an interrupt driven architecture?
NunoLava1998
Member
Member
Posts: 273
Joined: Sun Oct 09, 2016 4:38 am
Libera.chat IRC: NunoLava1998

Re: How can i remap IRQ1?

Post by NunoLava1998 »

sleephacker wrote:
NunoLava1998 wrote:loading interrupts? Uh.. absolutely not.
You do realise that x86 is an interrupt driven architecture?
Yes.
By "loading interrupts" i meant:

"the base size is 32 and will fit in a float, as the base = 16 and size = base*2 (32), also put the segment into bit 37 and 110101 for 32bit in bit 45..51, then do lidt pointing to the se-"
stuff like that.
Developing TRIODIUM OS. Or call it Dixium if you want. It doesn't matter.

https://github.com/NunoLava1998/DixiumOS
Post Reply