touch pad driver - c

Can anyone suggest some good references for writing a touchpad driver for linux. Where would I get hardware documentation from. I have read most of the linux device driver books and now I want to take it to the next level.

Are you sure there is no current support for your sentelic in linux kernel? Take a look at Documentation/input/sentelic.txt in Linux source code. If it does not give you direct answers, you'll be able to see how to implement something similar instead. Take a look at its sources, too.
Moreover, if you are not really, really familiar with Linux kernel programming yet, you can read Linux Device Drivers (freely available), Linux Kernel Mode Programming (available, too) and Linux Kernel Development. Some of those sources are somewhat dated, but will give you right ideas about development.

Related

Learning Linux Kernel programming on a virtual machine on Ubuntu?

I am just learning linux kernel programming with the LINUX KERNEL DEVELOPMENT book(I am beginner linux kernel programming but not on linux programming). It is possible to test programs in a kernel machine with VMware viritual on Ubuntu without damage my system ?
Yes you can safely test kernel modules on a virtual machine!
I'll give you some links that may help:
watch this site
http://free-electrons.com/
in particular this book:
http://free-electrons.com/doc/books/ldd3.pdf
Also this guide:
http://www.tldp.org/HOWTO/Module-HOWTO/
An embedded distro is even better
An Ubuntu guest is fine, but I prefer to keep things minimal and use an embedded distro, as this will make things:
simpler and easier to understand and control
faster
In particular, I recommend using:
Buildroot, which is highly configurable, documented and maintained, also builds host QEMU so easy to patch it up (e.g. to add your own devices since out-of-tree devices are not possible yet ?)
QEMU emulator: small comprehensible source, ARM support, official Android emulator, kernel GDB support
Embedded distros can generate rootfs images smaller than 10MiB, and it becomes possible to understand the entire userland setup, which will make it easier to focus on the kernel.
I have made a setup to make everything as automated as possible: https://github.com/cirosantilli/linux-kernel-module-cheat
I've been using a VM for a long time for Linux kernel programming and I've never had any problem. Actually, if you manage to violate the protections of a VM then you will probably be hired by Oracle or VMWare :D
However, I recommend you to read this post: https://security.stackexchange.com/questions/23452/is-it-safe-to-use-virtual-machines-when-examining-malware

FreeBSD POSIX C Oracle API

I have trouble finding Oracle Call Interface for FreeBSD. I maybe missing something simple but I searched net for several days and finally ended up here with question.
My task is fairly simple: write a program in posix C that connects to an Oracle database and works on a FreeBSD machine. In worst case scenario I will drop the POSIX and FreeBSD part and make it work on Linux but so far my goal is to do this on BSD. Here is what I found so far:
ftp://ftp.atnet.ru/pub/OS/FreeBSD/oracle/otl/otl.htm
A GNU library which I have not tested yet, if anybody knows anything about it please do tell so:
http://sourceforge.net/projects/orclib/files/OCILIB%20Sources/3.12.1/
If you have any kind of suggestion of how this could be done better please do tell. Or even better if you have experience in this situation.
Oracle themselves do not support FreeBSD. There are ports of their Linux client-libraries, however, that are made to work on the OS:
databases/oracle8-client
databases/oracle7-client
Unfortunately, the above two are currently only working on i386, but you may be able to use the same technique as the port's author to massage the x86_64 Linux binaries to work under FreeBSD/amd64.
And then there is a port of the open-source ODBC driver in:
databases/oracle_odbc_driver
This one requires oracle8-client and is thus also i386-only at this time.
There is oracle instance client for Mac OS X. AFAIK Mac OS somehow related to FreeBSD codebase. So, perhaps, adaptation of Mac OS client would be easier then Linux one. (I didn't try it however).

Custom Kernel: Implement filesystem

As a out of course project, I am currently developing a kernel in an attempt to better understand all the aspects of an actual OS. So far, I am done setting up a flat physical memory model with support for paging and the basic interrupts (keyboard and perhaps trackpad/mouse next). I thought the step forward would be to implement a filesystem and I am keen about the ext2. I have looked around, even on SO but there isn't anything explicit that answers my questions:
Is it possible to write a driver to access an ext2 filesystem in C or do I need to go lower?
If I plan to access the filesystem off a USB device, I am assuming I will need to get the device driver for USB running first. Any help on this would be greatly appreciated.
I know the code for detecting a filesystem is already available on the MINIX and other kernels but what I really want to know is if I want to build a custom albeit simple filesystem, how do I go about it? I am considering this possibility too.
My apologies if the question and details sound a little ignorant but I am still in the learning process.
Thanks :)
I'll try to give you a few tips/hints - a clear answer isn't that simple:
An ext2 filesystem written in C is just C. C is just a programming language - you can use C++, plain assembly or a few others (A few os'dever use D) - but not a "managed" language etc. But it is important that you have a rock solid understanding of this language. In my opinion assembly is a MUST (Take a look at the scheduler in an operating system -> plain assembly)
Do you really want to write an USB driver ? It isn't "just" a simple USB driver (Layer of abstractions). Why a USB driver and not a floppy disk or CD driver (Believe me - a floppy driver in 32 bit protected mode isn't that hard) ?
Please focus on your project. Of course Linux (Early versions) and Minix have example code, but take care of the design structure (Monolithic/Microkernel or hybrid-kernel) - and don't mix it, write your own code.
Please make on step after the other. You wrote a basic IRQ handling and the plan is to write a keyboard/mouse driver - write the keyboard driver ! Don't dream about loading and executing files (Rom wasn't built in one day).
You have to read documentations, for example the Intel manuals or other "books". A very popular forum is osdev.org - take a look at the wiki. As twalberg said, it's a very huge module - stay focused on the main parts of your operating system.
I know, this is not the answer to your question - but it's important not to go in the wrong direction and dream of a fancy UI or something like this ;)
osdev.org forum
osdev.org wiki
Intel manuals
And a few other books in my book shelf can you find here (Tanenbaum, Silberschatz with Peter Galvin - great books!):
Books

