KernelNewbies
  • Comments
  • Immutable Page
  • Menu
    • Navigation
    • RecentChanges
    • FindPage
    • Local Site Map
    • Help
    • HelpContents
    • HelpOnMoinWikiSyntax
    • Display
    • Attachments
    • Info
    • Raw Text
    • Print View
    • Edit
    • Load
    • Save
  • Login

Kernel Hacking

  • Frontpage

  • Kernel Hacking

  • Kernel Documentation

  • Kernel Glossary

  • FAQ

  • Found a bug?

  • Kernel Changelog

  • Upstream Merge Guide

Projects

  • KernelJanitors

  • KernelMentors

  • KernelProjects

Community

  • Why a community?

  • Regional Kernelnewbies

  • Personal Pages

  • Upcoming Events

References

  • Mailing Lists

  • Related Sites

  • Programming Links

Wiki

  • Recent Changes

  • Site Editors

  • Side Bar

  • Tips for Editors

  • Hosted by WikiWall

Navigation

  • RecentChanges
  • FindPage
  • HelpContents

Upload page content

You can upload content for the page named below. If you change the page name, you can also upload content for another page. If the page name is empty, we derive the page name from the file name.

File to load page content from
Page name
Comment

Revision 2 as of 2006-08-10 02:52:25
KernelNewbies:
  • FAQ
  • DoINeedToKnowAssembler

Do I need to know assembler to hack the kernel?

No.

In fact, even if you do know assembler it is better if you stick to C in most of the kernel, so your code is more portable, is more easily read and maintained and can be optimized by the compiler, which gets confused a lot less than humans do.

The kernel uses assembler code only where it is really needed:

  • very early boot code
  • system call and exception entry points
  • poking I/O ports
  • locking and barriers
  • switching between kernel and user space

Note that many of the things above need to be done from C code, for example device drivers need to poke at I/O ports. This is done through architecture defined C macros like inb, inw, inl, outb, outw and outl. These macros will automatically do the right thing by including the bits of inline assembler that are needed to make your driver work on the architecture on which it is compiled.

This means that the same device driver, written in C, can work on i386, x86-64, MIPS, PPC and other architectures. If the driver is written carefully, taking little/big endianness and 32 vs 64 bitness into account, no changes will be needed to run the driver on multiple architectures.

What about C++?

No. God no. Please see the [http://kernel.org/pub/linux/docs/lkml/#s15-3 LKML FAQ"] on that.

  • MoinMoin Powered
  • Python Powered
  • GPL licensed
  • Valid HTML 4.01