flat assembler
Message board for the users of flat assembler.

Index > OS Construction > PIC, IRQ, IDT, and ISR's...?

Goto page Previous  1, 2
Author
Thread Post new topic Reply to topic
vendu



Joined: 15 Nov 2014
Posts: 2
Location: Finland
vendu 16 Nov 2014, 00:16
First of all, I just heard about this cool board and this is my first post. I hope it's not too off-topic to link some C code with inline assembly macros, so here you go:

trap.h

And for more info on how to use this junk:

trap.c

I hope this helps. Smile

_________________
----8<----

/* vendu */
Post 16 Nov 2014, 00:16
View user's profile Send private message Visit poster's website Reply with quote
BAiC



Joined: 22 Mar 2011
Posts: 272
Location: California
BAiC 16 Nov 2014, 02:19
I forgot to mention two things.

first a better explanation for the code I presented:
Code:
mov al, 0x60+N
out 0x20, al    

you add the interrupt number (0-7) to 0x60 before sending the value. it corresponds to the interrupt your responding to. this only applies to 8259 Primary (interrupts 0-7). when you respond to the secondary 8259 interrupts you need a slightly more complicated code sequence. basically you perform the same sequence for each controller:
Code:
;issue the command to the second controller first. basically the same sequence as the earlier example.
mov al, 0x60+(N and 7)
out 0xA0, al

;now respond to interrupt 2 on the primary controller.
mov al, 0x60+2
out 0x20, al
    


- Stefan

_________________
byte me.
Post 16 Nov 2014, 02:19
View user's profile Send private message Visit poster's website Reply with quote
newport



Joined: 08 Jun 2012
Posts: 86
Location: Kentucky, USA
newport 16 Nov 2014, 20:59
Ok... after much deliberation and testing, I have found that I'm receiving an Invalid Opcode error which is probably why my keyboard IRQ was not firing... now I've got to track down what's causing this error. Anybody had experience with this?
Post 16 Nov 2014, 20:59
View user's profile Send private message Visit poster's website Reply with quote
BAiC



Joined: 22 Mar 2011
Posts: 272
Location: California
BAiC 17 Nov 2014, 01:42
that could be caused by a bunch of stuff.. these are just some cases I could think of off-hand:

1) you jump to an uninitialized region of memory. this is extremely easy to do with jump tables. it can also happen with loaders that send the data to a different location than the jump point.

2) unintentional SMC. this can happen if you keep data between blocks of code and write to it with array notation or loops with errant induction values.

3, and this is a really advanced one, you use FASMs data processing capabilities to generate errant code.

the most likely scenario IMO is that the interrupt table address isn't pointing to the correct address of the code.

_________________
byte me.
Post 17 Nov 2014, 01:42
View user's profile Send private message Visit poster's website Reply with quote
BAiC



Joined: 22 Mar 2011
Posts: 272
Location: California
BAiC 17 Nov 2014, 03:25
are you sure there is an Invalid Opcode exception? I modified the last instructions (your infinite loop) of your kernel code as such:

Code:
@@:
    
    rdtsc
    shr eax, 29
    add eax, 'A ! '
    mov[0xB8000], eax
    
jmp @b
    


it's an infinite loop that cycles through the first 8 letters of the alphabet slow enough to see them. it doesn't stop which means an exception doesn't happen. pressing a key gets ignored.

_________________
byte me.
Post 17 Nov 2014, 03:25
View user's profile Send private message Visit poster's website Reply with quote
BAiC



Joined: 22 Mar 2011
Posts: 272
Location: California
BAiC 17 Nov 2014, 03:32
found it.

you don't initialize the interrupt mask register correctly. in order to disable an interrupt you write a 1 to the bit. writing a 0 will enable the interrupt.

on line 182 of 'bootStage2.asm' it says:

Code:
mov al, 0FFh    

it should be something equivalent to:
Code:
mov al, 1111'1101b ; enable the keyboard interrupt while disabling everything else    

_________________
byte me.


Last edited by BAiC on 18 Nov 2014, 04:24; edited 1 time in total
Post 17 Nov 2014, 03:32
View user's profile Send private message Visit poster's website Reply with quote
newport



Joined: 08 Jun 2012
Posts: 86
Location: Kentucky, USA
newport 17 Nov 2014, 19:21
Thank you very much BAiC! I will try these suggestions as soon as I get back in town..
Post 17 Nov 2014, 19:21
View user's profile Send private message Visit poster's website Reply with quote
newport



Joined: 08 Jun 2012
Posts: 86
Location: Kentucky, USA
newport 18 Nov 2014, 06:32
BAiC wrote:
found it.

you don't initialize the interrupt mask register correctly. in order to disable an interrupt you write a 1 to the bit. writing a 0 will enable the interrupt.

on line 182 of 'bootStage2.asm' it says:

Code:
mov al, 0FFh    

it should be something equivalent to:
Code:
mov al, 1111'1101b ; enable the keyboard interrupt while disabling everything else    


Hot Dog! .. That fixed it... Thanks so much! I also changed the kernel endless loop like you said, and sure-enough, it cycles through the letters.. cool... I would have never figured this out on my own...

_________________
It's the desire to learn that leads to success...

http://www.webicomp.com
Post 18 Nov 2014, 06:32
View user's profile Send private message Visit poster's website Reply with quote
l_inc



Joined: 23 Oct 2009
Posts: 881
l_inc 18 Nov 2014, 12:12
newport
Quote:
Hot Dog! .. That fixed it... Thanks so much! [...] I would have never figured this out on my own...

I suppose, I pointed out to that problem at the very beginning of the topic.

_________________
Faith is a superposition of knowledge and fallacy
Post 18 Nov 2014, 12:12
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2

< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.