Writing a driver to fool Linux systems about having a GPU

I'm into something about writing a "Mock GPU driver" for Linux based systems. What I mean is that, simply I want to write a driver (Behind X-server obviously) to answer X's API calls with some debugging messages.
In other words I want to fool Linux about having an actual GPU. So I can make a test-bed for GUI-accelerated packages in console based systems.
Right now, if I execute a GUI-accelerated package in Linux console based systems; it'll simply dies due to lack of a real GPU (or a GPU driver better I'd say).
So I want to know:
Is it even possible? (Writing a GPU driver to fool Linux about having an actual GPU)
What resources do you recommend before getting my hands dirty in code?
Is there any similar projects around the net?
PS: I'm an experienced ANSI-C programmer but I don't have any clue in real Kernel/Driver development under *nix (read some tutorials about USB driver development though), so any resources about these areas will be really appreciated as well. Thanks in advance.
What you are looking for is actually part of Xorg server suite, and it is called Xvfb (virtual framebuffer).
If you're not afraid of a bit complex bash, you can take a look at Gentoo's virtualx.eclass for an use example (we use it to run tests which require X11).
A good place to start is the Mesa project - it implements OpenGL in software. It has a way to trick the OS into thinking that it is the OpenGL driver.

how to code drivers?

I want to code drivers in C in linux os, though I think its very tough. Can I get some hints as to how to start or books to follow? Drivers can be from my USB port to graphics card!!
I know as to where I can search for books, I would like to know as to what the basic knowledge I should start with. Do I need to have hardware knowledge and which specific books are good for novice like me?
Start with Linux Device Drivers by Rubini and Corbet, published by O'Reilly.
It's also available as a free PDF download.
"Linux Device Drivers" (the O'Reilley book) by Rubini and Corbet is the definitive book for Linux Device Drivers.
Cool! see the free pdf version in Roddy's answer & kristina's comment!
try amazon !! there is many books there for drivers . some have samples 2 !!
Several texts:
Essential Linux Device Drivers (I really enjoyed this one. It has a strong introductory section on Linux and how device drivers generally work.)
Linux Device Drivers (The "standard" with a free pdf link as mentioned by others)
Understanding the Linux Kernel (The longer you spend here, the better you need to really understand the kernel. This will help.)
Before you jump into designing drivers you should first get exceptional C skills and probably some Linux Kernel know-how. Desigining drivers is not trivial and might scare you off if you are not used to programming on a low-level.
I might recommend The C programming Language if you are not accustomed to C as it is, in my opinion, the primer on C if you have some programming background.
Drivers differ greatly in complexity depending on the device. USB drivers are on the simple side of the spectrum; GPU drivers are massively complex and even the authors of those drivers usually don't know everything that they do. My recommendation would be focusing on drivers for hardware you personally care about, rather than trying to be a jack-of-all-hardware; it'll be easier in the long run.
Everybody else's answers about documentation sources and various things to read are spot-on and you should really accept one of them.
Many of the more complex driver communities have their own domain-specific information as well. If you want to write a GPU driver, the DRI/DRM and Mesa communities have their own wikis and mailing lists which will help you out greatly, as well as their own documentation. http://dri.freedesktop.org/ is a decent starting place, as is http://wiki.x.org/.
Hope this helps!
you have here a really good example
http://www.linuxjournal.com/article/7353
Just look at the source codes of current drivers. I wrote my usb rndis driver by only reading the comments put above the codes.
Get the kernel source and look at /drivers directory. Usb drivers are in usb directory, however usb drivers about networking are resided in /net/usb.
You can learn lots by reading the comments.

Resources