FreeBASIC kernel IRQ Problem

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
ScorchOS
Member
Member
Posts: 44
Joined: Fri Oct 24, 2008 6:20 am
Location: Wiltshire, UK
Contact:

FreeBASIC kernel IRQ Problem

Post by ScorchOS »

Having created a FreeBASIC kernel which works with a GDT/IDT and page memory addressing, I can't for the life of me work out how to invoke IRQ0!

(Code available Here).

I have remapped the IRQs using a routine in /include/irq.bi named 'irq_remap()', then set the relevant entries in the IDT using irq_install(). How do I then invoke one of the IRQs (i.e. IRQ0)?

I have tried invoking it an IRQ in kernel.bas using the routine 'timer_install()' in sys/timer.bas and nothing seems to happen. I have been trying to use 'timer_init()' in the multi-tasker (I am currently rethinking how to implement a system timer at this stage once IRQs start working!).

I will see tonight if using irq_enable() in the irq_install() routine makes any difference. Thank you in advance for your suggestions! :-)
ScorchOS: http://sites.google.com/site/scorchopsys/


"The golden rule: RTFM, check the wiki, google it and have a go BEFORE asking the question!"
brentS
Posts: 16
Joined: Sat Jun 27, 2009 5:41 pm

Re: FreeBASIC kernel IRQ Problem

Post by brentS »

I am having the exact same problem with my Kernel in D. http://forum.osdev.org/viewtopic.php?f=1&t=20515
User avatar
ScorchOS
Member
Member
Posts: 44
Joined: Fri Oct 24, 2008 6:20 am
Location: Wiltshire, UK
Contact:

Re: FreeBASIC kernel IRQ Problem

Post by ScorchOS »

In the case of the IDT you could just do what I did (I am not familiar with D, so take the following FreeBASIC code as pseudocode)

Code: Select all

Sub isr0()
   Print "Divide by Zero Error"
   halt_system()
End Sub
which links to:

Code: Select all

Sub halt_system()
   Print "System Halted!"
   ASM
           hlt
   End ASM
End Sub
This works whenever I divide by zero (you could replace the ASM with an infinite loop to act as a halt). Ensure that your routine to call lidt is referred to in idt_install() somewhere. :-)

My problem unfortunately is not with getting IDT entry 0 (divide by zero error) working, but with getting IRQ0 (system timer) to fire at all. :(
ScorchOS: http://sites.google.com/site/scorchopsys/


"The golden rule: RTFM, check the wiki, google it and have a go BEFORE asking the question!"
User avatar
Zenith
Member
Member
Posts: 224
Joined: Tue Apr 10, 2007 4:42 pm

Re: FreeBASIC kernel IRQ Problem

Post by Zenith »

I'm wondering, have you initialized the PIT to a desired frequency yet?

Also, exceptions work regardless of the interrupt flag being set. Make sure you actually do perform an sti to enable interrupts.
"Sufficiently advanced stupidity is indistinguishable from malice."
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: FreeBASIC kernel IRQ Problem

Post by Combuster »

Most effective solution: Stop using FreeBASIC until you know what it is doing. Your code is a mess, you have implementations in header files, and you have no clue of calling conventions.
The Required Knowledge rule wrote:Programming experience: Learning a language with OS development is considered a bad idea. You should know the language in which you will be developing inside out, which means you should have written quite a few programs in that language successfully.
Oh and, your error is in isr.bi (yet another header with implementations, yuck)
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
ScorchOS
Member
Member
Posts: 44
Joined: Fri Oct 24, 2008 6:20 am
Location: Wiltshire, UK
Contact:

Re: FreeBASIC kernel IRQ Problem

Post by ScorchOS »

Your comments are a little blunt but completely right. #-o

I will explain:
After ApolloOS 0.0.5 (just bkerndev rebranded), I released ScorchOS 0.0.7. This was completely slated by the osdev community because I made just about every beginner mistake it was conceivable to make (first FOSS project, releasing too early, overhyping, thinking I'd make millions, building on top of a tutorial kernel, etc.). Having gone away and learned from these mistakes (and spending a few months reading up specifically on the theory behind systems architecture and design, and also studying other kernels), I then thought I'd make a clean break and write a kernel from scratch in a new language (see the fallacy here?!) and started out on the FreeBASIC barebones tutorial. As has been proven in the links you have posted I seem to look at FreeBASIC from a C/C++ developer's perspective (which is very much the wrong way to do it!), and my inexperience shows in the construction of the kernel itself.

Well, as they say you learn from your mistakes - and OS development has been a steep learning curve. I've been thinking this for a while, but I feel that this is one mistake too many. I will return to ScorchOS when I have the experience the project deserves - However, the last 18-24 months have still been a worthwhile exercise. I have learned the fundamental principles of running a FOSS project (the hard way! :lol:) which I hope to take to other FOSS projects I may come up with in the future! :D

Thanks for your help everyone! It's been fun! ;)
ScorchOS: http://sites.google.com/site/scorchopsys/


"The golden rule: RTFM, check the wiki, google it and have a go BEFORE asking the question!"
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: FreeBASIC kernel IRQ Problem

Post by Combuster »

I'm grateful that you take this in good faith. Feel free to come back any day. The previous post should have enough hints to identify and correct the error, and I hope in due time, you may find and fix it.

I wish you good luck with your endeavours, and I hope to see you again.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
Post Reply