Page 1 of 1
PIC does not reset?
Posted: Mon Nov 07, 2016 10:40 am
by DCNick3
I have this timer ISR
Code: Select all
.global KiIRQ0Handler
.type KiIRQ0Handler, @function
KiTimerCounter:
.long 0
KiItsTimeText:
.string "It's time!~"
KiIRQ0Handler:
addl $0x01, KiTimerCounter
cmpl $3, KiTimerCounter
jle KiIRQ0Handler_exit
push $KiItsTimeText
call KiFault
KiIRQ0Handler_exit:
push %eax
# Here I'm performing PIC reset, but it looks like It's not resetted...
# I can receive only one IRQ
mov $0x20, %al
out %al, $0x20
pop %eax
iret
This being called only once? but I set up timer like this
Code: Select all
static VOID inline KiPortOutByte(WORD bPort, BYTE bValue)
{
ASM VOLATILE ("mov %0, %%al; mov %1, %%dx; outb %%al, %%dx" : : "g"(bValue), "g"((WORD)bPort));
}
/* ......... */
KiPortOutByte(0x43, 0x33);
WORD wReloadValue = 65535;
KiPortOutByte(0x40, wReloadValue & 0xFF);
KiPortOutByte(0x40, (wReloadValue & 0xFF00) >> 8);
What am I doing wrong?
Re: PIC does not reset?
Posted: Mon Nov 07, 2016 10:48 am
by heat
Code: Select all
cmpl $3, KiTimerCounter
jle KiIRQ0Handler_exit
This seems odd, to say the least.
Re: PIC does not reset?
Posted: Mon Nov 07, 2016 10:54 am
by DCNick3
heat wrote:Code: Select all
cmpl $3, KiTimerCounter
jle KiIRQ0Handler_exit
This seems odd, to say the least.
Why it's odd?
It's checking if the counter is bigger than 3.
If yes - it runs KiFatal with argument - string "It's time!~"
P.S. I'm using QEMU debugger to determine, that ISR is called.
Re: PIC does not reset?
Posted: Mon Nov 07, 2016 11:07 am
by heat
DCNick3 wrote:heat wrote:Code: Select all
cmpl $3, KiTimerCounter
jle KiIRQ0Handler_exit
This seems odd, to say the least.
Why it's odd?
It's checking if the counter is bigger than 3.
If yes - it runs KiFatal with argument - string "It's time!~"
P.S. I'm using QEMU debugger to determine, that ISR is called.
Yes, you're right, my bad. Try replacing that iret for an 'iretd' or 'iretq'(iretq if you're in 64-bit mode).
PS: You also should want to add a 'cli' at the start of the IRQ handler
Re: PIC does not reset?
Posted: Mon Nov 07, 2016 11:14 am
by DCNick3
heat wrote:DCNick3 wrote:heat wrote:Code: Select all
cmpl $3, KiTimerCounter
jle KiIRQ0Handler_exit
This seems odd, to say the least.
Why it's odd?
It's checking if the counter is bigger than 3.
If yes - it runs KiFatal with argument - string "It's time!~"
P.S. I'm using QEMU debugger to determine, that ISR is called.
Yes, you're right, my bad. Try replacing that iret for an 'iretd' or 'iretq'(iretq if you're in 64-bit mode).
PS: You also should want to add a 'cli' at the start of the IRQ handler
Looks like GNU AS doesn't know instruction iretd, but iretl is ok.
Added cli, but all of this doesn't help =C
Re: PIC does not reset?
Posted: Mon Nov 07, 2016 11:23 am
by heat
Check if you're actually returning from the interrupt handler, for starters.
Re: PIC does not reset?
Posted: Mon Nov 07, 2016 11:30 am
by DCNick3
heat wrote:Check if you're actually returning from the interrupt handler, for starters.
Yes It returns, program continues to run, when I debug it step-by-step, it's successfully returns.
Re: PIC does not reset?
Posted: Mon Nov 07, 2016 1:03 pm
by iansjack
You seem to be configuring the PIT in one-shot, BCD mode. I'm not sure that's what you want.
Re: PIC does not reset?
Posted: Mon Nov 07, 2016 1:25 pm
by DCNick3
iansjack wrote:You seem to be configuring the PIT in one-shot, BCD mode. I'm not sure that's what you want.
Thanks a lot, I missed last bit of the command-code
UPD: But it still doesn't work =C
UPD2: It's alive, thanks a lot!