Is this a good or a bad idea?
Posted: Mon Jan 04, 2010 6:46 am
I had an idea (I want to write a bunch of little tools, mostly Perl scripts and such to ease writing my kernel later on (in a year or two)) yesterday which Linux users will recognise because it's based off the vmlinuz idea (the Linux kernel is built into vmlinux and then compressing into vmlinuz (because, let's face it: the Linux kernel is bloated with bells and whistles)).
I don't know how similar or otherwise this is to the vmlinuz process, because I don't know how they do it (I have built a Linux kernel, but all I did was, I couldn't build the modules or the initrd, so I never got it to boot); but anyway, here it is in the form of a 65-line C comment (I wrote it with C syntax highlighting because I wanted it coloured in).
I haven't come up with an official name yet (I'll do that later); but I like the name Prolix (pun on Minix, Prolix is an actual word meaning "verbose;" I've been told multiple times that I over-comment my code) so I'll use that for now (and maybe forever).
If you can read it, I made a flow chart in the hope of making the process easier to understand in-depth; but I don't know how comprehensible the flowchart actually is, so hopefully the bulleted list should be enough.
I don't know how similar or otherwise this is to the vmlinuz process, because I don't know how they do it (I have built a Linux kernel, but all I did was
Code: Select all
make menuconfig; make; make modules; make install; make modules_install [failed]; yaird [Yet Another mkInitRD] [failed];
I haven't come up with an official name yet (I'll do that later); but I like the name Prolix (pun on Minix, Prolix is an actual word meaning "verbose;" I've been told multiple times that I over-comment my code) so I'll use that for now (and maybe forever).
Code: Select all
/* Kernel build process:
* **** List: ****
* * Kernel is built into prolixkernel.bin (binary)
* * Clzss (C implementation of the LZSS compression algorithm) is called
* to create prolixkernel.zbin (zipped binary)
* * Cmd5 (C implementation of the MD5 hashing algorithm) is called to
* create an md5 hash of the kernel.
* * The resulting hash is built into the file prolixboot.bin, via a #define
* passed by gcc on the command-line
* * On boot, the prolixboot.bin program re-md5's the prolixkernel.zbin file
* and checks that it's the same as the #defined md5 (I'll build Clzss and
* Cmd5 into the prolixboot.bin program) and then either prints a warning
* message that the kernel was tainted or extracts it, depending on whether
* the md5s were different or the same, respectively.
* * The prolixkernel boots
*
* **** Flow Chart: ****
*
* Key:
* ( ... ): start or end of block
* [ ... ]: processing
* / ... /: input/output
* < ... >: conditional
* ->, <-, V or ^: control flow (right, left, down and up respectively).
*
* **** Building: ****
*
* ( start build process ) <---------------
* V ^
* < kernel built? > NO -> [ build kernel ]
* YES
* V
* / file prolixkernel.bin is created /
* V
* [ lzss-compress the kernel with Clzss ]
* V
* / file prolixkernel.zbin is created /
* V
* [ md5sum the kernel with Cmd5 ]
* V
* [ build prolixboot.bin from boot.o Cmd5.o and Clzss.o,
* pass the md5 hash on the command line as KERNEL_MD5 ]
* V
* / file prolixboot.bin is created /
* V
* [ create floppy disk image ]
* V
* / file prolix.img is created /
* ( end build process )
*
* **** Booting: ****
*
* ( start boot process )
* V
* [ re-MD5 the prolixkernel.zbin file with Cmd5 ]
* V
* < new MD5 matches KERNEL_MD5? > NO -> ( print error message and shut down )
* YES
* V
* [ de-compress the kernel with Clzss ]
* V
* [ boot the kernel ]
* V
* ( end boot process )
*/