i need help for interrupts..

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
trashmanso

i need help for interrupts..

Post by trashmanso »

sory about my english.. :D

i have started my first project... i have loaded my kernel but there are a lot of problems...

1. i cant use keyboard. i dont know asm and all codes are in asm about keyboard. are there any c source?
2. when i include a header to my kernel.c gcc compiles is well but my linker always creates problem. what should i do?
3.can i write irq,idt,gdt etc... codes in c? or i have to use asm?

thanks for ur help...
JoeKayzA

Re:i need help for keyboard...

Post by JoeKayzA »

I think I'll let the first 2 points to someone else....
trashmanso wrote: 3.can i write irq,idt,gdt etc... codes in c? or i have to use asm?
The code for creating and manipulating the gdt/ldt and idt can be written in C, no problem. Just create a struct (or class, in C++) for the appropriate descriptor types, and treat the descriptor table as an array of descriptors.

For loading these tables however you'll need _at least_ a single instruction in inline-asm, since you need special opcodes for these.

cheers
Joe
trashmanso

Re:i need help for keyboard...

Post by trashmanso »

thank u for ur answer. can i call an asm code from c, like a function? ( a linked *.asm code )
trashmanso

Re:i need help for keyboard...

Post by trashmanso »

and also i need the first and the second questions answers.. .D

thanks.
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re:i need help for keyboard...

Post by Brendan »

Hi,
trashmanso wrote:thank u for ur answer. can i call an asm code from c, like a function? ( a linked *.asm code )
Yes, but the exact details might depend on which compiler you're using.

For simple/small things it's usually much better to use inline assembly.
trashmanso wrote: and also i need the first and the second questions answers.. .D
trashmanso wrote:1. i cant use keyboard. i dont know asm and all codes are in asm about keyboard. are there any c source?
Have you tried this page about keyboards (which does use C examples)?
trashmanso wrote:2. when i include a header to my kernel.c gcc compiles is well but my linker always creates problem. what should i do?
That depends on what the problem is - if it's something like "can't create file - not enough free space on disk" it shouldn't be hard to fix, but if you don't tell us what the problem is we could be guessing for months.... :)


Cheers,

Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
trashmanso

Re:i need help for keyboard...

Post by trashmanso »

i've done a little project..
i only writes on screen in 32pmode and enables a20... and i stucked...

the problem is:

Code: Select all

start.o : file not recognized: File format not recognized
but i know there is a start.o file and also not empty..


My bıild.bat file

Code: Select all

nasm -f aout -o start.o start.asm


d:\mingw\bin\gcc -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o main.o main.c

d:\mingw\bin\gcc -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o scrn.o scrn.c

d:\mingw\bin\gcc -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o gdt.o gdt.c

d:\mingw\bin\gcc -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o idt.o idt.c

d:\mingw\bin\gcc -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o isrs.o isrs.c

d:\mingw\bin\gcc -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o irq.o irq.c

d:\mingw\bin\gcc -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o timer.o timer.c

d:\mingw\bin\gcc -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o kb.o kb.c



d:\mingw\bin\ld -T link.ld -o kernel.bin start.o main.o scrn.o gdt.o idt.o isrs.o irq.o timer.o kb.o

and i cant use Interrupt? i have searched lots of tutorials and also http://osdever.net/tutorials/interrupts.1.php?the_id=39 but i dont understand all.

where should i add irq,isr code? (in my bootf.asm or loader.asm)

pause
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:i need help for keyboard...

Post by Pype.Clicker »

trashmanso wrote: i've done a little project..
i only writes on screen in 32pmode and enables a20... and i stucked...

the problem is:

Code: Select all

start.o : file not recognized: File format not recognized
but i know there is a start.o file and also not empty..
That comes from a mismatch between your linker and your assembler output format. "nasm -hf" should tell you what output formats your assembler supports. In your case, "win32" might be the one you need.

Be aware, too, that mingw may be poorly suited to os development (though there are certainly workarounds for all the troubles you might encounter), so you might want to use cygwin instead, and even maybe building a cross-compiler, depending on your specific needs.
trashmanso

Re:i need help for keyboard...

Post by trashmanso »

i 've changed my build.bat but know the problem is

Code: Select all

PE operations on non PE file.
and i also installed cygwin on my pc. but i dont know how can i use it. i cant find gcc under cygwin...

thanks
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:i need help for interrupts..

Post by Pype.Clicker »

The Root Directory for Cygwin (default C:\cygwin) will become / within your Cygwin installation. You must have write access to the parent directory, and any ACLs on the parent directory will determine access to installed files.
If you have installed gcc with cygwin, it should thus appear in "/usr/bin/gcc" once in the cygwin shell or in "c:\cygwin\usr\bin\gcc" when in the MS shell/explorer/whatever.
PE operations on non PE file.
That's typical from an attempt to produce an ELF file with cygwin's linker...
trashmanso

Re:i need help for interrupts..

Post by trashmanso »

i think i should install cygwin again because there is no gcc file in usr/bin....

i need i good tutorial which i can compile easly in windows. i have downloaded lots of(about 50) but every of them gives errors while compiling. can u give me a tutorial like that. (print on screen, keyboard, irq,idt,gdt,pic etc...) maybe a need a small kernel source for learning..

can i reed "makefile"'s with cygwin with no problem :D.

thanks again. :D
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:i need help for interrupts..

Post by Pype.Clicker »

trashmanso wrote: i think i should install cygwin again because there is no gcc file in usr/bin....
well, just pick more packages to install. no need to undo what's already been done.
can i reed "makefile"'s with cygwin with no problem :D.
If you install "gnu make", probably ... unless the makefile contains something that's very unix-specific ... Just running "make" in the directory that contains the makefile should do the trick.
trashmanso

Re:i need help for interrupts..

Post by trashmanso »

where can i download gcc and how? am i have to download clibs..
Kemp

Re:i need help for interrupts..

Post by Kemp »

During the Cygwin installation you can choose a custom setup option which will let you choose what you want to install.
Post Reply