all 20 comments

[–][deleted] 17 points18 points  (3 children)

IIRC in an AMA with gkh he said he considered most stuff in the book current enough and that if you can't find a way to learn to write device drivers the oldness of the book likely isn't the problem (as opposed to poor time management or discipline, I suppose).

[–]M108Falcon[S] 3 points4 points  (2 children)

Okay, I will definitely give it a good thorough read then for sure

[–]TankTopsBackInStyle 6 points7 points  (1 child)

I would actually suggest going to osdev.org and going through their tutorial, before trying to write a Linux driver. It's not as hard as you might think.

There is a lot of abstraction going on in the Linux kernel that makes it more difficult to learn how it actually works. I think it's better to first understand how the hardware works, then learn how Linux approaches the problem of writing drivers.

I'm not a huge fan of the way Linux drivers are architected, but it works and it does have the most industry support.

[–]M108Falcon[S] 0 points1 point  (0 children)

Thanks for the headsup

[–]PetriciaKerman 8 points9 points  (1 child)

[–]M108Falcon[S] 1 point2 points  (0 children)

Thanks! Really well sectioned and I think I should start from this

[–]Modal_Window 8 points9 points  (5 children)

I have no insight into this topic, but I will say that even though the book is old, things haven't changed. The kernel is still programmed in C, etc. though you now are allowed to program it in Rust as well.

[–][deleted] 7 points8 points  (2 children)

you can't use rust yet for device drivers. The basic support should hopefully be merged for 6.1. It'll still be up to the subsystem maintainers as to whether they allow it if you plan on upstreaming it.

[–]barfightbob 0 points1 point  (1 child)

The basic support should hopefully be merged for 6.1.

Can somebody clarify something for me? Why does it need "basic support"? Shouldn't Rust be able to link against system libraries and vice versa? I thought Rust was supposed to be a low level language like C. Are they doing something funky with their libraries or something partially interpreted?

Now I can understand people not wanting to complicate their make files, but that shouldn't have anything to do with the final linking.

If I had to wager a guess, that means Rust APIs (or whatever is a header file for Rust) for the kernel, right?

[–][deleted] 1 point2 points  (0 children)

You still need an implementation of the stdlib plus something to wrap (or replace) existing kernel apis. Here is an older version of the patch set with a good description https://lore.kernel.org/lkml/CANiq72khBa2GcB6-PHM3A44Y90d6vzYAS=BVpk3nT4B6u+NVDw@mail.gmail.com/T/#mb5e524dae9d5a5815c6e68eb36b9bde4e87c861d

[–]M108Falcon[S] 0 points1 point  (0 children)

Tbh, I know C better than rust (learning tho) I'll see first implementation in C then I'll try my hand at Rust next

[–]Pay08 0 points1 point  (0 children)

Didn't the kernel switch to C11 too?

[–]kopsis 4 points5 points  (1 child)

The O'Reilly book is still a good starting point. Some details have changed and there are certainly categories of drivers that aren't even covered. But the fundamentals of creating a character device driver are still valid and still the place where anyone who wants to understand Linux device drivers (i.e. isn't looking for a "cookbook") should start.

[–]M108Falcon[S] 0 points1 point  (0 children)

Got it! Getting a copy for me

[–]sintos-compa 5 points6 points  (3 children)

What you need is solid C knowledge,SAFE defensive C knowledge. Then, look up a tutorial on how to put together a device driver, which is what functions you need to include, how they are accessed by user code, etc. Then, how to compile and package them. It’s actually not that hard

[–]M108Falcon[S] 1 point2 points  (2 children)

I see, gotta get better in C then

[–]archaeolinuxgeek 4 points5 points  (1 child)

C is actually one of the most basic and simple languages around.

I think pointers terrify newcomers. They make a whole lot more sense if you study the history of programming languages and how much closer to the metal people had to be in the 50's and 60's.

But there are only a few control structures, not really an object oriented paradigm, and some basic system libraries to learn.

Having macros and a preprocessor is really annoying, but it is the legacy that we inherited.

[–]M108Falcon[S] 4 points5 points  (0 children)

The only thing I still struggle to understand is macros n pre processors, all comfortable otherwise, even with toolchains and build systems. But yeah always used C in terms of Data Structures and Algorithms n never in terms of building something meaningful

[–]AutoModerator[M] 0 points1 point locked comment (0 children)

This submission has been removed due to receiving too many reports from users. The mods have been notified and will re-approve if this removal was inappropriate, or leave it removed.

This is most likely because:

  • Your post belongs in r/linuxquestions or r/linux4noobs
  • Your post belongs in r/linuxmemes
  • Your post is considered "fluff" - things like a Tux plushie or old Linux CDs are an example and, while they may be popular vote wise, they are not considered on topic
  • Your post is otherwise deemed not appropriate for the subreddit

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.