[SOLVED] IRQ12

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.
Post Reply
Klakap
Member
Member
Posts: 299
Joined: Sat Mar 10, 2018 10:16 am

[SOLVED] IRQ12

Post by Klakap »

Good day!
Please tell me what command should I write to work interrupt IRQ12 if I already have a set up IDT? For example, for the functioning of the IRQ1 is outb(0x21 , 0xFD); What such a command should I write to work IRQ12?
Last edited by Klakap on Thu Apr 19, 2018 10:44 am, edited 1 time in total.
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: IRQ12

Post by Brendan »

Hi,
Klakap wrote:Please tell me what command should I write to work interrupt IRQ12 if I already have a set up IDT? For example, for the functioning of the IRQ1 is outb(0x21 , 0xFD); What such a command should I write to work IRQ12?
The "outb(0x21 , 0xFD)" doesn't just unmask IRQ1, it masks everything else in the master PIC, and "everything else" includes the cascade line that the slave PIC is connected to.

What you really want is a pair of functions like "mask_IRQ(int IRQ_number);" and "unmask_IRQ(int IRQ_number);" that any code that wants to mask or unmask any IRQ can use safely (without upsetting the cascade line or any other IRQs). There is example code for these functions in the wiki.


Cheers,

Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
Klakap
Member
Member
Posts: 299
Joined: Sat Mar 10, 2018 10:16 am

Re: IRQ12

Post by Klakap »

When I copied the code to https://wiki.osdev.org/PIC#Masking and I wrote instead of outb(0x21, 0xFD); command IRQ_set_mask(1); IRQ1 didn't work. Please write me how do I properly call the method IRQ_set_mask(); to give me the interrupts of work.
User avatar
iansjack
Member
Member
Posts: 4706
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: IRQ12

Post by iansjack »

You set the mask on IRQ1 and then IRQ1 didn't work. Isn't that exactly what you would expect? You need to clear the mask to enable the line.
Klakap
Member
Member
Posts: 299
Joined: Sat Mar 10, 2018 10:16 am

Re: IRQ12

Post by Klakap »

Maybe I have wrong set up IRQ12 in the IDT. I proceeded according to arjunsreedharan.org/post/99370248137/kernel-201-lets-write-a-kernel-with-keyboard and according to this tutorial I IRQ12 is set by the commands:

/* populate IDT entry of the mouse's interrupt */
mouse_address = (unsigned long)mouse_handler;
IDT[0x32].offset_lowerbits = mouse_address & 0xffff;
IDT[0x32].selector = 0x08; /* KERNEL_CODE_SEGMENT_OFFSET */
IDT[0x32].zero = 0;
IDT[0x32].type_attr = 0x8e; /* INTERRUPT_GATE */
IDT[0x32].offset_higherbits = (mouse_address & 0xffff0000) >> 16;

Is this correct? If not, please tell me how do I change.
User avatar
iansjack
Member
Member
Posts: 4706
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: IRQ12

Post by iansjack »

Rather than blindly following dubious tutorials you would be better employed studying the various chips and how to program them. That way you will understand what you are doing rather than just copying code.
Klakap
Member
Member
Posts: 299
Joined: Sat Mar 10, 2018 10:16 am

Re: IRQ12

Post by Klakap »

I will ask a very silly question, calling qemu IRQ12?
Klakap
Member
Member
Posts: 299
Joined: Sat Mar 10, 2018 10:16 am

Re: IRQ12

Post by Klakap »

I've already figured out what the problem is, when I press some key, qemu calls the IRQ1 and IRQ12 but when move the mouse so IRQ12 calling only one time. Please help me. Code:

Code: Select all

/*PIC*/
outb(0x20, 0x11);
  outb(0xA0, 0x11);
  outb(0x21, 0x20);
  outb(0xA1, 40);
  outb(0x21, 0x04);
  outb(0xA1, 0x02);
  outb(0x21, 0x01);
  outb(0xA1, 0x01);
  outb(0x21, 0x0);
  outb(0xA1, 0x0);

	irq0_address = (unsigned long)irq0; 
	IDT[32].offset_lowerbits = irq0_address & 0xffff;
	IDT[32].selector = 0x08; /* KERNEL_CODE_SEGMENT_OFFSET */
	IDT[32].zero = 0;
	IDT[32].type_attr = 0x8e; /* INTERRUPT_GATE */
	IDT[32].offset_higherbits = (irq0_address & 0xffff0000) >> 16;

	irq1_address = (unsigned long)irq1; 
	IDT[33].offset_lowerbits = irq1_address & 0xffff;
	IDT[33].selector = 0x08; /* KERNEL_CODE_SEGMENT_OFFSET */
	IDT[33].zero = 0;
	IDT[33].type_attr = 0x8e; /* INTERRUPT_GATE */
	IDT[33].offset_higherbits = (irq1_address & 0xffff0000) >> 16;


	irq12_address = (unsigned long)irq12; 
	IDT[44].offset_lowerbits = irq12_address & 0xffff;
	IDT[44].selector = 0x08; /* KERNEL_CODE_SEGMENT_OFFSET */
	IDT[44].zero = 0;
	IDT[44].type_attr = 0x8e; /* INTERRUPT_GATE */
	IDT[44].offset_higherbits = (irq12_address & 0xffff0000) >> 16;



	/* fill the IDT descriptor */
	idt_address = (unsigned long)IDT ;
	idt_ptr[0] = (sizeof (struct IDT_entry) * 286) + ((idt_address & 0xffff) << 16);
	idt_ptr[1] = idt_address >> 16 ;

	load_idt(idt_ptr);
Klakap
Member
Member
Posts: 299
Joined: Sat Mar 10, 2018 10:16 am

Re: IRQ12

Post by Klakap »

I have already this problem is resolved. I forgot the fact, the load input from port 0x60 because I am irq12_handler used only to list on the screen how many times was the handler of the call. When I added the command inb(0x60) interrupts work correctly.
Post Reply