Keyboard driver does not work

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
sysfree

Keyboard driver does not work

Post by sysfree »

[attachment deleted by admin]
Silenger

Re:Keyboard driver does not work

Post by Silenger »

Is int21 not for dos interupts?

Some pascal code:

procedure WriteChr(Chr: Char);
begin
asm
PUSH Ax

MOV Al, Chr
MOV Ah, 0Eh
INT 10h

POP Ax
end;
end;

function ReadChr: Char;
var
Key: Char;
begin
asm
PUSH Ax

XOR Ax, Ax
INT 16h

{Result}
MOV Key, Al

POP Ax
end;

ReadChr := Key;
end;

This should work in real mode but i don't use protected mode yet.
guest

Re:Keyboard driver does not work

Post by guest »

IDT defined?
sysfree

Re:Keyboard driver does not work

Post by sysfree »

Silenger: Maybe you misundstood me. What i wrote is my own OS, not in DOS. But thanks anyway! :)
Guest: Yes, i had set up the IDT.
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:Keyboard driver does not work

Post by Pype.Clicker »

what does exactly set_intr do ? keep in mind that C code usually trash some registers such as eax & edx... so you should not declare your driver as a plain C function, but at least have an asm stub code that will

pusha
call handler
popa
iretd

by the by, C function also ignores it should return differently from a handler (it will perform a RET instead of an iretd )
sysfree

Re:Keyboard driver does not work

Post by sysfree »

Thank you Clicker! What you said is absolutely right. I DID put my c code into the IDT directly, and that was the fault.
Now my kernel works well. Here you may get the source of my OS:
http://chong2.3322.net/myos/

Regards
Sysfree
Post Reply