Documentation about device driver programming on kernel 3.x - linux

I have some homework which I should program a virtual device driver on kernel 3.x Can you suggest some documentation about it? I'm using fedora btw.
I know there are lots of tutorials, but there is some difference between 2.x and 3.x.

There is no major difference between the last 2.6.x series kernel and the 3.x series. It's an arbitrary distinction.
The reference work for Linux device drivers is the aptly named Linux Device Drivers. It's somewhat out of date (being based on 2.6.10), but still a good guide. There are slightly less out-of-date examples on Martinez Javiers GitHub.
Of course, the ultimate guide is the code itself. Regardless of what you do you will have to refer to the code frequently. Code reading is an incredibly valuable skill, and you should practice it as much as possible.

Related

OpenGL directly to Linux framebuffer without X-Server

I have a small OpenGL application that has been developed using GLUT. What are my best options to render directly to a Linux framebuffer (fbdev) with OpenGL, without an X-Server? I understand that GLUT needs X, so I'm not looking for ways to use GLUT without X.
The framebuffer device I intend to use is confirmed working with fbi and mplayer.
I have done (or I'd like to think that I have done) a pretty exhaustive research, and found some resources and libraries that might work. But most of the info is a bit outdated, and I'm not sure what to trust.
DirectFB looks good, exactly what I'm looking for, but does not seem to be in active development.
I'm inclined to try this out on my target device: https://github.com/mcdoh/glGears-on-DirectFB-with-OpenGL-ES - but again, this is the only example code I can find, and it's six years old.
Mesa is another interesting candidate, but I can't seem to find any recent information.
This looks interesting: http://www.mesa3d.org/glfbdev-driver.html - but I can not find any example code to go from.
So, while a lot of SO answers mention DirectFB and Mesa as solutions, I can't bring myself to be confident in those options while so little material can be found.
So, if you can point me in the right direction here, give me any examples to go from, that would be highly appreciated. What am I missing?
Edit due to question being marked as duplicate:
The answer to the related question recommends using DRM. I intend to run my code on an Allwinner H3-based embedded computer that does not yet support the mainline Linux kernel. Currently, it's running on kernel version 3.14, which I believe does not have DRM support.
So, are there any alternatives?

How to practice writing real Linux Device Drivers?

I am a intermediate level programmer with a decent experience in Linux Kernel Programming. During my internship I was mostly involved in debugging the kernel and driver code. I recently finished studying the Kernel Development book by Robert Love. I am halfway through the Linux Device Drivers Book by Jonathan Corbet. But I am now faced with a troubling issue. None of these books teach me how to actually write real (Hardware) Device Drivers. the LDD3e book tells me how to write memory based software drivers and sysfs interfacing in which I'm pretty good at. So where do I start ? What are the requirements and how do I go about it ?
P.S: I have begun reading the book 'Essential Linux Device Drivers by Sreekrishnan Venkateswaran'
You should DO it rather than just read it.
There is a great way to DO it first hand with fun.
Follow eudyptula challenge. Just got to eudyptula-challenge.org and do what they say. There are 20 tasks. After solving them you will not only know about kernel, but you would have done things with linux and kernel.
They says that they are using script to verify your drivers during challenge tasks, but I highly doubt it due to humorous and funny responses I get from them!

Linux kernel/os source code documentation?

Is there a Linux distro (other than Minix) with good documentation for the source code? Or, is there some good documentation to describe the general Linux source code?
I have downloaded the Kernel source code, but, it is (unsurprisingly) a little overwhelming to find my way around and I wondered if there were some higher-level documentation to go with how the Linux kernel works?
Have you tried having a look on The linux documentation project I've find it quietly exhaustive regarding linux
They have a section The Linux Kernel wich is an online book that explains
how the linux kernel works and why it does behaves in certain ways, you should deffinitely
look into it because it's very well made.
Some of the Linux kernel code has decent commenting as documentation, but if you're going to be getting into kernel development, I'd recommend picking up a good book. A good, relatively easy-to-read one is Linux Kernel Development, by Robert Love. I got started on the Second Edition when I was in college, and keep a copy of the third on my bookshelf now.
I also find the Linux Cross Reference site helpful in jumping around the kernel source code. It's nice for tracking down functions that are in different files, and getting at what you need.
If you want to learn about operating systems and their basics, I strongly suggest you to start with a small kernel and then ramp up to learn about Linux. Starting with an operating system like Linux would be overwhelming in terms of code and documentation.
There is XV6 operating system which follows the basic Unix notion of files and processes. You can get the code listing and the documentation explaining the code properly. Here is a link to it. link.
Since academia is using this course as a baseline, I think you should get good support for understanding the same.
Linux Core Kernel Commentary is a little dated, but is still an excellent source of info.
For something which is not obsolete (like kernel.org/doc is), you may see:
Free Electrons Linux/Documentation/ (3.8)
Linux Cross Reference kernel/Documentation/
kernel-doc (3.6.10)
The first is the one I prefer personally (clean, readable, pleasant, up‑to‑date).
The second is the most well known.
The third, is for download, if you wish to browse and search it off‑line (may be handy in some case).
My two cents as a side note before I leave: I feel it's weird how for such a famous stuff as the Linux kernel is, when you search the web for documentation, you get masses of obsolete documentations, and how the rather up‑to‑date ones seems to be rather hidden and far from the top position of search engines.

Resources that explain Linux source code

Looking for resources that can help getting 'into' the Linux code. Could not get much help on Google. I have no issues on the distro covered by the book/resource, but will like if Fedora is the base. Also, it would be great if the resource is well maintained and updated.
this looks promising:
http://kernelnewbies.org/KernelHacking
Note that you will need to be familiar with Operating Systems concepts to even understand the concepts of how memory is allocated, how processes are scheduled, and whatnot. Also, the code of the linux kernel is monstrously complex.
You are undertaking a daunting task. But have fun with it. You might want to start with a small device driver's code.
http://www.makelinux.net/kernel_map may be a good place to start. A clickable map which takes you to the part of the source you clicked. Readable in a browser.
If you are talking about the Linux kernel, kernel newbies is absolutely awesome. Besides that, I don't think theres a single resource to recommend.
If you are trying to understand the linux kernel source code, then the exact distribution you are using, is not very relevant.
I would recommend the book from Robert Love: Linux Kernel Development, currently in its third edition. It will give you an understanding of the main parts of the kernel.

Question regarding Unix/Linux kernel programming

I would like to learn about linux/Unix kernel programming for scalable multi processors (smps). I found this book UNIX(R) Systems for Modern Architectures http://www.amazon.com/UNIX-Systems-Modern-Architectures-Multiprocessing/dp/0201633388/ref=pd_rhf_p_t_3 . Is there any other good resources or a better book since its released in 1994. Thank you very much in advance.
Thanks & Regards,
Mousey.
Definitely buy this excellent book! You will get thorough introduction into:
caches, their types, and how to deal with them in the kernel,
synchronization and what hardware primitives are behind it,
general kernel designs as related to concurrency (cli/sti, giant lock, cli+spinlock, etc.)
The book is general enough not to be out of date by now. The only thing I don't remember mentioned there is NUMA, but I don't think there are any good published texts on this subjects yet except for maybe Gorman's Linux memman paper (somebody correct me if I'm wrong here).
I think the book was really worth the money.
Understanding the Linux Kernel is a great book about how the Linux kernel is built, it describes Linux 2.2, 2.4 and 2.6 (Third Edition).
If you want to make drivers, there's Linux Device Drivers , and is also a reference about how Linux is built.
For Linux, Rusty's Unreliable Guide to Kernel Locking is a must-read. After that, you can also read the file Documentation/spinlocks.txt located in the Linux kernel sources.

Resources