Mouse Location Always Zero

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.
User avatar
Octacone
Member
Member
Posts: 1138
Joined: Fri Aug 07, 2015 6:13 am

Mouse Location Always Zero

Post by Octacone »

I used this tutorial for my mouse driver: http://forum.osdev.org/viewtopic.php?t=10247
When I use my debug tool to see if the mouse has moved, I always get zero for both x and y.
I've been debugging for past two days and can not find what the issue is. :/
What could be a problem.
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
sebihepp
Member
Member
Posts: 190
Joined: Tue Aug 26, 2008 11:24 am
GitHub: https://github.com/sebihepp

Re: Mouse Location Always Zero

Post by sebihepp »

Do you have working interrupts?

I think the irq_install could be a common mistake, because it uses 12 as IRQ. In PMode there are Exceptions from 0x0 to 0x1F, so you need to remap the PIC. An the 12 is therefore not the 12. Exception, but the twelvth line of the PIC. Perhaps that's your mistake?
User avatar
Octacone
Member
Member
Posts: 1138
Joined: Fri Aug 07, 2015 6:13 am

Re: Mouse Location Always Zero

Post by Octacone »

sebihepp wrote:Do you have working interrupts?

I think the irq_install could be a common mistake, because it uses 12 as IRQ. In PMode there are Exceptions from 0x0 to 0x1F, so you need to remap the PIC. An the 12 is therefore not the 12. Exception, but the twelvth line of the PIC. Perhaps that's your mistake?
Yeah I think my interrupts are working fine.
I have a function that remaps IRQs.
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Mouse Location Always Zero

Post by Combuster »

Having code doesn't mean it works :wink:. The fact that you're not even telling us if you're getting interrupt 44 strongly suggests it doesn't.

Hint: If you have to write "I think" you usually did something wrong you could have already fixed.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
Octacone
Member
Member
Posts: 1138
Joined: Fri Aug 07, 2015 6:13 am

Re: Mouse Location Always Zero

Post by Octacone »

Combuster wrote:Having code doesn't mean it works :wink:. The fact that you're not even telling us if you're getting interrupt 44 strongly suggests it doesn't.

Hint: If you have to write "I think" you usually did something wrong you could have already fixed.
How am I supposed to tell if I am getting interrupt 44 when I don't have a way of seeing that. :?: :D
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
User avatar
neon
Member
Member
Posts: 1567
Joined: Sun Feb 18, 2007 7:28 pm
Contact:

Re: Mouse Location Always Zero

Post by neon »

Well, make a way to see it then. You really should have debugging services implemented prior to going into graphics. Its better to implement a protocol now rather then later on when it becomes much more harder. Options include, but are not limited to (1) display something on the screen, anything; (2) serial output; (3) stay in text mode and print the mouse status and interrupt information. In the long term, serial output is the way to go. Never assume your code works - verify that it actually works.

You mentioned using a debugging tool, so what prevents you from using it to check this?

With that said, sebihepp is right - looking over the code, it can't be simply copied and pasted. Depending on your architecture and where your PIC maps physical irq 12 to, your code will be slightly different. IIRC the way most tutorials map the PIC would map physical irq 12 to logical irq 44 but again, its all up to what you did in your code.
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
User avatar
Octacone
Member
Member
Posts: 1138
Joined: Fri Aug 07, 2015 6:13 am

Re: Mouse Location Always Zero

Post by Octacone »

neon wrote:Well, make a way to see it then. You really should have debugging services implemented prior to going into graphics. Its better to implement a protocol now rather then later on when it becomes much more harder. Options include, but are not limited to (1) display something on the screen, anything; (2) serial output; (3) stay in text mode and print the mouse status and interrupt information. In the long term, serial output is the way to go. Never assume your code works - verify that it actually works.

You mentioned using a debugging tool, so what prevents you from using it to check this?

With that said, sebihepp is right - looking over the code, it can't be simply copied and pasted. Depending on your architecture and where your PIC maps physical irq 12 to, your code will be slightly different. IIRC the way most tutorials map the PIC would map physical irq 12 to logical irq 44 but again, its all up to what you did in your code.

Yeah, I made a simple debugger that talks to QEMU's serial console. I can output text and see the output while my OS is running.
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
User avatar
iansjack
Member
Member
Posts: 4706
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: Mouse Location Always Zero

Post by iansjack »

So you know how to check if the interrupt is firing.
User avatar
Octacone
Member
Member
Posts: 1138
Joined: Fri Aug 07, 2015 6:13 am

Re: Mouse Location Always Zero

Post by Octacone »

iansjack wrote:So you know how to check if the interrupt is firing.
Maybe, I only have my IDT ready, no external interrupts inside assembly.
Also when I initialize my keyboard I can type and see the text, but when I move my mouse characters appear on the screen like I typed them.
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
User avatar
Octacone
Member
Member
Posts: 1138
Joined: Fri Aug 07, 2015 6:13 am

Re: Mouse Location Always Zero

Post by Octacone »

I "remade" my interrupts, now I am getting infinite restart loop. I can see my GUI for a second and then it restarts again and again.
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
User avatar
BrightLight
Member
Member
Posts: 901
Joined: Sat Dec 27, 2014 9:11 am
Location: Maadi, Cairo, Egypt
Contact:

Re: Mouse Location Always Zero

Post by BrightLight »

thehardcoreOS wrote:I "remade" my interrupts, now I am getting infinite restart loop. I can see my GUI for a second and then it restarts again and again.
That doesn't say much. Run it in Bochs and show us the log messages,
You know your OS is advanced when you stop using the Intel programming guide as a reference.
User avatar
Octacone
Member
Member
Posts: 1138
Joined: Fri Aug 07, 2015 6:13 am

Re: Mouse Location Always Zero

Post by Octacone »

omarrx024 wrote:
thehardcoreOS wrote:I "remade" my interrupts, now I am getting infinite restart loop. I can see my GUI for a second and then it restarts again and again.
That doesn't say much. Run it in Bochs and show us the log messages,
That is a very very good idea. Bosch has one really nice debugger.
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
User avatar
Octacone
Member
Member
Posts: 1138
Joined: Fri Aug 07, 2015 6:13 am

Re: Mouse Location Always Zero

Post by Octacone »

Bochs output:

Code: Select all

 using log file bochsout.log
Next at t=0
(0) [0x00000000fffffff0] f000:fff0 (unk. ctxt): jmp far f000:e05b         ; ea5be000f0
<bochs:1> c
(0).[240243672] [0x0000000000000003] 0008:0000000100000003 (unk. ctxt): lock push ebx             ; f053
Next at t=240243673
(0) [0x00000000fffffff0] f000:fff0 (unk. ctxt): jmp far f000:e05b         ; ea5be000f0
When I use QEMU I get infinite restart loop and when I use Bochs it works just fine.
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Mouse Location Always Zero

Post by Combuster »

thehardcoreOS wrote:when I use Bochs it works just fine.
Bochs works just fine, yes, but not your code. It still restarts the CPU on bochs, on the account of executing garbage memory.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
Octacone
Member
Member
Posts: 1138
Joined: Fri Aug 07, 2015 6:13 am

Re: Mouse Location Always Zero

Post by Octacone »

Combuster wrote:
thehardcoreOS wrote:when I use Bochs it works just fine.
Bochs works just fine, yes, but not your code. It still restarts the CPU on bochs, on the account of executing garbage memory.
Ummm... What could be the problem then.
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
Post Reply