How to make sure rtl8139 is connected to the PIC in QEMU
How to make sure rtl8139 is connected to the PIC in QEMU
Hi,
I am writing a driver for rtl8139 network card for my os.
I cannot get the card to fire interrupts.
My question is how to make sure that the card is connected to PIC and if it is not how to connect it.
I am using qemu.
Thanks
Karim.
I am writing a driver for rtl8139 network card for my os.
I cannot get the card to fire interrupts.
My question is how to make sure that the card is connected to PIC and if it is not how to connect it.
I am using qemu.
Thanks
Karim.
Re: How to make sure rtl8139 is connected to the PIC in QEMU
The irq number is found in the pci configuration space. If you dont recieve interrupts make sure that number is not masked in your pic code.
Fudge - Simplicity, clarity and speed.
http://github.com/Jezze/fudge/
http://github.com/Jezze/fudge/
Re: How to make sure rtl8139 is connected to the PIC in QEMU
Yes,
I can read it from the pci configuration space.
It is IRQ Line 11 and and IRQ Pin 1.
I make sure to clear the mask through calling this function with the IRQ Number:
Is that what you mean?
Thanks,
Karim.
I can read it from the pci configuration space.
It is IRQ Line 11 and and IRQ Pin 1.
I make sure to clear the mask through calling this function with the IRQ Number:
Code: Select all
void IRQ_clear_mask(unsigned char IRQline) {
uint16_t port;
uint8_t value;
if(IRQline < 8) {
port = PIC1_DATA;
} else {
port = PIC2_DATA;
IRQline -= 8;
}
value = Ports::inportb(port) & ~(1 << IRQline);
Ports::outportb(port, value);
}
Thanks,
Karim.
Re: How to make sure rtl8139 is connected to the PIC in QEMU
Hi,
Okay, what I have done is that I have compiled qemu with debug info and I have enabled debug inside the rtl8139.c file to see what is going on.
My packets get received by the card and it is copied to the rx buffer, and when I inspected the IntrMask and the IntrStatus of the device I found that their values are:
IntrMask: c07f
IntrStatus: 0001
The documentation at http://wiki.osdev.org/PCI says that bit 3 of the IntrStatus should be set for the interrupt to get fired. I don't know what is the reason for IntrStatus not to be set correctly, and when it should be set?
Any suggestions?
Thanks
Karim
Okay, what I have done is that I have compiled qemu with debug info and I have enabled debug inside the rtl8139.c file to see what is going on.
My packets get received by the card and it is copied to the rx buffer, and when I inspected the IntrMask and the IntrStatus of the device I found that their values are:
IntrMask: c07f
IntrStatus: 0001
The documentation at http://wiki.osdev.org/PCI says that bit 3 of the IntrStatus should be set for the interrupt to get fired. I don't know what is the reason for IntrStatus not to be set correctly, and when it should be set?
Any suggestions?
Thanks
Karim
Re: How to make sure rtl8139 is connected to the PIC in QEMU
What interrupt mask and interrupt status registers are you talking about? In my Realtek 8139 driver I had the following:
You should be getting 1 on a good RX. I checked my mask and it gets programmed to 0xc07f, so I think you've received OK. My interrupt is 5 on the PIC.
Code: Select all
#define RL_ISR 0x003E /* interrupt status register */
#define RL_ISR_RX_OK 0x0001
#define RL_ISR_RX_ERR 0x0002
Every universe of discourse has its logical structure --- S. K. Langer.
Re: How to make sure rtl8139 is connected to the PIC in QEMU
I am talking about the IntrStatus and the IntrMask of the qemu.
The debug mode prints them on every packet receival
Thanks
Karim
The debug mode prints them on every packet receival
Thanks
Karim
Re: How to make sure rtl8139 is connected to the PIC in QEMU
So Why do you think the interrupt does not fire?
Although PIT and the Keyboard fire their interrupts?
I have been working in this for the past 5 days, and I have traced the qemu as much as I can and I cannot know why the interrupt does not fire.
Any suggestions ?
Thanks
Karim
Although PIT and the Keyboard fire their interrupts?
I have been working in this for the past 5 days, and I have traced the qemu as much as I can and I cannot know why the interrupt does not fire.
Any suggestions ?
Thanks
Karim
Re: How to make sure rtl8139 is connected to the PIC in QEMU
1) Five days is nothing!kemosparc wrote:I have been working in this for the past 5 days, and I have traced the qemu as much as I can and I cannot know why the interrupt does not fire.
2) I've never seen the source code for qemu but there's no doubt in my mind that if you stepped through the code you would eventually figure out why you weren't getting an interrupt. It's just a question of how badly you want to solve the problem.
Every universe of discourse has its logical structure --- S. K. Langer.
Re: How to make sure rtl8139 is connected to the PIC in QEMU
I am kind of confused,
How to know if the hardware is configured with PIC or APIC?
Basically, the qemu fires the interrupt once, but it never reaches my handler hub, and it never fires again!!
Any help?
Thanks
Karim
How to know if the hardware is configured with PIC or APIC?
Basically, the qemu fires the interrupt once, but it never reaches my handler hub, and it never fires again!!
Any help?
Thanks
Karim
Re: How to make sure rtl8139 is connected to the PIC in QEMU
Another question,
Is there any special consisderation of my kernel runs in 64-bit Long mode?
Thanks
Karim
Is there any special consisderation of my kernel runs in 64-bit Long mode?
Thanks
Karim
[SOLVED]How to make sure rtl8139 is connected to the PIC in
Okay,
Finally I discovered my problem.
The IRQ for the network card is IRQ 11 which is on PIC 2.
So I had to enable IRQ2 (unmask it) as it cascades the interrupts on PIC2.
Now the interrupt fires
Thanks
Karim..
Finally I discovered my problem.
The IRQ for the network card is IRQ 11 which is on PIC 2.
So I had to enable IRQ2 (unmask it) as it cascades the interrupts on PIC2.
Now the interrupt fires
Thanks
Karim..