Page 1 of 1
FreeBASIC kernel IRQ Problem
Posted: Mon Jul 13, 2009 4:10 am
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!
Re: FreeBASIC kernel IRQ Problem
Posted: Mon Jul 13, 2009 6:06 am
by brentS
I am having the exact same problem with my Kernel in D.
http://forum.osdev.org/viewtopic.php?f=1&t=20515
Re: FreeBASIC kernel IRQ Problem
Posted: Mon Jul 13, 2009 6:23 am
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.
Re: FreeBASIC kernel IRQ Problem
Posted: Mon Jul 13, 2009 8:11 am
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.
Re: FreeBASIC kernel IRQ Problem
Posted: Mon Jul 13, 2009 11:50 am
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)
Re: FreeBASIC kernel IRQ Problem
Posted: Mon Jul 13, 2009 3:11 pm
by ScorchOS
Your comments are a little blunt but completely right.
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!
) which I hope to take to other FOSS projects I may come up with in the future!
Thanks for your help everyone! It's been fun!
Re: FreeBASIC kernel IRQ Problem
Posted: Mon Jul 13, 2009 4:54 pm
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.