Page 1 of 1

keyboard input in C kernel

Posted: Fri Sep 23, 2016 1:12 pm
by Haghiri75
I write this a long time ago (about a year ago) : https://github.com/prp-e/NanOS-old
and this code includes everything an operating system needs to communicate with a keyboard.
But, I'm sure I wrote terminal_getchar() function in a wrong way, and when I boot my operating system, and press any key from keyboard, it repeats the ">>" (shell sign) twice and stops working.
What should I do in the code?

Re: keyboard input in C kernel

Posted: Fri Sep 23, 2016 1:16 pm
by crunch
I think you should spend more time reading through the wiki + documentation, and perhaps some basic tutorials/theory.
How do you expect to get keyboard input when you have no interrupt handling code?

Re: keyboard input in C kernel

Posted: Fri Sep 23, 2016 2:07 pm
by Haghiri75
crunch wrote:I think you should spend more time reading through the wiki + documentation, and perhaps some basic tutorials/theory.
How do you expect to get keyboard input when you have no interrupt handling code?
So, it means I need to define a GDT for my OS?

Re: keyboard input in C kernel

Posted: Fri Sep 23, 2016 2:25 pm
by BrightLight
Haghiri75 wrote:So, it means I need to define a GDT for my OS?
Some of the first things in your OS's initialization code should be (in this order):
1. Load a GDT and reload all segment registers.
2. Load an IDT and install exception handlers.
3. Initialize paging and memory management.
4. Load a task state segment (TSS) -- although you can probably skip this now and do it when you support usermode.
5. Initialize the basic devices: the programmable interrupt controller, the programmable interrupt timer, and (as you're trying to do) the PS/2 controller.

Re: keyboard input in C kernel

Posted: Sat Sep 24, 2016 1:05 pm
by osdever
crunch wrote:I think you should spend more time reading through the wiki + documentation, and perhaps some basic tutorials/theory.
How do you expect to get keyboard input when you have no interrupt handling code?
You can do it, but it will conflict with mouse and fully load CPU, also this is VERY BAD. Port 0x60 polling, that's it. :)
I know it because OS365 used port polling, this is one of causes to discontinue it in start of 2016.

Re: keyboard input in C kernel

Posted: Sun Sep 25, 2016 6:41 am
by BrightLight
catnikita255 wrote:I know it because OS365 used port polling, this is one of causes to discontinue it in start of 2016.
I hardly think it's worth it to start a new OS project because something as minor as how a keyboard driver receives data. :roll:

Re: keyboard input in C kernel

Posted: Sun Sep 25, 2016 10:10 am
by onlyonemac
omarrx024 wrote:
catnikita255 wrote:I know it because OS365 used port polling, this is one of causes to discontinue it in start of 2016.
I hardly think it's worth it to start a new OS project because something as minor as how a keyboard driver receives data. :roll:
His whole OS used to be based around polling mode drivers because he didn't know how to use interrupts; he's slowly re-writing it to use interrupts rather than polling. I don't think he means that he's discontinuing his project; I think he means that he's discontinuing the exclusive use of polling mode for his drivers and has started to re-write them to use interrupts.

Re: keyboard input in C kernel

Posted: Wed Sep 28, 2016 11:12 am
by osdever
onlyonemac wrote:
omarrx024 wrote:
catnikita255 wrote:I know it because OS365 used port polling, this is one of causes to discontinue it in start of 2016.
I hardly think it's worth it to start a new OS project because something as minor as how a keyboard driver receives data. :roll:
His whole OS used to be based around polling mode drivers because he didn't know how to use interrupts; he's slowly re-writing it to use interrupts rather than polling. I don't think he means that he's discontinuing his project; I think he means that he's discontinuing the exclusive use of polling mode for his drivers and has started to re-write them to use interrupts.
No, no, I discontinued all OS365 in start of 2016, now I write U365.