Search code examples
operating-systemembeddedkerneldriverboot

How drivers work out of the box in x86 and not in embedded computers like Android phone


I'm curious about how the drivers work out of the box in x86 motherboards, like display, USB controllers etc.

For example : Booting a toy custom kernel in x86 can display to screen without doing any extra work on the drivers space, however for an Android phone which is an embedded system, it seems almost impossible to display to screen with my own toy custom kernel (as there is information out there available about the memory map of the device and how the display is interfaced with the device).

Why is that I/O works out of the box in x86 motherboards and doesn't on embedded computers?


Solution

  • x86 PC firmware has standard software interfaces (a lot like system calls), either modern UEFI or legacy BIOS int 0x10 and other interrupts.

    The key point is that it's not just bare-metal x86, it's IBM PC-compatible which means software and even emulated legacy hardware like a PS/2 port, VGA, and even legacy interrupt controller.

    If you didn't have all this help from firmware (for the benefit of bootloaders and toy OSes), you'd have a much harder job, e.g. needing at least a basic USB-hid and USB host-controller driver to get keyboard input. The lowest level function to handle a user input

    Why is that I/O works out of the box in x86 motherboards and doesn't on embedded computers?

    That's not your real question. Embedded machines have working I/O hardware, they just don't come with portable software APIs/ABIs wrapped around drivers as part of the firmware.

    I think most vendor's SDK comes with functions to access the I/O hardware (after maybe doing some fiddling to get it into a usable state). i.e. to write your own driver for it.


    Embedded doesn't need this in firmware because it's expected that the kernel will be customized for the hardware.

    Wouldn't it be better to have a BIOS or UEFI for maximum portability? Does it have any drawbacks to include one?

    Yes: code size in the boot ROM, and someone has to write + debug that code. This costs time and developer salary.

    No point in booting up what's nearly an OS (a UEFI environment) just to load a kernel which is going to take over the HW anyway.

    Also a downside in boot time: any code that runs other than loading the kernel where it wants to be is wasted CPU time that slows down the boot. Having a very lightweight interface that just lets you get your kernel loaded, and leaving all the I/O to it, makes sense for this.


    Unlike x86 PCs, there's no expectation that you can use this hardware with an OS install disc / image you downloaded that isn't specifically customized for this hardware.

    It's not intended to be easy for hobbyists to play with using training-wheels APIs. Real OSes on this hardware won't use such APIs so why provide them in the first place?