Writing on keyboard port via inb(), outb() system calls
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Writing on keyboard port via inb(), outb() system calls
Hi All,
I am working with fedora 6 , i386 architecture.I am trying to write on keyboard port via program.On inspation i come to know that 0x0060 to 0xz006f are used for keyboard in linux 2.6 kernel in the i/o space from kernel.
#include<sys/io.h>
#include<stdio.h>
#include</usr/lib/syslinux/com32/include/sys/io.h>
#include<unistd.h>
//#define
/*
Port Rd/Wte Function
0x60 Read Read Input Buffer
0x60 Write Write Output Buffer
0x64 Read Read Status Register
0x64 Write Send Command
The commands you're talking about are implemented in the BIOS (not in the x86 processor per se).
The whole purpose of an OS is to *insulate* you from the BIOS (and other low-level, hardware details).
Short answer: you can do it ... but it'll take considerably more effort than you might think.
Strong suggestion:
If you want "unbuffered keyboard I/O", then I strongly urge you to consider using a library like SDL (for "games-like" interfaces), or ncurses (for text-mode).
What paulsm4 said...
Do you know what writing to the keyboard will accomplish? If you really want to write to x86 IO ports, you can use the ioperm() + outb() family of functions, or the /dev/port interface. You will require root privileges to do this. There is quite likely an existing driver accessing that hardware, and you may be disallowed access altogether, or at best you will be competing for access to the hardware by said driver.
If this is more than just a target to practice throwing bytes at, I would be most interested in your application, especially if it is to for some novel way of using a PC keyboard interface.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.