PIC does not reset?

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
User avatar
DCNick3
Posts: 7
Joined: Mon Nov 07, 2016 10:35 am

PIC does not reset?

Post 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?
by DCNick3
heat
Member
Member
Posts: 103
Joined: Sat Mar 28, 2015 11:23 am
Libera.chat IRC: heat

Re: PIC does not reset?

Post by heat »

Code: Select all

cmpl $3, KiTimerCounter
jle KiIRQ0Handler_exit
This seems odd, to say the least.
If some of you people keep insisting on having backwards compatibitity with the stone age, we'll have stone tools forever.
My Hobby OS: https://github.com/heatd/Onyx
User avatar
DCNick3
Posts: 7
Joined: Mon Nov 07, 2016 10:35 am

Re: PIC does not reset?

Post 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.
by DCNick3
heat
Member
Member
Posts: 103
Joined: Sat Mar 28, 2015 11:23 am
Libera.chat IRC: heat

Re: PIC does not reset?

Post 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
If some of you people keep insisting on having backwards compatibitity with the stone age, we'll have stone tools forever.
My Hobby OS: https://github.com/heatd/Onyx
User avatar
DCNick3
Posts: 7
Joined: Mon Nov 07, 2016 10:35 am

Re: PIC does not reset?

Post 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
by DCNick3
heat
Member
Member
Posts: 103
Joined: Sat Mar 28, 2015 11:23 am
Libera.chat IRC: heat

Re: PIC does not reset?

Post by heat »

Check if you're actually returning from the interrupt handler, for starters.
If some of you people keep insisting on having backwards compatibitity with the stone age, we'll have stone tools forever.
My Hobby OS: https://github.com/heatd/Onyx
User avatar
DCNick3
Posts: 7
Joined: Mon Nov 07, 2016 10:35 am

Re: PIC does not reset?

Post 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.
by DCNick3
User avatar
iansjack
Member
Member
Posts: 4706
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: PIC does not reset?

Post by iansjack »

You seem to be configuring the PIT in one-shot, BCD mode. I'm not sure that's what you want.
User avatar
DCNick3
Posts: 7
Joined: Mon Nov 07, 2016 10:35 am

Re: PIC does not reset?

Post 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!
by DCNick3
Post Reply