in / out ports
in / out ports
does anyone have a list of the possible ports for in / out ? Im trying to accept input from the roll your own unix clone tutorial and i can't find the correct port for keyboard input anywhere. if someone could show me an example of how to use inb or inw i'd appreciate it!
Re: in / out ports
port 0x60 is to receive input from the keyboard.
and I don't know of a list off the top of my head sorry.
and I don't know of a list off the top of my head sorry.
Website: https://joscor.com
-
- Member
- Posts: 524
- Joined: Sun Nov 09, 2008 2:55 am
- Location: Pennsylvania, USA
Re: in / out ports
A quick google search for "io port list" reveals www.student.cs.uwaterloo.ca/~cs452/postscript/append.ps .
Re: in / out ports
I need a list of in return values and what key they correspond to, anyone have a list?
Re: in / out ports
Search Google for scan code sets (Assuming I understand your question right.)
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
Re: in / out ports
I just finished implementing keyboard input so I remember some links that helped me.
http://www.win.tue.nl/~aeb/linux/kbd/sc ... html#ss1.4
That site lists a bunch of the scancodes, and if you browse around the site, it has TONS of other information that might be useful.
Here's the wikis tips on getting started:
http://wiki.osdev.org/PS2_Keyboard
http://www.win.tue.nl/~aeb/linux/kbd/sc ... html#ss1.4
That site lists a bunch of the scancodes, and if you browse around the site, it has TONS of other information that might be useful.
Here's the wikis tips on getting started:
http://wiki.osdev.org/PS2_Keyboard
Hexciting: An open source hex editor for the command line.
https://sourceforge.net/projects/hexciting/
https://sourceforge.net/projects/hexciting/
Re: in / out ports
I've tried implementing keyboard in 2 ways, one way i did a for (;;) and printed the return of inb, the other way I did it was
and neither work. can someone help me out? samoz i think you might be able to give me tons of help because you just got this working!
thanks for the contributions:)
Code: Select all
void keyboard_callback()
{
int car;
car = inb(0x60);
if(car & 0x80)
{
// shift is pressed
}
else
{
monitor_write(kbdus[car]);
}
}
void init_keyboard()
{
register_interrupt_handler(IRQ1, &keyboard_callback);
}
thanks for the contributions:)
Re: in / out ports
A: you're reading a char, not an int, so make 'car' a char.
B: testing (car & 0x80) doesn't test for shift, it tests for a key_up instead of a key_down.
we would need to see your keymap and such to figure out your problem.
B: testing (car & 0x80) doesn't test for shift, it tests for a key_up instead of a key_down.
we would need to see your keymap and such to figure out your problem.
Website: https://joscor.com
Re: in / out ports
Code: Select all
unsigned char kbdus[128] =
{
0, 27, '1', '2', '3', '4', '5', '6', '7', '8', /* 9 */
'9', '0', '-', '=', '\b', /* Backspace */
'\t', /* Tab */
'q', 'w', 'e', 'r', /* 19 */
't', 'y', 'u', 'i', 'o', 'p', '[', ']', '\n', /* Enter key */
0, /* 29 - Control */
'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', /* 39 */
'\'', '`', 0, /* Left shift */
'\\', 'z', 'x', 'c', 'v', 'b', 'n', /* 49 */
'm', ',', '.', '/', 0, /* Right shift */
'*',
0, /* Alt */
' ', /* Space bar */
0, /* Caps lock */
0, /* 59 - F1 key ... > */
0, 0, 0, 0, 0, 0, 0, 0,
0, /* < ... F10 */
0, /* 69 - Num lock*/
0, /* Scroll Lock */
0, /* Home key */
0, /* Up Arrow */
0, /* Page Up */
'-',
0, /* Left Arrow */
0,
0, /* Right Arrow */
'+',
0, /* 79 - End key*/
0, /* Down Arrow */
0, /* Page Down */
0, /* Insert Key */
0, /* Delete Key */
0, 0, 0,
0, /* F11 Key */
0, /* F12 Key */
0, /* All other keys are undefined */
};
edit:
heres the new keyboard_callback
Code: Select all
void keyboard_callback()
{
char car;
car = inb(0x60);
monitor_write(kbdus[car]);
}
Re: in / out ports
do you even get an interrupt?
just print something to the screen, something arbitrary even, just to make sure that your IRQ1 fires on keypress.
just print something to the screen, something arbitrary even, just to make sure that your IRQ1 fires on keypress.
Website: https://joscor.com
Re: in / out ports
I have a hello world on the screen. Do you mean put a value in the callback function instead of trying to print the literal character??
Re: in / out ports
yeah, in the keyboard ISR (the handler), put like "monitor_write("key was pressed!\n");" and then, whenever a key is pressed it should print that. If it doesn't get printed, then your IDT is setup incorrectly or something.
Website: https://joscor.com
Re: in / out ports
yeah im not getting a response from the keyboard, the funny thing is if i do something like int 0x03 it'll catch the int! have you read the roll your own linux clone tutorial? thats what im working from
Re: in / out ports
This looks almost identical, in fact the keymap comments are even identical to Brans Kernel tutorial.sweetgum wrote:Code:
unsigned char kbdus[128] =
{
0, 27, '1', '2', '3', '4', '5', '6', '7', '8', /* 9 */
'9', '0', '-', '=', '\b', /* Backspace */
'\t', /* Tab */
'q', 'w', 'e', 'r', /* 19 */
't', 'y', 'u', 'i', 'o', 'p', '[', ']', '\n', /* Enter key */
0, /* 29 - Control */
'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', /* 39 */
'\'', '`', 0, /* Left shift */
'\\', 'z', 'x', 'c', 'v', 'b', 'n', /* 49 */
'm', ',', '.', '/', 0, /* Right shift */
'*',
0, /* Alt */
' ', /* Space bar */
0, /* Caps lock */
0, /* 59 - F1 key ... > */
0, 0, 0, 0, 0, 0, 0, 0,
0, /* < ... F10 */
0, /* 69 - Num lock*/
0, /* Scroll Lock */
0, /* Home key */
0, /* Up Arrow */
0, /* Page Up */
'-',
0, /* Left Arrow */
0,
0, /* Right Arrow */
'+',
0, /* 79 - End key*/
0, /* Down Arrow */
0, /* Page Down */
0, /* Insert Key */
0, /* Delete Key */
0, 0, 0,
0, /* F11 Key */
0, /* F12 Key */
0, /* All other keys are undefined */
};
theres my keymap
edit:
heres the new keyboard_callback
Code:
void keyboard_callback()
{
char car;
car = inb(0x60);
monitor_write(kbdus[car]);
}theres my keymapCode: Select all
unsigned char kbdus[128] = { 0, 27, '1', '2', '3', '4', '5', '6', '7', '8', /* 9 */ '9', '0', '-', '=', '\b', /* Backspace */ '\t', /* Tab */ 'q', 'w', 'e', 'r', /* 19 */ 't', 'y', 'u', 'i', 'o', 'p', '[', ']', '\n', /* Enter key */ 0, /* 29 - Control */ 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', /* 39 */ '\'', '`', 0, /* Left shift */ '\\', 'z', 'x', 'c', 'v', 'b', 'n', /* 49 */ 'm', ',', '.', '/', 0, /* Right shift */ '*', 0, /* Alt */ ' ', /* Space bar */ 0, /* Caps lock */ 0, /* 59 - F1 key ... > */ 0, 0, 0, 0, 0, 0, 0, 0, 0, /* < ... F10 */ 0, /* 69 - Num lock*/ 0, /* Scroll Lock */ 0, /* Home key */ 0, /* Up Arrow */ 0, /* Page Up */ '-', 0, /* Left Arrow */ 0, 0, /* Right Arrow */ '+', 0, /* 79 - End key*/ 0, /* Down Arrow */ 0, /* Page Down */ 0, /* Insert Key */ 0, /* Delete Key */ 0, 0, 0, 0, /* F11 Key */ 0, /* F12 Key */ 0, /* All other keys are undefined */ };
edit:
heres the new keyboard_callback
Code: Select all
void keyboard_callback() { char car; car = inb(0x60); monitor_write(kbdus[car]); }
@sweetgum: Try writing your own routines or at least rewriting someone elses instead of just copy pasting. The code might make more sense. I know OS dev is confusing, it is for me too. But use google and the wiki before posting.
Gizmic OS
Currently - Busy with FAT12 driver and VFS
Currently - Busy with FAT12 driver and VFS
Re: in / out ports
I don't see whats wrong with copying and pasting a scan code table. Anyway if someone can give me advice about what to do next I'd appreciate it