Recent

Author Topic: Have anyone know how to handle keyboard input in pascal-based kernel ?  (Read 7590 times)

TYDQ

  • New Member
  • *
  • Posts: 38
Before I ask this question I have refer to Free Pascal Operating System when I attempting to solve the keyboard input but failed,it can be executed in x86_64 protected mode.But my kernel is on 64 bit long mode and I don't know how to set idt,irq,isr in pascal not in assembly.my code for handling keyboard input is on the below:(It is tested on the virtual machine,but I cannot find a way to solve it)
Code: Pascal  [Select][+][-]
  1. unit keyboard;
  2.  
  3. interface
  4. uses port;
  5. function keyboard_get_input_char:byte;
  6. function keyboard_get_input_string:PByte;
  7. implementation
  8. function keyboard_get_input_char:byte;[public,alias:'keyboard_get_input_char'];
  9. var inputchar:byte;
  10. begin
  11.     Writeport($64,Byte($1));
  12.     Readport($60,inputchar);
  13.     while(inputchar<>0) and (inputchar<>8) and (inputchar<>10) and (inputchar<>13) do Readport($60,inputchar);
  14.     Writeport($64,Byte($0));
  15.     keyboard_get_input_char:=inputchar;
  16. end;
  17. function keyboard_get_input_string:PByte;[public,alias:'keyboard_get_input_string'];
  18. var mystr:array[0..255] of byte;
  19.        i:byte;
  20. begin
  21.   Writeport($64,Byte($1));
  22.   Readport($60,mystr[0]); i:=0;
  23.   while(mystr[i]<>0) and (mystr[i]<>8) and (mystr[i]<>10) and (mystr[i]<>13) do
  24.   begin
  25.     inc(i);
  26.     Readport($60,mystr[i]);
  27.     if(mystr[i]=8) then dec(i);
  28.   end;
  29.   Writeport($64,Byte($0));
  30.   keyboard_get_input_string:=@mystr;
  31. end;
  32. end.
« Last Edit: April 02, 2024, 10:24:02 am by TYDQ »

bytebites

  • Hero Member
  • *****
  • Posts: 644
Use code
Code: Pascal  [Select][+][-]
  1.  tags

Thaddy

  • Hero Member
  • *****
  • Posts: 14592
  • Sensorship about opinions does not belong here.
That is a nonsense answer. (it is about a kernel or did you miss that?)
A good way would be to look at how Ultibo has solved this.
That is great code for such things. Ultibo focusses on -even modular -kernel writing in FreePascal and is available through OPM. Comes with all sources.
Frankly, you may even give up on your own efforts, because Ultibo is as far kernel writing so easy, with the provision that the code may be smaller later. You are obviously a kernel writer so ignore any comments about tags. Few know what they are doing....
On this forum there are less than 50 people interested AND capable of kernel programming. But they are there and most are scientists in the field.
« Last Edit: April 01, 2024, 06:48:26 pm by Thaddy »
bitrate is always calculated like this:sample rate * bitdepth * number of channels.

bytebites

  • Hero Member
  • *****
  • Posts: 644
I don't know what it is about, but the code in nonsense because it has 8) and cursive text in it. Not using code tags should cause at least 3 hours ban.

Thaddy

  • Hero Member
  • *****
  • Posts: 14592
  • Sensorship about opinions does not belong here.
you may have a point in that context, but that is not necessary.
bitrate is always calculated like this:sample rate * bitdepth * number of channels.

TYDQ

  • New Member
  • *
  • Posts: 38
I don't know what it is about, but the code in nonsense because it has 8) and cursive text in it. Not using code tags should cause at least 3 hours ban.
I don't know without tag my code will be inserted with emoji......

PascalDragon

  • Hero Member
  • *****
  • Posts: 5519
  • Compiler Developer
That is a nonsense answer. (it is about a kernel or did you miss that?)

That is not a nonsense answer. If I had seen that post without code tags, I would have said the same even if it was the only thing I had to reply, cause using code-tags make the code much easier to read (and avoids misinterpretation by the forum software) and thus others might have an easier time to answer as well even if I didn't.

Thaddy

  • Hero Member
  • *****
  • Posts: 14592
  • Sensorship about opinions does not belong here.
was a misinterpretation of tag. I already explained that.
bitrate is always calculated like this:sample rate * bitdepth * number of channels.

Leledumbo

  • Hero Member
  • *****
  • Posts: 8760
  • Programming + Glam Metal + Tae Kwon Do = Me
You should setup your IRQ and IDT handlers BEFORE jumping to long mode. I think that's all you're missing, assuming everythng else you didn't show is correct.

MarkMLl

  • Hero Member
  • *****
  • Posts: 6750
You should setup your IRQ and IDT handlers BEFORE jumping to long mode. I think that's all you're missing, assuming everythng else you didn't show is correct.

When I was doing this sort of thing, I wrote a tool which I believe Intel would have referred to as a binder which built the descriptor tables from a text-format description and (I think) merged the files into an appropriate binary image which was booted by a ROM loader (which of course in those days people wrote in assembler and enjoyed it).

I don't know without tag my code will be inserted with emoji......

You could have looked at the topic after you'd posted to check for answers, or used the preview button. There's plenty of excuse for not knowing in advance that what was being posted was problematic, but very little for not realising afterwards.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

 

TinyPortal © 2005-2018