Re: Linux Assembly

From: Kasper Dupont (kasperd_at_daimi.au.dk)
Date: 12/07/03


Date: Sun, 07 Dec 2003 23:12:54 +0100

Bill Cunningham wrote:
>
> I know there are short assembly code in the MBR, small enough to bootstrap.

The conventional MBR just contained code to load the boot sector from
the active partition and transfer control.

> I've seen some assembley code in the kernel source designed to do this I
> believe.

I don't think so. The MBR is not part of the kernel. Kernels until
version 2.4 contains a boot record, that can be used to load the
kernel from a floppy, but that was removed from 2.6 kernel. But for
a long time the prefered way to load a kernel was with some other
loader.

The first sector of a loader like LILO or GRUB contains code to
load the next stage of the loader, which takes up multiple sectors.
That first sector can in both cases be located either in the MBR
or in the boot record of a partition, in which case you would use
a conventional MBR to transfer control. (Is it possible to boot
any of them from the boot record of a FAT partition?)

> Linus wrote alot of this code

I don't think Linus wrote any of the LILO or GRUB code.

> Can C be used to bootstrap a computer from BIOS?

Even the running kernel requires some assembly code, bootstrapping
is in some ways worse. Port I/O and interrupt handling are some
examples of what requires assembly code. While language support
for such stuff is possible, it is really not worth much. It would
still be architecture dependant, so you might as well do it with
inline assembly.

-- 
Kasper Dupont -- der bruger for meget tid paa usenet.
For sending spam use mailto:aaarep@daimi.au.dk
/* Would you like fries with that? */


Relevant Pages

  • Re: Problem with FASM
    ... fasm source of a driver and want to integrate it to my kernel. ... returns back to next line in C Code after assembling assembly code) ... For boot sector creation you better forget about any C ... ... Just create a .com file and have org 0 for BOOT or 7c00h for MBR ...
    (alt.lang.asm)
  • Re: OEMWriteDebugString problem
    ... set WINCEREL and rebuild the kernel. ... In the obj folder will be .COD ... files which contain the C code as well as the assembly code that it creates. ... beitman AT applieddata DOT net ...
    (microsoft.public.windowsce.platbuilder)
  • Re: Cross-compilation to i386
    ... > For some reason, as doesn't like big negative numbers. ... > The world and kernel builds then completed succesfully. ... > boots on a diskless machine. ...
    (freebsd-current)
  • Re: Linux* Processor Microcode Data File
    ... instructions are replaced in assembly code? ... The kernel doesn't load microcode automatically but it can provide a ... device to allow userspace to trigger a microcode update (via ...
    (Linux-Kernel)
  • Re: Producing assembly language listing of kernel
    ... want to see the assembly code for the whole kernel. ... imagine anybody actually sitting down and trying to read it at all. ... but I need to see how they are being built, when the kernel is assembled. ...
    (comp.os.linux.development.system)

Loading