Hi,
I have my kernel so it can get input one char at a time, but when I use my homemade gets function, the screen displays weird colors and text. can you help?
here is the code:
char getch()
{
char ch = '\0';
do
{
ch = kbdus[inportb(0x60)];
}while (ch == '\0');
putch(ch);
if(ch == '\r')
{
return '\r';
}
else if (ch == '\n')
{
return '\r';
}
else
{
return ch;
}
}
char gets(char *inp)
{
char c[128];
int cc = 0;
do
{
c[cc] = getch();
cc++;
}while( c[cc - 1] != '\n');
inp = c;
return c[0];
}
Thanks!!
keyboard input not working
Re:keyboard input not working!!!!!
first i dont see the need for these lines:next, as far as i know port 0x60 does not reset to '\0', so what will happen is if you push a key your handler will get that key over and over... so try this:
insted of
o and at an interupt run this: put it all together and you get this:hope that helps
Code: Select all
if(ch == '\r')
{
return '\r';
}
Code: Select all
volatile int int01_flag = 0;
while(int01_flag == 0)
hlt();
ch = kbdus[inportb(0x60)];
int01_flag = 0;
Code: Select all
do
{
ch = kbdus[inportb(0x60)];
}while (ch == '\0');
Code: Select all
void int01_handler()
{
int01_flag = 0;
}
Code: Select all
volatile int int01_flag = 0;
char ch = '\0';
char getch()
{
while(int01_flag == 0)
hlt();
ch = kbdus[ inportb(0x60) ];
int01_flag = 0;
putch( ch );
else if ( ch == '\n' )
return '\r';
else
return ch;
}
char gets(char *inp)
{
char c[128];
int cc = 0;
do
{
c[cc] = getch();
cc++;
}while( c[cc - 1] != '\n');
inp = c;
return c;
}
void int01_handler()
{
int01_flag = 1;
}
Re:keyboard input not working!!!!!
Thanks, but when I compile, the output says 'undefined reference to 'hlt()'
what is that?
what is that?
Re:keyboard input not working!!!!!
the function hlt() halts the cpu (so it can cool down when not needed):o and do you have int01_handler() hooked to your INT service handler?
Code: Select all
inline void hlt()
{
asm volatile("hlt");
}