[PATCH] Compressed ia32 ELF file generation for loading by Gujin 1/3

Etienne Lorrain
2007-02-05T23:56:14Z

[-- Attachment #1: Type: text/plain, Size: 3365 bytes --]

Hello,

The Gujin bootloader (now at version 1.8) can natively load
compressed ELF files, and these three patches enable to generate
this "linux-2.6.20.kgz" file format.
Just as a remainder, to generate a bzImage file, those steps
are needed:
1- Compile the core kernel and link it into the ELF file vmlinux
at the top of the directory. Also compile and link modules.
2- Create a binary image of the kernel memory.
3- Compress this binary image with GZIP.
4- Assemble and link in an independant file the bootsector, the
setup and the real-mode code (in assembler) to start and gather
BIOS information.
5- Compile the protected mode code to decompress the kernel,
and re-adjust relocation defined at step 1 after decompression.
6- Get the binary image for real-mode and protected-mode parts
7- Mix the 3 parts in the same file named bzImage.

The previous version of Gujin were loading Linux kernel as after
step 3, the new one is basically able to load after step 1.
The ELF image is still better stripped of its debugging information
(to reduce time to load from disk) and compressed by GZIP to be able
to check its CRC32.
The BIOS information gathering did not evolve that much since the
first version of this patch - still written in C and included in
the initial link at load address 0 (no conflict with linux code at
address 0xC0000000).
The standard comment field of the GZIP is still used to describe this
kernel (processor, license...) but no more needs address references
because all needed information (address to load, address and size of
the real-mode code to gather information from the BIOS) is taken from
the ELF program header table (if real-mode code is not found it is
also searched in the section table).

Gujin real-mode C BIOS gathering code is automatically removed by
the "objdump" at step 2 when generating a bzImage, so there is no
need to disable anything to continue using Lilo/Grub/Syslinux...

The first two patch contains the interesting parts, that is files
realmode.[ch] to gather the BIOS informations, a small modification
to the command line (treating the first words as the pathname and
kernel name if present) which help Gujin autodetect the root
partition, the linker modifications (there is a single link with
Gujin kernel file "/boot/linux-2.6.20.kgz") and the Makefile
modifications.
The third patch just adds two files as independant commands,
gzcopy.c to view/edit/modify Gzip files (BSD like licensed) and
gzparam.c to display a single line used as the GZIP comment,
to forbid to load ia64 kernels on ia32 and this kind of
restrictions.

For me, these patchs are ready to be included in the kernel,
but I am ready for (or even waiting) any interesting discussion
about them.
I most like the simplicity of the generation system / load
process after the patch, just execute:
make /boot/linux-2.6.20.kgz
(recompile the modules if you have some) and reboot...
More info about Gujin at:
http://gujin.org

Have fun,
Etienne.

___________________________________________________________________________
Découvrez une nouvelle façon d'obtenir des réponses à toutes vos questions !
Profitez des connaissances, des opinions et des expériences des internautes sur Yahoo! Questions/Réponses
http://fr.answers.yahoo.com

[-- Attachment #2: gujin-patch-2.6.20-1 --]
[-- Type: application/octet-stream, Size: 28980 bytes --]

diff -uprN -X linux-2.6.20/Documentation/dontdiff linux-2.6.20/arch/i386/Kconfig linux-2.6.20-gujin/arch/i386/Kconfig
--- linux-2.6.20/arch/i386/Kconfig 2007-02-04 18:44:54.000000000 +0000
+++ linux-2.6.20-gujin/arch/i386/Kconfig 2007-02-05 21:27:01.000000000 +0000
@@ -816,6 +816,12 @@ config PHYSICAL_START
vmlinux for dump capture. This option should go away down the
line.

+ You can also change this physical address when using the Gujin
+ bootloader (see http://gujin.org), for instance to maximize the
+ free ISA DMA-able memory or run the kernel at a huge TLB boundary,
+ set it to 0x1000000 (load and run the kernel at 16 Mbytes).
+ Gujin (v1.4 and later) does not impose any limit on this address.
+
Don't change this unless you know what you are doing.

config RELOCATABLE
diff -uprN -X linux-2.6.20/Documentation/dontdiff linux-2.6.20/arch/i386/kernel/Makefile linux-2.6.20-gujin/arch/i386/kernel/Makefile
--- linux-2.6.20/arch/i386/kernel/Makefile 2007-02-04 18:44:54.000000000 +0000
+++ linux-2.6.20-gujin/arch/i386/kernel/Makefile 2007-02-05 21:27:01.000000000 +0000
@@ -7,7 +7,8 @@ extra-y := head.o init_task.o vmlinux.ld
obj-y := process.o signal.o entry.o traps.o irq.o \
ptrace.o time.o ioport.o ldt.o setup.o i8259.o sys_i386.o \
pci-dma.o i386_ksyms.o i387.o bootflag.o e820.o\
- quirks.o i8237.o topology.o alternative.o i8253.o tsc.o
+ quirks.o i8237.o topology.o alternative.o i8253.o tsc.o \
+ realmode.o

obj-$(CONFIG_STACKTRACE) += stacktrace.o
obj-y += cpu/
diff -uprN -X linux-2.6.20/Documentation/dontdiff linux-2.6.20/arch/i386/kernel/setup.c linux-2.6.20-gujin/arch/i386/kernel/setup.c
--- linux-2.6.20/arch/i386/kernel/setup.c 2007-02-04 18:44:54.000000000 +0000
+++ linux-2.6.20-gujin/arch/i386/kernel/setup.c 2007-02-05 21:27:01.000000000 +0000
@@ -579,6 +579,19 @@ void __init setup_arch(char **cmdline_p)
strlcpy(command_line, saved_command_line, COMMAND_LINE_SIZE);
*cmdline_p = command_line;

+ /*
+ * If the command line begin with '/', it is the filename of the
+ * kernel file - like a shell command line. That can be used to
+ * deduce where root was located when the kernel was compiled,
+ * inside a directory of root named /boot, inside a small partition
+ * mounted on a directory of root named /boot or in the root
+ * directory itself.
+ */
+ if (**cmdline_p == '/')
+ while (**cmdline_p != ' ' && **cmdline_p != '\t'
+ && **cmdline_p != '\n' && **cmdline_p != '\0')
+ ++*cmdline_p;
+
max_low_pfn = setup_memory();

/*
diff -uprN -X linux-2.6.20/Documentation/dontdiff linux-2.6.20/arch/i386/kernel/vmlinux.lds.S linux-2.6.20-gujin/arch/i386/kernel/vmlinux.lds.S
--- linux-2.6.20/arch/i386/kernel/vmlinux.lds.S 2007-02-04 18:44:54.000000000 +0000
+++ linux-2.6.20-gujin/arch/i386/kernel/vmlinux.lds.S 2007-02-05 21:27:01.000000000 +0000
@@ -25,16 +25,48 @@
OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
OUTPUT_ARCH(i386)
ENTRY(phys_startup_32)
+EXTERN(__ERROR) /* Force a link error if function __ERROR() is ever called */
+NOCROSSREFS(.realmode .text)
+NOCROSSREFS(.realmode .data)
+NOCROSSREFS(.realmode .rodata)
jiffies = jiffies_64;
_proxy_pda = 0;

PHDRS {
- text PT_LOAD FLAGS(5); /* R_E */
- data PT_LOAD FLAGS(7); /* RWE */
- note PT_NOTE FLAGS(4); /* R__ */
+ text PT_LOAD FLAGS(5); /* R_E */
+ data PT_LOAD FLAGS(7); /* RWE */
+ note PT_NOTE FLAGS(4); /* R__ */
+ text16 PT_LOAD FLAGS(5); /* R_E */
}
SECTIONS
{
+ /* realmode BIOS (initialisation only) boot code/data area.
+ * Here, segment .code16 is relocatable but .data16 is not.
+ * To see the assembler of compiled file realmode.c:
+ * objdump -D -m i8086 arch/i386/kernel/realmode.o
+ * objdump -d --section=.realmode -m i8086 vmlinux
+ */
+ /* FIXME: remove space-space-tab at beginning of lines in this file, use vi! */
+ .realmode 0 : AT (ADDR(.bss) + SIZEOF(.bss) - LOAD_OFFSET) {
+ *(.init.text16)
+ . = ALIGN(16);
+ _sdata16 = .;
+ *(.rodata16* .data16 .bss16)
+ . = ALIGN(16);
+ _edata16 = .; /* maximum 0x1000 i.e. 4 Kb limit */
+ *(.text16)
+ . = ALIGN(16);
+ _end16 = .;
+ /* Keep a 16 bytes signature block at end of file: */
+ LONG(0)
+ LONG(SIZEOF (.realmode))
+ LONG(ADDR (.realmode))
+ BYTE(0x42) /* 'B' */
+ BYTE(0x49) /* 'I' */
+ BYTE(0x4F) /* 'O' */
+ BYTE(0x53) /* 'S' */
+ } :text16 = 0x9090
+
. = LOAD_OFFSET + LOAD_PHYSICAL_ADDR;
phys_startup_32 = startup_32 - LOAD_OFFSET;
/* read-only */
diff -uprN -X linux-2.6.20/Documentation/dontdiff linux-2.6.20/arch/i386/Makefile linux-2.6.20-gujin/arch/i386/Makefile
--- linux-2.6.20/arch/i386/Makefile 2007-02-04 18:44:54.000000000 +0000
+++ linux-2.6.20-gujin/arch/i386/Makefile 2007-02-05 21:27:01.000000000 +0000
@@ -25,7 +25,7 @@ CC := $(CC) -m32
endif

LDFLAGS := -m elf_i386
-OBJCOPYFLAGS := -O binary -R .note -R .comment -S
+OBJCOPYFLAGS := -O binary -R .note -R .comment -R .realmode -S
ifdef CONFIG_RELOCATABLE
LDFLAGS_vmlinux := --emit-relocs
endif
diff -uprN -X linux-2.6.20/Documentation/dontdiff linux-2.6.20/include/asm-i386/realmode.h linux-2.6.20-gujin/include/asm-i386/realmode.h
--- linux-2.6.20/include/asm-i386/realmode.h 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.6.20-gujin/include/asm-i386/realmode.h 2007-02-05 21:27:01.000000000 +0000
@@ -0,0 +1,531 @@
+/*
+ * This file "realmode.h" is licensed with the same license as the Linux
+ * kernel; anyway the mapping of the data structure produced is owned
+ * by Linux kernel copyright owner(s) - for a long time.
+ * More information in the "realmode.c" file.
+ *
+ * First version has been written by Etienne Lorrain in December 2004.
+ */
+
+/* try really hard to figure out the root filesystem when not given
+ on command line, uses Gujin data structures (GPL kernel) */
+#define ROOT_EXTENSIVE_SEARCH
+
+/* 16 bits segment in MSB, 16 bits offset in LSB: */
+typedef unsigned farptr;
+
+#define offsetof(type, field) ((unsigned)(&(((type *)0)->field)))
+
+/*
+ * This shall always be optimised away because the test has to be false,
+ * it shall produce an error in the build process.
+ * Corresponding line to the linker file 'vmlinux.lds': EXTERN(__ERROR)
+ */
+void __ERROR(void);
+
+/**
+ ** Mapping of the total structure exchanged in between the BIOS
+ ** boot code (in real mode) and the Linux kernel (in protected mode):
+ **
+ ** Some of those structures have to be put back in their corresponding
+ ** file - they are here until the big cleaning process begin...
+ **/
+struct screen_info { /* stolen^Wckeckout from linux/include/linux/tty.h */
+ unsigned char orig_x;
+ unsigned char orig_y;
+ unsigned short EXT_MEM_K; /* general info */
+ unsigned char undefined;
+ unsigned char orig_video_page;
+ unsigned char orig_video_mode;
+ unsigned char orig_video_cols;
+ unsigned short unused2;
+ unsigned short orig_video_ega_bx;
+ unsigned short unused3;
+ unsigned char orig_video_lines;
+ unsigned char orig_video_isVGA;
+ unsigned short orig_font_height;
+ /* VESA graphic mode -- linear frame buffer */
+ unsigned short lfb_width;
+ unsigned short lfb_height;
+ unsigned short lfb_depth;
+ unsigned lfb_base;
+ unsigned lfb_size;
+ unsigned short CL_MAGIC; /* 0xA33F, general info */
+ unsigned short CL_OFFSET; /* general info */
+ unsigned short lfb_linelength;
+ struct vesa_color_layout_str {
+ struct {
+ unsigned char MaskSize;
+ unsigned char FieldPosition;
+ } __attribute__ ((packed)) Red, Green, Blue, Rsvd;
+ } __attribute__ ((packed)) layout;
+ unsigned short vesapm_seg;
+ unsigned short vesapm_off;
+ unsigned short lfb_pages;
+ struct vesa_mode_attribute_str {
+ /* VESA: */
+ unsigned short mode_supported : 1; /* e.g. enought RAM for it */
+ unsigned short optional_info_available : 1;
+ unsigned short BIOS_output_supported : 1;
+ unsigned short color_mode : 1; /* else monochrome */
+ unsigned short graphic_mode : 1; /* else text mode */
+ /* VBE 2.0: */
+ unsigned short mode_not_VGA_compatible : 1;
+ unsigned short no_VGA_compatible_window : 1;
+ unsigned short linear_framebuffer_supported : 1;
+ unsigned short reserved : 8;
+ } __attribute__ ((packed)) vesa_attrib;
+ struct vesa_capabilities_str {
+ unsigned DAC8bit_present : 1;
+ unsigned nonVGAcontroller : 1;
+ unsigned DAC_needs_programmed_while_blanking : 1;
+ unsigned VBE_AF_extension : 1;
+ unsigned hardware_mouse_cursor : 1;
+ unsigned hardware_clipping : 1;
+ unsigned transparent_bitblt : 1;
+ unsigned reserved : 25;
+ } __attribute__ ((packed)) capabilities;
+ /* 0x3a -- 0x3f reserved for future expansion */
+ unsigned char reserved[6];
+} __attribute__ ((packed));
+
+struct apm_bios_info {
+ unsigned short version;
+ unsigned short cseg;
+ unsigned offset;
+ unsigned short cseg_16;
+ unsigned short dseg;
+ unsigned short flags;
+ unsigned short cseg_len;
+ unsigned short unused; /* cseg_16_len */
+ unsigned short dseg_len;
+} __attribute__ ((packed));
+
+/* See probe_cmos_for_drives() in linux/drivers/ide/ide-geometry.c */
+/* rarely used, also check for CMOS address 0x12 (int 0x41, 0x46) */
+union drive_info {
+ struct FDPT_str {
+ unsigned short phy_cyl;
+ unsigned char phy_head;
+ unsigned short start_reduced_write_current_cyl; /* PC XT only */
+ unsigned short start_write_precomp_cyl;
+ unsigned char max_ECC_burst_length; /* PC XT only */
+ union drive_ctl_byte_u {
+ struct {
+ unsigned char drive_step_speed:3;
+ unsigned char unused:3;
+ unsigned char disable_ecc_retry:1;
+ unsigned char disable_access_retry:1;
+ } __attribute__ ((packed)) xt;
+ struct {
+ unsigned char unused:1;
+ unsigned char disable_irq:1; /* 0 */
+ unsigned char no_reset:1; /* 0 */
+ unsigned char more_than_8_heads:1;
+ unsigned char always_0:1;
+ unsigned char manuf_defect_map_on_maxcyl:1; /* AT + */
+ unsigned char disable_ecc_retry:1;
+ unsigned char disable_access_retry:1;
+ } __attribute__ ((packed)) at;
+ unsigned char all;
+ } drive_ctl_byte;
+ unsigned char standard_timeout; /* PC XT only */
+ unsigned char formating_timeout; /* PC XT only */
+ unsigned char check_drive_timeout; /* PC XT only */
+ unsigned short landing_zone_cylinder; /* PC AT+ */
+ unsigned char phy_sect; /* PC AT+ */
+ unsigned char reserved;
+ } __attribute__ ((packed)) fdpt;
+ /* For translating BIOSes: */
+ struct EDPT_str {
+ unsigned short log_cyl; /* max 1024 */
+ unsigned char log_head; /* max 256 */
+ unsigned char signature_0xA0;
+ unsigned char phy_sect;
+ unsigned short start_write_precomp_cyl; /* obsolete */
+ unsigned char reserved;
+ union drive_ctl_byte_u drive_ctl_byte;
+ unsigned short phy_cyl; /* max 65536 */
+ unsigned char phy_head; /* max 16 */
+ unsigned short landing_zone_cylinder; /* obsolete */
+ unsigned char log_sect; /* max 63 */
+ unsigned char checksum;
+ } __attribute__ ((packed)) edpt;
+} __attribute__ ((packed));
+
+struct sys_desc_table_info {
+ unsigned short length;
+ unsigned char table[14];
+} __attribute__ ((packed));
+
+struct in_out_info {
+ unsigned char setup_sects; /* default 4 */
+ struct {
+ unsigned short read_only:1;
+ unsigned short unused:15;
+ } __attribute__ ((packed)) root_flags;
+ unsigned kernel_compressed_size; /* 16 bytes unit, rounded up; since 2.04 */
+ struct {
+ unsigned short size:11;
+ unsigned short unused:3;
+ unsigned short load:1; /* separate disk */
+ unsigned short prompt:1;
+ } __attribute__ ((packed)) ramdisk; /* RAMDISK, default 0 */
+ unsigned short vid_mode; /* Store mode for use in acpi_wakeup.S */
+ union {
+ struct {
+ unsigned char minor_root; /* ROOT_DEV */
+ unsigned char major_root; /* ROOT_DEV */
+ } __attribute__ ((packed)) fields;
+ unsigned short minor_major;
+ } __attribute__ ((packed)) root;
+ unsigned char AUX_DEVICE_INFO; /* ignored */
+ unsigned char jmp_trampoline[3];
+ union {
+ unsigned char bytes[4]; /* "HdrS" */
+ unsigned longword;
+ } __attribute__ ((packed)) header_signature;
+ unsigned short header_version_number; /* 0x0202 */
+ unsigned short realmode_swtch[2]; /* hook to plug in a A20-open func */
+ unsigned short start_sys_seg; /* SYSSEG */
+ unsigned short kernel_version; /* char pointer */
+ struct loader_t {
+ enum { LILO = 0, Loadlin, bootsect,
+ SYSLINUX, ETHERBOOT, ELILO, UNKNOWN,
+ GRUB, UBOOT, XEN, GUJIN
+ } type:4;
+ unsigned char version:4;
+ } __attribute__ ((packed)) type_of_loader;
+ struct {
+ unsigned char LOADED_HIGH:1;
+ unsigned char unused:6;
+ unsigned char CAN_USE_HEAP:1; /* heap_end_ptr is set */
+ } __attribute__ ((packed)) loadflags;
+ unsigned short setup_move_size; /* 0x8000 */
+ unsigned code32_start;
+ unsigned ramdisk_image;
+ unsigned ramdisk_size; /* in bytes */
+ unsigned short bootsect_kludge[2];
+ unsigned short heap_end_ptr; /* modelist+1024, version >= 0x0201 */
+ unsigned short pad1;
+ unsigned cmd_line_ptr; /* default 0x90800, version >= 0x0202 */
+ unsigned ramdisk_max; /* Protocol 2.03, Kernel 2.4.18-pre1 */
+ unsigned char free[96]; /* includes "trampoline" */;
+} __attribute__ ((packed));
+
+struct e820map_info {
+ long long addr; /* start of memory segment */
+ long long size; /* size of memory segment */
+ long type; /* type of memory segment */
+} __attribute__ ((packed));
+
+struct edd_device_params {
+ unsigned short length;
+ unsigned short info_flags;
+ unsigned num_default_cylinders;
+ unsigned num_default_heads;
+ unsigned sectors_per_track;
+ unsigned long long number_of_sectors;
+ unsigned short bytes_per_sector;
+ unsigned dpte_ptr; /* 0xFFFFFFFF for our purposes */
+ unsigned short key; /* = 0xBEDD */
+ unsigned char device_path_info_length; /* = 44 */
+ unsigned char reserved2;
+ unsigned short reserved3;
+ unsigned char host_bus_type[4];
+ unsigned char interface_type[8];
+ union {
+ struct {
+ unsigned short base_address;
+ unsigned short reserved1;
+ unsigned reserved2;
+ } __attribute__ ((packed)) isa;
+ struct {
+ unsigned char bus;
+ unsigned char slot;
+ unsigned char function;
+ unsigned char channel;
+ unsigned reserved;
+ } __attribute__ ((packed)) pci;
+ /* pcix is same as pci */
+ struct {
+ unsigned long long reserved;
+ } __attribute__ ((packed)) ibnd;
+ struct {
+ unsigned long long reserved;
+ } __attribute__ ((packed)) xprs;
+ struct {
+ unsigned long long reserved;
+ } __attribute__ ((packed)) htpt;
+ struct {
+ unsigned long long reserved;
+ } __attribute__ ((packed)) unknown;
+ } interface_path;
+ union {
+ struct {
+ unsigned char device;
+ unsigned char reserved1;
+ unsigned short reserved2;
+ unsigned reserved3;
+ unsigned long long reserved4;
+ } __attribute__ ((packed)) ata;
+ struct {
+ unsigned char device;
+ unsigned char lun;
+ unsigned char reserved1;
+ unsigned char reserved2;
+ unsigned reserved3;
+ unsigned long long reserved4;
+ } __attribute__ ((packed)) atapi;
+ struct {
+ unsigned short id;
+ unsigned long long lun;
+ unsigned short reserved1;
+ unsigned reserved2;
+ } __attribute__ ((packed)) scsi;
+ struct {
+ unsigned long long serial_number;
+ unsigned long long reserved;
+ } __attribute__ ((packed)) usb;
+ struct {
+ unsigned long long eui;
+ unsigned long long reserved;
+ } __attribute__ ((packed)) i1394;
+ struct {
+ unsigned long long wwid;
+ unsigned long long lun;
+ } __attribute__ ((packed)) fibre;
+ struct {
+ unsigned long long identity_tag;
+ unsigned long long reserved;
+ } __attribute__ ((packed)) i2o;
+ struct {
+ unsigned array_number;
+ unsigned reserved1;
+ unsigned long long reserved2;
+ } __attribute((packed)) raid;
+ struct {
+ unsigned char device;
+ unsigned char reserved1;
+ unsigned short reserved2;
+ unsigned reserved3;
+ unsigned long long reserved4;
+ } __attribute__ ((packed)) sata;
+ struct {
+ unsigned long long reserved1;
+ unsigned long long reserved2;
+ } __attribute__ ((packed)) unknown;
+ } device_path;
+ unsigned char reserved4;
+ unsigned char checksum;
+} __attribute__ ((packed));
+
+struct edd_info {
+ unsigned char device;
+ unsigned char version;
+ unsigned short interface_support;
+ unsigned short max_cyl;
+ unsigned char max_head;
+ unsigned char max_sect;
+ struct edd_device_params params;
+} __attribute__ ((packed));
+
+typedef struct {
+ unsigned char padding[8];
+ struct {
+ unsigned short padding:1; /* mapping right ? */
+ unsigned short first_letter:5;
+ unsigned short second_letter:5;
+ unsigned short third_letter:5;
+ } __attribute__ ((packed)) manufacturer_id;
+ unsigned short monitor_model;
+ unsigned serial_number;
+ unsigned char manufacture_week;
+ unsigned char manufacture_year; /* base: 1990 */
+ unsigned char version;
+ unsigned char revision;
+ unsigned char video_input_type; /* bitfield */
+ unsigned char max_horizontal_size_cm;
+ unsigned char max_vertical_size_cm;
+ unsigned char gamma_factor; /* gamma = 1.0 + gamma_factor/100 */
+ struct {
+ unsigned char unused:3;
+ unsigned char RBGcolor:1;
+ unsigned char unused2:1;
+ unsigned char active_off_supported:1;
+ unsigned char suspend_supported:1;
+ unsigned char standby_supported:1;
+ } __attribute__ ((packed)) DPMS;
+ unsigned char chroma_green_and_red;
+ unsigned char chroma_white_and_blue;
+ unsigned char chroma_red_Y;
+ unsigned char chroma_red_X;
+ unsigned char chroma_green_Y;
+ unsigned char chroma_green_X;
+ unsigned char chroma_blue_Y;
+ unsigned char chroma_blue_X;
+ unsigned char chroma_white_Y;
+ unsigned char chroma_white_X;
+ struct {
+ unsigned short _720_400_70Hz:1;
+ unsigned short _720_400_88Hz:1;
+ unsigned short _640_480_60Hz:1;
+ unsigned short _640_480_67Hz:1;
+ unsigned short _640_480_72Hz:1;
+ unsigned short _640_480_75Hz:1;
+ unsigned short _800_600_56Hz:1;
+ unsigned short _800_600_60Hz:1;
+
+ unsigned short _800_600_72Hz:1;
+ unsigned short _800_600_75Hz:1;
+ unsigned short _832_624_75Hz:1;
+ unsigned short _1024_768_i87Hz:1;
+ unsigned short _1024_768_60Hz:1;
+ unsigned short _1024_768_70Hz:1;
+ unsigned short _1024_768_75Hz:1;
+ unsigned short _1280_1024_75Hz:1;
+ } __attribute__ ((packed)) established_timming;
+ unsigned char manufacturer_timming;
+ struct {
+ unsigned short resolution:8; /* X resolution = (field+31)*8 */
+ unsigned short vertical_refresh_freq:6; /* add 60Hz */
+ unsigned short aspect_ratio:2; /* 01: 0.75 */
+ } __attribute__ ((packed)) standard_timming[8];
+ union {
+ struct {
+ unsigned short wordmarker_0;
+ unsigned char bytemarker_0;
+ enum { serial_number = 0xFF,
+ vendor_name = 0xFE,
+ vertical_horizontal_frequency_range = 0xFD,
+ model_name = 0xFC
+/* RB Interrupt List say that but I read something else... */
+/* } str_type : 8; */
+/* char string[14]; */
+ } str_type:16;
+ char string[13];
+ } __attribute__ ((packed)) strings;
+ struct {
+ unsigned char horizontal_freq_Khz; /* != 0 */
+ unsigned char vertical_freq_Hz; /* != 0 */
+ unsigned char horizontal_active_time_pix; /* != 0 */
+ unsigned char horizontal_blanking_time_pix;
+ unsigned char horizontal_active2_time;
+ unsigned char vertical_active_time_line;
+ unsigned char vertical_blanking_time_line;
+ unsigned char vertical_active_time2;
+ unsigned char horizontal_sync_offset;
+ unsigned char horizontal_sync_pulsewidth_pix;
+ unsigned char vertical_sync_pulsewidth;
+ unsigned char horizontal_vertical_sync_offset2;
+ unsigned char horizontal_image_size_mm;
+ unsigned char vertical_image_size_mm;
+ unsigned char horizontal_image_size_2;
+ unsigned char horizontal_border_pix;
+ unsigned char vertical_border_pix;
+ struct {
+ unsigned char unused:1;
+ unsigned char horizontal_sync_pol:1;
+ unsigned char vertical_sync_pol:1;
+ unsigned char sync_type:2;
+ enum { no_sound, stereo_right,
+ stereo_left, undefined
+ } sound:2;
+ unsigned char interlaced:1;
+ } __attribute__ ((packed)) display_t;
+ } __attribute__ ((packed)) timmings;
+ } __attribute__ ((packed)) detailed_timming[4];
+ unsigned char unused;
+ unsigned char checksum;
+} __attribute__ ((packed)) VBE_EDID_t;
+
+struct X86SpeedStepSmi_s {
+ unsigned data1, data2, data3, data4;
+};
+
+struct EFI_s { /* still not initialised in Gujin-1.2! */
+ unsigned system_table_pointer;
+ unsigned memory_descriptor_size;
+ unsigned memory_descriptor_version;
+ unsigned memory_descriptor_map_pointer;
+ unsigned memory_descriptor_map_size;
+};
+
+/*
+ * The complete version - and its offset tester:
+ */
+struct linux_param {
+ struct screen_info screen_info;
+ struct apm_bios_info apm_bios_info;
+ unsigned char free1[12];
+ struct X86SpeedStepSmi_s X86SpeedStepSmi;
+ unsigned char free2[16];
+ union drive_info drive1, drive2;
+ struct sys_desc_table_info sys_desc_table;
+ unsigned char free3[144];
+ VBE_EDID_t edid_data;
+ unsigned unused;
+ struct EFI_s EFI;
+ unsigned char free4[8];
+ unsigned ALT_MEM_K;
+ unsigned char free5[4];
+ unsigned char nb_E820_entries;
+ unsigned char nb_EDD_entries;
+ unsigned char nb_MBRSIG_entries;
+ unsigned char free6[6];
+ /* 512 bytes bootsector limit */
+ /* "in_out" is mostly init'ed in vmlinuz file: */
+ struct in_out_info in_out;
+ unsigned MBRSIG[16];
+ struct e820map_info e820map[64]; /* 20 bytes each */
+ unsigned char free8[48];
+ unsigned char command_line[1024];
+ unsigned char free9[256];
+ struct edd_info edd[6];
+ unsigned char free10[276];
+} __attribute__ ((packed));
+
+extern inline void test_linux_param_struct(void)
+{
+ if (offsetof(struct linux_param, screen_info.EXT_MEM_K) != 0x02)
+ __ERROR();
+ if (offsetof(struct linux_param, apm_bios_info) != 0x40)
+ __ERROR();
+ if (offsetof(struct linux_param, X86SpeedStepSmi) != 96)
+ __ERROR();
+ if (offsetof(struct linux_param, drive1) != 0x80)
+ __ERROR();
+ if (offsetof(struct linux_param, drive2) != 0x80 + 16)
+ __ERROR();
+ if (offsetof(struct linux_param, sys_desc_table) != 0xA0)
+ __ERROR();
+ if (offsetof(struct linux_param, edid_data) != 0x140)
+ __ERROR();
+ if (offsetof(struct linux_param, ALT_MEM_K) != 0x1E0)
+ __ERROR();
+ if (offsetof(struct linux_param, nb_E820_entries) != 0x1E8)
+ __ERROR();
+ if (offsetof(struct linux_param, nb_EDD_entries) != 0x1E9)
+ __ERROR();
+ if (offsetof(struct linux_param, in_out.setup_sects) != 0x1F1)
+ __ERROR();
+ if (offsetof(struct linux_param, in_out.root_flags) != 0x1F2)
+ __ERROR();
+ if (offsetof(struct linux_param, in_out.kernel_compressed_size) != 0x1F4)
+ __ERROR();
+ if (offsetof(struct linux_param, in_out.header_version_number) != 0x206)
+ __ERROR();
+ if (offsetof(struct linux_param, in_out.code32_start) != 0x214)
+ __ERROR();
+ if (offsetof(struct linux_param, in_out.heap_end_ptr) != 0x224)
+ __ERROR();
+ if (offsetof(struct linux_param, MBRSIG) != 0x290)
+ __ERROR();
+ if (offsetof(struct linux_param, e820map) != 0x2D0)
+ __ERROR();
+ if (offsetof(struct linux_param, command_line) != 0x800)
+ __ERROR();
+ if (offsetof(struct linux_param, edd) != 0xd00)
+ __ERROR();
+}
+
diff -uprN -X linux-2.6.20/Documentation/dontdiff linux-2.6.20/Makefile linux-2.6.20-gujin/Makefile
--- linux-2.6.20/Makefile 2007-02-04 18:44:54.000000000 +0000
+++ linux-2.6.20-gujin/Makefile 2007-02-05 21:27:01.000000000 +0000
@@ -289,6 +289,7 @@ STRIP = $(CROSS_COMPILE)strip
OBJCOPY = $(CROSS_COMPILE)objcopy
OBJDUMP = $(CROSS_COMPILE)objdump
AWK = awk
+GZIP = gzip
GENKSYMS = scripts/genksyms/genksyms
DEPMOD = /sbin/depmod
KALLSYMS = scripts/kallsyms
@@ -302,7 +303,22 @@ AFLAGS_MODULE = $(MODFLAGS)
LDFLAGS_MODULE = -r
CFLAGS_KERNEL =
AFLAGS_KERNEL =
+GZIPFLAGS =

+# Pamareters to add to the GZIP comment of the %.kgz target:
+LINUX_PARAM = ro
+ifdef ROOT
+# ROOT is present on command line or in environment (unusual case),
+# do not autodetect it at boot time:
+ifeq ($(ROOT),auto)
+# Command line is like "make /boot/linux-2.6.19.kgz ROOT=auto",
+# get value from /proc/cmdline (which can be more than one line):
+LINUX_ROOT = `sed '/root=/s/.*\(root=[_/.a-z0-9A-Z]*\).*/\1/' /proc/cmdline`
+else
+# Command line is like "make /boot/linux-2.6.19.kgz ROOT=/dev/sda6"
+LINUX_ROOT = "root=$(ROOT)"
+endif
+endif

# Use LINUXINCLUDE when you must reference the include/ directory.
# Needed to be compatible with the O= option
@@ -734,7 +750,7 @@ debug_kallsyms: .tmp_map$(last_kallsyms)

endif # ifdef CONFIG_KALLSYMS

-# vmlinux image - including updated kernel symbols
+# vmlinux ELF image - including updated kernel symbols
vmlinux: $(vmlinux-lds) $(vmlinux-init) $(vmlinux-main) $(kallsyms.o) FORCE
ifdef CONFIG_HEADERS_CHECK
$(Q)$(MAKE) -f $(srctree)/Makefile headers_check
@@ -743,6 +759,62 @@ endif
$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost $@
$(Q)rm -f .old_version

+# vmlinux ELF stripped image
+# Not absolutely needed, just to reduce the size loaded by the bootloader
+quiet_cmd_strip = OBJCOPY $@
+ cmd_strip = $(OBJCOPY) --strip-all $< $@
+vmlinux.elf: vmlinux FORCE
+ $(call if_changed,strip)
+
+# compressed vmlinux ELF image
+quiet_cmd_gzip = GZIP $@
+ cmd_gzip = $(GZIP) $(GZIPFLAGS) $< -c > $@
+vmlinux.elf.gz: vmlinux.elf FORCE
+ $(call if_changed,gzip)
+
+# If you have a modified GPL kernel but are not redistributing
+# anything, use the two lines as gzcopy parameter:
+# -c "This software is not used outside the copyright owner company." \
+# -al "Copyright owner: " "<official name of owner of the patch>"
+# Gujin also accept one or more "Copyright owner: " line for GPL files,
+# take care of the space after the semicolon.
+# For instance: -al="Copyright owner: Linus Torvalds" \
+# Keep the license first, then Copyright/source location line(s),
+# the following line is copied to the Linux parameter line by the (provided)
+# linux_set_params function, so the (provided) function may or may not also
+# include last line (i.e. Gujin parameters) as kernel parameters.
+# Note that the command line given to LINUX shall not be empty,
+# keep at least one space in the "-al=" of $(LINUX_ROOT).
+# USAGE gzcopy "-as=" check/add a space, "-al=" check/add a newline
+# in between the current and the appended comment.
+quiet_cmd_params = PARAMS $@
+ cmd_params = scripts/gzcopy -f $< $@ -n=$@ \
+ -c="This software is distributed under the GPL license." \
+ -al="Its source code is at: http://www.kernel.org" \
+ -al="$(LINUX_ROOT) " -as="$(LINUX_PARAM)" \
+ -al="`scripts/gzparam`" \
+ && echo "" \
+ && echo " `scripts/gzcopy -n0 $@` has been rebuilt with parameters:" \
+ && echo "`scripts/gzcopy -c0 $@`"
+
+# Gujin native bootable file: just type "make /boot/linux-2.6.20.kgz"
+# to get everything (but modules & initrd & initramfs) done.
+%.kgz : vmlinux.elf.gz scripts/gzparam scripts/gzcopy FORCE
+ $(call cmd,params)
+
+# Utility to display the kernel compile time parameters
+quiet_cmd_gzparam = HOSTCC $@
+ cmd_gzparam = $(HOSTCC) $(HOSTCFLAGS) -Wl,"-u __ERROR" -o $@ $<
+ # Need to rebuild this if "include/linux/autoconf.h" changed:
+scripts/gzparam: scripts/gzparam.c vmlinux FORCE
+ $(call cmd,gzparam)
+
+# Maybe move building this utility somewhere else?
+quiet_cmd_gzcopy = HOSTCC $@
+ cmd_gzcopy = $(HOSTCC) $(HOSTCFLAGS) -s -o $@ $<
+scripts/gzcopy: scripts/gzcopy.c
+ $(call cmd,gzcopy)
+
# The actual objects are generated when descending,
# make sure no implicit rule kicks in
$(sort $(vmlinux-init) $(vmlinux-main)) $(vmlinux-lds): $(vmlinux-dirs) ;
@@ -1021,6 +1093,7 @@ endif # CONFIG_MODULES
# Directories & files removed with 'make clean'
CLEAN_DIRS += $(MODVERDIR)
CLEAN_FILES += vmlinux System.map \
+ vmlinux.elf vmlinux.elf.gz scripts/gzparam scripts/gzcopy \
.tmp_kallsyms* .tmp_version .tmp_vmlinux* .tmp_System.map

# Directories & files removed with 'make mrproper'
@@ -1106,6 +1179,9 @@ help:
@echo 'Other generic targets:'
@echo ' all - Build all targets marked with [*]'
@echo '* vmlinux - Build the bare kernel'
+ @echo " /boot/linux-$(KERNELRELEASE).kgz - create a boot kernel for the Gujin bootloader"
+ @echo ' /boot/linux.kgz ROOT=/dev/hda1 - do not autodetect root filesystem at boot time'
+ @echo ' /boot/linux.kgz ROOT=auto - root filesystem from current /proc/cmdline'
@echo '* modules - Build all modules'
@echo ' modules_install - Install all modules to INSTALL_MOD_PATH (default: /)'
@echo ' dir/ - Build all files in dir and below'
diff -uprN -X linux-2.6.20/Documentation/dontdiff linux-2.6.20/Documentation/dontdiff linux-2.6.20-gujin/Documentation/dontdiff
--- linux-2.6.20/Documentation/dontdiff 2007-02-04 18:44:54.000000000 +0000
+++ linux-2.6.20-gujin/Documentation/dontdiff 2007-02-05 23:43:07.000000000 +0000
@@ -92,6 +92,8 @@ gen_crc32table
gen_init_cpio
genksyms
gentbl
+gzcopy
+gzparam
ikconfig.h*
initramfs_list
kallsyms
@@ -138,6 +140,8 @@ trix_boot.h
utsrelease.h*
version.h*
vmlinux
+vmlinux.elf
+vmlinux.elf.gz
vmlinux-*
vmlinux.lds
vsyscall.lds