OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 7:31 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 19 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: How can i remap IRQ1? [SOLVED: Stop replying.]
PostPosted: Mon Dec 19, 2016 1:06 pm 
Offline
Member
Member

Joined: Sun Oct 09, 2016 4:38 am
Posts: 273
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:
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:
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.

_________________
Developing TRIODIUM OS. Or call it Dixium if you want. It doesn't matter.

https://github.com/NunoLava1998/DixiumOS


Last edited by NunoLava1998 on Tue Dec 20, 2016 6:26 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: How can i remap IRQ1?
PostPosted: Mon Dec 19, 2016 1:35 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5099
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.


Top
 Profile  
 
 Post subject: Re: How can i remap IRQ1?
PostPosted: Mon Dec 19, 2016 2:14 pm 
Offline
Member
Member

Joined: Sun Oct 09, 2016 4:38 am
Posts: 273
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


Top
 Profile  
 
 Post subject: Re: How can i remap IRQ1?
PostPosted: Mon Dec 19, 2016 2:42 pm 
Offline
Member
Member
User avatar

Joined: Thu Aug 06, 2015 6:41 am
Posts: 97
Location: Netherlands
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?


Top
 Profile  
 
 Post subject: Re: How can i remap IRQ1?
PostPosted: Mon Dec 19, 2016 3:00 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5099
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.


Top
 Profile  
 
 Post subject: Re: How can i remap IRQ1?
PostPosted: Mon Dec 19, 2016 3:01 pm 
Offline
Member
Member

Joined: Sun Oct 09, 2016 4:38 am
Posts: 273
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


Top
 Profile  
 
 Post subject: Re: How can i remap IRQ1?
PostPosted: Tue Dec 20, 2016 1:24 am 
Offline
Member
Member

Joined: Sun Oct 09, 2016 4:38 am
Posts: 273
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


Top
 Profile  
 
 Post subject: Re: How can i remap IRQ1?
PostPosted: Tue Dec 20, 2016 1:37 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4591
Location: Chichester, UK
"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.


Top
 Profile  
 
 Post subject: Re: How can i remap IRQ1?
PostPosted: Tue Dec 20, 2016 6:14 am 
Offline
Member
Member
User avatar

Joined: Sun Dec 11, 2016 3:31 am
Posts: 29
Location: In your computer
(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:
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


Top
 Profile  
 
 Post subject: Re: How can i remap IRQ1?
PostPosted: Tue Dec 20, 2016 6:26 am 
Offline
Member
Member

Joined: Sun Oct 09, 2016 4:38 am
Posts: 273
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:
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)

_________________
Developing TRIODIUM OS. Or call it Dixium if you want. It doesn't matter.

https://github.com/NunoLava1998/DixiumOS


Last edited by NunoLava1998 on Tue Dec 20, 2016 7:32 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: How can i remap IRQ1?
PostPosted: Tue Dec 20, 2016 7:00 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4591
Location: Chichester, UK
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").


Top
 Profile  
 
 Post subject: Re: How can i remap IRQ1?
PostPosted: Tue Dec 20, 2016 7:32 am 
Offline
Member
Member

Joined: Sun Oct 09, 2016 4:38 am
Posts: 273
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


Top
 Profile  
 
 Post subject: Re: How can i remap IRQ1?
PostPosted: Tue Dec 20, 2016 8:52 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4591
Location: Chichester, UK
Oh dear! :(


Top
 Profile  
 
 Post subject: Re: How can i remap IRQ1?
PostPosted: Tue Dec 20, 2016 10:22 am 
Offline
Member
Member
User avatar

Joined: Thu Aug 06, 2015 6:41 am
Posts: 97
Location: Netherlands
NunoLava1998 wrote:
loading interrupts? Uh.. absolutely not.

You do realise that x86 is an interrupt driven architecture?


Top
 Profile  
 
 Post subject: Re: How can i remap IRQ1?
PostPosted: Tue Dec 20, 2016 10:44 am 
Offline
Member
Member

Joined: Sun Oct 09, 2016 4:38 am
Posts: 273
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 19 posts ]  Go to page 1, 2  Next

All times are UTC - 6 hours


Who is online

Users browsing this forum: DotBot [Bot], SemrushBot [Bot] and 65 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group