summaryrefslogtreecommitdiff
path: root/packages/lilo-sh
diff options
context:
space:
mode:
Diffstat (limited to 'packages/lilo-sh')
-rw-r--r--packages/lilo-sh/.mtn2git_empty0
-rw-r--r--packages/lilo-sh/files/.mtn2git_empty0
-rw-r--r--packages/lilo-sh/files/lilo-0.21-1.1.patch35
-rw-r--r--packages/lilo-sh/files/lilo-0.21-include.patch10
-rw-r--r--packages/lilo-sh/files/lilo-0.21-loopdev.patch11
-rw-r--r--packages/lilo-sh/files/lilo-0.21-second.patch36
-rw-r--r--packages/lilo-sh/files/lilo-linkgear.patch1039
-rw-r--r--packages/lilo-sh/files/lilo-noconfig-h.patch23
-rw-r--r--packages/lilo-sh/files/lilo-sh-linux.patch1971
-rw-r--r--packages/lilo-sh/files/lilo.patch42
-rw-r--r--packages/lilo-sh/files/lilo.raid1552
-rw-r--r--packages/lilo-sh/lilo-sh_21.bb41
12 files changed, 3760 insertions, 0 deletions
diff --git a/packages/lilo-sh/.mtn2git_empty b/packages/lilo-sh/.mtn2git_empty
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/packages/lilo-sh/.mtn2git_empty
diff --git a/packages/lilo-sh/files/.mtn2git_empty b/packages/lilo-sh/files/.mtn2git_empty
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/packages/lilo-sh/files/.mtn2git_empty
diff --git a/packages/lilo-sh/files/lilo-0.21-1.1.patch b/packages/lilo-sh/files/lilo-0.21-1.1.patch
new file mode 100644
index 0000000000..dfbab2a82c
--- /dev/null
+++ b/packages/lilo-sh/files/lilo-0.21-1.1.patch
@@ -0,0 +1,35 @@
+--- lilo/Makefile- Fri Dec 4 15:35:07 1998
++++ lilo/Makefile Wed Mar 17 01:04:07 1999
+@@ -24,7 +24,7 @@
+ # VARSETUP Enables use of variable-size setup segments.
+ # XL_SECS=n Support for extra large (non-standard) floppies.
+
+-CONFIG=-DIGNORECASE -DVARSETUP -DREWRITE_TABLE
++CONFIG=-DIGNORECASE -DVARSETUP -DREWRITE_TABLE -DLARGE_EBDA -DONE_SHOT
+
+ # End of configuration variables
+
+--- lilo/second.S- Fri Dec 4 15:20:07 1998
++++ lilo/second.S Wed Mar 17 01:03:53 1999
+@@ -830,9 +830,20 @@
+ call load1
+ seg es
+ mov CL_MAGIC_ADDR,#CL_MAGIC ! set magic number
++#ifndef LCF_LARGE_EBDA
+ seg es
+ mov word ptr CL_OFFSET,#PARMLINE+SECOND_SS
+ ! set parameter line offset
++#else
++ mov di,#0x8000
++ mov si,#PARMLINE
++ mov cx,#CL_LENGTH
++ rep
++ movsb
++ seg es
++ mov word ptr CL_OFFSET,#0x8000
++ ! set parameter line offset
++#endif
+ pop si ! restore SI
+ lodsw ! get flags bit map
+ mov bx,ax
+
diff --git a/packages/lilo-sh/files/lilo-0.21-include.patch b/packages/lilo-sh/files/lilo-0.21-include.patch
new file mode 100644
index 0000000000..61e298013c
--- /dev/null
+++ b/packages/lilo-sh/files/lilo-0.21-include.patch
@@ -0,0 +1,10 @@
+--- lilo.orig/common.h Wed Oct 14 17:44:28 1998
++++ lilo/common.h Mon Dec 7 18:05:17 1998
+@@ -7,6 +7,7 @@
+ #define COMMON_H
+
+ #include <sys/stat.h>
++#include <asm/types.h>
+ #include <linux/genhd.h>
+
+ #include "lilo.h"
diff --git a/packages/lilo-sh/files/lilo-0.21-loopdev.patch b/packages/lilo-sh/files/lilo-0.21-loopdev.patch
new file mode 100644
index 0000000000..e739c5b104
--- /dev/null
+++ b/packages/lilo-sh/files/lilo-0.21-loopdev.patch
@@ -0,0 +1,11 @@
+--- lilo/device.c.oot Mon Jan 10 09:37:00 2000
++++ lilo/device.c Mon Jan 10 09:37:37 2000
+@@ -192,4 +192,8 @@
+ sprintf(tmp,"/dev/sdb%d",i);
+ cache_add(tmp,0x810+i);
+ }
++ for (i = 0; i <= 7; i++) {
++ sprintf(tmp,"/dev/loop%d",i);
++ cache_add(tmp,0x700+i);
++ }
+ }
diff --git a/packages/lilo-sh/files/lilo-0.21-second.patch b/packages/lilo-sh/files/lilo-0.21-second.patch
new file mode 100644
index 0000000000..12a9af04c7
--- /dev/null
+++ b/packages/lilo-sh/files/lilo-0.21-second.patch
@@ -0,0 +1,36 @@
+I have a problem to report with lilo, and the fix for it. I am not sure
+whether this is the right place for it though, I am also CCing the lilo
+maintainer Werner Almesberger.
+
+When lilo gets control from the bios (whether lilo is on disk, or on the
+floppy), it is checking the wrong location when it tries to parse the
+parameter line construction area to determine whether it needs to clean
+up extra blank spaces. This is causing lilo to eat up the last character(s)
+of the command line that it passes to the kernel.
+
+Specifically, the code
+
+cpcodn: cmp byte ptr (di-1),#32 ! last was space ?
+
+is using the memory contents of ds:di-1 for the compare. It should
+really be using es:di-1. I checked, ds=0x0b00 around here, so the
+code ended up checking 0x0b00:(di-1) instead of 0x9000:(di-1). It
+is quite possible that the memory that lilo checks has garbage,
+causing it to make wrong decision. A "seg es" just before the cmp
+fixes the problem. I am attaching the patch below.
+
+Kanoj
+
+--- second.0 Mon Sep 20 13:52:01 1999
++++ second.S Tue Sep 28 10:20:54 1999
+@@ -816,7 +816,8 @@
+ je cpcodsp ! yes -> discard next
+ lodsb ! get next byte
+ jmp cpcolp
+-cpcodn: cmp byte ptr (di-1),#32 ! last was space ?
++cpcodn: seg es
++ cmp byte ptr (di-1),#32 ! last was space ?
+ jne nocopt ! no -> go on
+ dec di ! discard it
+ nocopt: mov si,options ! append variable options
+
diff --git a/packages/lilo-sh/files/lilo-linkgear.patch b/packages/lilo-sh/files/lilo-linkgear.patch
new file mode 100644
index 0000000000..598a92a7af
--- /dev/null
+++ b/packages/lilo-sh/files/lilo-linkgear.patch
@@ -0,0 +1,1039 @@
+diff -Naur --exclude=CVS --exclude='*.orig' lilo/Makefile lilosh/Makefile
+--- lilo/Makefile 2006-02-01 21:16:29.000000000 +0000
++++ lilosh/Makefile 2006-02-01 21:23:37.000000000 +0000
+@@ -40,7 +40,6 @@
+
+ SHELL=/bin/sh
+
+-CROSS_COMPILE = sh3-linux-
+ CC =$(CROSS_COMPILE)gcc
+ LD =$(CROSS_COMPILE)ld
+ OBJCOPY =$(CROSS_COMPILE)objcopy
+@@ -72,10 +71,10 @@
+ $(OBJCOPY) -R .comment -S second.exe -O binary second.bin
+
+ first.exe: first.o
+- $(LD) -EL -e start first.o -o first.exe -Ttext 0x8c200000
++ $(LD) -EL -e start first.o -o first.exe -Ttext 0x88a00000
+
+ second.exe: second.o string.o
+- $(LD) -T second.lds -EL second.o string.o -o second.exe -Ttext 0x8c201000
++ $(LD) -T second.lds -EL second.o string.o -o second.exe -Ttext 0x88a01000
+
+ first.o: first.S
+ $(CC) $(CFLAGS) -c first.S
+diff -Naur --exclude=CVS --exclude='*.orig' lilo/boot.c lilosh/boot.c
+--- lilo/boot.c 1997-06-20 12:48:28.000000000 +0000
++++ lilosh/boot.c 2006-01-31 19:46:21.000000000 +0000
+@@ -11,6 +11,7 @@
+ #include <errno.h>
+ #include <a.out.h>
+ #include <sys/stat.h>
++#include <asm/page.h>
+
+ #include "config.h"
+ #include "common.h"
+@@ -70,6 +71,7 @@
+ geo_close(&geo);
+ if (verbose > 1)
+ printf("Mapped %d sector%s.\n",sectors,sectors == 1 ? "" : "s");
++ memset(&descr->initrd, 0, sizeof(descr->initrd));
+ if ((initrd = cfg_get_strg(cf_kernel,"initrd")) || (initrd = cfg_get_strg(
+ cf_options,"initrd"))) {
+ if (!modern_kernel) die("Kernel doesn't support initial RAM disks");
+diff -Naur --exclude=CVS --exclude='*.orig' lilo/bsect.c lilosh/bsect.c
+--- lilo/bsect.c 1998-10-14 20:30:32.000000000 +0000
++++ lilosh/bsect.c 2004-10-01 19:05:58.000000000 +0000
+@@ -189,11 +189,11 @@
+ }
+ }
+ bsect.par_1.prompt = cfg_get_flag(cf_options,"prompt");
+- if (delay*100/55 > 0xffff) die("Maximum delay is one hour.");
+- else bsect.par_1.delay = delay*100/55;
++ if (delay >= 36000) die("Maximum delay is one hour.");
++ else bsect.par_1.delay = delay;
+ if (timeout == -1) bsect.par_1.timeout = 0xffff;
+- else if (timeout*100/55 >= 0xffff) die("Maximum timeout is one hour.");
+- else bsect.par_1.timeout = timeout*100/55;
++ else if (timeout >= 36000) die("Maximum timeout is one hour.");
++ else bsect.par_1.timeout = timeout;
+ if (!(keytable = cfg_get_strg(cf_options,"keytable"))) {
+ int i;
+
+diff -Naur --exclude=CVS --exclude='*.orig' lilo/defs.h lilosh/defs.h
+--- lilo/defs.h 2006-02-01 21:16:29.000000000 +0000
++++ lilosh/defs.h 2004-05-19 16:39:08.000000000 +0000
+@@ -1,2 +1,3 @@
+ extern void *memcpy (void *__dest, const void *__src, unsigned int __n);
+ extern int strlen (__const char *__s);
++extern void *memset(void *s, int c, unsigned int n);
+diff -Naur --exclude=CVS --exclude='*.orig' lilo/first.S lilosh/first.S
+--- lilo/first.S 2006-02-01 21:16:29.000000000 +0000
++++ lilosh/first.S 2006-02-01 22:02:02.000000000 +0000
+@@ -1,4 +1,4 @@
+-/* $Id: first.S,v 1.16 2000/11/26 07:11:58 gniibe Exp $
++/* $Id: first.S,v 1.1.1.1 2002/05/15 06:44:39 bmann Exp $
+ *
+ * Primary boot loader
+ *
+@@ -54,7 +54,7 @@
+ ! /* ^--- Minor Version*/
+ #endif
+
+-/* x86 LILO parameters (Not used for SuperH... yet) */
++/* x86 LILO parameters (port and sparam not used for SuperH... yet) */
+ timeout:.word 0 ! input timeout
+ delay: .word 0 ! boot delay
+ port: .byte 0 ! COM port (0 = unused, 1 = COM1, etc.)
+@@ -67,11 +67,13 @@
+ d1_cx: .word 0
+ d1_dx: .word 0
+ d1_al: .byte 0
++ .byte 0 ! align next .word
+
+ /* Second descripter sector (Filled by LILO command) */
+ d2_cx: .word 0
+ d2_dx: .word 0
+ d2_al: .byte 0
++ .byte 0 ! align next .word
+
+ /* Default command-line sector (Filled by LILO command) */
+ dc_cx: .word 0
+@@ -87,11 +89,13 @@
+ ms_cx: .word 0
+ ms_dx: .word 0
+ ms_al: .byte 0
++ .byte 0 ! align next .word
+
+ /* Second descripter sector (Filled by LILO command) */
+ kt_cx: .word 0 ! keyboard translation table
+ kt_dx: .word 0
+ kt_al: .byte 0
++ .byte 0 ! align next .long
+
+ d_addr: ! second stage sector addresses
+
+diff -Naur --exclude=CVS --exclude='*.orig' lilo/geometry.c lilosh/geometry.c
+--- lilo/geometry.c 2006-02-01 21:15:51.000000000 +0000
++++ lilosh/geometry.c 2006-02-01 22:13:05.000000000 +0000
+@@ -16,6 +16,7 @@
+ #include <linux/fs.h>
+ #include <linux/fd.h>
+ #include <linux/hdreg.h>
++#include <linux/kdev_t.h>
+
+ #include "config.h"
+ #include "lilo.h"
+@@ -37,7 +38,7 @@
+
+
+ DT_ENTRY *disktab = NULL;
+-int old_disktab = 0;
++static int old_disktab = 0;
+
+
+ void geo_init(char *name)
+@@ -297,6 +298,7 @@
+ case MAJOR_ESDI:
+ /* fall through */
+ case MAJOR_XT:
++ /* fall through */
+ geo->device = 0x80+(MINOR(device) >> 6)+(MAJOR(device) == MAJOR_HD ?
+ 0 : last_dev(MAJOR_HD,64));
+ if (ioctl(fd,HDIO_GETGEO,&hdprm) < 0)
+@@ -353,6 +355,17 @@
+ geo->sectors = hdprm.sectors;
+ geo->start = hdprm.start;
+ break;
++ case MAJOR_NAND:
++ /* fall through */
++ geo->device = 0x80+(MINOR(device));
++ if (ioctl(fd,HDIO_GETGEO,&hdprm) < 0)
++ die("geo_query_dev HDIO_GETGEO (dev 0x%04x): %s",device,
++ strerror(errno));
++ geo->heads = hdprm.heads;
++ geo->cylinders = hdprm.cylinders;
++ geo->sectors = hdprm.sectors;
++ geo->start = hdprm.start;
++ break;
+
+ default:
+ die("Sorry, don't know how to handle device 0x%04x",device);
+diff -Naur --exclude=CVS --exclude='*.orig' lilo/geometry.h lilosh/geometry.h
+--- lilo/geometry.h 2006-02-01 21:15:51.000000000 +0000
++++ lilosh/geometry.h 2006-02-01 22:14:07.000000000 +0000
+@@ -8,7 +8,6 @@
+
+ #include "lilo.h"
+
+-
+ typedef struct {
+ int device,heads;
+ int cylinders,sectors;
+@@ -29,6 +28,7 @@
+
+ extern DT_ENTRY *disktab;
+
++
+ void geo_init(char *name);
+
+ /* Loads the disk geometry table. */
+diff -Naur --exclude=CVS --exclude='*.orig' lilo/lilo.c lilosh/lilo.c
+--- lilo/lilo.c 2006-02-01 21:15:51.000000000 +0000
++++ lilosh/lilo.c 2006-02-01 21:56:56.000000000 +0000
+@@ -85,11 +85,11 @@
+ if (verbose > 0) {
+ bsect_read(cfg_get_strg(cf_options,"boot"),&boot);
+ printf("Global settings:\n");
+- tsecs = (boot.par_1.delay*55+50)/100;
++ tsecs = boot.par_1.delay;
+ printf(" Delay before booting: %d.%d seconds\n",tsecs/10,tsecs % 10);
+ if (boot.par_1.timeout == 0xffff) printf(" No command-line timeout\n");
+ else {
+- tsecs = (boot.par_1.timeout*55+50)/100;
++ tsecs = boot.par_1.timeout;
+ printf(" Command-line timeout: %d.%d seconds\n",tsecs/10,
+ tsecs % 10);
+ }
+@@ -411,11 +411,11 @@
+ else if (st.st_mode & (S_IWGRP | S_IWOTH))
+ fprintf(stderr,"Warning: %s should be writable only for "
+ "root\n",config_file);
+- else if ((cfg_get_strg(cf_all,"password") || cfg_get_strg(
+- cf_options,"password")) && (st.st_mode & (S_IRGRP |
+- S_IROTH)))
+- fprintf(stderr,"Warning: %s should be readable only "
+- "for root if using PASSWORD\n",config_file);
++ else if ((cfg_get_strg(cf_all,"password") || cfg_get_strg(
++ cf_options,"password")) && (st.st_mode & (S_IRGRP |
++ S_IROTH)))
++ fprintf(stderr,"Warning: %s should be readable only "
++ "for root if using PASSWORD\n",config_file);
+ }
+ }
+ preload_dev_cache();
+@@ -491,7 +491,7 @@
+ md_disk.cylinders = geo.cylinders;
+ md_disk.start = geo.start;
+ }
+-
++
+ pass++;
+ if (uninstall)
+ bsect_uninstall(uninst_dev ? uninst_dev : cfg_get_strg(cf_options,
+@@ -517,8 +517,8 @@
+ cf_options,"delay")) : 0,cfg_get_strg(cf_options,"timeout") ?
+ to_number(cfg_get_strg(cf_options,"timeout")) : -1);
+ if (more) {
+- cfg_init(cf_top);
+- if (cfg_parse(cf_top)) cfg_error("Syntax error");
++ cfg_init(cf_top);
++ if (cfg_parse(cf_top)) cfg_error("Syntax error");
+ }
+ if (!bsect_number()) die("No images have been defined.");
+ check_fallback();
+diff -Naur --exclude=CVS --exclude='*.orig' lilo/lilo.h lilosh/lilo.h
+--- lilo/lilo.h 2006-02-01 21:15:44.000000000 +0000
++++ lilosh/lilo.h 2006-02-01 21:28:33.000000000 +0000
+@@ -39,6 +39,7 @@
+ #define MAJOR_DAC960 48 /* First Mylex DAC960 PCI RAID controller */
+ #define MAJOR_IDE5 55 /* IDE on fifth interface */
+ #define MAJOR_IDE6 57 /* IDE on sixth interface */
++#define MAJOR_NAND 240 /* proprietary (board-level) nand flash block device */
+ #define COMPAQ_SMART2_MAJOR 72 /* First Smart/2 Major */
+
+ #define MAX_IMAGES ((SECTOR_SIZE*2-2)/sizeof(IMAGE_DESCR))
+diff -Naur --exclude=CVS --exclude='*.orig' lilo/md-int.h lilosh/md-int.h
+--- lilo/md-int.h 2006-02-01 21:15:51.000000000 +0000
++++ lilosh/md-int.h 2006-02-01 22:11:13.000000000 +0000
+@@ -287,4 +287,4 @@
+ #define RAID5_ALGORITHM_LEFT_SYMMETRIC 2
+ #define RAID5_ALGORITHM_RIGHT_SYMMETRIC 3
+
+-#endif _MD_H
++#endif /* _MD_H */
+diff -Naur --exclude=CVS --exclude='*.orig' lilo/md-int.h~ lilosh/md-int.h~
+--- lilo/md-int.h~ 1970-01-01 00:00:00.000000000 +0000
++++ lilosh/md-int.h~ 2006-02-01 21:15:51.000000000 +0000
+@@ -0,0 +1,290 @@
++/*
++ md.h : Multiple Devices driver for Linux
++ Copyright (C) 1994-96 Marc ZYNGIER
++ <zyngier@ufr-info-p7.ibp.fr> or
++ <maz@gloups.fdn.fr>
++
++ This program is free software; you can redistribute it and/or modify
++ it under the terms of the GNU General Public License as published by
++ the Free Software Foundation; either version 2, or (at your option)
++ any later version.
++
++ You should have received a copy of the GNU General Public License
++ (for example /usr/src/linux/COPYING); if not, write to the Free
++ Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++*/
++
++#ifndef MD_INT_H
++#define MD_INT_H
++
++/* don't include the kernel RAID header! */
++#define _MD_H
++
++typedef unsigned int md_u32;
++typedef unsigned short md_u16;
++typedef unsigned char md_u8;
++
++#include <linux/major.h>
++#include <sys/ioctl.h>
++
++/*
++ * Different major versions are not compatible.
++ * Different minor versions are only downward compatible.
++ * Different patchlevel versions are downward and upward compatible.
++ */
++
++struct md_version {
++ int major;
++ int minor;
++ int patchlevel;
++};
++
++/*
++ * default readahead
++ */
++#define MD_READAHEAD (256 * 1024)
++
++/* These are the ioctls for md versions < 0.50 */
++#define REGISTER_MD_DEV _IO (MD_MAJOR, 1)
++#define START_MD _IO (MD_MAJOR, 2)
++#define STOP_MD _IO (MD_MAJOR, 3)
++
++/* status */
++#define RAID_VERSION _IOR (MD_MAJOR, 0x10, struct md_version)
++#define GET_ARRAY_INFO _IOR (MD_MAJOR, 0x11, md_array_info_t)
++#define GET_DISK_INFO _IOR (MD_MAJOR, 0x12, md_disk_info_t)
++#define PRINT_RAID_DEBUG _IO (MD_MAJOR, 0x13)
++
++/* configuration */
++#define CLEAR_ARRAY _IO (MD_MAJOR, 0x20)
++#define ADD_NEW_DISK _IOW (MD_MAJOR, 0x21, md_disk_info_t)
++#define HOT_REMOVE_DISK _IO (MD_MAJOR, 0x22)
++#define SET_ARRAY_INFO _IOW (MD_MAJOR, 0x23, md_array_info_t)
++#define SET_DISK_INFO _IO (MD_MAJOR, 0x24)
++#define WRITE_RAID_INFO _IO (MD_MAJOR, 0x25)
++#define UNPROTECT_ARRAY _IO (MD_MAJOR, 0x26)
++#define PROTECT_ARRAY _IO (MD_MAJOR, 0x27)
++#define HOT_ADD_DISK _IO (MD_MAJOR, 0x28)
++
++/* usage */
++#define RUN_ARRAY _IOW (MD_MAJOR, 0x30, struct md_param)
++#define START_ARRAY _IO (MD_MAJOR, 0x31)
++#define STOP_ARRAY _IO (MD_MAJOR, 0x32)
++#define STOP_ARRAY_RO _IO (MD_MAJOR, 0x33)
++#define RESTART_ARRAY_RW _IO (MD_MAJOR, 0x34)
++
++
++/* for raid < 0.50 only */
++#define MD_PERSONALITY_SHIFT 16
++
++#define MD_RESERVED 0UL
++#define LINEAR 1UL
++#define STRIPED 2UL
++#define RAID0 STRIPED
++#define RAID1 3UL
++#define RAID5 4UL
++#define TRANSLUCENT 5UL
++#define LVM 6UL
++#define MAX_PERSONALITY 7UL
++
++/*
++ * MD superblock.
++ *
++ * The MD superblock maintains some statistics on each MD configuration.
++ * Each real device in the MD set contains it near the end of the device.
++ * Some of the ideas are copied from the ext2fs implementation.
++ *
++ * We currently use 4096 bytes as follows:
++ *
++ * word offset function
++ *
++ * 0 - 31 Constant generic MD device information.
++ * 32 - 63 Generic state information.
++ * 64 - 127 Personality specific information.
++ * 128 - 511 12 32-words descriptors of the disks in the raid set.
++ * 512 - 911 Reserved.
++ * 912 - 1023 Disk specific descriptor.
++ */
++
++/*
++ * If x is the real device size in bytes, we return an apparent size of:
++ *
++ * y = (x & ~(MD_RESERVED_BYTES - 1)) - MD_RESERVED_BYTES
++ *
++ * and place the 4kB superblock at offset y.
++ */
++#define MD_RESERVED_BYTES (64 * 1024)
++#define MD_RESERVED_SECTORS (MD_RESERVED_BYTES / 512)
++#define MD_RESERVED_BLOCKS (MD_RESERVED_BYTES / BLOCK_SIZE)
++
++#define MD_NEW_SIZE_SECTORS(x) ((x & ~(MD_RESERVED_SECTORS - 1)) - MD_RESERVED_SECTORS)
++#define MD_NEW_SIZE_BLOCKS(x) ((x & ~(MD_RESERVED_BLOCKS - 1)) - MD_RESERVED_BLOCKS)
++
++#define MD_SB_BYTES 4096
++#define MD_SB_WORDS (MD_SB_BYTES / 4)
++#define MD_SB_BLOCKS (MD_SB_BYTES / BLOCK_SIZE)
++#define MD_SB_SECTORS (MD_SB_BYTES / 512)
++
++/*
++ * The following are counted in 32-bit words
++ */
++#define MD_SB_GENERIC_OFFSET 0
++#define MD_SB_PERSONALITY_OFFSET 64
++#define MD_SB_DISKS_OFFSET 128
++#define MD_SB_DESCRIPTOR_OFFSET 992
++
++#define MD_SB_GENERIC_CONSTANT_WORDS 32
++#define MD_SB_GENERIC_STATE_WORDS 32
++#define MD_SB_GENERIC_WORDS (MD_SB_GENERIC_CONSTANT_WORDS + MD_SB_GENERIC_STATE_WORDS)
++#define MD_SB_PERSONALITY_WORDS 64
++#define MD_SB_DISKS_WORDS 384
++#define MD_SB_DESCRIPTOR_WORDS 32
++#define MD_SB_RESERVED_WORDS (1024 - MD_SB_GENERIC_WORDS - MD_SB_PERSONALITY_WORDS - MD_SB_DISKS_WORDS - MD_SB_DESCRIPTOR_WORDS)
++#define MD_SB_EQUAL_WORDS (MD_SB_GENERIC_WORDS + MD_SB_PERSONALITY_WORDS + MD_SB_DISKS_WORDS)
++#define MD_SB_DISKS (MD_SB_DISKS_WORDS / MD_SB_DESCRIPTOR_WORDS)
++
++/*
++ * Device "operational" state bits
++ */
++#define MD_DISK_FAULTY 0 /* disk is faulty / operational */
++#define MD_DISK_ACTIVE 1 /* disk is running or spare disk */
++#define MD_DISK_SYNC 2 /* disk is in sync with the raid set */
++
++typedef struct md_device_descriptor_s {
++ md_u32 number; /* 0 Device number in the entire set */
++ md_u32 major; /* 1 Device major number */
++ md_u32 minor; /* 2 Device minor number */
++ md_u32 raid_disk; /* 3 The role of the device in the raid set */
++ md_u32 state; /* 4 Operational state */
++ md_u32 reserved[MD_SB_DESCRIPTOR_WORDS - 5];
++} md_descriptor_t;
++
++#define MD_SB_MAGIC 0xa92b4efc
++
++/*
++ * Superblock state bits
++ */
++#define MD_SB_CLEAN 0
++#define MD_SB_ERRORS 1
++
++typedef struct md_superblock_s {
++ /*
++ * Constant generic information
++ */
++ md_u32 md_magic; /* 0 MD identifier */
++ md_u32 major_version; /* 1 major version to which the set conforms */
++ md_u32 minor_version; /* 2 minor version ... */
++ md_u32 patch_version; /* 3 patchlevel version ... */
++ md_u32 gvalid_words; /* 4 Number of used words in this section */
++ md_u32 set_magic; /* 5 Raid set identifier */
++ md_u32 ctime; /* 6 Creation time */
++ md_u32 level; /* 7 Raid personality */
++ md_u32 size; /* 8 Apparent size of each individual disk */
++ md_u32 nr_disks; /* 9 total disks in the raid set */
++ md_u32 raid_disks; /* 10 disks in a fully functional raid set */
++ md_u32 md_minor; /* 11 preferred MD minor device number */
++ md_u32 gstate_creserved[MD_SB_GENERIC_CONSTANT_WORDS - 12];
++
++ /*
++ * Generic state information
++ */
++ md_u32 utime; /* 0 Superblock update time */
++ md_u32 state; /* 1 State bits (clean, ...) */
++ md_u32 active_disks; /* 2 Number of currently active disks */
++ md_u32 working_disks; /* 3 Number of working disks */
++ md_u32 failed_disks; /* 4 Number of failed disks */
++ md_u32 spare_disks; /* 5 Number of spare disks */
++ md_u32 gstate_sreserved[MD_SB_GENERIC_STATE_WORDS - 6];
++
++ /*
++ * Personality information
++ */
++ md_u32 layout; /* 0 the array's physical layout */
++ md_u32 chunk_size; /* 1 chunk size in bytes */
++ md_u32 pstate_reserved[MD_SB_PERSONALITY_WORDS - 2];
++
++ /*
++ * Disks information
++ */
++ md_descriptor_t disks[MD_SB_DISKS];
++
++ /*
++ * Reserved
++ */
++ md_u32 reserved[MD_SB_RESERVED_WORDS];
++
++ /*
++ * Active descriptor
++ */
++ md_descriptor_t descriptor;
++
++} md_superblock_t;
++
++/*
++ * options passed in raidstart:
++ */
++
++#define MAX_CHUNK_SIZE (4096*1024)
++
++struct md_param
++{
++ int personality; /* 1,2,3,4 */
++ int chunk_size; /* in bytes */
++ int max_fault; /* unused for now */
++};
++
++typedef struct md_array_info_s {
++ /*
++ * Generic constant information
++ */
++ md_u32 major_version;
++ md_u32 minor_version;
++ md_u32 patch_version;
++ md_u32 ctime;
++ md_u32 level;
++ md_u32 size;
++ md_u32 nr_disks;
++ md_u32 raid_disks;
++ md_u32 md_minor;
++ md_u32 not_persistent;
++
++ /*
++ * Generic state information
++ */
++ md_u32 utime; /* 0 Superblock update time */
++ md_u32 state; /* 1 State bits (clean, ...) */
++ md_u32 active_disks; /* 2 Number of currently active disks */
++ md_u32 working_disks; /* 3 Number of working disks */
++ md_u32 failed_disks; /* 4 Number of failed disks */
++ md_u32 spare_disks; /* 5 Number of spare disks */
++
++ /*
++ * Personality information
++ */
++ md_u32 layout; /* 0 the array's physical layout */
++ md_u32 chunk_size; /* 1 chunk size in bytes */
++
++} md_array_info_t;
++
++typedef struct md_disk_info_s {
++ /*
++ * configuration/status of one particular disk
++ */
++ md_u32 number;
++ md_u32 major;
++ md_u32 minor;
++ md_u32 raid_disk;
++ md_u32 state;
++
++} md_disk_info_t;
++
++
++/*
++ * Supported RAID5 algorithms
++ */
++#define RAID5_ALGORITHM_LEFT_ASYMMETRIC 0
++#define RAID5_ALGORITHM_RIGHT_ASYMMETRIC 1
++#define RAID5_ALGORITHM_LEFT_SYMMETRIC 2
++#define RAID5_ALGORITHM_RIGHT_SYMMETRIC 3
++
++#endif _MD_H
+diff -Naur --exclude=CVS --exclude='*.orig' lilo/partition.c lilosh/partition.c
+--- lilo/partition.c 1998-10-14 20:12:42.000000000 +0000
++++ lilosh/partition.c 2006-01-31 19:51:58.000000000 +0000
+@@ -13,6 +13,8 @@
+ #include <sys/stat.h>
+
+ #include <linux/fs.h>
++#include <linux/genhd.h>
++#include <linux/kdev_t.h>
+
+ #include "config.h"
+ #include "lilo.h"
+@@ -23,7 +25,7 @@
+
+
+ /* For older kernels ... */
+-
++#if 0
+ #ifndef DOS_EXTENDED_PARTITION
+ #define DOS_EXTENDED_PARTITION EXTENDED_PARTITION
+ #endif
+@@ -31,6 +33,7 @@
+ #ifndef LINUX_EXTENDED_PARTITION
+ #define LINUX_EXTENDED_PARTITION EXTENDED_PARTITION
+ #endif
++#endif
+
+
+ void part_verify(int dev_nr,int type)
+diff -Naur --exclude=CVS --exclude='*.orig' lilo/second.c lilosh/second.c
+--- lilo/second.c 2006-02-01 21:16:41.000000000 +0000
++++ lilosh/second.c 2006-02-01 20:25:07.000000000 +0000
+@@ -1,4 +1,4 @@
+-/* $Id: second.c,v 1.22 2000/11/26 07:11:16 gniibe Exp $
++/* $Id: second.c,v 1.6 2004/10/01 19:05:58 cpchen Exp $
+ *
+ * Secondary boot loader
+ *
+@@ -12,7 +12,35 @@
+ */
+
+ #include "defs.h"
++#include "common.h"
+
++#define TAB_CHAR '\t'
++#define BACKSPACE '\b'
++
++#define R64CNT 0xFFC80000
++#define RSECCNT 0xFFC80004
++#define RMINCNT 0xFFC80008
++#define RHRCNT 0xFFC8000C
++#define RSECAR 0xFFC80020
++#define RMINAR 0xFFC80024
++#define RHRAR 0xFFC80028
++#define RWKAR 0xFFC8002C
++#define RDAYAR 0xFFC80030
++#define RMONAR 0xFFC80034
++#define RTCRCR1 0xFFC80038
++#define RTCRCR2 0xFFC8003C
++
++#ifndef BCD_TO_BIN
++#define BCD_TO_BIN(val) ((val)=((val)&15) + ((val)>>4)*10)
++#endif
++
++#ifndef BIN_TO_BCD
++#define BIN_TO_BCD(val) ((val)=(((val)/10)<<4) + (val)%10)
++#endif
++
++static inline char get_char(void);
++static void dump_image_names(DESCR_SECTORS *);
++static IMAGE_DESCR * descr_label_match(char *);
+ static void put_string (unsigned char *);
+ static int get_sector_address (unsigned long, int *, unsigned long *);
+ static int load_sectors (unsigned long, unsigned long);
+@@ -30,19 +58,35 @@
+ static inline char highhex (int x) { return hexchars[(x >> 4) & 0xf]; }
+ static inline char lowhex (int x) { return hexchars[x & 0xf]; }
+ static void printouthex (int);
++static void set_delay(short delay);
++static inline int lilo_timeout() {
++ return *((char *) RTCRCR1) & 0x01;
++}
+
+ static unsigned long base_pointer = 0; /* Avoid BSS */
+ static unsigned long kernel_image = 0; /* Avoid BSS */
++static unsigned long initrd_start = 0;
++static unsigned long initrd_end = 0;
++
++#define INPUT_BUF_SIZE 256
++static char input_buffer[INPUT_BUF_SIZE];
+
+ /* Sector descriptor */
+ #define SD_DESCR1 24
++#define SD_DESCR1_MEM 0x3200
+ #define SD_DESCR2 29
++#define SD_DESCR2_MEM 0x3400
+ #define SD_DEFCMD 34
+ /* 39 prompt (byte) */
+ /* 40 length (word) */
+ #define SD_MSG 42
+ #define SD_KBDTBL 47
+
++/* use the section attribute and linker script to force the start function to
++ the beginning of the second stage reserved area.
++ This is where first.S will jmp */
++void start (unsigned long base) __attribute__((section(".entry")));
++
+ static inline char *string_set (char *dest, const char *str)
+ {
+ int len = strlen (str);
+@@ -53,11 +97,16 @@
+ void
+ start (unsigned long base)
+ {
+- base_pointer = base;
++ base_pointer = base;
++ unsigned char ch;
++ int input_idx;
++ IMAGE_DESCR *image_descr;
++ int desc;
++ int defer_delay=0;
+
+ put_string ("I");
+- load_sectors (SD_DESCR1, 0x3200);
+- load_sectors (SD_DESCR2, 0x3400);
++ load_sectors (SD_DESCR1, SD_DESCR1_MEM);
++ load_sectors (SD_DESCR2, SD_DESCR2_MEM);
+ put_string ("L");
+ /* XXX: checksum */
+
+@@ -73,30 +122,72 @@
+ /* XXX: check signature */
+ /* Input command line */
+ /* XXX: Is there default command line? Use it! */
+- put_string ("boot: ");
+- put_string ("first-image\n"); /* XXX: should handle input commandline... */
+
+- /* Structure of descriptor
+- [ checksum 2byte ]
+- [ DESCR_SIZE:52-byte
+- (image-name (16-byte)
+- passwd (16-byte)
+- rd_size (4-byte)
+- initrd (5-byte sector desc)
+- start (5-byte sector desc)
+- start_page (16-bit)
+- flags (16-bit)
+- vga_mode (16-bit)
+- )
+- ] * 19
+- */
++ /* Structure of descriptor
++ [ checksum 2byte ]
++ [ DESCR_SIZE:52-byte
++ (image-name (16-byte)
++ passwd (16-byte)
++ rd_size (4-byte)
++ initrd (5-byte sector desc)
++ start (5-byte sector desc)
++ start_page (16-bit)
++ flags (16-bit)
++ vga_mode (16-bit)
++ )
++ ] * 19
++ */
++
++ input_buffer[0] = '\0';
++ if (((BOOT_SECTOR *) base_pointer)->par_1.prompt) {
++ if (((BOOT_SECTOR *) base_pointer)->par_1.timeout != 0xffff)
++ set_delay(((BOOT_SECTOR *) base_pointer)->par_1.timeout);
++boot_loop:
++ input_idx = 0;
++ put_string ("boot: ");
++ while ((ch=get_char()) != 0x0d && input_idx < INPUT_BUF_SIZE-1) {
++ switch (ch) {
++ case TAB_CHAR:
++ defer_delay = 1;
++ dump_image_names((DESCR_SECTORS *) (base_pointer + SD_DESCR1_MEM));
++ goto boot_loop;
++ break;
++ case BACKSPACE:
++ defer_delay = 1;
++ if (input_idx) --input_idx;
++ break;
++ case 0x00FF:
++ break;
++ default:
++ defer_delay = 1;
++ input_buffer[input_idx++] = ch;
++ break;
++ }
++ if (!defer_delay && lilo_timeout())
++ break;
++ }
++ input_buffer[input_idx++] = ' ';
++ input_buffer[input_idx] = '\0';
++ if ( ! (image_descr = descr_label_match(input_buffer)) ) {
++ put_string("No such image. [Tab] shows a list.\n");
++ goto boot_loop;
++ }
++ }
++ else {
++ // dispatch the default image after the delayed timeout
++ // 0 or default == immediate dispatch
++ set_delay(((BOOT_SECTOR *) base_pointer)->par_1.delay);
++ do {
++ } while (!lilo_timeout()); /* NULL */
++ image_descr = descr_label_match(input_buffer);
++ }
+
+ put_string ("Loading ");
+- put_string ((char *)(base_pointer+0x3200+2)); /* Image name */
++ put_string (image_descr->name); /* Image name */
+
+ kernel_image = base_pointer + 0x10000 - 0x400;
+ {
+- int desc = 0x3200+2+16+16+4+5; /* kernel image */
++ desc = (int) image_descr+(16+16+4+5) - (int) base_pointer;
+
+ /* Skip two sectors: Fallback command line and options */
+ desc = load_sectors_with_maps (desc, 0, &kernel_image);
+@@ -108,7 +199,21 @@
+ put_string (".");
+ }
+ }
+- put_string ("done.\n");
++ put_string ("done.\n\n");
++
++ desc = (int) image_descr+(16+16+4) - (int) base_pointer;
++ initrd_start = kernel_image = 0x88000000 + memory_size() / 2;
++ desc = load_sectors_with_maps (desc, 0, &kernel_image);
++ if (desc) {
++ put_string("ramdisk image loading");
++ put_string(".");
++ while (desc != 0) {
++ desc = load_sectors_with_maps (desc, 0, &kernel_image);
++ put_string(".");
++ }
++ put_string ("done.\n\n");
++ }
++ initrd_end = kernel_image;
+
+ #if 0
+ {
+@@ -123,24 +228,39 @@
+
+ /* XXX: kernel paramerter setting */
+ {
+- unsigned long parm = base_pointer - 0x200000 + 0x1000;
++ unsigned long parm = base_pointer + (~0x9cf000+1);
+ char *cmdline = (char *)(parm+256);
+ int mem_size;
+- unsigned char *p;
++ unsigned char *p, *debug_p;
+
+ *(long *)parm = 1; /* Read only mount? */
+ *(long *)(parm+4) = 0; /* RAMDISK Flags */
+ *(long *)(parm+8) = 0x0301; /* Root device: XXX should get from cls.. */
+ *(long *)(parm+12) = 1; /* Loader type (LILO = 1) */
+- *(long *)(parm+16) = 0; /* Initrd start */
+- *(long *)(parm+20) = 0; /* Initrd size */
++ if (initrd_end - initrd_start) {
++ initrd_start += ~0x88030000 + 1;
++ *(long *)(parm+16) = initrd_start; /* Initrd start */
++ initrd_end += ~0x88030000 + 1; /* Initrd size */
++ *(long *)(parm+20) = initrd_end + (~initrd_start + 1);/* Initrd size */
++ }
++ else {
++ *(long *)(parm+16) = 0; /* Initrd start */
++ *(long *)(parm+20) = 0; /* Initrd size */
++ }
+ *(long *)(parm+24) = 0; /* Not defined yet */
+
+ /* XXX: Should take the line from command line sector... */
++ if (*input_buffer) {
++ debug_p = cmdline;
++ cmdline = string_set(cmdline, input_buffer);
++ *cmdline = '\0';
++ }
++
+ #define DC_MAGIC 0xf4f2 /* magic number of default cmd. line sector */
+ p = (unsigned char *)(base_pointer+0x3600);
+ if(p[0] == (DC_MAGIC & 0xff) && p[1] == (DC_MAGIC >> 8))
+ cmdline = string_set(cmdline, p+2);
++
+ cmdline = string_set(cmdline, (char *)(base_pointer + 0x10000 - 0x200));
+
+ #if 0
+@@ -231,7 +351,7 @@
+ /* There's next map */
+ return 0x3000+505;
+ }
+-
++
+ static int
+ machine_type (void)
+ {
+@@ -296,6 +416,77 @@
+ : "memory");
+ }
+
++static char inline
++get_char(void)
++{
++ register long __sc0 __asm__ ("r0") = 1; /* OUTPUT */
++
++ asm volatile ("trapa #0x3F"
++ : "=z" (__sc0)
++ : "0" (__sc0)
++ : "memory");
++ return __sc0;
++}
++
++static IMAGE_DESCR *
++descr_label_match(char * boot_buffer)
++{
++ IMAGE_DESCR *descr =
++ ((DESCR_SECTORS *) (base_pointer + SD_DESCR1_MEM))->d.descr;
++ char * buf_ptr=boot_buffer;
++ char * name;
++
++ while (*boot_buffer && (*boot_buffer == ' ' || *boot_buffer == '\t'))
++ ++boot_buffer;
++
++ if ( ! *boot_buffer ) {
++ return descr;
++ }
++
++ for ( buf_ptr=boot_buffer; *descr->name; ++descr, buf_ptr=boot_buffer) {
++ name = descr->name;
++ for ( ; *name == *buf_ptr; ++name, ++buf_ptr) ;
++ if (!*name && (!*buf_ptr || *buf_ptr == ' ' || *buf_ptr == '\t')) {
++ // overwrite the boot_buffer with the string after the
++ // boot image name.
++ while (*boot_buffer++ = *buf_ptr++) ;
++ return descr;
++ }
++ }
++ return NULL;
++}
++
++static void
++dump_image_names(DESCR_SECTORS *descr_area)
++{
++ int buf_idx=0, name_len;
++ char * name;
++ IMAGE_DESCR *descr = descr_area->d.descr;
++
++ put_string("\n");
++ for ( ; *descr->name; ++descr)
++ {
++ name = descr->name;
++ name_len = strlen(name);
++ memcpy(input_buffer + buf_idx, name, name_len);
++ buf_idx += name_len;
++ name_len = MAX_IMAGE_NAME+1 - name_len;
++ memset(input_buffer + buf_idx, ' ', name_len);
++ buf_idx += name_len;
++ if ( buf_idx >= 78 ) {
++ input_buffer[buf_idx++] = '\n';
++ input_buffer[buf_idx++] = '\0';
++ put_string(input_buffer);
++ buf_idx = 0;
++ }
++ }
++ if (buf_idx) {
++ input_buffer[buf_idx++] = '\n';
++ input_buffer[buf_idx] = '\0';
++ put_string(input_buffer);
++ }
++}
++
+ static void inline
+ put_string_1 (unsigned char *str, long len)
+ {
+@@ -344,15 +535,17 @@
+ unsigned char *p = (unsigned char *)(sector_desc+base_pointer);
+ int len;
+
++
+ /* Number of sectors */
+ len = (int)p[4];
+ if (len == 0)
+ return 0;
+
+ /* p[2]: drive number */
+- if ((int)p[2] < 0xc0)
++ if ((int)p[2] < 0xc0) {
+ /* XXX: should return error */
+ put_string ("ERROR: Sector address is not in LBA\n");
++ }
+
+ *devp = (int)p[2] & 0x0f;
+
+@@ -394,8 +587,56 @@
+
+ return -1;
+ }
+-
+-#if 0
++
++static void set_delay(short delay)
++{
++ char rtc_sec, rtc_min, rtc_hr;
++ int alarm_time;
++ char arm_sec, arm_min, arm_hr;
++ char regval;
++ char tenths, seconds, minutes, hour;
++
++ // Make sure the RTC is running
++ *(char*)RTCRCR2 = 0x09;
++
++ // Make sure ENB bits are off
++ *(char*)RWKAR &= 0x7f;
++ *(char*)RDAYAR &= 0x7f;
++ *(char*)RMONAR &= 0x7f;
++
++ // Read time
++ do {
++ *(char*)RTCRCR1 = 0x00; // Clear CF-bit
++ rtc_sec = *(char*)RSECCNT;
++ rtc_min = *(char*)RMINCNT;
++ rtc_hr = *(char*)RHRCNT;
++ } while ((*(char*)RTCRCR1 & 0x80) != 0);
++
++ BCD_TO_BIN(rtc_hr);
++ BCD_TO_BIN(rtc_min);
++ BCD_TO_BIN(rtc_sec);
++
++ alarm_time = ((rtc_hr * 60) + rtc_min) * 60 + rtc_sec + (delay / 10);
++
++ arm_sec = alarm_time % 60;
++ arm_min = (alarm_time / 60) % 60;
++ arm_hr = alarm_time / 3600;
++ if (arm_hr >= 24)
++ arm_hr = arm_hr - 24;
++
++ BIN_TO_BCD(arm_sec);
++ BIN_TO_BCD(arm_min);
++ BIN_TO_BCD(arm_hr);
++
++ *(char*)RSECAR = arm_sec | 0x80;
++ *(char*)RMINAR = arm_min | 0x80;
++ *(char*)RHRAR = arm_hr | 0x80;
++
++ // Clear AF bit
++ *(char*)RTCRCR1 = 0;
++}
++
++#if 1
+ static void
+ printouthex(int x)
+ {
+@@ -408,4 +649,14 @@
+
+ put_string (z);
+ }
++
++static void dump_desc(char * desc)
++{
++ printouthex((int) desc[0]);
++ printouthex((int) desc[1]);
++ printouthex((int) desc[2]);
++ printouthex((int) desc[3]);
++ printouthex((int) desc[4]);
++ put_string("\n");
++}
+ #endif
+diff -Naur --exclude=CVS --exclude='*.orig' lilo/second.lds lilosh/second.lds
+--- lilo/second.lds 2006-02-01 21:16:41.000000000 +0000
++++ lilosh/second.lds 2006-01-31 22:44:27.000000000 +0000
+@@ -83,6 +83,7 @@
+ .plt : { *(.plt) }
+ .text :
+ {
++ *(.entry)
+ *(.text)
+ *(.text.*)
+ *(.stub)
+diff -Naur --exclude=CVS --exclude='*.orig' lilo/string.c lilosh/string.c
+--- lilo/string.c 2006-02-01 21:16:41.000000000 +0000
++++ lilosh/string.c 2004-05-19 16:39:08.000000000 +0000
+@@ -20,3 +20,8 @@
+
+ return dest;
+ }
++
++void * memset(void * dest, int val, unsigned int count)
++{
++ while (count--) *((char *)dest++) = val;
++}
diff --git a/packages/lilo-sh/files/lilo-noconfig-h.patch b/packages/lilo-sh/files/lilo-noconfig-h.patch
new file mode 100644
index 0000000000..01b6cbddd3
--- /dev/null
+++ b/packages/lilo-sh/files/lilo-noconfig-h.patch
@@ -0,0 +1,23 @@
+Stop it looking for config.h. It doesn't need it and trying to include this
+from libc-headers results in an compile time error.
+
+--- lilo/lilo.h 2006/06/28 05:40:25 1.1
++++ lilo/lilo.h 2006/06/28 05:40:36
+@@ -11,17 +11,6 @@
+ #ifndef LILO_H
+ #define LILO_H
+
+-/*
+- * Starting with 2.1.something, Linux kernels put VGA constants and segment
+- * definitions into asm/boot.h instead of linux/config.h
+- */
+-
+-#ifdef HAS_BOOT_H
+-#include <asm/boot.h>
+-#else
+-#include <linux/config.h>
+-#endif
+-
+ #define VERSION 20 /* Boot sector, map file, and chain loader format
+ revision. This number does not necessarily have
+ to correspond to the version number of the entire
diff --git a/packages/lilo-sh/files/lilo-sh-linux.patch b/packages/lilo-sh/files/lilo-sh-linux.patch
new file mode 100644
index 0000000000..0eadf26cff
--- /dev/null
+++ b/packages/lilo-sh/files/lilo-sh-linux.patch
@@ -0,0 +1,1971 @@
+This is the patch that upgrade lilo to match the version included in
+the old lilosh CVS.
+
+diff -ruN lilo.orig/ChangeLog lilo/ChangeLog
+--- lilo.orig/ChangeLog Thu Jan 1 09:00:00 1970
++++ lilo/ChangeLog Thu Dec 7 16:17:10 2000
+@@ -0,0 +1,44 @@
++2000-11-26 NIIBE Yutaka <gniibe@m17n.org>
++
++ * first.S (done): Flush the cache.
++ * second.c (start): Call cache_flush.
++ (cache_flush): New function.
++
++2000-11-25 NIIBE Yutaka <gniibe@m17n.org>
++
++ * first.S: Don't put '$' for register spec.
++ * second.c (start): Don't put '$' for register spec.
++ (machine_type, memory_size, io_base, put_string_1, read_sectors):
++ Likewise.
++ * second.lds: Use new tool chain's ldscript.
++ * defs.h: Add declaration of memcpy.
++
++2000-09-09 NIIBE Yutaka <gniibe@m17n.org>
++
++ * first.S (real_start): Set argument 0 for cache enable call.
++
++2000-08-19 NIIBE Yutaka <gniibe@m17n.org>
++
++ * second.c (get_sector_address): Bug fix for # of sector == 0.
++ (start): Support machine types of CqREEK and SolutionEngine.
++
++ * first.S (load_sector_address): Bug fix for checking LBA.
++ (real_start): Call "enable cache" BIOS feature.
++
++2000-08-05 NIIBE Yutaka <gniibe@m17n.org>
++
++ * Makefile (first.o): Added -traditional for "'" in comments.
++
++ * second.c (machine_type, serial_type, memory_size, io_base): New
++ functions.
++ (start): Implement kernel command line handling a bit.
++ (read_sectors): Emit error message.
++ (get_sector_address): Emit error message.
++
++ * first.S (read_a_sector): Implement error handling.
++ (load_sector_address): Check if it's LBA.
++
++2000-07-22 NIIBE Yutaka <gniibe@m17n.org>
++
++ * second.c (start): Don't load two magic sectors at the memory
++ of executable image.
+diff -ruN lilo.orig/Makefile lilo/Makefile
+--- lilo.orig/Makefile Fri Dec 8 10:10:02 2000
++++ lilo/Makefile Fri Dec 8 11:46:04 2000
+@@ -39,76 +39,55 @@
+ GO=-DGO=0x`sed '/go/s/^.*go 0 \(....\) A.*$$/\1/p;d' first.lis`
+
+ SHELL=/bin/sh
+-CC=cc
+-CPP=$(CC) -E
+-AS86=as86 -0 -a
+-LD86=ld86 -0
+
+-CFLAGS=-Wall -g $(PCONFIG)
+-LDFLAGS=#-Xlinker -qmagic
++CROSS_COMPILE = sh3-linux-
++CC =$(CROSS_COMPILE)gcc
++LD =$(CROSS_COMPILE)ld
++OBJCOPY =$(CROSS_COMPILE)objcopy
++STRIP =$(CROSS_COMPILE)strip
++
++CFLAGS = -O2 -I. -pipe -fPIC $(CONFIG) -DPATH_MAX=255
++CPP=$(CC) -E -traditional
++
++#CFLAGS=-Wall -g $(PCONFIG)
++#LDFLAGS=#-Xlinker -qmagic
+
+ OBJS=lilo.o map.o geometry.o boot.o device.o common.o bsect.o cfg.o temp.o \
+ partition.o identify.o
+
+-.SUFFIXES: .img .b
++.SUFFIXES: .b
+
+-all: check-config lilo boot.b dump.b os2_d.b chain.b dparam.com \
+- activate
+-
+-check-config:
+- $(CPP) check-config.cpp $(PCONFIG) >/dev/null
++all: lilo boot.b
+
+ .c.o:
+ $(CC) -c $(CFLAGS) $*.c
+
+-.s.o:
+- $(AS86) -w -o $*.o $*.s
+-
+-.o.img:
+- $(LD86) -s -o $*.img $*.o
++boot.b: first.bin second.bin
++ cat first.bin second.bin >boot.b
+
+-.img.b:
+- dd if=$*.img of=$*.b bs=32 skip=1
++first.bin: first.exe
++ $(OBJCOPY) -S first.exe -O binary first.bin
+
+-activate: activate.c
+- $(CC) -Wall -s -O -o activate activate.c $(LDFLAGS)
+-
+-dparam.com: dparam.img
+- dd if=dparam.img of=dparam.com bs=288 skip=1
+-
+-lilo: $(OBJS)
+- $(CC) -o lilo $(LDFLAGS) $(OBJS)
++second.bin: second.exe
++ $(OBJCOPY) -R .comment -S second.exe -O binary second.bin
+
+-boot.b: first.b second.b
+- (dd if=first.b bs=512 conv=sync; dd if=second.b) >boot.b
++first.exe: first.o
++ $(LD) -EL -e start first.o -o first.exe -Ttext 0x8c200000
+
+-first.s: first.S lilo.h lilo
+- $(CPP) $(PCONFIG) `./lilo -X` first.S -o first.s
++second.exe: second.o string.o
++ $(LD) -T second.lds -EL second.o string.o -o second.exe -Ttext 0x8c201000
+
+-second.s: second.S lilo.h lilo
+- $(CPP) $(PCONFIG) $(GO) `./lilo -X` second.S -o second.s
++first.o: first.S
++ $(CC) $(CFLAGS) -c first.S
+
+-chain.s: chain.S lilo.h
+- $(CPP) $(PCONFIG) $(GO) chain.S -o chain.s
++second.o: second.c
++ $(CC) $(CFLAGS) -c second.c
+
+-os2_d.s: chain.S lilo.h
+- $(CPP) $(PCONFIG) $(GO) chain.S -DDOS_D -o os2_d.s
++string.o: string.c
++ $(CC) $(CFLAGS) -c string.c
+
+-#dos_d.s: chain.S lilo.h first.lis
+-# $(CPP) $(PCONFIG) $(GO) chain.S -DDOS_D -o dos_d.s
+-
+-dump.s: dump.S lilo.h first.lis
+- $(CPP) $(PCONFIG) `./lilo -X` dump.S -DDOS_D -o dump.s \
+- -DGO=0x`sed '/go/s/^.*go 0 \(....\) A.*$$/\1/p;d' first.lis`
+-
+-xxx.s: chain.S lilo.h
+- $(CPP) chain.S -DXXX -o xxx.s
+-
+-first.o first.lis: first.s
+- $(AS86) -w -o first.o -l first.lis first.s
+-
+-second.lis: second.s
+- $(AS86) -w -l second.lis second.s
++lilo: $(OBJS)
++ $(CC) -o lilo $(LDFLAGS) $(OBJS)
+
+ install: all
+ if [ ! -d $$ROOT$(SBIN_DIR) ]; then mkdir $$ROOT$(SBIN_DIR); fi
+@@ -118,13 +97,9 @@
+ mkdir $$ROOT$(USRSBIN_DIR); fi
+ if [ -f $$ROOT$(BOOT_DIR)/boot.b ]; then \
+ mv $$ROOT$(BOOT_DIR)/boot.b $$ROOT$(BOOT_DIR)/boot.old; fi
+- if [ -f $$ROOT$(BOOT_DIR)/chain.b ]; then \
+- mv $$ROOT$(BOOT_DIR)/chain.b $$ROOT$(BOOT_DIR)/chain.old; fi
+- if [ -f $$ROOT$(BOOT_DIR)/os2_d.b ]; then \
+- mv $$ROOT$(BOOT_DIR)/os2_d.b $$ROOT$(BOOT_DIR)/os2_d.old; fi
+- cp boot.b chain.b os2_d.b $$ROOT$(BOOT_DIR)
++ cp boot.b $$ROOT$(BOOT_DIR)
+ cp lilo $$ROOT$(SBIN_DIR)
+- strip $$ROOT$(SBIN_DIR)/lilo
++ $(STRIP) $$ROOT$(SBIN_DIR)/lilo
+ cp keytab-lilo.pl $$ROOT$(USRSBIN_DIR)
+ @if [ -e $$ROOT/etc/lilo/install ]; then echo; \
+ echo -n "$$ROOT/etc/lilo/install is obsolete. LILO is now ";\
+@@ -142,11 +117,8 @@
+ && mv ../lilo ../lilo-`cat VERSION`
+
+ clean:
+- rm -f *.o *.img *.lis first.s second.s chain.s \
+- os2_d.s dump.s tmp_make first.b second.b
+-
+-spotless: clean
+- rm -f lilo activate boot.b chain.b os2_d.b dump.b dparam.com
++ rm -f *.o *.exe *.bin tmp_make
++ rm -f lilo boot.b
+
+ ### Dependencies
+ activate.o : activate.c
+diff -ruN lilo.orig/chain.S lilo/chain.S
+--- lilo.orig/chain.S Thu Oct 15 05:14:25 1998
++++ lilo/chain.S Thu Jan 1 09:00:00 1970
+@@ -1,255 +0,0 @@
+-/* chain.S - LILO boot chainer */
+-
+-/* Copyright 1992-1998 Werner Almesberger. See file COPYING for details. */
+-
+-
+-#define LILO_ASM
+-#include "lilo.h"
+-
+-
+- .text
+-
+- .globl _main
+- .org 0
+-
+-_main: jmp start
+-
+- .org 6
+-
+- .ascii "LILO"
+- .word STAGE_CHAIN
+- .word VERSION
+-
+-offset: .word 0
+-drive: .byte 0
+- .byte 0 ! head, always zero
+-
+-hint: .word drvmap ! pointer to drive map
+-
+-ptable: .blkw 0x20 ! partition table to preload
+-
+-start: cli ! set SS:SP to 0:7C00
+- xor ax,ax
+- mov ss,ax
+- mov ax,#0x7c00
+- mov sp,ax
+- sti
+- mov ax,#SETUPSEG ! move boot sector to default location
+- mov ds,ax
+- xor ax,ax
+- mov es,ax
+- mov cx,#256
+-mtmp = SETUPSECS-1 ! broken math ...
+- mov si,#mtmp*512
+- mov di,#BOOTSEG*16
+- rep
+- movsw
+-#ifdef DOS_D
+-dos4: seg es
+- mov byte ptr BOOTSEG*16+0x24,#0x81
+-#endif
+- mov cx,#0x20 ! move partition table
+- mov si,#ptable
+- mov di,#PART_TABLE
+- rep
+- movsw
+- ! mess with the partition table
+-#if defined(LCF_REWRITE_TABLE) || defined(LCF_READONLY)
+- mov si,#prtmap ! get partition table change rules
+-prtclp: lodsw ! bios == 0 indicates end
+- or al,al
+- jz pmend ! at end -> quit
+- cmp al,cache ! already in cache ?
+- je incache ! yes -> no loading required
+- push ax ! save table data
+- call flush ! flush the cache
+- pop ax
+- push ax
+- mov cache,al ! remember drive in cache
+- cmp al,drive ! boot drive ?
+- jne noc ! no -> load into scratch area
+- xor ax,ax ! load at 0000:0600
+- mov bx,#PARTS_LOAD
+- jmp loadit
+-noc: mov ax,ds
+- mov bx,#PARTS_SCR ! scratch area
+-loadit: mov es,ax ! set up pointers and remember them
+- mov ces,ax
+- mov cbx,bx
+- mov ax,#0x201 ! load partition table, one sector
+- mov dx,cache ! drive from cache (DH = 0)
+- mov cx,#1
+- int 0x13 ! load it
+- jc wrfail ! error -> abort
+- pop ax ! get BIOS and offset
+-incache:les bx,cbx ! load pointer
+- add bx,#PART_TABLE_OFFSET ! move to partition table
+- add bl,ah ! offset is always in [0x1be,0x1fd]
+- lodsw ! see what we need to do
+- seg es ! match ?
+- cmp byte ptr (bx),al
+- jne nocng ! no -> do not change
+- seg es ! change
+- mov byte ptr (bx),ah
+- mov byte ptr dirty,#1 ! mark as dirty
+-nocng: br prtclp ! next one
+-
+-flush: test byte ptr dirty,#1 ! dirty ?
+- jz noflush ! no -> do not write
+- mov ax,#0x301 ! write one sector
+- mov dx,cache ! get the drive
+- or dl,dl ! nothing cached ?
+- jz noflush ! no -> do not flush
+- les bx,cbx ! reload pointer
+- int 0x13 ! write ...
+- jc wrfail ! argl
+-noflush:ret
+-pmend: call flush ! flush table
+- br nopp ! and proceed
+-wrfail: mov si,#failmsg ! complain
+- call say
+- mov ax,#FIRSTSEG ! try to restart LILO
+- jmpi #GO,FIRSTSEG
+-
+-cache: .byte 0 ! drive, 0 means not cached
+- .byte 0 ! head, always 0
+-cbx: .blkw 1
+-ces: .blkw 1
+-dirty: .byte 0
+-
+-#endif
+-
+-nopp:
+- mov ax,drvmap ! need to install mapper ?
+- or ax,ax
+- jz noimap ! no -> go on
+- call swap13
+-noimap:
+-
+- mov si,offset ! DS:SI and ES:SI point to the partition
+- add si,#PART_TABLE
+- mov dx,drive ! initialize DX (drive and head)
+- xor ax,ax ! set DS and ES to zero
+-#ifdef XXX
+- mov ax,ds
+- mov es,ax
+- mov si,#lilosig
+- mov bx,#cmd
+- mov dl,#0xfe
+-#else
+- mov ds,ax
+- mov es,ax
+-#endif
+- mov bp,#0 ! might help some boot problems
+- mov ax,#0xaa55 ! boot signature (just in case ...)
+- jmpi #BOOTSEG*16,0 ! start boot sector
+-
+-#ifdef XXX
+-lilosig:.ascii "LILO"
+-cmd: .ascii "98"
+- .byte 0
+-#endif
+-
+-#if defined(LCF_REWRITE_TABLE)
+-
+-! Display a NUL-terminated string on the console
+-
+-say: lodsb ! get byte
+- or al,al ! NUL ?
+- jz aret ! yes -> done
+- mov ah,#14 ! display, tty-style
+- xor bh,bh
+- int 0x10
+- jmp say ! next one
+-aret: ret ! done
+-
+-failmsg:.ascii "Rewrite error."
+- .byte 13,10,0
+-
+-#endif
+-
+-swap13: seg es ! allocate 1 kB
+- dec word ptr [0x413]
+- int 0x12 ! get start segment
+- mov cl,#6
+- shl ax,cl
+- cli ! disable interrupts
+- xor bx,bx ! zero a few registers
+- mov di,bx
+- seg es ! change offset
+- xchg bx,[0x4c]
+- mov old13of,bx
+- mov bx,ax ! change segment
+- seg es
+- xchg bx,[0x4e]
+- mov old13sg,bx
+- mov es,ax ! move drive swapper
+- mov si,#new13
+- mov cx,#new13end-new13
+- rep
+- movsb
+- sti ! enable interrupts
+- ret ! done
+-
+-new13: push ax ! save AX (contains function code in AH)
+- push bp ! need BP to mess with stack
+- mov bp,sp
+- ! Stack layout:
+- !
+- ! +8 INT flags
+- ! +6 INT CS
+- ! +4 INT IP
+- ! +2 AX
+- ! BP+0 BP
+- pushf ! push flags (to act like interrupt)
+- push si
+- mov si,#drvmap-new13
+-mapfl: seg cs ! get next entry
+- lodsw
+- or ax,ax ! at end ?
+- jz nomap ! yes -> do not map
+- cmp dl,al ! match ?
+- jne mapfl ! no -> continue
+- mov dl,ah ! map drive
+-nomap: pop si ! restore SI
+- mov 8(bp),ax ! overwrite old flags (to remember mapping)
+- mov ax,2(bp) ! restore AX
+- mov bp,(bp) ! restore BP
+- .byte 0x9a ! CALL FAR
+-old13of:.word 0
+-old13sg:.word 0
+- push bp ! save BP again
+- mov bp,sp
+- ! New stack layout:
+- !
+- ! +10 mapping (was flags)
+- ! +8 INT CS
+- ! +6 INT IP
+- ! +4 AX
+- ! +2 obsolete BP
+- ! BP+0 BP
+- xchg ax,4(bp) ! save AX and get command
+- pushf ! fix driver number, if necessary
+- cmp ah,#8 ! do not fix
+- je done13
+- cmp ah,#0x15 ! do not fix
+- je done13
+- mov ax,10(bp) ! no mapping ?
+- or ax,ax
+- jz done13
+- mov dl,al ! fix mapping
+-done13: mov ax,4(bp) ! restore AX
+- pop 10(bp) ! restore flags
+- pop bp ! get BP
+- add sp,#4 ! fix SP
+- iret ! done
+-
+-drvmap: .blkw DRVMAP_SIZE+1
+-
+-new13end:
+-
+-#if defined(LCF_REWRITE_TABLE)
+-prtmap: .blkw PRTMAP_SIZE*2+1 ! only first word of last entry is read
+-#endif
+-
+-theend:
+diff -ruN lilo.orig/chain.old.S lilo/chain.old.S
+--- lilo.orig/chain.old.S Wed Jun 18 16:42:15 1997
++++ lilo/chain.old.S Thu Jan 1 09:00:00 1970
+@@ -1,260 +0,0 @@
+-/* chain.S - LILO boot chainer */
+-
+-/* Copyright 1992-1997 Werner Almesberger. See file COPYING for details. */
+-
+-
+-#define LILO_ASM
+-#include "lilo.h"
+-
+-
+- .text
+-
+- .globl _main
+- .org 0
+-
+-_main: jmp start
+-
+- .org 2
+-
+- .ascii "LILO"
+- .word STAGE_CHAIN
+- .word VERSION
+-
+-offset: .word 0
+-drive: .byte 0
+- .byte 0 ! head, always zero
+-
+-start: cli ! set SS:SP to 0:7C00
+- xor ax,ax
+- mov ss,ax
+- mov ax,#0x7c00
+- mov sp,ax
+- sti
+- mov ax,#SETUPSEG ! move boot sector to default location
+- mov ds,ax
+- xor ax,ax
+- mov es,ax
+- mov cx,#256
+- mov si,#512
+- mov di,#BOOTSEG*16
+- rep
+- movsw
+- push bx ! save secret message
+-#ifdef DOS_D
+-#if 0
+- seg es
+- cmp byte ptr BOOTSEG*16+0x26,#0x29
+- je dos4
+- mov bx,#baddos ! complain
+- call say
+- mov ax,#FIRSTSEG ! restart LILO
+- jmpi #GO,FIRSTSEG
+-#endif
+-dos4: seg es
+- mov byte ptr BOOTSEG*16+0x24,#0x81
+-#endif
+- mov cx,#0x20 ! move partition table
+- mov si,#PART_TABLE_OFFSET
+- mov di,#PART_TABLE
+- rep
+- movsw
+-#if defined(SWAP_HD) || defined(SWAP_FD)
+- call swap13
+-#endif
+- ! table entry
+- pop bx ! get secret message (active partition)
+-#ifdef LCF_REWRITE_TABLE
+- or bl,bl ! none set ?
+- jz tonopp ! yes -> do not patch
+-br tonopp
+- cmp bx,#0x81 ! valid code ?
+- jb towrfail ! no -> abort
+- cmp bx,#0x84
+- jna wrokay ! yes -> continue
+-towrfail:br wrfail
+-tonopp: br nopp
+-wrokay: push bx ! save BX
+- xor ax,ax ! ES becomes 0
+- mov es,ax
+- mov ax,#0x201 ! load partition table, one sector
+- mov dx,#0x80 ! first drive
+- mov cx,#1
+- mov bx,#PARTS_LOAD
+- int 0x13 ! load it
+- jc wrfail ! error -> abort
+- mov cx,#4 ! process all four entries
+- mov bx,#PART_TABLE
+-ptchpt: seg es ! clear all active flags
+- mov byte ptr (bx),#0
+-#if defined(LCF_FIX_TYPE) && defined(LCF_HIDE_DOS)
+- seg es
+- mov al,(bx+4) ! get partition type
+- cmp al,#PART_DOS12 ! hidden ?
+- je hideme ! no -> hide it
+- cmp al,#PART_DOS16
+- je hideme
+- cmp al,#PART_DOS32
+- jne nonrel ! already hidden -> continue
+-hideme: add al,#HIDDEN_OFF ! write back corrected value
+- seg es
+- mov (bx+4),al
+-#endif
+-nonrel: add bx,#16 ! next entry
+- loop ptchpt
+- pop bx ! compute active flag position
+- dec bx
+- shl bl,1
+- shl bx,1
+- shl bx,1
+- shl bx,1
+- cmp bx,offset ! right ?
+- jne wrfail ! no -> abort
+- seg es ! set active flag
+- mov byte ptr (bx+PART_TABLE),#0x80
+-#ifdef LCF_FIX_TYPE
+- seg es ! is this a
+- mov al,byte ptr (bx+PART_TABLE+4)
+- cmp al,#PART_HDOS12 ! hidden ?
+- je unhideme ! yes -> unhide it
+- cmp al,#PART_HDOS16
+- je unhideme
+- cmp al,#PART_HDOS32
+- jne nounhid ! not hidden -> continue
+-unhideme:sub al,#HIDDEN_OFF ! write back corrected value
+- seg es
+- mov (bx+PART_TABLE+4),al
+-#endif
+-nounhid:mov ax,#0x301 ! save it (restore all registers for
+- mov dx,#0x80 ! paranoia)
+- mov cx,#1
+- mov bx,#0x600
+- int 0x13 ! write ...
+- jc wrfail ! argl
+- mov bx,#passmsg ! confirm modification
+- call say
+- jmp nopp
+-wrfail: mov bx,#failmsg ! complain
+- call say
+- mov ax,#FIRSTSEG ! restart LILO
+- jmpi #GO,FIRSTSEG
+-#endif
+-nopp: mov si,offset ! DS:SI and ES:SI point to the partition
+- add si,#PART_TABLE
+- mov dx,drive ! initialize DX (drive and head)
+- xor ax,ax ! set DS and ES to zero
+-#ifdef XXX
+- mov ax,ds
+- mov es,ax
+- mov si,#lilosig
+- mov bx,#cmd
+- mov dl,#0xfe
+-#else
+- mov ds,ax
+- mov es,ax
+-#endif
+- mov bp,#0 ! might help some boot problems
+- mov ax,#0xaa55 ! boot signature (just in case ...)
+- jmpi #BOOTSEG*16,0 ! start boot sector
+-
+-#ifdef XXX
+-lilosig:.ascii "LILO"
+-cmd: .ascii "98"
+- .byte 0
+-#endif
+-
+-#if defined(DOS_D) || defined(LCF_REWRITE_TABLE)
+-
+-! Display a NUL-terminated string on the console
+-
+-say: mov al,(bx) ! get byte
+- or al,al ! NUL ?
+- jz aret ! yes -> done
+- push bx ! save pointer
+- mov ah,#14 ! display, tty-style
+- xor bh,bh
+- int 0x10
+- pop bx
+- inc bx ! next one
+- jmp say
+-aret: ret ! done
+-
+-#ifdef DOS_D
+-baddos: .ascii "Need DOS version 4 or newer."
+- .byte 13,10,0
+-#endif
+-
+-failmsg:.ascii "Rewrite error."
+- .byte 13,10,0
+-
+-passmsg:.ascii "Rewrote the partition table."
+- .byte 13,10,0
+-
+-#endif
+-
+-#if defined(SWAP_HD) || defined(SWAP_FD)
+-
+-swap13: seg es ! allocate 1 kB
+- dec word ptr [0x413]
+- int 0x12 ! get start segment
+- mov cl,#6
+- shl ax,cl
+- cli ! disable interrupts
+- xor bx,bx ! zero a few registers
+- mov di,bx
+- seg es ! change offset
+- xchg bx,[0x4c]
+- mov old13of,bx
+- mov bx,ax ! change segment
+- seg es
+- xchg bx,[0x4e]
+- mov old13sg,bx
+- mov es,ax ! move drive swapper
+- mov si,#new13
+- mov cx,#new13end-new13
+- rep
+- movsb
+- sti ! enable interrupts
+- ret ! done
+-
+-new13: seg cs ! save function code
+- mov fcode-new13,ah
+- test dl,#0x80 ! hard disk drive ?
+-#ifdef SWAP_FD
+- jnz noswap ! yes -> go on
+-#else
+- jz noswap ! no -> go on
+-#endif
+- xor dl,#1 ! swap drive 0 and 1
+-noswap: pushf
+- .byte 0x9a ! CALL FAR
+-old13of:.word 0
+-old13sg:.word 0
+- pushf ! fix driver number, if necessary
+- seg cs
+- cmp byte ptr fcode-new13,#8 ! do not fix
+- je done13
+- seg cs
+- cmp byte ptr fcode-new13,#0x15 ! do not fix
+- je done13
+- test dl,#0x80 ! hard disk drive ?
+-#ifdef SWAP_FD
+- jnz done13 ! yes -> go on
+-#else
+- jz done13 ! no -> go on
+-#endif
+- xor dl,#1 ! fix it
+-done13: seg cs
+- mov tmpbx-new13,bx ! restore flags
+- mov bx,sp
+- seg ss
+- pop 6(bx)
+- seg cs
+- mov bx,tmpbx-new13
+- iret ! done
+-new13end:
+-fcode: .byte 0 ! function code
+-tmpbx: .word 0
+-
+-#endif
+-
+-theend:
+diff -ruN lilo.orig/defs.h lilo/defs.h
+--- lilo.orig/defs.h Thu Jan 1 09:00:00 1970
++++ lilo/defs.h Thu Dec 7 16:17:10 2000
+@@ -0,0 +1,2 @@
++extern void *memcpy (void *__dest, const void *__src, unsigned int __n);
++extern int strlen (__const char *__s);
+diff -ruN lilo.orig/dump.S lilo/dump.S
+--- lilo.orig/dump.S Wed Jun 18 16:42:22 1997
++++ lilo/dump.S Thu Jan 1 09:00:00 1970
+@@ -1,131 +0,0 @@
+-/* dump.S - LILO register dumper */
+-
+-/* Copyright 1995-1997 Werner Almesberger. See file COPYING for details. */
+-
+-
+-#define LILO_ASM
+-#include "lilo.h"
+-
+-
+- .text
+-
+- .globl _main
+- .org 0
+-
+-_main: push sp ! push all registers
+- push ss
+- pushf
+- push es
+- push ds
+- push cs
+- push bp
+- push di
+- push si
+- push dx
+- push cx
+- push bx
+- push ax
+- mov ax,#BOOTSEG ! let DS point to where we really are
+- mov ds,ax
+- mov bx,#msgs ! set up loop
+-l: call say ! output message
+- cmp byte ptr (bx),#0 ! at end ?
+- je back ! yes -> back to LILO
+- pop ax ! get next data word
+- push bx
+- call wout ! output data word
+- pop bx
+- jmp l ! next round
+-
+-#if 0
+-back: mov ax,#FIRSTSEG
+- mov ds,ax
+- mov word ptr (CODE_START_1),#CODE_START_1+8
+- mov word ptr (CODE_START_1+2),#FIRSTSEG
+- mov word ptr (CODE_START_1+4),#CODE_START_1+12
+- mov byte ptr (CODE_START_1+6),#0xfe
+- mov es,ax ! adjust segments
+- mov ax,#BOOTSEG
+- mov ds,ax
+- mov word ptr (10),#0xffff ! no timeout
+- mov si,#haltnow ! copy string data
+- mov di,#CODE_START_1+8
+- mov cx,#6
+- rep
+- movsb
+- mov ax,#FIRSTSEG ! restart LILO
+- jmpi #GO,FIRSTSEG
+-#else
+-back: hlt ! stay here
+- jmp back
+-#endif
+-
+-! Display a NUL-terminated string on the console
+-
+-say: mov al,(bx) ! get byte
+- inc bx ! move pointer
+- or al,al ! NUL ?
+- jz aret ! yes -> done
+- push bx ! save pointer
+- mov ah,#14 ! display, tty-style
+- xor bh,bh
+- int 0x10
+- pop bx
+- jmp say ! next one
+-
+-wout: push ax ! display one word
+- mov al,ah
+- call bout
+- pop ax
+-bout: push ax ! display one byte
+- shr al,#4
+- call nout
+- pop ax
+-nout: and al,#15 ! display one nibble
+- add al,#48
+- cmp al,#58
+- jb nokay
+- add al,#7
+-nokay: xor bh,bh ! display on screen
+- mov ah,#14
+- int 0x10
+-aret: ret
+-
+-msgs: .byte 13,10
+- .ascii "Register dump:"
+- .byte 13,10,10
+- .ascii "AX="
+- .byte 0
+- .ascii " BX="
+- .byte 0
+- .ascii " CX="
+- .byte 0
+- .ascii " DX="
+- .byte 0,13,10
+- .ascii "SI="
+- .byte 0
+- .ascii " DI="
+- .byte 0
+- .ascii " BP="
+- .byte 0,13,10
+- .ascii "CS="
+- .byte 0
+- .ascii " DS="
+- .byte 0
+- .ascii " ES="
+- .byte 0,13,10
+- .ascii "F="
+- .byte 0,13,10
+- .ascii "SS:SP="
+- .byte 0
+- .ascii ":"
+- .byte 0,13,10,10
+-#if 0
+- .ascii "Restarting LILO ..."
+-#else
+- .ascii "System halted."
+-#endif
+- .byte 13,10,10,0,0
+-
+-haltnow:.ascii "LILO" ! prevent automatic reboot
+- .byte 0
+diff -ruN lilo.orig/first.S lilo/first.S
+--- lilo.orig/first.S Sat Dec 5 08:20:12 1998
++++ lilo/first.S Thu Dec 7 16:17:10 2000
+@@ -1,226 +1,257 @@
+-/* first.S - LILO first stage boot loader */
+-
+-/* Copyright 1992-1998 Werner Almesberger. See file COPYING for details. */
+-
+-
+-#define LILO_ASM
+-#include "lilo.h"
+-
+-#ifndef LCF_NO1STDIAG
+-#define CYL_CHECK
+-#endif
+-
+-
+- .text
+-
+- .globl _main
+-
+- .org 0
+-
+-_main: cli ! NT 4 blows up if this is missing
+- jmp start
+-
+- .org 6
+-
+-! Boot device parameters. They are set by the installer.
+-
++/* $Id: first.S,v 1.16 2000/11/26 07:11:58 gniibe Exp $
++ *
++ * Primary boot loader
++ *
++ * lilo/arch/sh/first.S
++ *
++ * Copyright (C) 2000 Niibe Yutaka
++ *
++ * This file is subject to the terms and conditions of the GNU General
++ * Public License.
++ *
++ */
++
++/*
++ * NOTE: Keep this code "position independent", so that this works well
++ * among machines with different memory map.
++ *
++ * Some machine starts its memmory at 0x08000000 (Area2),
++ * while others starts at 0x0c000000 (Area3).
++ */
++
++/*
++ * Memory map:
++ * [ First Loader ] 512
++ * [ Stack ] 4096-512
++ * [ Second Loader ] 4KB
++ * [ Reserved ] 4KB
++ * [ MAP load area ] 512
++ * [ Descriptor table 1/2 ] 512
++ * [ Descriptor table 2/2 ] 512
++ * [ Default Command Line ] 512
++ * [ Keyboard Translation ] 512
++ * [ Greeting Message ] 512
++ * [ Reserved ]
++ * [ Reserved ]
++ *
++ */
++ .global start
++start:
++ bra real_start
++ .byte 3 ! This becomes "mov r0, r12" with next "l"
++ !
++ .ascii "lba" ! special marker for LBA32
++ !
+ .ascii "LILO"
+- .word STAGE_FIRST
+- .word VERSION
++ .word 1
++#if 1
++ /* EDIT HERE ! */
++ ! Depends LILOs version
++ .word 20
++#else
++ /* v--- Major Version */
++ .word 4*256 + 21
++ ! /* ^--- Minor Version*/
++#endif
+
++/* x86 LILO parameters (Not used for SuperH... yet) */
+ timeout:.word 0 ! input timeout
+ delay: .word 0 ! boot delay
+ port: .byte 0 ! COM port (0 = unused, 1 = COM1, etc.)
+ sparam: .byte 0 ! serial port parameters (0 = unused)
+
+-tstamp: .long 0 ! timestamp
++/* Timestamp (Filled by LILO command) */
++tstamp: .long 0
+
+-d1_cx: .word 0 ! first descriptor sector address
++/* First descripter sector (Filled by LILO command) */
++d1_cx: .word 0
+ d1_dx: .word 0
+-d1_al: .byte 0 ! (unused)
++d1_al: .byte 0
+
+-d2_cx: .word 0 ! second descriptor sector address
++/* Second descripter sector (Filled by LILO command) */
++d2_cx: .word 0
+ d2_dx: .word 0
+-d2_al: .byte 0 ! (unused)
++d2_al: .byte 0
+
+-dc_cx: .word 0 ! default command-line sector address
++/* Default command-line sector (Filled by LILO command) */
++dc_cx: .word 0
+ dc_dx: .word 0
+-dc_al: .byte 0 ! (unused)
++dc_al: .byte 0
+
++/* Prompt? (Filled by LILO command) */
+ prompt: .byte 0 ! indicates whether to always enter prompt
+ ! (also used as alignment byte)
+
++/* Greeting message length & sector (Filled by LILO command) */
+ ms_len: .word 0 ! initial greeting message
+ ms_cx: .word 0
+ ms_dx: .word 0
+-ms_al: .byte 0 ! (unused)
++ms_al: .byte 0
+
++/* Second descripter sector (Filled by LILO command) */
+ kt_cx: .word 0 ! keyboard translation table
+ kt_dx: .word 0
+ kt_al: .byte 0
+
+ d_addr: ! second stage sector addresses
+
+- .org CODE_START_1
+-
+-ext_si: .word 0 ! external interface
+-ext_es: .word 0
+-ext_bx: .word 0
+-ext_dl: .byte 0
+-
+-start: mov ax,#BOOTSEG ! set DS
+- mov ds,ax
+- mov ext_es,es ! copy possible external parameters
+- mov ext_si,si
+- mov ext_bx,bx
+- mov ext_dl,dl
+- mov ax,#FIRSTSEG ! beam us up ...
+- mov es,ax
+- mov cx,#256
+- sub si,si
+- sub di,di
+- cld
+- rep
+- movsw
+- jmpi go,FIRSTSEG
+-
+-go: cli ! no interrupts
+- mov ds,ax ! AX is already set
+- mov es,ax ! (ES may be wrong when restarting)
+- mov sp,#STACK ! set the stack
+- mov ax,#STACKSEG
+- mov ss,ax
+- sti ! now it is safe
+-
+- mov al,#0x0d ! gimme a CR ...
+- call display
+- mov al,#0x0a ! ... an LF ...
+- call display
+- mov al,#0x4c ! ... an 'L' ...
+- call display
+-
+-lagain: mov si,#d_addr ! ready to load the second stage loader
+- mov bx,#SECOND
+- cld
+-sload: lodsw ! get CX
+- mov cx,ax
+- lodsw ! get DX
+- mov dx,ax
+- or ax,cx ! at EOF ?
+- jz done ! yes -> start it
+- inc si ! skip the length byte
+- call cread
+- jc error ! error -> start over again
+- add bx,#512 ! next sector
+- jmp sload
+-error:
+-#ifndef LCF_NO1STDIAG
+- push ax ! display a space
+- mov al,#32
+- call display
+- pop ax
+- mov al,ah ! display error code
+- call bout
+-#endif
+- xor ax,ax ! reset the FDC
+- mov dl,al
+- int 0x13
+- jmp lagain ! redo from start
+-done: mov al,#0x49 ! display an 'I'
+- call display
+- jmpi 0,SECONDSEG ! start the second stage loader
+-
+-#ifndef LCF_NO1STDIAG
+-bout: push ax ! display one byte
+- shr al,#4
+- call nout
+- pop ax
+-nout: and al,#15 ! display one nibble
+- add al,#48
+- cmp al,#58
+- jb nokay
+- add al,#7
+-nokay: ! fall through
+-#endif
+-
+-display:xor bh,bh ! display on screen
+- mov ah,#14
+- int 0x10
+- ret
+-
+-linerr: pop dx ! discard stack contents
+- pop cx
+- pop bx
+- ret ! (carry is already set)
+-
+-cread: test dl,#LINEAR_FLAG ! linear address ?
+- jz readsect ! no -> go on
+- and dl,#0xff-LINEAR_FLAG ! remove flag
+-
+-!
+-! Translate the linear address into a sector/track/cylinder address
+-!
+- push bx ! BX is used as scratch
+- push cx ! LSW
+- push dx ! MSW with drive
+- mov ah,#8 ! get drive geometry (do not clobber ES:DI)
+- int 0x13
+- jc linerr ! error -> quit
+- mov al,dh ! AL <- #heads-1
+- pop dx ! get MSW
+- mov t_drive,dl ! save drive
+- mov dl,dh ! linear address (high) into DX
+- xor dh,dh
+-#ifdef CYL_CHECK
+- push cx ! compute #cyls-1
+- xchg ch,cl
+- rol ch,1
+- rol ch,1
+- and ch,#3
+- mov n_cyl,cx ! save #cyls-1
+- pop cx
+-#endif
+- and cx,#0x3f ! CX <- #secs
+- mul cl ! AX <- #secs/cyl
+- add ax,cx
+- xchg ax,bx
+- pop ax ! linear address (low) into AX
+- div bx ! DX <- cylinder, AX <- remaining secs
+- xchg ax,dx
+- div cl ! AL <- track, AH <- sector
+- inc ah
+- mov t_sector,ah
+- xchg ax,dx ! AX <- cylinder, DL <- track
+- mov dh,dl ! set up DX (head:drive)
+- mov dl,t_drive
+-#ifdef CYL_CHECK
+- cmp ax,n_cyl ! valid cylinder number ?
+- ja linerr3 ! no -> error
+-#endif
+- xchg ah,al ! build cylinder number
+- ror al,1
+- ror al,1
+- or al,t_sector
+- mov cx,ax
+- pop bx ! restore BX
+-readsect:
+- mov ax,#0x201 ! read one sector
+- int 0x13
+- ret ! quit, possibly with errors
+-
+-#ifdef CYL_CHECK
+-linerr3:pop bx ! pop BX and linear address
+- xor ax,ax ! zero indicates internal error
+- stc ! error
+- ret
+-
+-n_cyl: .word 0 ! temporary space
+-#endif
+-t_drive:.byte 0
+-t_sector:.byte 0
+-
+-
+-/* Here are at least 66 bytes of free space. This is reserved for the
+- partition table and the boot signature. */
++ .long 0xffffffff
++ .long 0xffffffff
++ .long 0xffffffff
++ .long 0xffffffff
++ .long 0xffffffff
++ .long 0xffffffff
++ .long 0xffffffff
++ .long 0xffffffff
++ .long 0xffffffff
++ .long 0xffffffff
++ .long 0xffffffff
++
++ .word 0xffff
++
++ .align 2
++real_start:
++ /* Get base pointer, to be position independent */
++ mova next, r0
++ mov #0x02, r1
++ shll8 r1
++ sub r1, r0
++ mov r0, r12 ! Base pointer
++ !
++ mov #0x10, r1
++ shll8 r1
++ mov r12, r15
++ add r1, r15 ! Setup stack pointer
++ !
++ mov #0x10, r13 ! buffer number
++ !
++ /* Enable cache */
++ mov #6, r0 ! Cache "on"
++ mov #0, r4
++ trapa #0x3f
++ !
++ /* Output message "L" */
++ mova message, r0
++ mov r0, r4
++ mov #1, r5
++ mov #0, r0 ! Serial Output
++ trapa #0x3f
++ !
++ /* Load second stage loader */
++ mov #52, r11 ! #52: desc# of second stage loader
++loop: mov r11, r4
++ bsr load_sector_address ! get r4 (=dev) and r5 (=lba)
++ add r12, r4 ! desc# --> address of descriptor
++ bt done
++ !
++ mov r13, r6
++ shll8 r6
++ bsr read_a_sector
++ add r12, r6 ! buffer number -> buffer address
++ !
++ add #2, r13 ! buffer # += 2
++ bra loop
++ add #5, r11 ! next desc# is +5
++
++done:
++ /* Flush cache */
++ mov #6, r0 ! Cache "on"
++ mov #0, r4
++ trapa #0x3f
++
++ /* Jump to the second loader */
++ mov #0x10, r0
++ shll8 r0
++ add r12, r0 ! Get the address into r0
++ jmp @r0
++ mov r12, r4 ! First argument is base pointer
++
++ .align 2
++message:
++ .string "L"
++
++ .align 2
++/*
++ * LOAD_SECTOR_ADDRESS:
++ * Read the sector descripter (5-byte tuple), and translate
++ * it as device number and lba. Set T flag if its NULL.
++ *
++ * INPUT: r4 (pointer to descripter (5-byte long, not aligned)
++ * OUTPUT: r4 (DEVICE #), r5 (LBA) and T register (T when done)
++ * Clobbers: r0, r1, r2, r3
++ */
++load_sector_address:
++ mov.b @r4+, r0
++ extu.b r0, r0
++ mov.b @r4+, r1
++ extu.b r1, r1
++ mov.b @r4+, r2
++ extu.b r2, r2
++ mov.b @r4+, r3
++ extu.b r3, r3
++ !
++ shll8 r3
++ or r3, r1
++ shll8 r1
++ or r0, r1
++ mov r1, r5
++ mov.b @r4, r0
++ cmp/eq #0, r0
++ bt 1f ! NULL (end of descriptor)
++ !
++ /* Check if its really LBA... */
++ mov r2, r0
++ and #0x0F, r0 ! Get device number
++ mov #0xc0, r3
++ extu.b r3, r3
++ cmp/hi r2, r3
++ bf 1f ! Unset T
++ !
++ /* Its not LBA!! */
++ mova not_lba_message, r0
++ mov r0, r4
++ mov #36, r5
++ mov #0, r0 ! Serial Output
++ trapa #0x3f
++ sett ! End of descriptor
++ !
++1: rts
++ mov r0, r4 ! device number
++
++/*
++ * READ a sector
++ * INPUT: r4 (DEVICE #), r5 (LBA), r6 (BUFFER ADDRESS)
++ * OUTPUT: r0 (RESULT)
++ *
++ * Invoke BIOS call READ_SECTORS with number_of_sectors=1.
++ */
++read_a_sector:
++ mov #2, r0 ! READ SECTORS
++ mov #1, r7 ! number of sectors
++ trapa #0x3f
++ !
++ tst r0, r0
++ bt 1f
++ ! /* ERROR */
++ mova read_error_message, r0
++ mov r0, r4
++ mov #19, r5
++ mov #0, r0 ! Serial Output
++ trapa #0x3f
++ ! /* Go to the monitor */
++ mov #0, r0
++ jmp @r0
++ nop
++ !
++1: rts
++ nop
++
++ .align 2
++not_lba_message:
++ .string "ERROR: Sector address is not in LBA\n"
++ .align 2
++read_error_message:
++ .string "ERROR: Sector read\n"
+
+-theend:
++ .align 9
++next:
+--- lilo.orig/second.c Thu Jan 1 09:00:00 1970
++++ lilo/second.c Thu Dec 7 21:03:56 2000
+@@ -0,0 +1,411 @@
++/* $Id: second.c,v 1.22 2000/11/26 07:11:16 gniibe Exp $
++ *
++ * Secondary boot loader
++ *
++ * lilo/arch/sh/second.c
++ *
++ * Copyright (C) 2000 Niibe Yutaka
++ *
++ * This file is subject to the terms and conditions of the GNU General
++ * Public License.
++ *
++ */
++
++#include "defs.h"
++
++static void put_string (unsigned char *);
++static int get_sector_address (unsigned long, int *, unsigned long *);
++static int load_sectors (unsigned long, unsigned long);
++static int read_sectors (int, unsigned long, unsigned char *, int);
++static int load_sectors_with_maps (int, int, unsigned long *);
++
++static int machine_type (void);
++static int serial_type (void);
++static int memory_size (void);
++static int io_base (void);
++static void cache_flush (void);
++
++static const char hexchars[] = "0123456789abcdef";
++#define digits hexchars /* 10base is same for 16base (up to 10) */
++static inline char highhex (int x) { return hexchars[(x >> 4) & 0xf]; }
++static inline char lowhex (int x) { return hexchars[x & 0xf]; }
++static void printouthex (int);
++
++static unsigned long base_pointer = 0; /* Avoid BSS */
++static unsigned long kernel_image = 0; /* Avoid BSS */
++
++/* Sector descriptor */
++#define SD_DESCR1 24
++#define SD_DESCR2 29
++#define SD_DEFCMD 34
++/* 39 prompt (byte) */
++/* 40 length (word) */
++#define SD_MSG 42
++#define SD_KBDTBL 47
++
++static inline char *string_set (char *dest, const char *str)
++{
++ int len = strlen (str);
++ memcpy (dest, str, len);
++ return dest + len;
++}
++
++void
++start (unsigned long base)
++{
++ base_pointer = base;
++
++ put_string ("I");
++ load_sectors (SD_DESCR1, 0x3200);
++ load_sectors (SD_DESCR2, 0x3400);
++ put_string ("L");
++ /* XXX: checksum */
++
++ load_sectors (SD_DEFCMD, 0x3600);
++ load_sectors (SD_KBDTBL, 0x3800);
++ put_string ("O ");
++
++#if 0
++ load_sectors (SD_MSG, 0x3a00);
++#endif
++ /* XXX: delay, key check... */
++ /* XXX: list up images */
++ /* XXX: check signature */
++ /* Input command line */
++ /* XXX: Is there default command line? Use it! */
++ put_string ("boot: ");
++ put_string ("first-image\n"); /* XXX: should handle input commandline... */
++
++ /* Structure of descriptor
++ [ checksum 2byte ]
++ [ DESCR_SIZE:52-byte
++ (image-name (16-byte)
++ passwd (16-byte)
++ rd_size (4-byte)
++ initrd (5-byte sector desc)
++ start (5-byte sector desc)
++ start_page (16-bit)
++ flags (16-bit)
++ vga_mode (16-bit)
++ )
++ ] * 19
++ */
++
++ put_string ("Loading ");
++ put_string ((char *)(base_pointer+0x3200+2)); /* Image name */
++
++ kernel_image = base_pointer + 0x10000 - 0x400;
++ {
++ int desc = 0x3200+2+16+16+4+5; /* kernel image */
++
++ /* Skip two sectors: Fallback command line and options */
++ desc = load_sectors_with_maps (desc, 0, &kernel_image);
++ put_string (".");
++
++ while (desc != 0)
++ {
++ desc = load_sectors_with_maps (desc, 0, &kernel_image);
++ put_string (".");
++ }
++ }
++ put_string ("done.\n");
++
++#if 0
++ {
++ int i;
++
++ put_string ("DUMP: ");
++ for (i=0; i<16; i++)
++ printouthex (*(unsigned char *)(base_pointer+0x10000+i));
++ put_string ("\n");
++ }
++#endif
++
++ /* XXX: kernel paramerter setting */
++ {
++ unsigned long parm = base_pointer - 0x200000 + 0x1000;
++ char *cmdline = (char *)(parm+256);
++ int mem_size;
++ unsigned char *p;
++
++ *(long *)parm = 1; /* Read only mount? */
++ *(long *)(parm+4) = 0; /* RAMDISK Flags */
++ *(long *)(parm+8) = 0x0301; /* Root device: XXX should get from cls.. */
++ *(long *)(parm+12) = 1; /* Loader type (LILO = 1) */
++ *(long *)(parm+16) = 0; /* Initrd start */
++ *(long *)(parm+20) = 0; /* Initrd size */
++ *(long *)(parm+24) = 0; /* Not defined yet */
++
++ /* XXX: Should take the line from command line sector... */
++#define DC_MAGIC 0xf4f2 /* magic number of default cmd. line sector */
++ p = (unsigned char *)(base_pointer+0x3600);
++ if(p[0] == (DC_MAGIC & 0xff) && p[1] == (DC_MAGIC >> 8))
++ cmdline = string_set(cmdline, p+2);
++ cmdline = string_set(cmdline, (char *)(base_pointer + 0x10000 - 0x200));
++
++#if 0
++ /* Query to BIOS and build the command line string */
++ /* Build string "mem=XXM" */
++ mem_size = memory_size ();
++ mem_size >>= 20; /* In Mega-byte */
++ cmdline = string_set (cmdline, "mem=");
++ if (mem_size >= 100)
++ {
++ *cmdline++ = digits[mem_size/100];
++ mem_size = mem_size % 100;
++ }
++ if (mem_size >= 10)
++ {
++ *cmdline++ = digits[mem_size/10];
++ mem_size = mem_size % 10;
++ }
++ *cmdline++ = digits[mem_size];
++ *cmdline++ = 'M';
++ *cmdline++ = ' ';
++
++ switch (machine_type ())
++ {
++ case 0: /* Unknown board */
++ { /* Build string "sh_mv=unknown,0xXXXXXX,1" */
++ unsigned int io = io_base ();
++ int b31_24, b23_16, b15_08, b07_00;
++
++ b31_24 = (io>>24)&0xff;
++ b23_16 = (io>>16)&0xff;
++ b15_08 = (io>>8)&0xff;
++ b07_00 = (io>>0)&0xff;
++
++ cmdline = string_set (cmdline, "sh_mv=unknown,0x");
++ *cmdline++ = highhex (b31_24); *cmdline++ = lowhex (b31_24);
++ *cmdline++ = highhex (b23_16); *cmdline++ = lowhex (b23_16);
++ *cmdline++ = highhex (b15_08); *cmdline++ = lowhex (b15_08);
++ *cmdline++ = highhex (b07_00); *cmdline++ = lowhex (b07_00);
++ cmdline = string_set (cmdline, ",1 ");
++ break;
++ }
++
++ case 1:
++ cmdline = string_set (cmdline, "sh_mv=CqREEK ");
++ break;
++
++ case 3:
++ cmdline = string_set (cmdline, "sh_mv=SolutionEngine ");
++ break;
++ }
++
++ if (serial_type () == 0)
++ cmdline = string_set (cmdline, "console=ttySC0,115200");
++ else
++ cmdline = string_set (cmdline, "console=ttySC1,115200");
++#endif
++
++ *cmdline = '\0'; /* Terminate the string */
++ }
++
++ cache_flush ();
++ asm volatile ("jmp @r0; nop"
++ : /* no output */
++ : "z" (base_pointer + 0x10000));
++}
++
++static int
++load_sectors_with_maps (int desc, int offset, unsigned long *buf_p)
++{
++ int dev;
++ unsigned long lba;
++ int i, count;
++
++ /* Load the map at 0x3000 */
++ if (load_sectors (desc, 0x3000) < 0)
++ return 0;
++
++ for (i = offset*5; i<505; i+=5)
++ {
++ if ((count = get_sector_address (0x3000+i, &dev, &lba)) == 0)
++ return 0;
++
++ read_sectors (dev, lba, (unsigned char *)*buf_p, count);
++ *buf_p += count*512;
++ }
++
++ /* There's next map */
++ return 0x3000+505;
++}
++
++static int
++machine_type (void)
++{
++ register long __sc0 __asm__ ("r0") = 3; /* FEATURE QUERY */
++
++ asm volatile ("trapa #0x3F"
++ : "=z" (__sc0)
++ : "0" (__sc0)
++ : "memory");
++
++ return (__sc0 >> 8);
++}
++
++static int
++serial_type (void)
++{
++ register long __sc0 __asm__ ("r0") = 3; /* FEATURE QUERY */
++
++ asm volatile ("trapa #0x3F"
++ : "=z" (__sc0)
++ : "0" (__sc0)
++ : "memory");
++
++ return (__sc0 & 0x07);
++}
++
++static int
++memory_size (void)
++{
++ register long __sc0 __asm__ ("r0") = 4; /* MEMORY SIZE */
++
++ asm volatile ("trapa #0x3F"
++ : "=z" (__sc0)
++ : "0" (__sc0)
++ : "memory");
++
++ return (__sc0);
++}
++
++static int
++io_base (void)
++{
++ register long __sc0 __asm__ ("r0") = 5; /* IO BASE */
++
++ asm volatile ("trapa #0x3F"
++ : "=z" (__sc0)
++ : "0" (__sc0)
++ : "memory");
++
++ return (__sc0);
++}
++
++static void
++cache_flush (void)
++{
++ register long __sc0 __asm__ ("r0") = 6; /* CACHE_CONTROL */
++ register long __sc4 __asm__ ("r4") = 0; /* ENABLE */
++
++ asm volatile ("trapa #0x3F"
++ : "=z" (__sc0)
++ : "0" (__sc0), "r" (__sc4)
++ : "memory");
++}
++
++static void inline
++put_string_1 (unsigned char *str, long len)
++{
++ register long __sc0 __asm__ ("r0") = 0; /* OUTPUT */
++ register long __sc4 __asm__ ("r4") = (long) str;
++ register long __sc5 __asm__ ("r5") = (long) len; /* For New BIOS */
++
++ asm volatile ("trapa #0x3F"
++ : "=z" (__sc0)
++ : "0" (__sc0), "r" (__sc4), "r" (__sc5)
++ : "memory");
++}
++
++static void
++put_string (unsigned char *str)
++{
++ int len = strlen (str);
++ put_string_1 (str, len);
++}
++
++static int
++read_sectors (int dev, unsigned long lba, unsigned char *buf, int count)
++{
++ register long __sc0 __asm__ ("r0") = 2; /* READ SECTORS */
++ register long __sc4 __asm__ ("r4") = (long) dev;
++ register long __sc5 __asm__ ("r5") = (long) lba;
++ register long __sc6 __asm__ ("r6") = (long) buf;
++ register long __sc7 __asm__ ("r7") = (long) count;
++
++ asm volatile ("trapa #0x3F"
++ : "=z" (__sc0)
++ : "0" (__sc0), "r" (__sc4), "r" (__sc5),
++ "r" (__sc6), "r" (__sc7)
++ : "memory");
++
++ if (__sc0 < 0)
++ put_string ("ERROR: Sector read\n");
++
++ return __sc0;
++}
++
++static int
++get_sector_address (unsigned long sector_desc, int *devp, unsigned long *lbap)
++{
++ unsigned long s;
++ unsigned char *p = (unsigned char *)(sector_desc+base_pointer);
++ int len;
++
++ /* Number of sectors */
++ len = (int)p[4];
++ if (len == 0)
++ return 0;
++
++ /* p[2]: drive number */
++ if ((int)p[2] < 0xc0)
++ /* XXX: should return error */
++ put_string ("ERROR: Sector address is not in LBA\n");
++
++ *devp = (int)p[2] & 0x0f;
++
++ s = p[0] + (p[1]<<8) + (p[3]<<16);
++
++ *lbap = s;
++
++#if 0
++ {
++ unsigned long lba = *lbap;
++
++ put_string ("DEV= ");
++ printouthex ((*devp)&0xff);
++ put_string ("\n");
++ put_string ("LBA= ");
++ printouthex ((lba>>24)&0xff);
++ printouthex ((lba>>16)&0xff);
++ printouthex ((lba>>8)&0xff);
++ printouthex (lba&0xff);
++ put_string ("\n");
++ }
++#endif
++
++ return len;
++}
++
++static int
++load_sectors (unsigned long sector_desc, unsigned long mem)
++{
++ int dev;
++ unsigned long lba;
++ int count;
++ unsigned char *buf = (unsigned char *)(mem+base_pointer);
++
++ count = get_sector_address (sector_desc, &dev, &lba);
++
++ if (count)
++ return read_sectors (dev, lba, buf, count);
++
++ return -1;
++}
++
++#if 0
++static void
++printouthex(int x)
++{
++ char z[4];
++
++ z[0] = highhex (x);
++ z[1] = lowhex (x);
++ z[2] = ' ';
++ z[3] = '\0';
++
++ put_string (z);
++}
++#endif
+diff -ruN lilo.orig/second.lds lilo/second.lds
+--- lilo.orig/second.lds Thu Jan 1 09:00:00 1970
++++ lilo/second.lds Fri Dec 8 11:13:20 2000
+@@ -0,0 +1,212 @@
++OUTPUT_FORMAT("elf32-sh-linux", "elf32-sh-linux", "elf32-sh-linux")
++OUTPUT_ARCH(sh)
++ENTRY(start)
++SECTIONS
++{
++ /* Read-only sections, merged into text segment: */
++ . = 0x400000 + SIZEOF_HEADERS;
++ .interp : { *(.interp) }
++ .hash : { *(.hash) }
++ .dynsym : { *(.dynsym) }
++ .dynstr : { *(.dynstr) }
++ .gnu.version : { *(.gnu.version) }
++ .gnu.version_d : { *(.gnu.version_d) }
++ .gnu.version_r : { *(.gnu.version_r) }
++ .rel.init : { *(.rel.init) }
++ .rela.init : { *(.rela.init) }
++ .rel.text :
++ {
++ *(.rel.text)
++ *(.rel.text.*)
++ *(.rel.gnu.linkonce.t*)
++ }
++ .rela.text :
++ {
++ *(.rela.text)
++ *(.rela.text.*)
++ *(.rela.gnu.linkonce.t*)
++ }
++ .rel.fini : { *(.rel.fini) }
++ .rela.fini : { *(.rela.fini) }
++ .rel.rodata :
++ {
++ *(.rel.rodata)
++ *(.rel.rodata.*)
++ *(.rel.gnu.linkonce.r*)
++ }
++ .rela.rodata :
++ {
++ *(.rela.rodata)
++ *(.rela.rodata.*)
++ *(.rela.gnu.linkonce.r*)
++ }
++ .rel.data :
++ {
++ *(.rel.data)
++ *(.rel.data.*)
++ *(.rel.gnu.linkonce.d*)
++ }
++ .rela.data :
++ {
++ *(.rela.data)
++ *(.rela.data.*)
++ *(.rela.gnu.linkonce.d*)
++ }
++ .rel.ctors : { *(.rel.ctors) }
++ .rela.ctors : { *(.rela.ctors) }
++ .rel.dtors : { *(.rel.dtors) }
++ .rela.dtors : { *(.rela.dtors) }
++ .rel.got : { *(.rel.got) }
++ .rela.got : { *(.rela.got) }
++ .rel.sdata :
++ {
++ *(.rel.sdata)
++ *(.rel.sdata.*)
++ *(.rel.gnu.linkonce.s*)
++ }
++ .rela.sdata :
++ {
++ *(.rela.sdata)
++ *(.rela.sdata.*)
++ *(.rela.gnu.linkonce.s*)
++ }
++ .rel.sbss : { *(.rel.sbss) }
++ .rela.sbss : { *(.rela.sbss) }
++ .rel.bss : { *(.rel.bss) }
++ .rela.bss : { *(.rela.bss) }
++ .rel.plt : { *(.rel.plt) }
++ .rela.plt : { *(.rela.plt) }
++ .init :
++ {
++ KEEP (*(.init))
++ } =0
++ .plt : { *(.plt) }
++ .text :
++ {
++ *(.text)
++ *(.text.*)
++ *(.stub)
++ /* .gnu.warning sections are handled specially by elf32.em. */
++ *(.gnu.warning)
++ *(.gnu.linkonce.t*)
++ } =0
++ _etext = .;
++ PROVIDE (etext = .);
++ .fini :
++ {
++ KEEP (*(.fini))
++ } =0
++ .rodata : { *(.rodata) *(.rodata.*) *(.gnu.linkonce.r*) }
++ .rodata1 : { *(.rodata1) }
++ /* Adjust the address for the data segment. We want to adjust up to
++ the same address within the page on the next page up. */
++/* . = ALIGN(0x10000) + (. & (0x10000 - 1)); */
++ .data :
++ {
++ __data_start = . ;
++ *(.data)
++ *(.data.*)
++ *(.gnu.linkonce.d*)
++ SORT(CONSTRUCTORS)
++ }
++ .data1 : { *(.data1) }
++ .eh_frame : { *(.eh_frame) }
++ .gcc_except_table : { *(.gcc_except_table) }
++ .note.ABI-tag : { *(.note.ABI-tag) }
++ .ctors :
++ {
++ /* gcc uses crtbegin.o to find the start of
++ the constructors, so we make sure it is
++ first. Because this is a wildcard, it
++ doesn't matter if the user does not
++ actually link against crtbegin.o; the
++ linker won't look for a file to match a
++ wildcard. The wildcard also means that it
++ doesn't matter which directory crtbegin.o
++ is in. */
++ KEEP (*crtbegin.o(.ctors))
++ /* We don't want to include the .ctor section from
++ from the crtend.o file until after the sorted ctors.
++ The .ctor section from the crtend file contains the
++ end of ctors marker and it must be last */
++ KEEP (*(EXCLUDE_FILE (*crtend.o ) .ctors))
++ KEEP (*(SORT(.ctors.*)))
++ KEEP (*(.ctors))
++ }
++ .dtors :
++ {
++ KEEP (*crtbegin.o(.dtors))
++ KEEP (*(EXCLUDE_FILE (*crtend.o ) .dtors))
++ KEEP (*(SORT(.dtors.*)))
++ KEEP (*(.dtors))
++ }
++ .got : { *(.got.plt) *(.got) }
++ .dynamic : { *(.dynamic) }
++ /* We want the small data sections together, so single-instruction offsets
++ can access them all, and initialized data all before uninitialized, so
++ we can shorten the on-disk segment size. */
++ .sdata :
++ {
++ *(.sdata)
++ *(.sdata.*)
++ *(.gnu.linkonce.s.*)
++ }
++ _edata = .;
++ PROVIDE (edata = .);
++ __bss_start = .;
++ .sbss :
++ {
++ *(.dynsbss)
++ *(.sbss)
++ *(.sbss.*)
++ *(.scommon)
++ }
++ .bss :
++ {
++ *(.dynbss)
++ *(.bss)
++ *(.bss.*)
++ *(COMMON)
++ /* Align here to ensure that the .bss section occupies space up to
++ _end. Align after .bss to ensure correct alignment even if the
++ .bss section disappears because there are no input sections. */
++ . = ALIGN(32 / 8);
++ }
++ . = ALIGN(32 / 8);
++ _end = .;
++ PROVIDE (end = .);
++ /* Stabs debugging sections. */
++ .stab 0 : { *(.stab) }
++ .stabstr 0 : { *(.stabstr) }
++ .stab.excl 0 : { *(.stab.excl) }
++ .stab.exclstr 0 : { *(.stab.exclstr) }
++ .stab.index 0 : { *(.stab.index) }
++ .stab.indexstr 0 : { *(.stab.indexstr) }
++ .comment 0 : { *(.comment) }
++ /* DWARF debug sections.
++ Symbols in the DWARF debugging sections are relative to the beginning
++ of the section so we begin them at 0. */
++ /* DWARF 1 */
++ .debug 0 : { *(.debug) }
++ .line 0 : { *(.line) }
++ /* GNU DWARF 1 extensions */
++ .debug_srcinfo 0 : { *(.debug_srcinfo) }
++ .debug_sfnames 0 : { *(.debug_sfnames) }
++ /* DWARF 1.1 and DWARF 2 */
++ .debug_aranges 0 : { *(.debug_aranges) }
++ .debug_pubnames 0 : { *(.debug_pubnames) }
++ /* DWARF 2 */
++ .debug_info 0 : { *(.debug_info) }
++ .debug_abbrev 0 : { *(.debug_abbrev) }
++ .debug_line 0 : { *(.debug_line) }
++ .debug_frame 0 : { *(.debug_frame) }
++ .debug_str 0 : { *(.debug_str) }
++ .debug_loc 0 : { *(.debug_loc) }
++ .debug_macinfo 0 : { *(.debug_macinfo) }
++ /* SGI/MIPS DWARF 2 extensions */
++ .debug_weaknames 0 : { *(.debug_weaknames) }
++ .debug_funcnames 0 : { *(.debug_funcnames) }
++ .debug_typenames 0 : { *(.debug_typenames) }
++ .debug_varnames 0 : { *(.debug_varnames) }
++ /* These must appear regardless of . */
++}
+diff -ruN lilo.orig/string.c lilo/string.c
+--- lilo.orig/string.c Thu Jan 1 09:00:00 1970
++++ lilo/string.c Thu Dec 7 16:17:10 2000
+@@ -0,0 +1,22 @@
++#include <stddef.h>
++
++/* Implementation taken from Linux kernel (linux/lib/string.c) */
++
++size_t strlen(const char * s)
++{
++ const char *sc;
++
++ for (sc = s; *sc != '\0'; ++sc)
++ /* nothing */;
++ return sc - s;
++}
++
++void * memcpy(void * dest,const void *src,size_t count)
++{
++ char *tmp = (char *) dest, *s = (char *) src;
++
++ while (count--)
++ *tmp++ = *s++;
++
++ return dest;
++}
diff --git a/packages/lilo-sh/files/lilo.patch b/packages/lilo-sh/files/lilo.patch
new file mode 100644
index 0000000000..227eaf69f1
--- /dev/null
+++ b/packages/lilo-sh/files/lilo.patch
@@ -0,0 +1,42 @@
+diff -u --new-file --recursive lilo.old/geometry.c lilo/geometry.c
+--- lilo.old/geometry.c Wed Oct 14 15:24:41 1998
++++ lilo/geometry.c Sat Feb 20 15:27:23 1999
+@@ -342,6 +342,27 @@
+ geo->sectors = hdprm.sectors;
+ geo->start = hdprm.start;
+ break;
++ case COMPAQ_SMART2_MAJOR+0:
++ case COMPAQ_SMART2_MAJOR+1:
++ case COMPAQ_SMART2_MAJOR+2:
++ case COMPAQ_SMART2_MAJOR+3:
++ case COMPAQ_SMART2_MAJOR+4:
++ case COMPAQ_SMART2_MAJOR+5:
++ case COMPAQ_SMART2_MAJOR+6:
++ case COMPAQ_SMART2_MAJOR+7:
++ geo->device = 0x80+last_dev(MAJOR_HD,64)+(MINOR(device) >> 4);
++ if (ioctl(fd,HDIO_GETGEO,&hdprm) < 0)
++ die("geo_query_dev HDIO_GETGEO (dev 0x%04x): %s",device,
++ strerror(errno));
++ if (all && !hdprm.sectors)
++ die("HDIO_REQ not supported for your Array controller. Please "
++ "use a DISK section");
++ geo->heads = hdprm.heads;
++ geo->cylinders = hdprm.cylinders;
++ geo->sectors = hdprm.sectors;
++ geo->start = hdprm.start;
++ break;
++
+ default:
+ die("Sorry, don't know how to handle device 0x%04x",device);
+ }
+diff -u --new-file --recursive lilo.old/lilo.h lilo/lilo.h
+--- lilo.old/lilo.h Fri Dec 4 12:55:31 1998
++++ lilo/lilo.h Sat Feb 20 15:29:10 1999
+@@ -39,6 +39,7 @@
+ #define MAJOR_DAC960 48 /* First Mylex DAC960 PCI RAID controller */
+ #define MAJOR_IDE5 55 /* IDE on fifth interface */
+ #define MAJOR_IDE6 57 /* IDE on sixth interface */
++#define COMPAQ_SMART2_MAJOR 72 /* First Smart/2 Major */
+
+ #define MAX_IMAGES ((SECTOR_SIZE*2-2)/sizeof(IMAGE_DESCR))
+ /* maximum number of images */
diff --git a/packages/lilo-sh/files/lilo.raid1 b/packages/lilo-sh/files/lilo.raid1
new file mode 100644
index 0000000000..5f29bc9fc1
--- /dev/null
+++ b/packages/lilo-sh/files/lilo.raid1
@@ -0,0 +1,552 @@
+--- lilo.new/lilo.c.noraid Tue Sep 21 23:58:01 1999
++++ lilo.new/lilo.c Wed Sep 22 04:18:22 1999
+@@ -24,11 +24,11 @@
+ #include "cfg.h"
+ #include "identify.h"
+ #include "partition.h"
+-
++#include "md-int.h"
+
+ #define S2(x) #x
+ #define S(x) S2(x)
+-
++#define MAX_TOKEN 200
+
+ static void show_other(int fd)
+ {
+@@ -227,15 +227,21 @@
+ {
+ char *name,*config_file,*reboot_arg,*identify,*ident_opt,*new_root;
+ char *uninst_dev;
+- int query,more,version,uninstall,validate;
++ int query,more,version,uninstall,validate,do_md_install,pass;
+ BOOT_SECTOR dummy;
+ IMAGE_DESCR dummy2;
+ struct stat st;
+- int fd;
++ int fd, md_fd;
++ md_array_info_t md_array_info;
++ md_disk_info_t md_disk_info;
++ char md_boot_name[MAX_TOKEN+1];
++ char md_boot_map[MAX_TOKEN+1];
++ DT_ENTRY md_disk;
++ DT_ENTRY *disk;
+
+ config_file = DFL_CONFIG;
+ reboot_arg = identify = ident_opt = new_root = uninst_dev = NULL;
+- query = version = uninstall = validate = 0;
++ pass = do_md_install = query = version = uninstall = validate = 0;
+ name = *argv++;
+ argc--;
+ cfg_init(cf_options);
+@@ -414,43 +420,117 @@
+ }
+ preload_dev_cache();
+ if (identify) identify_image(identify,ident_opt);
+- if (uninstall)
+- bsect_uninstall(uninst_dev ? uninst_dev : cfg_get_strg(cf_options,
+- "boot"),cfg_get_strg(cf_options,"backup"),validate);
+- compact = cfg_get_flag(cf_options,"compact");
+- linear = cfg_get_flag(cf_options,"linear");
+- nowarn = cfg_get_flag(cf_options,"nowarn");
+- if (cfg_get_strg(cf_options,"verbose"))
+- verbose += to_number(cfg_get_strg(cf_options,"verbose"));
+- if (reboot_arg) {
+- map_patch_first(cfg_get_strg(cf_options,"map") ? cfg_get_strg(
+- cf_options,"map") : MAP_FILE,reboot_arg);
+- exit(0);
+- }
+- if (argc) usage(name);
+- geo_init(cfg_get_strg(cf_options,"disktab"));
+- if (query)
+- show_images(!cfg_get_strg(cf_options,"map") ? MAP_FILE :
+- cfg_get_strg(cf_options,"map"));
+- bsect_open(cfg_get_strg(cf_options,"boot"),cfg_get_strg(cf_options,"map") ?
+- cfg_get_strg(cf_options,"map") : MAP_FILE,cfg_get_strg(cf_options,
+- "install"),cfg_get_strg(cf_options,"delay") ? to_number(cfg_get_strg(
+- cf_options,"delay")) : 0,cfg_get_strg(cf_options,"timeout") ?
+- to_number(cfg_get_strg(cf_options,"timeout")) : -1);
+- if (more) {
+- cfg_init(cf_top);
+- if (cfg_parse(cf_top)) cfg_error("Syntax error");
+- }
+- if (!bsect_number()) die("No images have been defined.");
+- check_fallback();
+- if (!test)
+- if (cfg_get_strg(cf_options,"force-backup"))
+- bsect_update(cfg_get_strg(cf_options,"force-backup"),1);
+- else bsect_update(cfg_get_strg(cf_options,"backup"),0);
+- else {
+- bsect_cancel();
+- fprintf(stderr,"The boot sector and the map file have *NOT* been "
+- "altered.\n");
++ if (strncmp("/dev/md",cfg_get_strg(cf_options,"boot"),7) == 0) {
++ if ((md_fd=open(cfg_get_strg(cf_options,"boot"),O_NOACCESS)) < 0)
++ die("Unable to open %s",cfg_get_strg(cf_options,"boot"));
++ if (fstat(md_fd,&st) < 0)
++ die("Unable to stat %s",cfg_get_strg(cf_options,"boot"));
++ if (!S_ISBLK(st.st_mode))
++ die("%s is not a block device",cfg_get_strg(cf_options,"boot"));
++ if (ioctl(md_fd,GET_ARRAY_INFO,&md_array_info) < 0)
++ die("Unable to get RAID info on %s",cfg_get_strg(cf_options,"boot"));
++ if ((md_array_info.major_version == 0) && (md_array_info.minor_version < 90))
++ die("Raid versions < 0.90 are not supported");
++ if (md_array_info.level != 1)
++ die("Only RAID1 devices are supported as boot devices");
++ do_md_install = 1;
++ strcpy(md_boot_name,cfg_get_strg(cf_options,"boot"));
++ if (cfg_get_strg(cf_options,"map"))
++ strcpy(md_boot_map,cfg_get_strg(cf_options,"map"));
++ else
++ strcpy(md_boot_map,MAP_FILE);
++ md_disk.device = (MD_MAJOR << 8) | md_array_info.md_minor;
++ md_disk.bios = 0x80;
++ md_disk.next = disktab;
++ disktab = &md_disk;
++ }
++ while( (pass == 0) || (do_md_install && (pass < md_array_info.nr_disks)) ) {
++ if(do_md_install) {
++ GEOMETRY geo;
++ DEVICE dev;
++ int device,disk_fd;
++ char new_name[MAX_TOKEN+1];
++
++ if(pass > 0) {
++ close(fd);
++ cfg_init(cf_options);
++ fd = cfg_open(config_file);
++ more = cfg_parse(cf_options);
++ }
++ md_disk_info.number = pass;
++ if (ioctl(md_fd,GET_DISK_INFO,&md_disk_info) < 0)
++ die("main: GET_DISK_INFO: %s", strerror(errno));
++ device = (md_disk_info.major << 8) | md_disk_info.minor;
++ disk_fd = dev_open(&dev,device,O_NOACCESS);
++ if (md_disk_info.state == MD_DISK_FAULTY) {
++ printf("disk %s marked as faulty, skipping\n",dev.name);
++ pass++;
++ continue;
++ }
++ geo_query_dev(&geo,device,1);
++ disk = alloc_t(DT_ENTRY);
++ disk->bios = 0x80;
++ disk->device = device & 0xfff0;
++ disk->sectors = geo.sectors;
++ disk->heads = geo.heads;
++ disk->cylinders = geo.cylinders;
++ disk->start = geo.start;
++ disk->next = disktab;
++ disktab = disk;
++ if (cfg_get_strg(cf_options,"boot")) cfg_unset(cf_options,"boot");
++ if (cfg_get_strg(cf_options,"map")) cfg_unset(cf_options,"map");
++ strncpy(new_name,dev.name,8);
++ new_name[8] = '\0';
++ cfg_set(cf_options,"boot",new_name,NULL);
++ snprintf(new_name,MAX_TOKEN,"%s.%04x",md_boot_map,device);
++ cfg_set(cf_options,"map",new_name,NULL);
++ printf("boot = %s, map = %s\n", cfg_get_strg(cf_options,"boot"),
++ cfg_get_strg(cf_options,"map"));
++ md_disk.sectors = geo.sectors;
++ md_disk.heads = geo.heads;
++ md_disk.cylinders = geo.cylinders;
++ md_disk.start = geo.start;
++ }
++
++ pass++;
++ if (uninstall)
++ bsect_uninstall(uninst_dev ? uninst_dev : cfg_get_strg(cf_options,
++ "boot"),cfg_get_strg(cf_options,"backup"),validate);
++ compact = cfg_get_flag(cf_options,"compact");
++ linear = cfg_get_flag(cf_options,"linear");
++ nowarn = cfg_get_flag(cf_options,"nowarn");
++ if (cfg_get_strg(cf_options,"verbose"))
++ verbose += to_number(cfg_get_strg(cf_options,"verbose"));
++ if (reboot_arg) {
++ map_patch_first(cfg_get_strg(cf_options,"map") ? cfg_get_strg(
++ cf_options,"map") : MAP_FILE,reboot_arg);
++ exit(0);
++ }
++ if (argc) usage(name);
++ geo_init(cfg_get_strg(cf_options,"disktab"));
++ if (query)
++ show_images(!cfg_get_strg(cf_options,"map") ? MAP_FILE :
++ cfg_get_strg(cf_options,"map"));
++ bsect_open(cfg_get_strg(cf_options,"boot"),cfg_get_strg(cf_options,"map") ?
++ cfg_get_strg(cf_options,"map") : MAP_FILE,cfg_get_strg(cf_options,
++ "install"),cfg_get_strg(cf_options,"delay") ? to_number(cfg_get_strg(
++ cf_options,"delay")) : 0,cfg_get_strg(cf_options,"timeout") ?
++ to_number(cfg_get_strg(cf_options,"timeout")) : -1);
++ if (more) {
++ cfg_init(cf_top);
++ if (cfg_parse(cf_top)) cfg_error("Syntax error");
++ }
++ if (!bsect_number()) die("No images have been defined.");
++ check_fallback();
++ if (!test)
++ if (cfg_get_strg(cf_options,"force-backup"))
++ bsect_update(cfg_get_strg(cf_options,"force-backup"),1);
++ else bsect_update(cfg_get_strg(cf_options,"backup"),0);
++ else {
++ bsect_cancel();
++ fprintf(stderr,"The boot sector and the map file have *NOT* been "
++ "altered.\n");
++ }
+ }
+ return 0;
+ }
+--- lilo.new/geometry.c.noraid Wed Sep 22 00:55:32 1999
++++ lilo.new/geometry.c Wed Sep 22 03:13:29 1999
+@@ -35,18 +35,9 @@
+ struct stat st;
+ } ST_BUF;
+
+-typedef struct _dt_entry {
+- int device,bios;
+- int sectors;
+- int heads; /* 0 if inaccessible */
+- int cylinders;
+- int start;
+- struct _dt_entry *next;
+-} DT_ENTRY;
+
+-
+-static DT_ENTRY *disktab = NULL;
+-static int old_disktab = 0;
++DT_ENTRY *disktab = NULL;
++int old_disktab = 0;
+
+
+ void geo_init(char *name)
+@@ -260,7 +251,7 @@
+ }
+
+
+-static void geo_query_dev(GEOMETRY *geo,int device,int all)
++void geo_query_dev(GEOMETRY *geo,int device,int all)
+ {
+ DEVICE dev;
+ int fd,get_all;
+--- lilo.new/geometry.h.noraid Wed Sep 22 00:56:06 1999
++++ lilo.new/geometry.h Wed Sep 22 03:12:23 1999
+@@ -18,6 +18,17 @@
+ int boot; /* non-zero after geo_open_boot */
+ } GEOMETRY;
+
++typedef struct _dt_entry {
++ int device,bios;
++ int sectors;
++ int heads; /* 0 if inaccessible */
++ int cylinders;
++ int start;
++ struct _dt_entry *next;
++} DT_ENTRY;
++
++extern DT_ENTRY *disktab;
++
+ void geo_init(char *name);
+
+ /* Loads the disk geometry table. */
+@@ -59,5 +70,10 @@
+
+ /* lseeks in the file associated with GEO for the sector at address ADDR.
+ Returns a non-zero integer on success, zero on failure. */
++
++void geo_query_dev(GEOMETRY *geo,int device,int all);
++
++/* opens the specified device and gets the geometry information. That
++ information is then stored in *geo */
+
+ #endif
+--- lilo.new/md-int.h.noraid Wed Sep 22 13:06:36 1999
++++ lilo.new/md-int.h Tue Sep 21 22:57:41 1999
+@@ -0,0 +1,290 @@
++/*
++ md.h : Multiple Devices driver for Linux
++ Copyright (C) 1994-96 Marc ZYNGIER
++ <zyngier@ufr-info-p7.ibp.fr> or
++ <maz@gloups.fdn.fr>
++
++ This program is free software; you can redistribute it and/or modify
++ it under the terms of the GNU General Public License as published by
++ the Free Software Foundation; either version 2, or (at your option)
++ any later version.
++
++ You should have received a copy of the GNU General Public License
++ (for example /usr/src/linux/COPYING); if not, write to the Free
++ Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++*/
++
++#ifndef MD_INT_H
++#define MD_INT_H
++
++/* don't include the kernel RAID header! */
++#define _MD_H
++
++typedef unsigned int md_u32;
++typedef unsigned short md_u16;
++typedef unsigned char md_u8;
++
++#include <linux/major.h>
++#include <sys/ioctl.h>
++
++/*
++ * Different major versions are not compatible.
++ * Different minor versions are only downward compatible.
++ * Different patchlevel versions are downward and upward compatible.
++ */
++
++struct md_version {
++ int major;
++ int minor;
++ int patchlevel;
++};
++
++/*
++ * default readahead
++ */
++#define MD_READAHEAD (256 * 1024)
++
++/* These are the ioctls for md versions < 0.50 */
++#define REGISTER_MD_DEV _IO (MD_MAJOR, 1)
++#define START_MD _IO (MD_MAJOR, 2)
++#define STOP_MD _IO (MD_MAJOR, 3)
++
++/* status */
++#define RAID_VERSION _IOR (MD_MAJOR, 0x10, struct md_version)
++#define GET_ARRAY_INFO _IOR (MD_MAJOR, 0x11, md_array_info_t)
++#define GET_DISK_INFO _IOR (MD_MAJOR, 0x12, md_disk_info_t)
++#define PRINT_RAID_DEBUG _IO (MD_MAJOR, 0x13)
++
++/* configuration */
++#define CLEAR_ARRAY _IO (MD_MAJOR, 0x20)
++#define ADD_NEW_DISK _IOW (MD_MAJOR, 0x21, md_disk_info_t)
++#define HOT_REMOVE_DISK _IO (MD_MAJOR, 0x22)
++#define SET_ARRAY_INFO _IOW (MD_MAJOR, 0x23, md_array_info_t)
++#define SET_DISK_INFO _IO (MD_MAJOR, 0x24)
++#define WRITE_RAID_INFO _IO (MD_MAJOR, 0x25)
++#define UNPROTECT_ARRAY _IO (MD_MAJOR, 0x26)
++#define PROTECT_ARRAY _IO (MD_MAJOR, 0x27)
++#define HOT_ADD_DISK _IO (MD_MAJOR, 0x28)
++
++/* usage */
++#define RUN_ARRAY _IOW (MD_MAJOR, 0x30, struct md_param)
++#define START_ARRAY _IO (MD_MAJOR, 0x31)
++#define STOP_ARRAY _IO (MD_MAJOR, 0x32)
++#define STOP_ARRAY_RO _IO (MD_MAJOR, 0x33)
++#define RESTART_ARRAY_RW _IO (MD_MAJOR, 0x34)
++
++
++/* for raid < 0.50 only */
++#define MD_PERSONALITY_SHIFT 16
++
++#define MD_RESERVED 0UL
++#define LINEAR 1UL
++#define STRIPED 2UL
++#define RAID0 STRIPED
++#define RAID1 3UL
++#define RAID5 4UL
++#define TRANSLUCENT 5UL
++#define LVM 6UL
++#define MAX_PERSONALITY 7UL
++
++/*
++ * MD superblock.
++ *
++ * The MD superblock maintains some statistics on each MD configuration.
++ * Each real device in the MD set contains it near the end of the device.
++ * Some of the ideas are copied from the ext2fs implementation.
++ *
++ * We currently use 4096 bytes as follows:
++ *
++ * word offset function
++ *
++ * 0 - 31 Constant generic MD device information.
++ * 32 - 63 Generic state information.
++ * 64 - 127 Personality specific information.
++ * 128 - 511 12 32-words descriptors of the disks in the raid set.
++ * 512 - 911 Reserved.
++ * 912 - 1023 Disk specific descriptor.
++ */
++
++/*
++ * If x is the real device size in bytes, we return an apparent size of:
++ *
++ * y = (x & ~(MD_RESERVED_BYTES - 1)) - MD_RESERVED_BYTES
++ *
++ * and place the 4kB superblock at offset y.
++ */
++#define MD_RESERVED_BYTES (64 * 1024)
++#define MD_RESERVED_SECTORS (MD_RESERVED_BYTES / 512)
++#define MD_RESERVED_BLOCKS (MD_RESERVED_BYTES / BLOCK_SIZE)
++
++#define MD_NEW_SIZE_SECTORS(x) ((x & ~(MD_RESERVED_SECTORS - 1)) - MD_RESERVED_SECTORS)
++#define MD_NEW_SIZE_BLOCKS(x) ((x & ~(MD_RESERVED_BLOCKS - 1)) - MD_RESERVED_BLOCKS)
++
++#define MD_SB_BYTES 4096
++#define MD_SB_WORDS (MD_SB_BYTES / 4)
++#define MD_SB_BLOCKS (MD_SB_BYTES / BLOCK_SIZE)
++#define MD_SB_SECTORS (MD_SB_BYTES / 512)
++
++/*
++ * The following are counted in 32-bit words
++ */
++#define MD_SB_GENERIC_OFFSET 0
++#define MD_SB_PERSONALITY_OFFSET 64
++#define MD_SB_DISKS_OFFSET 128
++#define MD_SB_DESCRIPTOR_OFFSET 992
++
++#define MD_SB_GENERIC_CONSTANT_WORDS 32
++#define MD_SB_GENERIC_STATE_WORDS 32
++#define MD_SB_GENERIC_WORDS (MD_SB_GENERIC_CONSTANT_WORDS + MD_SB_GENERIC_STATE_WORDS)
++#define MD_SB_PERSONALITY_WORDS 64
++#define MD_SB_DISKS_WORDS 384
++#define MD_SB_DESCRIPTOR_WORDS 32
++#define MD_SB_RESERVED_WORDS (1024 - MD_SB_GENERIC_WORDS - MD_SB_PERSONALITY_WORDS - MD_SB_DISKS_WORDS - MD_SB_DESCRIPTOR_WORDS)
++#define MD_SB_EQUAL_WORDS (MD_SB_GENERIC_WORDS + MD_SB_PERSONALITY_WORDS + MD_SB_DISKS_WORDS)
++#define MD_SB_DISKS (MD_SB_DISKS_WORDS / MD_SB_DESCRIPTOR_WORDS)
++
++/*
++ * Device "operational" state bits
++ */
++#define MD_DISK_FAULTY 0 /* disk is faulty / operational */
++#define MD_DISK_ACTIVE 1 /* disk is running or spare disk */
++#define MD_DISK_SYNC 2 /* disk is in sync with the raid set */
++
++typedef struct md_device_descriptor_s {
++ md_u32 number; /* 0 Device number in the entire set */
++ md_u32 major; /* 1 Device major number */
++ md_u32 minor; /* 2 Device minor number */
++ md_u32 raid_disk; /* 3 The role of the device in the raid set */
++ md_u32 state; /* 4 Operational state */
++ md_u32 reserved[MD_SB_DESCRIPTOR_WORDS - 5];
++} md_descriptor_t;
++
++#define MD_SB_MAGIC 0xa92b4efc
++
++/*
++ * Superblock state bits
++ */
++#define MD_SB_CLEAN 0
++#define MD_SB_ERRORS 1
++
++typedef struct md_superblock_s {
++ /*
++ * Constant generic information
++ */
++ md_u32 md_magic; /* 0 MD identifier */
++ md_u32 major_version; /* 1 major version to which the set conforms */
++ md_u32 minor_version; /* 2 minor version ... */
++ md_u32 patch_version; /* 3 patchlevel version ... */
++ md_u32 gvalid_words; /* 4 Number of used words in this section */
++ md_u32 set_magic; /* 5 Raid set identifier */
++ md_u32 ctime; /* 6 Creation time */
++ md_u32 level; /* 7 Raid personality */
++ md_u32 size; /* 8 Apparent size of each individual disk */
++ md_u32 nr_disks; /* 9 total disks in the raid set */
++ md_u32 raid_disks; /* 10 disks in a fully functional raid set */
++ md_u32 md_minor; /* 11 preferred MD minor device number */
++ md_u32 gstate_creserved[MD_SB_GENERIC_CONSTANT_WORDS - 12];
++
++ /*
++ * Generic state information
++ */
++ md_u32 utime; /* 0 Superblock update time */
++ md_u32 state; /* 1 State bits (clean, ...) */
++ md_u32 active_disks; /* 2 Number of currently active disks */
++ md_u32 working_disks; /* 3 Number of working disks */
++ md_u32 failed_disks; /* 4 Number of failed disks */
++ md_u32 spare_disks; /* 5 Number of spare disks */
++ md_u32 gstate_sreserved[MD_SB_GENERIC_STATE_WORDS - 6];
++
++ /*
++ * Personality information
++ */
++ md_u32 layout; /* 0 the array's physical layout */
++ md_u32 chunk_size; /* 1 chunk size in bytes */
++ md_u32 pstate_reserved[MD_SB_PERSONALITY_WORDS - 2];
++
++ /*
++ * Disks information
++ */
++ md_descriptor_t disks[MD_SB_DISKS];
++
++ /*
++ * Reserved
++ */
++ md_u32 reserved[MD_SB_RESERVED_WORDS];
++
++ /*
++ * Active descriptor
++ */
++ md_descriptor_t descriptor;
++
++} md_superblock_t;
++
++/*
++ * options passed in raidstart:
++ */
++
++#define MAX_CHUNK_SIZE (4096*1024)
++
++struct md_param
++{
++ int personality; /* 1,2,3,4 */
++ int chunk_size; /* in bytes */
++ int max_fault; /* unused for now */
++};
++
++typedef struct md_array_info_s {
++ /*
++ * Generic constant information
++ */
++ md_u32 major_version;
++ md_u32 minor_version;
++ md_u32 patch_version;
++ md_u32 ctime;
++ md_u32 level;
++ md_u32 size;
++ md_u32 nr_disks;
++ md_u32 raid_disks;
++ md_u32 md_minor;
++ md_u32 not_persistent;
++
++ /*
++ * Generic state information
++ */
++ md_u32 utime; /* 0 Superblock update time */
++ md_u32 state; /* 1 State bits (clean, ...) */
++ md_u32 active_disks; /* 2 Number of currently active disks */
++ md_u32 working_disks; /* 3 Number of working disks */
++ md_u32 failed_disks; /* 4 Number of failed disks */
++ md_u32 spare_disks; /* 5 Number of spare disks */
++
++ /*
++ * Personality information
++ */
++ md_u32 layout; /* 0 the array's physical layout */
++ md_u32 chunk_size; /* 1 chunk size in bytes */
++
++} md_array_info_t;
++
++typedef struct md_disk_info_s {
++ /*
++ * configuration/status of one particular disk
++ */
++ md_u32 number;
++ md_u32 major;
++ md_u32 minor;
++ md_u32 raid_disk;
++ md_u32 state;
++
++} md_disk_info_t;
++
++
++/*
++ * Supported RAID5 algorithms
++ */
++#define RAID5_ALGORITHM_LEFT_ASYMMETRIC 0
++#define RAID5_ALGORITHM_RIGHT_ASYMMETRIC 1
++#define RAID5_ALGORITHM_LEFT_SYMMETRIC 2
++#define RAID5_ALGORITHM_RIGHT_SYMMETRIC 3
++
++#endif _MD_H
diff --git a/packages/lilo-sh/lilo-sh_21.bb b/packages/lilo-sh/lilo-sh_21.bb
new file mode 100644
index 0000000000..eb4ba0cccf
--- /dev/null
+++ b/packages/lilo-sh/lilo-sh_21.bb
@@ -0,0 +1,41 @@
+#
+# Bootloader for sh4 based devices using a HDD or block translation
+# layer over the flash. NOTE that this version has the 1024 cylinder
+# limit, so you probably need a seperate /boot partition as the first
+# partition on the disk. Tested on the NP51R (Titan) booting from the
+# onboard flash
+#
+DESCRIPTION="LILO (LInux LOader) is a basic system program which \
+boots your Linux system. LILO loads the Linux kernel from a floppy or \
+a hard drive, boots the kernel, and passes control of the system to \
+the kernel. LILO can also boot other operating systems. LILO-sh is a \
+port of LILO to the SH processor."
+SECTION="bootloader"
+MAINTAINER = "Jamie Lenehan <lenehan@twibble.org>"
+LICENSE = "MIT"
+PR = "r0"
+
+SRC_URI = "http://twibble.org/dist/sh4/src/lilosh/lilo-21.tar.gz \
+ file://lilo-0.21-include.patch;patch=1 \
+ file://lilo-0.21-1.1.patch;patch=1 \
+ file://lilo.patch;patch=1 \
+ file://lilo.raid1;patch=1 \
+ file://lilo-0.21-loopdev.patch;patch=1 \
+ file://lilo-0.21-second.patch;patch=1;pnum=0 \
+ file://lilo-sh-linux.patch;patch=1 \
+ file://lilo-linkgear.patch;patch=1 \
+ file://lilo-noconfig-h.patch;patch=1"
+S = "${WORKDIR}/lilo"
+
+EXTRA_OEMAKE = "CROSS_COMPILE=${TARGET_PREFIX}"
+
+# Include /boot in the package
+FILES_${PN} = "${base_sbindir} /boot"
+
+do_install() {
+ # Create the base directores
+ mkdir -p ${D}${sysconfdir} ${D}${sbindir}
+ oe_runmake ROOT=${D} install
+ # We don't ship this file
+ rm ${D}/usr/sbin/keytab-lilo.pl
+}