--- sibyl-2.4.2.orig/debian/changelog
+++ sibyl-2.4.2/debian/changelog
@@ -0,0 +1,15 @@
+sibyl (2.4.2-2) unstable; urgency=low
+
+ * Fix race condition in tftp loader.
+
+ -- Peter De Schrijver (p2) <p2@debian.org> Thu, 22 Sep 2005 15:17:11 +0200
+
+sibyl (2.4.2-1) unstable; urgency=low
+
+ * Initial Release. (Closes: #261295)
+ * Integration with e2fslib by
+ Thiemo Seufer (<ica2_ts@csv.ica.uni-stuttgart.de>)
+ * Adapted initrd arguments to Debian kernel.
+
+ -- Peter De Schrijver (p2) <p2@mind.be> Wed, 28 Jul 2004 00:05:04 +0200
+
--- sibyl-2.4.2.orig/debian/control
+++ sibyl-2.4.2/debian/control
@@ -0,0 +1,18 @@
+Source: sibyl
+Section: admin
+Priority: optional
+Maintainer: Peter De Schrijver (p2) <p2@mind.be>
+Uploaders: Martin Michlmayr <tbm@cyrius.com>, Thiemo Seufer <ica2_ts@csv.ica.uni-stuttgart.de>
+Build-Depends: e2fslibs-dev, debhelper (>> 4.0.0), dpatch
+Standards-Version: 3.6.1
+
+Package: sibyl
+Architecture: mips mipsel
+Depends: ${shlibs:Depends}
+Description: boot loader for Broadcom SiByte MIPS boards
+ Sibyl is a boot loader for boards using the Broadcom CFE firmware (such as
+ the Broadcom SWARM board (BCM91250A)). It is started by the Broadcom CFE
+ firmware and uses this firmware to load and start the Linux kernel. This
+ package also includes an installation utility to write the sibyl boot
+ loader to the hard disk.
+
--- sibyl-2.4.2.orig/debian/patches/01-loader.dpatch
+++ sibyl-2.4.2/debian/patches/01-loader.dpatch
@@ -0,0 +1,2863 @@
+#! /bin/sh -e
+## loader.dpatch by Thiemo Seufer <ica2_ts@csv.ica.uni-stuttgart.de>
+##
+## DP: patches to sibyl
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch ${2:+-d $2}}"
+
+if [ $# -lt 1 ]; then
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1
+fi
+
+case "$1" in
+ -patch) patch $patch_opts -p1 < $0;;
+ -unpatch) patch $patch_opts -p1 -R < $0;;
+ *)
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1;;
+esac
+
+exit 0
+@DPATCH@
+
+diff -wurN orig/loader/BUILD debian/loader/BUILD
+--- orig/loader/BUILD 2002-11-21 18:17:57.000000000 +0100
++++ debian/loader/BUILD 1970-01-01 01:00:00.000000000 +0100
+@@ -1,31 +0,0 @@
+-#!/bin/sh -e
+-# $Id: BUILD,v 1.2 2002/11/21 17:17:57 kwalker Exp $
+-
+-sb_tool_prefix=`sbtoolinfo prefix`
+-sb_target=`sbtoolinfo target`
+-if [ -z "$sb_tool_prefix" ] || [ -z "$sb_target" ]; then
+- echo "$0: sbtoolinfo providing bogus information" 1>&2
+- exit 1
+-fi
+-sb_target_prefix=$sb_tool_prefix/$sb_target
+-sb_tool_env=$sb_target-env
+-sb_tool_make=$sb_target-make
+-
+-case ${1:-all} in
+-all)
+- $sb_tool_make
+- ;;
+-clean)
+- $sb_tool_make -k clean
+- ;;
+-cmdname)
+- cd `dirname $0`
+- pwdname=`pwd`
+- cmdname=`basename $pwdname`
+- echo $cmdname
+- ;;
+-*)
+- echo "usage: $0 all|clean|cmdname" 1>&2
+- false
+- ;;
+-esac
+diff -wurN orig/loader/config.h debian/loader/config.h
+--- orig/loader/config.h 1970-01-01 01:00:00.000000000 +0100
++++ debian/loader/config.h 2004-07-25 14:10:59.000000000 +0200
+@@ -0,0 +1,47 @@
++/* $Id: config.h,v 1.4 2003/05/30 00:42:38 cgd Exp $ */
++
++/*
++ * Copyright 2001, 2003
++ * Broadcom Corporation. All rights reserved.
++ *
++ * This software is furnished under license and may be used and copied only
++ * in accordance with the following terms and conditions. Subject to these
++ * conditions, you may download, copy, install, use, modify and distribute
++ * modified or unmodified copies of this software in source and/or binary
++ * form. No title or ownership is transferred hereby.
++ *
++ * 1) Any source code used, modified or distributed must reproduce and
++ * retain this copyright notice and list of conditions as they appear in
++ * the source file.
++ *
++ * 2) No right is granted to use any trade name, trademark, or logo of
++ * Broadcom Corporation. The "Broadcom Corporation" name may not be
++ * used to endorse or promote products derived from this software
++ * without the prior written permission of Broadcom Corporation.
++ *
++ * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR IMPLIED
++ * WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED WARRANTIES OF
++ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
++ * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL BROADCOM BE LIABLE
++ * FOR ANY DAMAGES WHATSOEVER, AND IN PARTICULAR, BROADCOM SHALL NOT BE
++ * LIABLE FOR DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
++ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
++ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
++ * OR OTHERWISE), EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
++ */
++
++#ifndef _CONFIG_H
++#define _CONFIG_H
++
++/* Network support */
++#ifndef CONFIG_BLOCKDEV
++#define CONFIG_NETWORK
++#endif
++
++/* Support for booting from block devices (Currently broken) */
++//#define CONFIG_BLOCKDEV
++
++#endif
++
+diff -wurN orig/loader/console.h debian/loader/console.h
+--- orig/loader/console.h 1970-01-01 01:00:00.000000000 +0100
++++ debian/loader/console.h 2004-07-25 14:10:59.000000000 +0200
+@@ -0,0 +1,41 @@
++/* $Id: console.h,v 1.3 2003/05/30 00:42:38 cgd Exp $ */
++
++/*
++ * Copyright 2001, 2003
++ * Broadcom Corporation. All rights reserved.
++ *
++ * This software is furnished under license and may be used and copied only
++ * in accordance with the following terms and conditions. Subject to these
++ * conditions, you may download, copy, install, use, modify and distribute
++ * modified or unmodified copies of this software in source and/or binary
++ * form. No title or ownership is transferred hereby.
++ *
++ * 1) Any source code used, modified or distributed must reproduce and
++ * retain this copyright notice and list of conditions as they appear in
++ * the source file.
++ *
++ * 2) No right is granted to use any trade name, trademark, or logo of
++ * Broadcom Corporation. The "Broadcom Corporation" name may not be
++ * used to endorse or promote products derived from this software
++ * without the prior written permission of Broadcom Corporation.
++ *
++ * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR IMPLIED
++ * WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED WARRANTIES OF
++ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
++ * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL BROADCOM BE LIABLE
++ * FOR ANY DAMAGES WHATSOEVER, AND IN PARTICULAR, BROADCOM SHALL NOT BE
++ * LIABLE FOR DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
++ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
++ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
++ * OR OTHERWISE), EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
++ */
++
++#ifndef _CONSOLE_H
++#define _CONSOLE_H
++
++void console_print(char *string);
++int open_console();
++
++#endif
+diff -wurN orig/loader/elf.h debian/loader/elf.h
+--- orig/loader/elf.h 1970-01-01 01:00:00.000000000 +0100
++++ debian/loader/elf.h 2004-07-25 14:10:59.000000000 +0200
+@@ -0,0 +1,177 @@
++/* $Id: elf.h,v 1.4 2003/05/30 00:42:38 cgd Exp $ */
++
++/*
++ * Copyright 2001, 2003
++ * Broadcom Corporation. All rights reserved.
++ *
++ * This software is furnished under license and may be used and copied only
++ * in accordance with the following terms and conditions. Subject to these
++ * conditions, you may download, copy, install, use, modify and distribute
++ * modified or unmodified copies of this software in source and/or binary
++ * form. No title or ownership is transferred hereby.
++ *
++ * 1) Any source code used, modified or distributed must reproduce and
++ * retain this copyright notice and list of conditions as they appear in
++ * the source file.
++ *
++ * 2) No right is granted to use any trade name, trademark, or logo of
++ * Broadcom Corporation. The "Broadcom Corporation" name may not be
++ * used to endorse or promote products derived from this software
++ * without the prior written permission of Broadcom Corporation.
++ *
++ * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR IMPLIED
++ * WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED WARRANTIES OF
++ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
++ * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL BROADCOM BE LIABLE
++ * FOR ANY DAMAGES WHATSOEVER, AND IN PARTICULAR, BROADCOM SHALL NOT BE
++ * LIABLE FOR DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
++ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
++ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
++ * OR OTHERWISE), EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
++ */
++
++#ifndef ELF_H
++#define ELF_H
++
++#include "port.h"
++
++/* Elf types */
++typedef uint8_t Elf_Byte;
++
++typedef uint16_t Elf32_Half;
++typedef uint32_t Elf32_Word;
++typedef int32_t Elf32_Sword;
++typedef uint32_t Elf32_Off;
++typedef uint32_t Elf32_Addr;
++
++typedef uint16_t Elf64_Quarter;
++typedef uint32_t Elf64_Half;
++typedef int32_t Elf64_Shalf;
++typedef uint64_t Elf64_Word;
++typedef int64_t Elf64_Sword;
++typedef uint64_t Elf64_Addr;
++typedef uint64_t Elf64_Off;
++
++
++/* ELF Header */
++#define EI_NIDENT 16
++
++/* Quick rant: Why, oh why, do these all have to start with e_? Isn't
++ it enough to see they're elements of an Ehdr struct? Maybe there's
++ a worldwide conspiracy to increase the number of 'e's in existance.
++ The truth is out there, and I'm REALLY tired right now - JDC */
++
++typedef struct {
++ Elf_Byte e_ident[EI_NIDENT] ; /* ID. Elf0x7f+ */
++ Elf32_Half e_type ; /* File type */
++ Elf32_Half e_machine ; /* Machine type */
++ Elf32_Word e_version ; /* Version (Duh!) */
++ Elf32_Addr e_entry ; /* Execution entry point */
++ Elf32_Off e_phoff ; /* Program header offset */
++ Elf32_Off e_shoff ; /* Section header offset */
++ Elf32_Word e_flags ; /* Processor flags */
++ Elf32_Half e_ehsize ; /* Ehder size */
++ Elf32_Half e_phentsize ; /* Prog header entry size */
++ Elf32_Half e_phnum ; /* Prog header count */
++ Elf32_Half e_shentsize ; /* Section header entry size */
++ Elf32_Half e_shnum ; /* Number of section headers */
++ Elf32_Half e_shstrndx ; /* String table index */
++} Elf32_Ehdr;
++
++
++typedef struct {
++ Elf_Byte e_ident[EI_NIDENT] ; /* ID. Elf0x7f+ */
++ Elf64_Quarter e_type ; /* File type */
++ Elf64_Quarter e_machine ; /* Machine type */
++ Elf64_Half e_version ; /* Version (Duh!) */
++ Elf64_Addr e_entry ; /* Execution entry point */
++ Elf64_Off e_phoff ; /* Program header offset */
++ Elf64_Off e_shoff ; /* Section header offset */
++ Elf64_Half e_flags ; /* Processor flags */
++ Elf64_Quarter e_ehsize ; /* Ehder size */
++ Elf64_Quarter e_phentsize ; /* Prog header entry size */
++ Elf64_Quarter e_phnum ; /* Prog header count */
++ Elf64_Quarter e_shentsize ; /* Section header entry size */
++ Elf64_Quarter e_shnum ; /* Number of section headers */
++ Elf64_Quarter e_shstrndx ; /* String table index */
++} Elf64_Ehdr;
++
++
++/* e_ident offsets */
++#define EI_MAG0 0 /* File identification */
++#define EI_MAG1 1 /* File identification */
++#define EI_MAG2 2 /* File identification */
++#define EI_MAG3 3 /* File identification */
++#define EI_CLASS 4 /* Class (Duh!) */
++#define EI_DATA 5 /* Encoding */
++#define EI_VERSION 6 /* Version */
++#define EI_PAD 7 /* Start of padding */
++
++/* e_ident magic cookie */
++#define ELFMAG0 0x7f
++#define ELFMAG1 'E'
++#define ELFMAG2 'L'
++#define ELFMAG3 'F'
++#define ELFMAG "\177ELF"
++
++/* e_ident[EI_CLASS] values */
++#define ELFCLASSNONE 0
++#define ELFCLASS32 1
++#define ELFCLASS64 2
++
++/* e_ident[EI_DATA] values */
++#define ELFDATANONE 0 /* straight out! */
++#define ELFDATA2LSB 1 /* little-endian */
++#define ELFDATA2MSB 2 /* big-endian */
++
++/* e_type values */
++#define ET_NONE 0 /* Go away! */
++#define ET_REL 1 /* Relocatable */
++#define ET_EXEC 2 /* Executable */
++#define ET_DYN 3 /* Shared object */
++#define ET_CORE 4 /* Core (Not Arm) */
++#define ET_LOPROC 0xff00 /* Processor specific */
++#define ET_HIPROC 0xffff /* Processor specific */
++
++
++typedef struct {
++ Elf32_Word p_type ; /* Segment type */
++ Elf32_Off p_offset ; /* Offset to segment data */
++ Elf32_Addr p_vaddr ; /* Virt addr of segment */
++ Elf32_Addr p_paddr ; /* Ignored segment phys addr */
++ Elf32_Word p_filesz ; /* Segment file image size */
++ Elf32_Word p_memsz ; /* Segment memory image size */
++ Elf32_Word p_flags ; /* Flags for segment */
++ Elf32_Word p_align ; /* Segment alignment enforced */
++} Elf32_Phdr;
++
++typedef struct {
++ Elf64_Half p_type ; /* Segment type */
++ Elf64_Half p_flags ; /* Flags for segment */
++ Elf64_Off p_offset ; /* Offset to segment data */
++ Elf64_Addr p_vaddr ; /* Virt addr of segment */
++ Elf64_Addr p_paddr ; /* Ignored segment phys addr */
++ Elf64_Word p_filesz ; /* Segment file image size */
++ Elf64_Word p_memsz ; /* Segment memory image size */
++ Elf64_Word p_align ; /* Segment alignment enforced */
++} Elf64_Phdr;
++
++/* p_type values */
++#define PT_NULL 0 /* Ignore */
++#define PT_LOAD 1 /* Loadable segment */
++#define PT_DYNAMIC 2 /* Dynamic linking info */
++#define PT_INTERP 3 /* Program interpreter */
++#define PT_NOTE 4 /* Auxilliary info location */
++#define PT_SHLIB 5 /* Reserved */
++#define PT_PHDR 6 /* Location of phdr table (?) */
++#define PT_LOPROC 0x70000000 /* Proc specific range low */
++#define PT_HIPROV 0x7fffffff /* Proc specific range high */
++
++/* p_flags vaules (Not related to PFLAG...:) */
++#define PHP_X 0x1 /* Execute */
++#define PHP_W 0x2 /* Write */
++#define PHP_R 0x4 /* Read */
++
++#endif
+diff -wurN orig/loader/ext2_fileops.c debian/loader/ext2_fileops.c
+--- orig/loader/ext2_fileops.c 2003-05-30 02:42:37.000000000 +0200
++++ debian/loader/ext2_fileops.c 2004-07-25 14:10:59.000000000 +0200
+@@ -33,6 +33,7 @@
+ */
+
+ #include <stdio.h> /* To make ext2lib happy. We don't actually use anything from it */
++#include "port.h"
+ #include "getfile.h"
+ #include "libc.h"
+ #include "partition.h"
+@@ -40,13 +41,17 @@
+ #include "ext2_fs.h" /* From linux kernel */
+ #include "ext2fs.h" /* From e2fsprogs */
+
++extern unsigned long long my_strtoull(const char *ptr);
+
+ typedef struct {
+-// int32_t offset;
+ ext2_filsys fs;
+ ext2_file_t file;
+ } ext2_ops_data_t;
+
++typedef struct cfe_private_data_struct {
++ int handle;
++ unsigned long linear_offset;
++} cfe_channel_private_t;
+
+ /*
+ * I/O Manager Glue
+@@ -58,7 +63,7 @@
+ static errcode_t cfe_manager_write_blk(io_channel channel, unsigned long block, int count, const void *buf);
+ static errcode_t cfe_manager_flush(io_channel channel);
+
+-static struct struct_io_manager struct_cfe_manager = {
++static struct struct_io_manager cfe_io_manager = {
+ EXT2_ET_MAGIC_IO_MANAGER,
+ "CFE I/O Manager",
+ cfe_manager_open,
+@@ -66,165 +71,115 @@
+ cfe_manager_set_blksize,
+ cfe_manager_read_blk,
+ cfe_manager_write_blk,
+- cfe_manager_flush
+-};
+-
+-io_manager cfe_io_manager = &struct_cfe_manager;
+-
+-/* This is probably a big no-no, but I'm 99% sure we don't need reentrancy for
+- the intended use, and we've not good way of allocating memory from the firmware...*/
+-
+-#define CFE_CHANNEL_NAME_SIZE 64
+-static char cfe_channel_name[CFE_CHANNEL_NAME_SIZE];
+-
+-typedef struct cfe_private_data_struct {
+- int handle;
+- unsigned long linear_offset;
+-} cfe_channel_private_t;
+-
+-static cfe_channel_private_t cfe_channel_private = {
+- handle: 0,
+- linear_offset: 0
++ cfe_manager_flush,
++ NULL,
++ {0, }
+ };
+
+-static struct struct_io_channel cfe_channel = {
+- magic: EXT2_ET_MAGIC_IO_CHANNEL,
+- manager: &struct_cfe_manager,
+- name: cfe_channel_name,
+- block_size: 1024,
+- read_error: NULL,
+- write_error: NULL,
+- refcount: 0,
+- private_data: (void *)&cfe_channel_private,
+- app_data: NULL
+-};
+-
+-
+-
+-static unsigned long long my_strtoull(char *ptr)
+-{
+- unsigned long long retval = 0;
+- unsigned int newdigit;
+- while(*ptr) {
+- if (*ptr >= 'a' && *ptr <= 'f') {
+- newdigit = *ptr - ('a' - 10);
+- } else if (*ptr >= 'A' && *ptr <= 'F') {
+- newdigit = *ptr - ('A' - 10);
+- } else if (*ptr >= '0' && *ptr <= '9') {
+- newdigit = *ptr - '0';
+- } else if (*ptr == ' '
+- || *ptr == '\t'
+- || *ptr == '\n') {
+- /* Just skip it */
+- } else {
+- return -1UL;
+- }
+- retval <<= 4;
+- retval |= newdigit;
+- ptr++;
+- }
+- return retval;
+-}
+-
+ static errcode_t cfe_manager_open(const char *name, int flags, io_channel *channel)
+ {
++ io_channel io;
+ char *tmp;
+ cfe_channel_private_t *priv;
+- (*channel) = &cfe_channel;
+
+- if ((*channel)->refcount) {
+- return -1;
+- }
++ io = (io_channel)lib_malloc(sizeof(struct struct_io_channel));
++ if (!io)
++ lib_die("Out of memory");
++ lib_memset(io, 0, sizeof(struct struct_io_channel));
++
++ io->magic = EXT2_ET_MAGIC_IO_CHANNEL;
++ io->manager = &cfe_io_manager;
++ io->block_size = 1024;
++
++ priv = (cfe_channel_private_t *)lib_malloc(sizeof(cfe_channel_private_t));
++ if (!priv)
++ lib_die("Out of memory");
++ lib_memset(priv, 0, sizeof(cfe_channel_private_t));
++ io->private_data = priv;
+
+- priv = (cfe_channel_private_t *)((*channel)->private_data);
+ for (tmp = (char *) name; *tmp; tmp++) {
+ if (*tmp == '@') {
+ *tmp = '\0';
+ tmp++;
+ priv->linear_offset = my_strtoull(tmp);
+- if (priv->linear_offset == -1UL) {
++ if (priv->linear_offset == -1UL)
+ return -1;
+- }
++
+ break;
+ }
+ }
+
+- lib_strncpy(cfe_channel_name, (char *) name, CFE_CHANNEL_NAME_SIZE-1);
+- cfe_channel_name[CFE_CHANNEL_NAME_SIZE-1] = '\0';
+- priv->handle = cfe_open(cfe_channel_name);
+-
+- (*channel)->refcount++;
++ io->name = (char *)lib_strdup(name);
++ if (!io->name)
++ lib_die("Out of memory");
+
+- if (priv->handle < 0) {
++ priv->handle = cfe_open(io->name);
++ if (priv->handle < 0)
+ return -1;
+- }
++
++ *channel = io;
+ return 0;
+ }
+
+-
+ static errcode_t cfe_manager_close(io_channel channel)
+ {
+ cfe_channel_private_t *priv;
+
+- /* Should only have exactly 1 open when close is called */
+- if (channel->refcount != 1 ) {
+- return -1;
+- }
+ priv = (cfe_channel_private_t *)channel->private_data;
+ cfe_close(priv->handle);
+- channel->refcount--;
+ return 0;
+ }
+
+-
+ static errcode_t cfe_manager_set_blksize(io_channel channel, int blksize)
+ {
+ channel->block_size = blksize;
+ return 0;
+ }
+
+-
+ static errcode_t cfe_manager_read_blk(io_channel channel, unsigned long block, int count, void *buf)
+ {
+ int retval;
+ long size;
++ long offset;
+ cfe_channel_private_t *priv;
++
+ priv = (cfe_channel_private_t *)channel->private_data;
+- size = (count & 1<<((sizeof(long)*8)-1))?((~count) + 1):(count * channel->block_size);
++ offset = priv->linear_offset + block * channel->block_size;
+
+- retval = cfe_readblk(priv->handle, priv->linear_offset + (block * channel->block_size),
+- (unsigned char *)buf, size);
++ /* If it is negative count means bytes -- positive -> blocks */
++ size = (count < 0) ? -count : count * channel->block_size;
++
++ retval = cfe_readblk(priv->handle, offset, (unsigned char *)buf, size);
+
+ return (retval < 0)?-1:0;
+ }
+
+-
+ static errcode_t cfe_manager_write_blk(io_channel channel, unsigned long block, int count, const void *buf)
+ {
+ int retval;
+ long size;
++ long offset;
+ cfe_channel_private_t *priv;
+- size = (count & 1<<((sizeof(long)*8)-1))?((~count) + 1):(count * channel->block_size);
++
+ priv = (cfe_channel_private_t *)channel->private_data;
++ offset = priv->linear_offset + block * channel->block_size;
++
++ /* If it is negative count means bytes -- positive -> blocks */
++ size = (count < 0) ? -count : count * channel->block_size;
+
+ retval = -1;
+- return retval;
+ #if 0
+ /* XXX we don't support writing. */
+- retval = cfe_writeblk(priv->handle, priv->linear_offset + (block * channel->block_size),
+- (unsigned char *)buf, size);
+- return (retval < 0)?-1:0;
++ retval = cfe_writeblk(priv->handle, offset, (unsigned char *)buf, size);
+ #endif
++ return (retval < 0) ? -1 : 0;
+ }
+
+-
+ static errcode_t cfe_manager_flush(io_channel channel)
+ {
+ return 0;
+ }
+
+-
+-
+ /* Print an ascii version of val in buf. return the number of characters written */
+ static int hexprint(char *buf, unsigned long long val)
+ {
+@@ -261,12 +216,12 @@
+ int cfe_handle;
+ int partition;
+ part_entry_t part_info;
+- ino_t ino;
++ ext2_ino_t ino;
+ char *name;
+
+- if (lib_strncmp(loc, "ext2:", 5)) {
++ if (lib_strncmp(loc, "ext2:", 5))
+ return 0;
+- }
++
+ loc += 5;
+ /* OK, we think it's for us. Next field should be a cfe device name */
+
+@@ -286,10 +241,6 @@
+
+ /* Then a partition number */
+ partition = (part[0] == '*') ? -1 : lib_atoi(part);
+- ret = lib_malloc(sizeof(ext2_ops_data_t));
+- if (!ret) {
+- lib_die("Out of memory");
+- }
+ cfe_handle = cfe_open(dev);
+ if (cfe_handle < 0) {
+ lib_printf("CFE open of %s failed: %d\n", dev,cfe_handle);
+@@ -307,30 +258,33 @@
+ tok++;
+ hexprint(tok, le_to_cpu32(part_info.start_sector) * 512);
+
+- if (ext2fs_open(buf, 0, 0, 0, cfe_io_manager, &(ret->fs))) {
++ ret = lib_malloc(sizeof(ext2_ops_data_t));
++ if (!ret)
++ lib_die("Out of memory");
++
++ if (ext2fs_open(buf, 0, 0, 0, &cfe_io_manager, &(ret->fs))) {
+ lib_printf("Failed to open ext2 filesystem on partition %i of device %s\n", partition, dev);
+ goto fail;
+ }
+
+-
+ /* ex2fs_lookup expects the name *not* to start with a slash. */
+-
+ if (*name == '/') name++;
+
+ ino = 0;
+ if (ext2fs_lookup(ret->fs,EXT2_ROOT_INO,name,lib_strlen(name),0,&ino)) {
+ lib_printf("Could not find inode for file %s\n",name);
+- ext2fs_close(ret->fs);
+- goto fail;
++ goto fail2;
+ }
+
+ if (ext2fs_file_open(ret->fs,ino,0,&(ret->file))) {
+- ext2fs_close(ret->fs);
+- goto fail;
++ lib_printf("Failed to open file %s\n",name);
++ goto fail2;
+ }
+
+ return ret;
+
++fail2:
++ ext2fs_close(ret->fs);
+ fail:
+ lib_free(ret);
+ return 0;
+@@ -360,9 +314,8 @@
+ ext2_ops_data_t *data = (ext2_ops_data_t *)private;
+ unsigned int retval = 0;
+
+- if (ext2fs_file_read(data->file,buf,(unsigned int) amount,&retval)) {
++ if (ext2fs_file_read(data->file, buf, (unsigned int)amount, &retval))
+ return -1;
+- }
+
+ return (int32_t) retval;
+ }
+@@ -377,12 +330,9 @@
+ lib_free(data);
+ }
+
+-
+ file_ops_t ext2_ops = {
+ ext2_op_open,
+ ext2_op_seek,
+ ext2_op_read,
+ ext2_op_close
+ };
+-
+-
+diff -wurN orig/loader/getfile.c debian/loader/getfile.c
+--- orig/loader/getfile.c 2003-05-30 02:42:37.000000000 +0200
++++ debian/loader/getfile.c 2004-07-25 14:10:59.000000000 +0200
+@@ -32,6 +32,8 @@
+ * OR OTHERWISE), EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
++#include <stdlib.h>
++
+ #include "libc.h"
+ #include "getfile.h"
+
+@@ -47,14 +49,16 @@
+ {
+ file_handler_node_t *tmp;
+ void *priv;
++
+ for (tmp = handler_chain; tmp; tmp = tmp->next) {
+ priv = (*(tmp->ops->open))(name);
+ if (priv) {
+- (*data) = priv;
++ *data = priv;
+ return tmp->ops;
+ }
+ }
+- return 0;
++
++ return NULL;
+ }
+
+ void file_handler_close(file_ops_t *ops,void *priv)
+@@ -66,9 +70,9 @@
+ {
+ file_handler_node_t *new_node;
+ new_node = lib_malloc(sizeof(file_handler_node_t));
+- if (!new_node) {
++ if (!new_node)
+ return -1;
+- }
++
+ new_node->ops = ops;
+ new_node->next = handler_chain;
+ handler_chain = new_node;
+diff -wurN orig/loader/getfile.h debian/loader/getfile.h
+--- orig/loader/getfile.h 1970-01-01 01:00:00.000000000 +0100
++++ debian/loader/getfile.h 2004-07-25 14:10:59.000000000 +0200
+@@ -0,0 +1,60 @@
++/* $Id: getfile.h,v 1.6 2003/05/30 00:42:38 cgd Exp $ */
++
++/*
++ * Copyright 2001, 2003
++ * Broadcom Corporation. All rights reserved.
++ *
++ * This software is furnished under license and may be used and copied only
++ * in accordance with the following terms and conditions. Subject to these
++ * conditions, you may download, copy, install, use, modify and distribute
++ * modified or unmodified copies of this software in source and/or binary
++ * form. No title or ownership is transferred hereby.
++ *
++ * 1) Any source code used, modified or distributed must reproduce and
++ * retain this copyright notice and list of conditions as they appear in
++ * the source file.
++ *
++ * 2) No right is granted to use any trade name, trademark, or logo of
++ * Broadcom Corporation. The "Broadcom Corporation" name may not be
++ * used to endorse or promote products derived from this software
++ * without the prior written permission of Broadcom Corporation.
++ *
++ * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR IMPLIED
++ * WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED WARRANTIES OF
++ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
++ * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL BROADCOM BE LIABLE
++ * FOR ANY DAMAGES WHATSOEVER, AND IN PARTICULAR, BROADCOM SHALL NOT BE
++ * LIABLE FOR DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
++ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
++ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
++ * OR OTHERWISE), EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
++ */
++
++#ifndef _GETFILE_H
++#define _GETFILE_H
++
++#include "port.h"
++
++typedef enum {
++ GF_SEEK_SET,
++ GF_SEEK_CUR
++} file_handler_whence_t;
++
++
++typedef struct {
++ void *(*open)(char *loc);
++ int32_t (*seek)(void *private, int32_t ofs, file_handler_whence_t whence);
++ int32_t (*read)(void *private, void *buf, int32_t amount);
++ void (*close)(void *private);
++} file_ops_t;
++
++
++int file_handler_add(file_ops_t *ops);
++void file_handler_del(file_ops_t *ops);
++file_ops_t *file_handler_find(char *name, void **data);
++void file_handler_close(file_ops_t *ops,void *priv);
++
++
++#endif
+diff -wurN orig/loader/include/config.h debian/loader/include/config.h
+--- orig/loader/include/config.h 2003-05-30 02:42:38.000000000 +0200
++++ debian/loader/include/config.h 1970-01-01 01:00:00.000000000 +0100
+@@ -1,47 +0,0 @@
+-/* $Id: config.h,v 1.4 2003/05/30 00:42:38 cgd Exp $ */
+-
+-/*
+- * Copyright 2001, 2003
+- * Broadcom Corporation. All rights reserved.
+- *
+- * This software is furnished under license and may be used and copied only
+- * in accordance with the following terms and conditions. Subject to these
+- * conditions, you may download, copy, install, use, modify and distribute
+- * modified or unmodified copies of this software in source and/or binary
+- * form. No title or ownership is transferred hereby.
+- *
+- * 1) Any source code used, modified or distributed must reproduce and
+- * retain this copyright notice and list of conditions as they appear in
+- * the source file.
+- *
+- * 2) No right is granted to use any trade name, trademark, or logo of
+- * Broadcom Corporation. The "Broadcom Corporation" name may not be
+- * used to endorse or promote products derived from this software
+- * without the prior written permission of Broadcom Corporation.
+- *
+- * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR IMPLIED
+- * WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED WARRANTIES OF
+- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
+- * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL BROADCOM BE LIABLE
+- * FOR ANY DAMAGES WHATSOEVER, AND IN PARTICULAR, BROADCOM SHALL NOT BE
+- * LIABLE FOR DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+- * OR OTHERWISE), EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+- */
+-
+-#ifndef _CONFIG_H
+-#define _CONFIG_H
+-
+-/* Network support */
+-#ifndef CONFIG_BLOCKDEV
+-#define CONFIG_NETWORK
+-#endif
+-
+-/* Support for booting from block devices (Currently broken) */
+-//#define CONFIG_BLOCKDEV
+-
+-#endif
+-
+diff -wurN orig/loader/include/console.h debian/loader/include/console.h
+--- orig/loader/include/console.h 2003-05-30 02:42:38.000000000 +0200
++++ debian/loader/include/console.h 1970-01-01 01:00:00.000000000 +0100
+@@ -1,41 +0,0 @@
+-/* $Id: console.h,v 1.3 2003/05/30 00:42:38 cgd Exp $ */
+-
+-/*
+- * Copyright 2001, 2003
+- * Broadcom Corporation. All rights reserved.
+- *
+- * This software is furnished under license and may be used and copied only
+- * in accordance with the following terms and conditions. Subject to these
+- * conditions, you may download, copy, install, use, modify and distribute
+- * modified or unmodified copies of this software in source and/or binary
+- * form. No title or ownership is transferred hereby.
+- *
+- * 1) Any source code used, modified or distributed must reproduce and
+- * retain this copyright notice and list of conditions as they appear in
+- * the source file.
+- *
+- * 2) No right is granted to use any trade name, trademark, or logo of
+- * Broadcom Corporation. The "Broadcom Corporation" name may not be
+- * used to endorse or promote products derived from this software
+- * without the prior written permission of Broadcom Corporation.
+- *
+- * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR IMPLIED
+- * WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED WARRANTIES OF
+- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
+- * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL BROADCOM BE LIABLE
+- * FOR ANY DAMAGES WHATSOEVER, AND IN PARTICULAR, BROADCOM SHALL NOT BE
+- * LIABLE FOR DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+- * OR OTHERWISE), EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+- */
+-
+-#ifndef _CONSOLE_H
+-#define _CONSOLE_H
+-
+-void console_print(char *string);
+-int open_console();
+-
+-#endif
+diff -wurN orig/loader/include/elf.h debian/loader/include/elf.h
+--- orig/loader/include/elf.h 2003-05-30 02:42:38.000000000 +0200
++++ debian/loader/include/elf.h 1970-01-01 01:00:00.000000000 +0100
+@@ -1,177 +0,0 @@
+-/* $Id: elf.h,v 1.4 2003/05/30 00:42:38 cgd Exp $ */
+-
+-/*
+- * Copyright 2001, 2003
+- * Broadcom Corporation. All rights reserved.
+- *
+- * This software is furnished under license and may be used and copied only
+- * in accordance with the following terms and conditions. Subject to these
+- * conditions, you may download, copy, install, use, modify and distribute
+- * modified or unmodified copies of this software in source and/or binary
+- * form. No title or ownership is transferred hereby.
+- *
+- * 1) Any source code used, modified or distributed must reproduce and
+- * retain this copyright notice and list of conditions as they appear in
+- * the source file.
+- *
+- * 2) No right is granted to use any trade name, trademark, or logo of
+- * Broadcom Corporation. The "Broadcom Corporation" name may not be
+- * used to endorse or promote products derived from this software
+- * without the prior written permission of Broadcom Corporation.
+- *
+- * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR IMPLIED
+- * WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED WARRANTIES OF
+- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
+- * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL BROADCOM BE LIABLE
+- * FOR ANY DAMAGES WHATSOEVER, AND IN PARTICULAR, BROADCOM SHALL NOT BE
+- * LIABLE FOR DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+- * OR OTHERWISE), EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+- */
+-
+-#ifndef ELF_H
+-#define ELF_H
+-
+-#include "port.h"
+-
+-/* Elf types */
+-typedef uint8_t Elf_Byte;
+-
+-typedef uint16_t Elf32_Half;
+-typedef uint32_t Elf32_Word;
+-typedef int32_t Elf32_Sword;
+-typedef uint32_t Elf32_Off;
+-typedef uint32_t Elf32_Addr;
+-
+-typedef uint16_t Elf64_Quarter;
+-typedef uint32_t Elf64_Half;
+-typedef int32_t Elf64_Shalf;
+-typedef uint64_t Elf64_Word;
+-typedef int64_t Elf64_Sword;
+-typedef uint64_t Elf64_Addr;
+-typedef uint64_t Elf64_Off;
+-
+-
+-/* ELF Header */
+-#define EI_NIDENT 16
+-
+-/* Quick rant: Why, oh why, do these all have to start with e_? Isn't
+- it enough to see they're elements of an Ehdr struct? Maybe there's
+- a worldwide conspiracy to increase the number of 'e's in existance.
+- The truth is out there, and I'm REALLY tired right now - JDC */
+-
+-typedef struct {
+- Elf_Byte e_ident[EI_NIDENT] ; /* ID. Elf0x7f+ */
+- Elf32_Half e_type ; /* File type */
+- Elf32_Half e_machine ; /* Machine type */
+- Elf32_Word e_version ; /* Version (Duh!) */
+- Elf32_Addr e_entry ; /* Execution entry point */
+- Elf32_Off e_phoff ; /* Program header offset */
+- Elf32_Off e_shoff ; /* Section header offset */
+- Elf32_Word e_flags ; /* Processor flags */
+- Elf32_Half e_ehsize ; /* Ehder size */
+- Elf32_Half e_phentsize ; /* Prog header entry size */
+- Elf32_Half e_phnum ; /* Prog header count */
+- Elf32_Half e_shentsize ; /* Section header entry size */
+- Elf32_Half e_shnum ; /* Number of section headers */
+- Elf32_Half e_shstrndx ; /* String table index */
+-} Elf32_Ehdr;
+-
+-
+-typedef struct {
+- Elf_Byte e_ident[EI_NIDENT] ; /* ID. Elf0x7f+ */
+- Elf64_Quarter e_type ; /* File type */
+- Elf64_Quarter e_machine ; /* Machine type */
+- Elf64_Half e_version ; /* Version (Duh!) */
+- Elf64_Addr e_entry ; /* Execution entry point */
+- Elf64_Off e_phoff ; /* Program header offset */
+- Elf64_Off e_shoff ; /* Section header offset */
+- Elf64_Half e_flags ; /* Processor flags */
+- Elf64_Quarter e_ehsize ; /* Ehder size */
+- Elf64_Quarter e_phentsize ; /* Prog header entry size */
+- Elf64_Quarter e_phnum ; /* Prog header count */
+- Elf64_Quarter e_shentsize ; /* Section header entry size */
+- Elf64_Quarter e_shnum ; /* Number of section headers */
+- Elf64_Quarter e_shstrndx ; /* String table index */
+-} Elf64_Ehdr;
+-
+-
+-/* e_ident offsets */
+-#define EI_MAG0 0 /* File identification */
+-#define EI_MAG1 1 /* File identification */
+-#define EI_MAG2 2 /* File identification */
+-#define EI_MAG3 3 /* File identification */
+-#define EI_CLASS 4 /* Class (Duh!) */
+-#define EI_DATA 5 /* Encoding */
+-#define EI_VERSION 6 /* Version */
+-#define EI_PAD 7 /* Start of padding */
+-
+-/* e_ident magic cookie */
+-#define ELFMAG0 0x7f
+-#define ELFMAG1 'E'
+-#define ELFMAG2 'L'
+-#define ELFMAG3 'F'
+-#define ELFMAG "\177ELF"
+-
+-/* e_ident[EI_CLASS] values */
+-#define ELFCLASSNONE 0
+-#define ELFCLASS32 1
+-#define ELFCLASS64 2
+-
+-/* e_ident[EI_DATA] values */
+-#define ELFDATANONE 0 /* straight out! */
+-#define ELFDATA2LSB 1 /* little-endian */
+-#define ELFDATA2MSB 2 /* big-endian */
+-
+-/* e_type values */
+-#define ET_NONE 0 /* Go away! */
+-#define ET_REL 1 /* Relocatable */
+-#define ET_EXEC 2 /* Executable */
+-#define ET_DYN 3 /* Shared object */
+-#define ET_CORE 4 /* Core (Not Arm) */
+-#define ET_LOPROC 0xff00 /* Processor specific */
+-#define ET_HIPROC 0xffff /* Processor specific */
+-
+-
+-typedef struct {
+- Elf32_Word p_type ; /* Segment type */
+- Elf32_Off p_offset ; /* Offset to segment data */
+- Elf32_Addr p_vaddr ; /* Virt addr of segment */
+- Elf32_Addr p_paddr ; /* Ignored segment phys addr */
+- Elf32_Word p_filesz ; /* Segment file image size */
+- Elf32_Word p_memsz ; /* Segment memory image size */
+- Elf32_Word p_flags ; /* Flags for segment */
+- Elf32_Word p_align ; /* Segment alignment enforced */
+-} Elf32_Phdr;
+-
+-typedef struct {
+- Elf64_Half p_type ; /* Segment type */
+- Elf64_Half p_flags ; /* Flags for segment */
+- Elf64_Off p_offset ; /* Offset to segment data */
+- Elf64_Addr p_vaddr ; /* Virt addr of segment */
+- Elf64_Addr p_paddr ; /* Ignored segment phys addr */
+- Elf64_Word p_filesz ; /* Segment file image size */
+- Elf64_Word p_memsz ; /* Segment memory image size */
+- Elf64_Word p_align ; /* Segment alignment enforced */
+-} Elf64_Phdr;
+-
+-/* p_type values */
+-#define PT_NULL 0 /* Ignore */
+-#define PT_LOAD 1 /* Loadable segment */
+-#define PT_DYNAMIC 2 /* Dynamic linking info */
+-#define PT_INTERP 3 /* Program interpreter */
+-#define PT_NOTE 4 /* Auxilliary info location */
+-#define PT_SHLIB 5 /* Reserved */
+-#define PT_PHDR 6 /* Location of phdr table (?) */
+-#define PT_LOPROC 0x70000000 /* Proc specific range low */
+-#define PT_HIPROV 0x7fffffff /* Proc specific range high */
+-
+-/* p_flags vaules (Not related to PFLAG...:) */
+-#define PHP_X 0x1 /* Execute */
+-#define PHP_W 0x2 /* Write */
+-#define PHP_R 0x4 /* Read */
+-
+-#endif
+diff -wurN orig/loader/include/getfile.h debian/loader/include/getfile.h
+--- orig/loader/include/getfile.h 2003-05-30 02:42:38.000000000 +0200
++++ debian/loader/include/getfile.h 1970-01-01 01:00:00.000000000 +0100
+@@ -1,60 +0,0 @@
+-/* $Id: getfile.h,v 1.6 2003/05/30 00:42:38 cgd Exp $ */
+-
+-/*
+- * Copyright 2001, 2003
+- * Broadcom Corporation. All rights reserved.
+- *
+- * This software is furnished under license and may be used and copied only
+- * in accordance with the following terms and conditions. Subject to these
+- * conditions, you may download, copy, install, use, modify and distribute
+- * modified or unmodified copies of this software in source and/or binary
+- * form. No title or ownership is transferred hereby.
+- *
+- * 1) Any source code used, modified or distributed must reproduce and
+- * retain this copyright notice and list of conditions as they appear in
+- * the source file.
+- *
+- * 2) No right is granted to use any trade name, trademark, or logo of
+- * Broadcom Corporation. The "Broadcom Corporation" name may not be
+- * used to endorse or promote products derived from this software
+- * without the prior written permission of Broadcom Corporation.
+- *
+- * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR IMPLIED
+- * WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED WARRANTIES OF
+- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
+- * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL BROADCOM BE LIABLE
+- * FOR ANY DAMAGES WHATSOEVER, AND IN PARTICULAR, BROADCOM SHALL NOT BE
+- * LIABLE FOR DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+- * OR OTHERWISE), EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+- */
+-
+-#ifndef _GETFILE_H
+-#define _GETFILE_H
+-
+-#include "port.h"
+-
+-typedef enum {
+- GF_SEEK_SET,
+- GF_SEEK_CUR
+-} file_handler_whence_t;
+-
+-
+-typedef struct {
+- void *(*open)(char *loc);
+- int32_t (*seek)(void *private, int32_t ofs, file_handler_whence_t whence);
+- int32_t (*read)(void *private, void *buf, int32_t amount);
+- void (*close)(void *private);
+-} file_ops_t;
+-
+-
+-int file_handler_add(file_ops_t *ops);
+-void file_handler_del(file_ops_t *ops);
+-file_ops_t *file_handler_find(char *name, void **data);
+-void file_handler_close(file_ops_t *ops,void *priv);
+-
+-
+-#endif
+diff -wurN orig/loader/include/parse_config.h debian/loader/include/parse_config.h
+--- orig/loader/include/parse_config.h 2003-05-30 02:42:38.000000000 +0200
++++ debian/loader/include/parse_config.h 1970-01-01 01:00:00.000000000 +0100
+@@ -1,53 +0,0 @@
+-/* $Id: parse_config.h,v 1.4 2003/05/30 00:42:38 cgd Exp $ */
+-
+-/*
+- * Copyright 2001, 2003
+- * Broadcom Corporation. All rights reserved.
+- *
+- * This software is furnished under license and may be used and copied only
+- * in accordance with the following terms and conditions. Subject to these
+- * conditions, you may download, copy, install, use, modify and distribute
+- * modified or unmodified copies of this software in source and/or binary
+- * form. No title or ownership is transferred hereby.
+- *
+- * 1) Any source code used, modified or distributed must reproduce and
+- * retain this copyright notice and list of conditions as they appear in
+- * the source file.
+- *
+- * 2) No right is granted to use any trade name, trademark, or logo of
+- * Broadcom Corporation. The "Broadcom Corporation" name may not be
+- * used to endorse or promote products derived from this software
+- * without the prior written permission of Broadcom Corporation.
+- *
+- * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR IMPLIED
+- * WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED WARRANTIES OF
+- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
+- * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL BROADCOM BE LIABLE
+- * FOR ANY DAMAGES WHATSOEVER, AND IN PARTICULAR, BROADCOM SHALL NOT BE
+- * LIABLE FOR DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+- * OR OTHERWISE), EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+- */
+-
+-/*
+- * Parse a config file.
+- */
+-
+-#ifndef _PARSE_CONFIG_H
+-#define _PARSE_CONFIG_H
+-
+-typedef struct boot_config_struct {
+- char *kernel;
+- char *initrd;
+- char *extra_args;
+- char *root_dev;
+-} boot_config_t;
+-
+-extern boot_config_t *boot_config;
+-
+-void parse_config_buf(char *buf);
+-
+-#endif
+diff -wurN orig/loader/include/partition.h debian/loader/include/partition.h
+--- orig/loader/include/partition.h 2003-05-30 02:42:38.000000000 +0200
++++ debian/loader/include/partition.h 1970-01-01 01:00:00.000000000 +0100
+@@ -1,61 +0,0 @@
+-/* $Id: partition.h,v 1.3 2003/05/30 00:42:38 cgd Exp $ */
+-
+-/*
+- * Copyright 2001, 2003
+- * Broadcom Corporation. All rights reserved.
+- *
+- * This software is furnished under license and may be used and copied only
+- * in accordance with the following terms and conditions. Subject to these
+- * conditions, you may download, copy, install, use, modify and distribute
+- * modified or unmodified copies of this software in source and/or binary
+- * form. No title or ownership is transferred hereby.
+- *
+- * 1) Any source code used, modified or distributed must reproduce and
+- * retain this copyright notice and list of conditions as they appear in
+- * the source file.
+- *
+- * 2) No right is granted to use any trade name, trademark, or logo of
+- * Broadcom Corporation. The "Broadcom Corporation" name may not be
+- * used to endorse or promote products derived from this software
+- * without the prior written permission of Broadcom Corporation.
+- *
+- * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR IMPLIED
+- * WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED WARRANTIES OF
+- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
+- * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL BROADCOM BE LIABLE
+- * FOR ANY DAMAGES WHATSOEVER, AND IN PARTICULAR, BROADCOM SHALL NOT BE
+- * LIABLE FOR DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+- * OR OTHERWISE), EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+- */
+-
+-#ifndef _PARTITION_H
+-#define _PARTITION_H
+-
+-/*
+- * Routines for dealing with partitions
+- */
+-
+-#include <stdint.h>
+-
+-typedef struct {
+- unsigned char active;
+- unsigned char start_chs[3];
+- unsigned char id;
+- unsigned char end_chs[3];
+- uint32_t start_sector;
+- uint32_t size;
+-} part_entry_t;
+-
+-
+-/* Take a CFE handle and read the partition table, returning
+- the linear offset of the desired partion or -1 for failure
+-*/
+-int part_get_info(int handle, int partno, part_entry_t *part_info);
+-
+-
+-
+-#endif
+diff -wurN orig/loader/include/port.h debian/loader/include/port.h
+--- orig/loader/include/port.h 2004-07-25 01:46:15.000000000 +0200
++++ debian/loader/include/port.h 1970-01-01 01:00:00.000000000 +0100
+@@ -1,65 +0,0 @@
+-/* $Id: port.h,v 1.10 2003/11/17 20:54:52 kwalker Exp $ */
+-
+-/*
+- * Copyright 2001, 2003
+- * Broadcom Corporation. All rights reserved.
+- *
+- * This software is furnished under license and may be used and copied only
+- * in accordance with the following terms and conditions. Subject to these
+- * conditions, you may download, copy, install, use, modify and distribute
+- * modified or unmodified copies of this software in source and/or binary
+- * form. No title or ownership is transferred hereby.
+- *
+- * 1) Any source code used, modified or distributed must reproduce and
+- * retain this copyright notice and list of conditions as they appear in
+- * the source file.
+- *
+- * 2) No right is granted to use any trade name, trademark, or logo of
+- * Broadcom Corporation. The "Broadcom Corporation" name may not be
+- * used to endorse or promote products derived from this software
+- * without the prior written permission of Broadcom Corporation.
+- *
+- * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR IMPLIED
+- * WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED WARRANTIES OF
+- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
+- * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL BROADCOM BE LIABLE
+- * FOR ANY DAMAGES WHATSOEVER, AND IN PARTICULAR, BROADCOM SHALL NOT BE
+- * LIABLE FOR DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+- * OR OTHERWISE), EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+- */
+-
+-#ifndef PORT_H
+-#define PORT_H
+-
+-#ifdef __linux__
+-#include <stdint.h>
+-#else /* !__linux__ */
+-typedef unsigned char uint8_t;
+-typedef signed char int8_t;
+-typedef unsigned short uint16_t;
+-typedef signed short int16_t;
+-typedef unsigned int uint32_t;
+-typedef signed int int32_t;
+-typedef unsigned long long uint64_t;
+-typedef signed long long int64_t;
+-
+-#define unsigned signed /* Kludge to get unsigned size-shaped type. */
+-typedef __SIZE_TYPE__ intptr_t;
+-#undef unsigned
+-typedef __SIZE_TYPE__ uintptr_t;
+-
+-#define UINT64_C(arg) (arg ## ULL)
+-#define UINT32_MAX (0xffffffffU)
+-
+-#endif /* __linux__ */
+-
+-
+-uint16_t port_swap_16(uint16_t src);
+-uint32_t port_swap_32(uint32_t src);
+-uint64_t port_swap_64(uint64_t src);
+-
+-#endif
+diff -wurN orig/loader/include/tftp_fileops.h debian/loader/include/tftp_fileops.h
+--- orig/loader/include/tftp_fileops.h 2003-05-30 02:42:38.000000000 +0200
++++ debian/loader/include/tftp_fileops.h 1970-01-01 01:00:00.000000000 +0100
+@@ -1,42 +0,0 @@
+-/* $Id: tftp_fileops.h,v 1.4 2003/05/30 00:42:38 cgd Exp $ */
+-
+-/*
+- * Copyright 2001, 2003
+- * Broadcom Corporation. All rights reserved.
+- *
+- * This software is furnished under license and may be used and copied only
+- * in accordance with the following terms and conditions. Subject to these
+- * conditions, you may download, copy, install, use, modify and distribute
+- * modified or unmodified copies of this software in source and/or binary
+- * form. No title or ownership is transferred hereby.
+- *
+- * 1) Any source code used, modified or distributed must reproduce and
+- * retain this copyright notice and list of conditions as they appear in
+- * the source file.
+- *
+- * 2) No right is granted to use any trade name, trademark, or logo of
+- * Broadcom Corporation. The "Broadcom Corporation" name may not be
+- * used to endorse or promote products derived from this software
+- * without the prior written permission of Broadcom Corporation.
+- *
+- * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR IMPLIED
+- * WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED WARRANTIES OF
+- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
+- * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL BROADCOM BE LIABLE
+- * FOR ANY DAMAGES WHATSOEVER, AND IN PARTICULAR, BROADCOM SHALL NOT BE
+- * LIABLE FOR DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+- * OR OTHERWISE), EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+- */
+-
+-#ifndef _TFTP_FILEOPS_H
+-#define _TFTP_FILEOPS_H
+-
+-#include "getfile.h"
+-
+-extern file_ops_t tftp_ops;
+-
+-#endif
+diff -wurN orig/loader/init.S debian/loader/init.S
+--- orig/loader/init.S 2003-05-30 02:42:37.000000000 +0200
++++ debian/loader/init.S 2004-07-25 14:10:59.000000000 +0200
+@@ -1,43 +1,48 @@
+-/* $Id: init.S,v 1.4 2003/05/30 00:42:37 cgd Exp $ */
++#include <regdef.h>
+
+-/*
+- * Copyright 2001, 2003
+- * Broadcom Corporation. All rights reserved.
+- *
+- * This software is furnished under license and may be used and copied only
+- * in accordance with the following terms and conditions. Subject to these
+- * conditions, you may download, copy, install, use, modify and distribute
+- * modified or unmodified copies of this software in source and/or binary
+- * form. No title or ownership is transferred hereby.
+- *
+- * 1) Any source code used, modified or distributed must reproduce and
+- * retain this copyright notice and list of conditions as they appear in
+- * the source file.
+- *
+- * 2) No right is granted to use any trade name, trademark, or logo of
+- * Broadcom Corporation. The "Broadcom Corporation" name may not be
+- * used to endorse or promote products derived from this software
+- * without the prior written permission of Broadcom Corporation.
+- *
+- * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR IMPLIED
+- * WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED WARRANTIES OF
+- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
+- * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL BROADCOM BE LIABLE
+- * FOR ANY DAMAGES WHATSOEVER, AND IN PARTICULAR, BROADCOM SHALL NOT BE
+- * LIABLE FOR DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+- * OR OTHERWISE), EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+- */
+-
+-.globl entry
+ .text
++ .globl __start
++ .ent __start
++__start:
++ # Set up gp (for PIC code)
++ .frame fp, 32, ra
++ .set noreorder
++ bltzal zero, 1f
++ nop
++1:
++ .cpload ra
++ .set reorder
++
++ # Set up sp
++# Already done by firmware?
++# la sp, _stack_start - 32
++ addiu sp, -32
++ sw ra, 20(sp)
++ .cprestore 16
++ move fp, sp
++
++ # Clear .bss before compiler generated code uses it.
++ la t0, _fbss
++ la t1, _end
++clearbss:
++ sw zero, (t0)
++ addiu t0, 4
++ bne t0, t1, clearbss
++
++ la t9, sibylmain
++ jalr t9
++
++ # If we ever return, jump to the reset vector.
++ lw t9, 0xbfc00000
++ jalr t9
++ .end __start
++
++
++
++
+
+
+
+-entry:
+ /* Grumble grumble. This wouldn't be necessary,
+ but the abi expects the address of the function
+ to be in $t9. So we do that for start() here
+diff -wurN orig/loader/instimage.c debian/loader/instimage.c
+--- orig/loader/instimage.c 2003-05-30 02:42:37.000000000 +0200
++++ debian/loader/instimage.c 2004-07-25 14:10:59.000000000 +0200
+@@ -39,18 +39,15 @@
+ #include <unistd.h>
+ #include <stdlib.h>
+ #include <linux/unistd.h>
+-
+-#define le_to_cpu32(val) (val)
+-
+-typedef unsigned int u32;
++#include "port.h"
+
+ typedef struct {
+- unsigned char active;
+- unsigned char start_chs[3];
+- unsigned char id;
+- unsigned char end_chs[3];
+- u32 start_sector;
+- u32 size;
++ uint8_t active;
++ uint8_t start_chs[3];
++ uint8_t id;
++ uint8_t end_chs[3];
++ uint32_t start_sector;
++ uint32_t size;
+ } part_entry_t;
+
+ #define VERSION_MAJOR 0
+@@ -119,8 +116,9 @@
+ }
+ }
+
+-static int read_table(int fd, int *entry_num, unsigned long ext_part_sector, unsigned long sector_offset,
+- unsigned long *start_sector, unsigned long *size)
++static int read_table(int fd, int *entry_num, uint32_t ext_part_sector,
++ uint32_t sector_offset, uint32_t *start_sector,
++ uint32_t *size)
+ {
+ int i;
+ part_entry_t entry;
+diff -wurN orig/loader/ld.script debian/loader/ld.script
+--- orig/loader/ld.script 2003-05-30 02:42:37.000000000 +0200
++++ debian/loader/ld.script 2004-07-25 14:10:59.000000000 +0200
+@@ -33,7 +33,7 @@
+ */
+
+ OUTPUT_ARCH(mips)
+-ENTRY(entry)
++ENTRY(__start)
+ /* Do we need any of these for elf?
+ __DYNAMIC = 0; */
+ SECTIONS
+diff -wurN orig/loader/lib/c/libc.c debian/loader/lib/c/libc.c
+--- orig/loader/lib/c/libc.c 2003-05-30 02:42:39.000000000 +0200
++++ debian/loader/lib/c/libc.c 2004-07-25 14:10:59.000000000 +0200
+@@ -139,7 +139,7 @@
+ }
+ }
+
+-void lib_vprintf(char *format, va_list arg)
++void lib_vprintf(const char *format, va_list arg)
+ {
+ char c;
+ while ((c = *format++) != '\0') {
+@@ -262,7 +262,7 @@
+ }
+ }
+
+-void lib_printf(char *fmt, ...)
++void lib_printf(const char *fmt, ...)
+ {
+ va_list ap;
+ va_start(ap, fmt);
+@@ -270,9 +270,6 @@
+ va_end(ap);
+ }
+
+-
+-
+-
+ void *lib_malloc(unsigned int amount)
+ {
+ unsigned int cur_block_size;
+@@ -355,9 +352,9 @@
+ return s;
+ }
+
+-int lib_memcmp(void *s1, void *s2, unsigned int n)
++int lib_memcmp(const void *s1, const void *s2, unsigned int n)
+ {
+- unsigned char *tmp1 = s1, *tmp2 = s2;
++ const unsigned char *tmp1 = s1, *tmp2 = s2;
+ while (n--) {
+ if (*tmp1 < *tmp2) {
+ return -1;
+@@ -375,7 +372,7 @@
+ lib_memset(s, 0, n);
+ }
+
+-void *lib_memcpy(void *dest, void *src, unsigned int n)
++void *lib_memcpy(void *dest, const void *src, unsigned int n)
+ {
+ unsigned char *s1 = (unsigned char *)dest;
+ unsigned char *s2 = (unsigned char *)src;
+@@ -387,7 +384,7 @@
+ return dest;
+ }
+
+-char *lib_strncpy(char *dest, char *src, unsigned int amount)
++char *lib_strncpy(char *dest, const char *src, unsigned int amount)
+ {
+ char *retval = dest;
+ while (amount && *src) {
+@@ -402,14 +399,14 @@
+ return retval;
+ }
+
+-int lib_strlen(char *s)
++int lib_strlen(const char *s)
+ {
+ int retval = 0;
+ while (*s++) retval++;
+ return retval;
+ }
+
+-char *lib_strcpy(char *dest, char *src)
++char *lib_strcpy(char *dest, const char *src)
+ {
+ char *tmp = dest;
+ while (*src) {
+@@ -421,7 +418,7 @@
+ return dest;
+ }
+
+-int lib_strnlen(char *str, unsigned int maxlen)
++int lib_strnlen(const char *str, unsigned int maxlen)
+ {
+ unsigned int retval = 0;
+ while ((retval < maxlen)
+@@ -441,7 +438,7 @@
+
+ }
+
+-char *lib_strdup(char *src)
++char *lib_strdup(const char *src)
+ {
+ char *retval = lib_malloc(lib_strlen(src)+1);
+ if (!retval) {
+@@ -451,7 +448,7 @@
+ return retval;
+ }
+
+-char *lib_strchr(char *str,char c)
++const char *lib_strchr(const char *str, char c)
+ {
+ while (*str && (*str != c)) str++;
+ if (*str) return str;
+@@ -495,7 +492,7 @@
+ || (c >= 'a' && (c <= 'z'));
+ }
+
+-int lib_strncmp(char *s1, char *s2, unsigned long n)
++int lib_strncmp(const char *s1, const char *s2, unsigned long n)
+ {
+ while (n && *s1 && (*s1 == *s2)) {
+ n--;
+@@ -512,7 +509,7 @@
+ return 0;
+ }
+
+-int lib_strcmp(char *s1, char *s2)
++int lib_strcmp(const char *s1, const char *s2)
+ {
+ // if (!(s1 && s2)) {
+ // lib_printf("strcmp\n");
+@@ -520,7 +517,7 @@
+ return lib_strncmp(s1, s2, UINT32_MAX);
+ }
+
+-char *lib_strcat(char *s1, char *s2)
++char *lib_strcat(char *s1, const char *s2)
+ {
+ char *tmp = s1 + lib_strlen(s1);
+ lib_strcpy(tmp, s2);
+@@ -685,7 +682,7 @@
+ return retval;
+ }
+
+-void lib_die(char *fmt, ...)
++void lib_die(const char *fmt, ...)
+ {
+ va_list ap;
+ va_start(ap, fmt);
+@@ -711,7 +708,7 @@
+ (int)(addr & 0xff));
+ }
+
+-int lib_atoi(char *str)
++int lib_atoi(const char *str)
+ {
+ int retval = 0;
+ while ((*str >= '0') && ((*str <= '9'))) {
+diff -wurN orig/loader/lib/c/libc.h debian/loader/lib/c/libc.h
+--- orig/loader/lib/c/libc.h 2003-05-30 02:42:39.000000000 +0200
++++ debian/loader/lib/c/libc.h 2004-07-25 14:10:59.000000000 +0200
+@@ -51,24 +51,23 @@
+ */
+ void lib_init(void *backend_data);
+
+-
+ void *lib_malloc(unsigned int size);
+ void lib_free(void *alloc);
+-void lib_vprintf(char *fmt, va_list ap);
+-void lib_printf(char *fmt, ...);
++void lib_vprintf(const char *fmt, va_list ap);
++void lib_printf(const char *fmt, ...);
+ void *lib_memset(void *s, int c, unsigned int n);
+ void lib_bzero(void *s, unsigned int n);
+-void *lib_memcpy(void *dest, void *src, unsigned int n);
+-int lib_memcmp(void *s1, void *s2, unsigned int n);
+-char *lib_strncpy(char *dest, char *src, unsigned int n);
+-char *lib_strcpy(char *dest, char *src);
+-char *lib_strdup(char *src);
+-char *lib_strchr(char *src,char c);
+-int lib_strlen(char *str);
+-int lib_strncmp(char *s1, char *s2, unsigned long n);
+-int lib_strcmp(char *s1, char *s2);
+-char *lib_strcat(char *s1, char *s2);
+-int lib_strnlen(char *str, unsigned int maxlen);
++void *lib_memcpy(void *dest, const void *src, unsigned int n);
++int lib_memcmp(const void *s1, const void *s2, unsigned int n);
++char *lib_strncpy(char *dest, const char *src, unsigned int n);
++char *lib_strcpy(char *dest, const char *src);
++char *lib_strdup(const char *src);
++const char *lib_strchr(const char *src, char c);
++int lib_strlen(const char *str);
++int lib_strncmp(const char *s1, const char *s2, unsigned long n);
++int lib_strcmp(const char *s1, const char *s2);
++char *lib_strcat(char *s1, const char *s2);
++int lib_strnlen(const char *str, unsigned int maxlen);
+ void lib_usleep(unsigned long usec);
+ void lib_putc(char c);
+ void lib_exit(void);
+@@ -86,10 +85,8 @@
+ uint32_t lib_parse_ip(char *str);
+ void lib_print_ip(uint32_t ip);
+ void lib_print_mac_addr(uint64_t mac_addr);
+-int lib_atoi(char *str);
+-
+-void lib_die(char *msg, ...);
+-
++int lib_atoi(const char *str);
+
++void lib_die(const char *msg, ...);
+
+ #endif
+diff -wurN orig/loader/lib/c/Makefile debian/loader/lib/c/Makefile
+--- orig/loader/lib/c/Makefile 2003-05-28 08:35:35.000000000 +0200
++++ debian/loader/lib/c/Makefile 2004-07-25 14:10:59.000000000 +0200
+@@ -39,10 +39,25 @@
+ all: $(LIBNAME)
+ @echo "Built standalone library"
+
+-include ../../make.config
++CFLAGS = -Wall -g -O0 -fno-builtin
++
++%.o: %.c Makefile
++ $(CC) -MMD -c -o $*.o $(CPPFLAGS) $(CFLAGS) $<
++
++%.o: %.S
++ $(CC) -MMD -c -o $*.o $(CPPFLAGS) $(CFLAGS) $<
++
++%.d: %.c
++ $(CC) -MM $(CPPFLAGS) $< > $*.d
++
++
++.PHONY: clean common_clean
++
++common_clean:
++ rm -f *.o *~ *.d *\#
+
+ # Preprocessor flags we need
+-CPPFLAGS += -I../cfe -I ../../include
++CPPFLAGS += -I../cfe -I../..
+ CFLAGS +=
+
+
+@@ -61,6 +76,5 @@
+ rm -f $(LIBNAME)
+
+ ifneq ($(MAKECMDGOALS),clean)
+-sinclude $(ALL_OBJS:.o=.d)
++include $(ALL_OBJS:.o=.d)
+ endif
+-
+diff -wurN orig/loader/lib/cfe/Makefile debian/loader/lib/cfe/Makefile
+--- orig/loader/lib/cfe/Makefile 2003-05-28 08:35:36.000000000 +0200
++++ debian/loader/lib/cfe/Makefile 2004-07-25 14:10:59.000000000 +0200
+@@ -33,9 +33,24 @@
+ LIBNAME = libcfe.a
+ all: $(LIBNAME)
+
+-include ../../make.config
++CFLAGS = -Wall -g -O0 -fno-builtin
+
+-CPPFLAGS += -I../../include
++%.o: %.c Makefile
++ $(CC) -MMD -c -o $*.o $(CPPFLAGS) $(CFLAGS) $<
++
++%.o: %.S
++ $(CC) -MMD -c -o $*.o $(CPPFLAGS) $(CFLAGS) $<
++
++%.d: %.c
++ $(CC) -MM $(CPPFLAGS) $< > $*.d
++
++
++.PHONY: clean common_clean
++
++common_clean:
++ rm -f *.o *~ *.d *\#
++
++CPPFLAGS += -I../..
+ CFLAGS +=
+
+ CFILES = \
+diff -wurN orig/loader/lib/Makefile debian/loader/lib/Makefile
+--- orig/loader/lib/Makefile 2003-05-28 08:35:34.000000000 +0200
++++ debian/loader/lib/Makefile 2004-07-25 14:10:59.000000000 +0200
+@@ -32,17 +32,16 @@
+
+ SUBDIRS = c net cfe
+
+-all:
+- for dir in $(SUBDIRS); \
+- do \
+- (cd $$dir && $(MAKE) all);\
+- done
+-
+-clean:
+- for dir in $(SUBDIRS); \
+- do \
+- (cd $$dir && $(MAKE) clean);\
+- done
+-
+-
++.PHONY: all
++all: $(SUBDIRS)
+
++.PHONY: $(SUBDIRS)
++$(SUBDIRS):
++ $(MAKE) -C $@ all
++
++.PHONY: clean
++clean: $(patsubst %,clean_%,$(SUBDIRS))
++
++.PHONY: $(patsubst %,clean_%,$(SUBDIRS))
++$(patsubst %,clean_%,$(SUBDIRS)):
++ $(MAKE) -C $(patsubst clean_%,%,$@) clean
+diff -wurN orig/loader/lib/net/Makefile debian/loader/lib/net/Makefile
+--- orig/loader/lib/net/Makefile 2003-05-28 08:35:37.000000000 +0200
++++ debian/loader/lib/net/Makefile 2004-07-25 14:10:59.000000000 +0200
+@@ -40,9 +40,24 @@
+ all: $(LIBNAME)
+ @echo "Built network library"
+
+-include ../../make.config
++CFLAGS = -Wall -g -O0 -fno-builtin
+
+-CPPFLAGS += -I../c -I../cfe -I../../include
++%.o: %.c Makefile
++ $(CC) -MMD -c -o $*.o $(CPPFLAGS) $(CFLAGS) $<
++
++%.o: %.S
++ $(CC) -MMD -c -o $*.o $(CPPFLAGS) $(CFLAGS) $<
++
++%.d: %.c
++ $(CC) -MM $(CPPFLAGS) $< > $*.d
++
++
++.PHONY: clean common_clean
++
++common_clean:
++ rm -f *.o *~ *.d *\#
++
++CPPFLAGS += -I../c -I../cfe -I../..
+
+ CFILES = \
+ arp.c \
+diff -wurN orig/loader/main.c debian/loader/main.c
+--- orig/loader/main.c 2004-07-25 01:46:15.000000000 +0200
++++ debian/loader/main.c 2004-07-25 14:10:59.000000000 +0200
+@@ -32,6 +32,9 @@
+ * OR OTHERWISE), EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
++#include <stdlib.h>
++#include <stdint.h>
++
+ #include "libc.h"
+ #include "cfe_api.h"
+ #include "elf.h"
+@@ -43,10 +46,10 @@
+ #include "port.h"
+
+ typedef struct {
+- unsigned char active;
+- unsigned char start_chs[3];
+- unsigned char id;
+- unsigned char end_chs[3];
++ uint8_t active;
++ uint8_t start_chs[3];
++ uint8_t id;
++ uint8_t end_chs[3];
+ uint32_t start_sector;
+ uint32_t size;
+ } part_entry_t;
+@@ -54,47 +57,26 @@
+ /* Don't set this too large; we do have to allocate a buffer this size */
+ #define MAX_CONFIG_FILE_SIZE (32 * 1024)
+
+-#define PAGE_SIZE (4*1024)
++#define PAGE_SIZE (1 << 12)
+
+-static void elf32_ehdr_swap(Elf32_Ehdr *ehdr_ptr);
++static void init_libs(char *,int);
++static void uninit_libs(void);
++extern void my_gets(char *,int,int);
++static void fatal_error(char *str);
+ static int get_config_file(char *loc, char *buf, int32_t buf_size);
+-static void elf32_phdr_swap(Elf32_Phdr *phdr_ptr);
+ static void *load_kernel(char *loc);
+ static int32_t load_ramdisk(char *loc, char *mem_start);
+-static void zero_bss(void);
+-extern int _fbss;
+-extern int _end;
++
+ typedef void kernel_entry_fn_t(int, unsigned char **, char **, long *);
+-kernel_entry_fn_t *kernel_entry;
++static kernel_entry_fn_t *kernel_entry;
+
+ static int swap;
+
+-#ifndef SILENT
+-#define msg(str) lib_printf str
+-#else
+-#define msg(str) do {} while(0)
+-#endif
+-
+ #ifdef CONFIG_BLOCKDEV
+ extern file_ops_t ext2_ops;
+ #endif
+
+-
+-static void init_libs(char *,int);
+-static void uninit_libs(void);
+-
+-extern void gets(char *,int,int);
+-
+-static void fatal_error(char *str);
+-
+-/*
+- * We end up here after init.S is done setting
+- * up some sane environment .
+- * Massive trickery here -- we actually *fall into* this
+- * routine, so main.c must be linked immediately after init.S.
+- * gross!
+- */
+-void start(long handle, long reserved, long ept, long eptseal)
++void sibylmain(long handle, long reserved, long ept, long eptseal)
+ {
+ char *tmp;
+ char *config_file;
+@@ -103,7 +85,6 @@
+ int bootdev_type;
+ long *linux_args;
+
+- zero_bss();
+ cfe_init(handle, ept);
+ lib_init(0);
+ lib_printf("SiByte Loader, version %i.%i.%i\n",
+@@ -176,7 +157,7 @@
+ if (config_file[0] == 0) {
+ lib_printf("BOOT_CONFIG not defined.\n"
+ "Enter config file location: ");
+- gets(config_file,128,0);
++ my_gets(config_file,128,0);
+ }
+
+ config_file[127] = 0;
+@@ -187,10 +168,11 @@
+ lib_printf("Getting configuration file %s...\n", config_file);
+
+ for (;;) {
+- if (get_config_file(config_file, tmp, MAX_CONFIG_FILE_SIZE) == 0) break;
++ if (!get_config_file(config_file, tmp, MAX_CONFIG_FILE_SIZE))
++ break;
+ lib_printf("Failed to get configuration file.\n"
+ "Enter configuration file location: ");
+- gets(config_file,128,0);
++ my_gets(config_file,128,0);
+ }
+ lib_printf("Config file retrieved.\n");
+ parse_config_buf(tmp);
+@@ -256,14 +238,12 @@
+ kernel_entry(0, 0, 0, linux_args);
+ }
+
+-
+-void fatal_error(char *str)
++static void fatal_error(char *str)
+ {
+ uninit_libs();
+ lib_die(str);
+ }
+
+-
+ static void init_libs(char *bootdev_name,int bootdev_type)
+ {
+ #ifdef CONFIG_NETWORK
+@@ -315,6 +295,13 @@
+ #endif
+ }
+
++static void uninit_libs(void)
++{
++#ifdef CONFIG_NETWORK
++ net_uninit();
++#endif
++}
++
+ static int get_config_file(char *loc, char *buf, int32_t buf_size)
+ {
+ file_ops_t *ops;
+@@ -322,17 +309,14 @@
+ int32_t file_len;
+
+ ops = file_handler_find(loc, &ops_data);
+-
+ if (!ops) {
+ lib_printf("No handler found for this: %s\n", loc);
+ return -1;
+ }
+
+ file_len = ops->read(ops_data, buf, buf_size);
+-
+- if (file_len == MAX_CONFIG_FILE_SIZE) {
++ if (file_len >= buf_size)
+ fatal_error("Config file too large\n");
+- }
+
+ file_handler_close(ops,ops_data);
+
+@@ -401,16 +385,18 @@
+ phdr_ptr->p_align = port_swap_64(phdr_ptr->p_align);
+ }
+
+-
+ static void *load_kernel_elf32(Elf32_Ehdr *ehdr,
+ file_ops_t *ops,
+ void *ops_data)
+ {
+ unsigned long initrd_start_loc = 0;
+ Elf32_Phdr *phdrs;
+- int32_t readlen;
++ uint32_t readlen;
+ int i;
+
++ if (swap)
++ elf32_ehdr_swap(ehdr);
++
+ phdrs = lib_malloc(sizeof(Elf32_Phdr) * ehdr->e_phnum);
+ if (!phdrs) {
+ fatal_error("Out of memory");
+@@ -454,7 +440,6 @@
+ }
+ }
+ lib_printf("done\n");
+- file_handler_close(ops,ops_data);
+ kernel_entry = (kernel_entry_fn_t *) (
+ #ifndef __linux__
+ (int64_t)
+@@ -469,7 +454,7 @@
+ unsigned long initrd_start_loc = 0;
+ Elf64_Ehdr ehdr;
+ Elf64_Phdr *phdrs;
+- int32_t readlen;
++ uint32_t readlen;
+ int i;
+
+ ops->seek(ops_data, 0, GF_SEEK_SET);
+@@ -477,9 +462,9 @@
+ if (readlen != sizeof(ehdr)) {
+ lib_die("ELF header read failed\n");
+ }
+-
+ if (swap)
+ elf64_ehdr_swap(&ehdr);
++
+ phdrs = lib_malloc(sizeof(Elf64_Phdr) * ehdr.e_phnum);
+ if (!phdrs) {
+ fatal_error("Out of memory");
+@@ -521,7 +506,6 @@
+ }
+ }
+ lib_printf("done\n");
+- file_handler_close(ops,ops_data);
+ kernel_entry = (kernel_entry_fn_t *) (
+ #ifndef __linux__
+ (int64_t)
+@@ -540,6 +524,7 @@
+ void *ops_data;
+ Elf32_Ehdr ehdr;
+ int32_t readlen;
++ void *ret = NULL;
+
+ ops = file_handler_find(loc, &ops_data);
+ if (!ops) {
+@@ -550,23 +535,24 @@
+ if (readlen != sizeof(ehdr)) {
+ lib_die("ELF header read failed\n");
+ }
+- if (lib_memcmp(ehdr.e_ident, ELFMAG, 4)) {
+- fatal_error("Elf magic number not present in kernel\n");
+- }
+ #ifdef __MIPSEL__
+ swap = (ehdr.e_ident[EI_DATA] == ELFDATA2MSB);
+ #else
+ swap = (ehdr.e_ident[EI_DATA] == ELFDATA2LSB);
+ #endif
+- if (swap)
+- elf32_ehdr_swap(&ehdr);
+- if (ehdr.e_ident[EI_CLASS] == ELFCLASS32) {
+- return load_kernel_elf32(&ehdr, ops, ops_data);
+- } else {
+-// fatal_error("Elf64 not supported");
+- return load_kernel_elf64(ops, ops_data);
+- }
+- return 0;
++ if (lib_memcmp(ehdr.e_ident, ELFMAG, 4))
++ fatal_error("ELF magic number not present in kernel\n");
++
++ if (ehdr.e_ident[EI_CLASS] == ELFCLASS32)
++ ret = load_kernel_elf32(&ehdr, ops, ops_data);
++ else if (ehdr.e_ident[EI_CLASS] == ELFCLASS64)
++ ret = load_kernel_elf64(ops, ops_data);
++ else
++ fatal_error("Unknown ELF class in kernel\n");
++
++ file_handler_close(ops, ops_data);
++
++ return ret;
+ }
+
+ static int32_t load_ramdisk(char *loc, char *mem_start)
+@@ -585,23 +571,6 @@
+ return readlen;
+ }
+
+-static void uninit_libs(void)
+-{
+-#ifdef CONFIG_NETWORK
+- net_uninit();
+-#endif
+-}
+-
+-static void zero_bss(void)
+-{
+- int *ptr,*eptr;
+-
+- ptr = &_fbss;
+- eptr = &_end;
+-
+- while (ptr < eptr) *ptr++ = 0;
+-}
+-
+ #ifdef CONFIG_BLOCKDEV
+ /* libext2fs wants this defined when you compile with -O0. Must
+ be inlined at -O2 or some such */
+@@ -614,6 +583,7 @@
+ lib_strcpy(dest,arg);
+ return lib_strlen(dest);
+ }
+-#endif
+-
+
++//void __udivdi3() {};
++//void __umoddi3() {};
++#endif
+diff -wurN orig/loader/make.config debian/loader/make.config
+--- orig/loader/make.config 2003-05-28 08:35:31.000000000 +0200
++++ debian/loader/make.config 1970-01-01 01:00:00.000000000 +0100
+@@ -1,54 +0,0 @@
+-# $Id: make.config,v 1.7 2003/05/28 06:35:31 cgd Exp $
+-
+-# Copyright 2001, 2003
+-# Broadcom Corporation. All rights reserved.
+-#
+-# This software is furnished under license and may be used and copied only
+-# in accordance with the following terms and conditions. Subject to these
+-# conditions, you may download, copy, install, use, modify and distribute
+-# modified or unmodified copies of this software in source and/or binary
+-# form. No title or ownership is transferred hereby.
+-#
+-# 1) Any source code used, modified or distributed must reproduce and
+-# retain this copyright notice and list of conditions as they appear in
+-# the source file.
+-#
+-# 2) No right is granted to use any trade name, trademark, or logo of
+-# Broadcom Corporation. The "Broadcom Corporation" name may not be
+-# used to endorse or promote products derived from this software
+-# without the prior written permission of Broadcom Corporation.
+-#
+-# 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR IMPLIED
+-# WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED WARRANTIES OF
+-# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
+-# NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL BROADCOM BE LIABLE
+-# FOR ANY DAMAGES WHATSOEVER, AND IN PARTICULAR, BROADCOM SHALL NOT BE
+-# LIABLE FOR DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+-# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+-# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+-# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+-# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+-# OR OTHERWISE), EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+-
+-# Global configuration for make
+-
+-CPPFLAGS =
+-CFLAGS = -Wall -g -O0 -fno-builtin
+-LDFLAGS =
+-
+-%.o: %.c Makefile
+- $(CC) -MMD -c -o $*.o $(CPPFLAGS) $(CFLAGS) $<
+-
+-%.o: %.S
+- $(CC) -MMD -c -o $*.o $(CPPFLAGS) $(CFLAGS) $<
+-
+-%.d: %.c
+- $(CC) -MM $(CPPFLAGS) $< > $*.d
+-
+-
+-.PHONY: clean common_clean
+-
+-common_clean:
+- rm -f *.o *~ *.d *\#
+-
+-
+diff -wurN orig/loader/Makefile debian/loader/Makefile
+--- orig/loader/Makefile 2003-06-27 19:12:48.000000000 +0200
++++ debian/loader/Makefile 2004-07-25 14:10:59.000000000 +0200
+@@ -34,36 +34,33 @@
+ VERSION_MINOR = 4
+ VERSION_MINUTE = 2
+
+-DISK_SUPPORT=0
++#DISK_SUPPORT=0
++DISK_SUPPORT=1
+
+-all: sibyl sibyl.bin
++all: sibyl.bin
+
+-include make.config
+-
+-CPPFLAGS += -Ilib/c -Ilib/net -Ilib/cfe -I./include -DVERSION_MAJOR=$(VERSION_MAJOR) \
+--DVERSION_MINOR=$(VERSION_MINOR) -DVERSION_MINUTE=$(VERSION_MINUTE)
++CFLAGS += -W -Wall -g -O0 -ffreestanding
++CPPFLAGS += -I. -Ilib/c -Ilib/net -Ilib/cfe \
++ -DVERSION_MAJOR=$(VERSION_MAJOR) \
++ -DVERSION_MINOR=$(VERSION_MINOR) \
++ -DVERSION_MINUTE=$(VERSION_MINUTE)
+ LDFLAGS += -Llib/net -Llib/c -Llib/cfe
+
+-
+-
++OBJCOPY = objcopy
++OBJDUMP = objdump
+
+ # all objects built in this directory
+-ALL_OBJS = \
+- init.o \
+- main.o \
+- getfile.o \
+- parse_config.o \
+- port.o
++OBJS = init.o main.o malloc.o stringops.o getfile.o parse_config.o port.o
+
+ ifeq ($(strip ${DISK_SUPPORT}),1)
+-ALL_OBJS += partition.o ext2_fileops.o
+-CPPFLAGS += -DCONFIG_BLOCKDEV -I../e2fsprogs/lib/ext2fs -I../e2fsprogs/lib -I../e2fsprogs/include/linux
+-DISKLIB = ../e2fsprogs/lib/libembext2fs.a
+-LDFLAGS += -L../e2fsprogs/lib -lembext2fs
++OBJS += partition.o ext2_fileops.o
++CPPFLAGS += -DCONFIG_BLOCKDEV -I/usr/include/ext2fs
++LDFLAGS += -lext2fs -lstandalone -lnet -lcfe $$($(CC) -print-libgcc-file-name)
+ else
+-ALL_OBJS += tftp_fileops.o
++OBJS += tftp_fileops.o
+ endif
+
++.PHONY: disk
+ disk: sibyl.bin
+ mkbootimage -S 1 sibyl.bin disk.img
+
+@@ -75,26 +72,33 @@
+ $(OBJCOPY) --remove-section=reginfo --output-target=binary $^ $@
+
+
+-sibyl: $(ALL_OBJS) libs
+- $(LD) -T ld.script -Map sibyl.map -static -o $@ $(ALL_OBJS) $(LDFLAGS) -lstandalone -lnet -lcfe ${DISKLIB}
++sibyl: $(OBJS) libs
++ $(LD) -T ld.script -Map sibyl.map -static -o $@ $(OBJS) $(LDFLAGS)
+
+ instimage: instimage.c Makefile
+ gcc -o instimage instimage.c
+
+-../e2fsprogs/lib/libembext2fs.a:
+- (cd ../e2fsprogs && BUILD)
+-
+ .PHONY: libs
+-
+ libs:
+- (cd lib && $(MAKE))
++ $(MAKE) -C lib
+
++%.o: %.c Makefile
++ $(CC) -MMD -c -o $*.o $(CPPFLAGS) $(CFLAGS) $<
+
+-clean: common_clean
+- rm -f sibyl sibyl.bin sibyl.dis sibyl.map instimage
+- (cd lib && $(MAKE) clean)
++%.o: %.S
++ $(CC) -MMD -c -o $*.o $(CPPFLAGS) $(CFLAGS) $<
++
++%.d: %.c
++ $(CC) -MM $(CPPFLAGS) $< > $*.d
++
++%.d: %.S
++ $(CC) -MM $(CPPFLAGS) $< > $*.d
++
++.PHONY: clean
++clean:
++ rm -f *.o *~ *.d *\# sibyl sibyl.bin sibyl.dis sibyl.map instimage
++ $(MAKE) -C lib clean
+
+ ifneq ($(MAKECMDGOALS),clean)
+-sinclude $(ALL_OBJS:.o=.d)
++include $(OBJS:.o=.d)
+ endif
+-
+diff -wurN orig/loader/malloc.c debian/loader/malloc.c
+--- orig/loader/malloc.c 1970-01-01 01:00:00.000000000 +0100
++++ debian/loader/malloc.c 2004-07-25 14:10:59.000000000 +0200
+@@ -0,0 +1,16 @@
++#include "libc.h"
++
++void *malloc(unsigned long size)
++{
++ return lib_malloc(size);
++}
++
++void free(void *ptr)
++{
++ lib_free(ptr);
++}
++
++void *realloc(void *ptr, unsigned long size)
++{
++ return 0; /* not supported */
++}
+diff -wurN orig/loader/parse_config.c debian/loader/parse_config.c
+--- orig/loader/parse_config.c 2003-05-30 02:42:37.000000000 +0200
++++ debian/loader/parse_config.c 2004-07-25 14:10:59.000000000 +0200
+@@ -262,6 +262,7 @@
+ {
+ char *ptr, *ptr2;
+ char saved_char;
++
+ ptr = buf;
+ skip_whitespace(&ptr);
+ for ( ; *ptr; skip_whitespace(&ptr)) {
+@@ -338,7 +339,7 @@
+ }
+ }
+
+-void gets(char *buf,int buflen,int timeout)
++void my_gets(char *buf, int buflen, int timeout)
+ {
+ int got_choice;
+ int buf_ptr;
+@@ -352,7 +353,7 @@
+ char foo;
+ if (timeout &&
+ (((lib_get_time() - timeout_start)>>20)
+- >= timeout)) {
++ >= (unsigned int)timeout)) {
+ got_choice = 1;
+ buf[0] = 0;
+ }
+@@ -409,7 +410,7 @@
+ }
+ if (!tmp) {
+ lib_printf("Default configuration %s doesn't exist. Using"
+- " %s instead\n", default_name);
++ " %s instead\n", default_name, config_chain->name);
+ lib_free(default_name);
+ default_name = lib_strdup(config_chain->name);
+ if (!default_name) {
+@@ -425,7 +426,7 @@
+ lib_printf(" %s\n", tmp->name);
+ }
+ lib_printf("Boot which configuration [%s]: ", default_name);
+- gets(buf,sizeof(buf),timeout);
++ my_gets(buf,sizeof(buf),timeout);
+
+ if (buf[0] == 0) {
+ prompt = 0;
+diff -wurN orig/loader/parse_config.h debian/loader/parse_config.h
+--- orig/loader/parse_config.h 1970-01-01 01:00:00.000000000 +0100
++++ debian/loader/parse_config.h 2004-07-25 14:10:59.000000000 +0200
+@@ -0,0 +1,53 @@
++/* $Id: parse_config.h,v 1.4 2003/05/30 00:42:38 cgd Exp $ */
++
++/*
++ * Copyright 2001, 2003
++ * Broadcom Corporation. All rights reserved.
++ *
++ * This software is furnished under license and may be used and copied only
++ * in accordance with the following terms and conditions. Subject to these
++ * conditions, you may download, copy, install, use, modify and distribute
++ * modified or unmodified copies of this software in source and/or binary
++ * form. No title or ownership is transferred hereby.
++ *
++ * 1) Any source code used, modified or distributed must reproduce and
++ * retain this copyright notice and list of conditions as they appear in
++ * the source file.
++ *
++ * 2) No right is granted to use any trade name, trademark, or logo of
++ * Broadcom Corporation. The "Broadcom Corporation" name may not be
++ * used to endorse or promote products derived from this software
++ * without the prior written permission of Broadcom Corporation.
++ *
++ * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR IMPLIED
++ * WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED WARRANTIES OF
++ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
++ * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL BROADCOM BE LIABLE
++ * FOR ANY DAMAGES WHATSOEVER, AND IN PARTICULAR, BROADCOM SHALL NOT BE
++ * LIABLE FOR DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
++ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
++ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
++ * OR OTHERWISE), EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
++ */
++
++/*
++ * Parse a config file.
++ */
++
++#ifndef _PARSE_CONFIG_H
++#define _PARSE_CONFIG_H
++
++typedef struct boot_config_struct {
++ char *kernel;
++ char *initrd;
++ char *extra_args;
++ char *root_dev;
++} boot_config_t;
++
++extern boot_config_t *boot_config;
++
++void parse_config_buf(char *buf);
++
++#endif
+diff -wurN orig/loader/partition.c debian/loader/partition.c
+--- orig/loader/partition.c 2003-05-30 02:42:37.000000000 +0200
++++ debian/loader/partition.c 2004-07-25 14:10:59.000000000 +0200
+@@ -33,10 +33,10 @@
+ */
+
+ #include "partition.h"
++#include "port.h"
+ #include "cfe_api.h"
+ #include "libc.h"
+
+-
+ /*
+ * Recurse down the current chain of partitions. Return 0 if found, nonzero otherwise
+ */
+diff -wurN orig/loader/partition.h debian/loader/partition.h
+--- orig/loader/partition.h 1970-01-01 01:00:00.000000000 +0100
++++ debian/loader/partition.h 2004-07-25 14:10:59.000000000 +0200
+@@ -0,0 +1,61 @@
++/* $Id: partition.h,v 1.3 2003/05/30 00:42:38 cgd Exp $ */
++
++/*
++ * Copyright 2001, 2003
++ * Broadcom Corporation. All rights reserved.
++ *
++ * This software is furnished under license and may be used and copied only
++ * in accordance with the following terms and conditions. Subject to these
++ * conditions, you may download, copy, install, use, modify and distribute
++ * modified or unmodified copies of this software in source and/or binary
++ * form. No title or ownership is transferred hereby.
++ *
++ * 1) Any source code used, modified or distributed must reproduce and
++ * retain this copyright notice and list of conditions as they appear in
++ * the source file.
++ *
++ * 2) No right is granted to use any trade name, trademark, or logo of
++ * Broadcom Corporation. The "Broadcom Corporation" name may not be
++ * used to endorse or promote products derived from this software
++ * without the prior written permission of Broadcom Corporation.
++ *
++ * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR IMPLIED
++ * WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED WARRANTIES OF
++ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
++ * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL BROADCOM BE LIABLE
++ * FOR ANY DAMAGES WHATSOEVER, AND IN PARTICULAR, BROADCOM SHALL NOT BE
++ * LIABLE FOR DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
++ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
++ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
++ * OR OTHERWISE), EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
++ */
++
++#ifndef _PARTITION_H
++#define _PARTITION_H
++
++/*
++ * Routines for dealing with partitions
++ */
++
++#include <stdint.h>
++
++typedef struct {
++ unsigned char active;
++ unsigned char start_chs[3];
++ unsigned char id;
++ unsigned char end_chs[3];
++ uint32_t start_sector;
++ uint32_t size;
++} part_entry_t;
++
++
++/* Take a CFE handle and read the partition table, returning
++ the linear offset of the desired partion or -1 for failure
++*/
++int part_get_info(int handle, int partno, part_entry_t *part_info);
++
++
++
++#endif
+diff -wurN orig/loader/port.h debian/loader/port.h
+--- orig/loader/port.h 1970-01-01 01:00:00.000000000 +0100
++++ debian/loader/port.h 2004-07-25 14:10:59.000000000 +0200
+@@ -0,0 +1,93 @@
++/* $Id: port.h,v 1.10 2003/11/17 20:54:52 kwalker Exp $ */
++
++/*
++ * Copyright 2001, 2003
++ * Broadcom Corporation. All rights reserved.
++ *
++ * This software is furnished under license and may be used and copied only
++ * in accordance with the following terms and conditions. Subject to these
++ * conditions, you may download, copy, install, use, modify and distribute
++ * modified or unmodified copies of this software in source and/or binary
++ * form. No title or ownership is transferred hereby.
++ *
++ * 1) Any source code used, modified or distributed must reproduce and
++ * retain this copyright notice and list of conditions as they appear in
++ * the source file.
++ *
++ * 2) No right is granted to use any trade name, trademark, or logo of
++ * Broadcom Corporation. The "Broadcom Corporation" name may not be
++ * used to endorse or promote products derived from this software
++ * without the prior written permission of Broadcom Corporation.
++ *
++ * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR IMPLIED
++ * WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED WARRANTIES OF
++ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
++ * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL BROADCOM BE LIABLE
++ * FOR ANY DAMAGES WHATSOEVER, AND IN PARTICULAR, BROADCOM SHALL NOT BE
++ * LIABLE FOR DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
++ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
++ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
++ * OR OTHERWISE), EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
++ */
++
++#ifndef PORT_H
++#define PORT_H
++
++#ifdef __linux__
++#include <stdint.h>
++#else /* !__linux__ */
++typedef unsigned char uint8_t;
++typedef signed char int8_t;
++typedef unsigned short uint16_t;
++typedef signed short int16_t;
++typedef unsigned int uint32_t;
++typedef signed int int32_t;
++typedef unsigned long long uint64_t;
++typedef signed long long int64_t;
++
++#define unsigned signed /* Kludge to get unsigned size-shaped type. */
++typedef __SIZE_TYPE__ intptr_t;
++#undef unsigned
++typedef __SIZE_TYPE__ uintptr_t;
++
++#define UINT64_C(arg) (arg ## ULL)
++#define UINT32_MAX (0xffffffffU)
++
++#endif /* __linux__ */
++
++
++uint16_t port_swap_16(uint16_t src);
++uint32_t port_swap_32(uint32_t src);
++uint64_t port_swap_64(uint64_t src);
++
++#ifdef __MIPSEL__
++#define cpu_to_le16(foo) (foo)
++#define cpu_to_le32(foo) (foo)
++#define cpu_to_le64(foo) (foo)
++#define cpu_to_be16(foo) port_swap_16(foo)
++#define cpu_to_be32(foo) port_swap_32(foo)
++#define cpu_to_be64(foo) port_swap_64(foo)
++#define le_to_cpu16(foo) (foo)
++#define le_to_cpu32(foo) (foo)
++#define le_to_cpu64(foo) (foo)
++#define be_to_cpu16(foo) port_swap_16(foo)
++#define be_to_cpu32(foo) port_swap_32(foo)
++#define be_to_cpu64(foo) port_swap_64(foo)
++#else
++#define cpu_to_le16(foo) port_swap_16(foo)
++#define cpu_to_le32(foo) port_swap_32(foo)
++#define cpu_to_le64(foo) port_swap_64(foo)
++#define cpu_to_be16(foo) (foo)
++#define cpu_to_be32(foo) (foo)
++#define cpu_to_be64(foo) (foo)
++#define le_to_cpu16(foo) port_swap_16(foo)
++#define le_to_cpu32(foo) port_swap_32(foo)
++#define le_to_cpu64(foo) port_swap_64(foo)
++#define be_to_cpu16(foo) (foo)
++#define be_to_cpu32(foo) (foo)
++#define be_to_cpu64(foo) (foo)
++#endif
++
++#endif
+diff -wurN orig/loader/stringops.c debian/loader/stringops.c
+--- orig/loader/stringops.c 1970-01-01 01:00:00.000000000 +0100
++++ debian/loader/stringops.c 2004-07-25 14:10:59.000000000 +0200
+@@ -0,0 +1,216 @@
++/*
++ * This file is licensed under the terms of the GNU General Public License,
++ * version 2. See the file COPYING in the main directory for details.
++ *
++ * Slooow, but small string operations, so that we don't have to link lib in.
++ * Originally from linux/lib/string.c, which is
++ * Copyright (C) 1991, 1992 Linus Torvalds
++ *
++ * Added I/O functions for libcom_err.
++ *
++ * Copyright (C) 2003,2004 Thiemo Seufer <seufer@csv.ica.uni-stuttgart.de>
++ */
++
++#include "libc.h"
++
++void *memset(void *s, int c, unsigned long count)
++{
++ return lib_memset(s, c, count);
++}
++
++void *memcpy(void *dest, const void *src, unsigned long count)
++{
++ return lib_memcpy(dest, src, count);
++}
++
++int memcmp(const void *cs, const void *ct, unsigned long count)
++{
++ return lib_memcmp(cs, ct, count);
++}
++
++char *strcpy(char *dest, const char *src)
++{
++ return lib_strcpy(dest, src);
++}
++
++char *strncpy(char *dest, const char *src, int count)
++{
++ return lib_strncpy(dest, src, count);
++}
++
++char *strcat(char *dest, const char *src)
++{
++ return lib_strcat(dest, src);
++}
++
++char *strncat(char *dest, const char *src, int n)
++{
++ char *tmp = dest;
++ while (*dest) dest++;
++ while (n && (*dest++ = *src++) != '\0') n--;
++ if (!n) *dest = 0;
++ return tmp;
++}
++
++int strcmp(const char *cs, const char *ct)
++{
++ return lib_strcmp(cs, ct);
++}
++
++int strncmp(const char *cs, const char *ct, int count)
++{
++ return lib_strncmp(cs, ct, count);
++}
++
++char *strchr(const char *s, int c)
++{
++ for(; *s != (char) c; ++s)
++ if (*s == '\0')
++ return 0;
++ return (char *) s;
++}
++
++char *strrchr(const char *s, int c)
++{
++ const char *p = s + lib_strlen(s);
++ do {
++ if (*p == (char)c)
++ return (char *)p;
++ } while (--p >= s);
++ return 0;
++}
++
++unsigned int strlen(const char *s)
++{
++ return lib_strlen(s);
++}
++
++char *strdup(const char *str)
++{
++ return lib_strdup(str);
++}
++
++int tolower(int c)
++{
++ return lib_tolower(c);
++}
++
++int strcasecmp(const char *cs, const char *ct)
++{
++ register signed char __res;
++ while (1)
++ if ((__res = lib_tolower(*cs) - lib_tolower(*ct++)) != 0 || !*cs++)
++ break;
++ return __res;
++}
++
++int strncasecmp(const char *cs, const char *ct, unsigned long n)
++{
++ register signed char __res = 0;
++ while (n--)
++ if ((__res = lib_tolower(*cs) - lib_tolower(*ct++)) != 0 || !*cs++)
++ break;
++ return __res;
++}
++
++char *strstr(const char *s1, const char *s2)
++{
++ int l1, l2;
++
++ l2 = lib_strlen(s2);
++ if (!l2)
++ return (char *) s1;
++ l1 = lib_strlen(s1);
++ while (l1 >= l2) {
++ l1--;
++ if (!lib_memcmp(s1,s2,l2))
++ return (char *) s1;
++ s1++;
++ }
++ return 0;
++}
++
++int isdigit(char c)
++{
++ return lib_isdigit(c);
++}
++
++/* Not a string op, and we don't support it. */
++typedef int time_t;
++
++time_t time(time_t *result)
++{
++ if (result)
++ *result = -1;
++ return -1;
++}
++
++/* libcom_err wants to have some stdio functions. */
++typedef int FILE;
++FILE *stderr;
++
++int fputc(int c, FILE *stream)
++{
++ lib_putc(c);
++ return 0;
++}
++
++int fputs(const char *s, FILE *stream)
++{
++ lib_printf("%s", s);
++ return 1;
++}
++
++unsigned long fwrite(const void *ptr, unsigned long size, unsigned long nmemb, FILE *stream)
++{
++ unsigned long i;
++ const char *p = (char *)ptr;
++
++ for (i = 0; i < (size * nmemb); i++)
++ lib_putc(*p++);
++
++ return nmemb;
++}
++
++int vfprintf(FILE *stream, const char *format, va_list ap)
++{
++ lib_vprintf(format, ap);
++ return 0;
++}
++
++int fflush(FILE *stream)
++{
++ return 0;
++}
++
++/* We don't support this */
++char *strerror(int errno)
++{
++ return 0;
++}
++
++unsigned long long my_strtoull(const char *ptr)
++{
++ unsigned long long retval = 0;
++ unsigned int newdigit;
++
++ while(*ptr) {
++ if (*ptr >= 'a' && *ptr <= 'f') {
++ newdigit = *ptr - ('a' - 10);
++ } else if (*ptr >= 'A' && *ptr <= 'F') {
++ newdigit = *ptr - ('A' - 10);
++ } else if (*ptr >= '0' && *ptr <= '9') {
++ newdigit = *ptr - '0';
++ } else if (*ptr == ' '
++ || *ptr == '\t'
++ || *ptr == '\n') {
++ /* Just skip it */
++ } else {
++ return -1UL;
++ }
++ retval <<= 4;
++ retval |= newdigit;
++ ptr++;
++ }
++ return retval;
++}
+diff -wurN orig/loader/tftp_fileops.h debian/loader/tftp_fileops.h
+--- orig/loader/tftp_fileops.h 1970-01-01 01:00:00.000000000 +0100
++++ debian/loader/tftp_fileops.h 2004-07-25 14:10:59.000000000 +0200
+@@ -0,0 +1,42 @@
++/* $Id: tftp_fileops.h,v 1.4 2003/05/30 00:42:38 cgd Exp $ */
++
++/*
++ * Copyright 2001, 2003
++ * Broadcom Corporation. All rights reserved.
++ *
++ * This software is furnished under license and may be used and copied only
++ * in accordance with the following terms and conditions. Subject to these
++ * conditions, you may download, copy, install, use, modify and distribute
++ * modified or unmodified copies of this software in source and/or binary
++ * form. No title or ownership is transferred hereby.
++ *
++ * 1) Any source code used, modified or distributed must reproduce and
++ * retain this copyright notice and list of conditions as they appear in
++ * the source file.
++ *
++ * 2) No right is granted to use any trade name, trademark, or logo of
++ * Broadcom Corporation. The "Broadcom Corporation" name may not be
++ * used to endorse or promote products derived from this software
++ * without the prior written permission of Broadcom Corporation.
++ *
++ * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR IMPLIED
++ * WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED WARRANTIES OF
++ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
++ * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL BROADCOM BE LIABLE
++ * FOR ANY DAMAGES WHATSOEVER, AND IN PARTICULAR, BROADCOM SHALL NOT BE
++ * LIABLE FOR DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
++ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
++ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
++ * OR OTHERWISE), EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
++ */
++
++#ifndef _TFTP_FILEOPS_H
++#define _TFTP_FILEOPS_H
++
++#include "getfile.h"
++
++extern file_ops_t tftp_ops;
++
++#endif
--- sibyl-2.4.2.orig/debian/patches/05-initrd.dpatch
+++ sibyl-2.4.2/debian/patches/05-initrd.dpatch
@@ -0,0 +1,48 @@
+#! /bin/sh -e
+## initrd.dpatch by Peter De Schrijver <p2@mind.be>
+##
+## DP: patches to use the new commandline arguments for initrd
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch ${2:+-d $2}}"
+
+if [ $# -lt 1 ]; then
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1
+fi
+
+case "$1" in
+ -patch) patch $patch_opts -p1 < $0;;
+ -unpatch) patch $patch_opts -p1 -R < $0;;
+ *)
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1;;
+esac
+
+exit 0
+@DPATCH@
+
+--- sibyl-2.4.2/loader/main.c.old 2004-07-27 18:33:33.000000000 +0200
++++ sibyl-2.4.2/loader/main.c 2004-07-27 18:51:48.000000000 +0200
+@@ -188,13 +188,15 @@
+ char *ptr;
+ ramdisk_size = load_ramdisk(boot_config->initrd, initrd_start);
+ lib_free(boot_config->initrd);
+- boot_config->initrd = lib_malloc(36);
+- lib_strcpy(boot_config->initrd, "initrd=");
+- ptr = boot_config->initrd + 7;
+- ptr += lib_ultostr(ptr, ramdisk_size);
+- *ptr = '@';
++ boot_config->initrd = lib_malloc(39);
++ lib_strcpy(boot_config->initrd, "rd_start=0x");
++ ptr = boot_config->initrd + 11;
++ ptr += lib_ultostr(ptr, (unsigned long)initrd_start);
++ *ptr = ' ';
+ ptr++;
+- lib_ultostr(ptr, (unsigned long)initrd_start);
++ lib_strcpy(ptr, "rd_size=0x");
++ ptr += 10;
++ ptr += lib_ultostr(ptr, ramdisk_size);
+ }
+
+ /*
--- sibyl-2.4.2.orig/debian/patches/02-hosttools.dpatch
+++ sibyl-2.4.2/debian/patches/02-hosttools.dpatch
@@ -0,0 +1,265 @@
+#! /bin/sh -e
+## hosttools.dpatch by Thiemo Seufer <ica2_ts@csv.ica.uni-stuttgart.de>
+##
+## DP: patches to hosttools for installing sibyl
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch ${2:+-d $2}}"
+
+if [ $# -lt 1 ]; then
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1
+fi
+
+case "$1" in
+ -patch) patch $patch_opts -p1 < $0;;
+ -unpatch) patch $patch_opts -p1 -R < $0;;
+ *)
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1;;
+esac
+
+exit 0
+@DPATCH@
+
+diff -wurN orig/hosttools/docprep.c debian/hosttools/docprep.c
+--- orig/hosttools/docprep.c 2003-05-23 19:19:27.000000000 +0200
++++ debian/hosttools/docprep.c 1970-01-01 01:00:00.000000000 +0100
+@@ -1,118 +0,0 @@
+-/*
+- * This program will take an image and make a 32K page aligned file
+- * from the given source file so that we can write the EDC syndrom
+- * bytes to the DiskOnChip device using the M-Systems BDK.
+- *
+- * $Id: docprep.c,v 1.1 2003/05/23 17:19:27 mpl Exp $
+- *
+- */
+-#include <sys/types.h>
+-#include <sys/stat.h>
+-#include <fcntl.h>
+-#include <stdlib.h>
+-#include <stdio.h>
+-#include <string.h>
+-#include <stdlib.h>
+-#include <stdio.h>
+-
+-#define KBYTE 1024
+-#define BOUNDARY (32*KBYTE)
+-
+-
+-int
+-main(int argc, char *argv[])
+-{
+- int fh;
+- unsigned char* image;
+- unsigned char* padding;
+-
+- int totalsize = 0;
+- int pa, npages, padbytes;
+-
+-
+- if(argc != 3){
+-
+- printf("Usage: %s <infile> <outfile>\n",
+- argv[0]);
+- exit(1);
+-
+- }
+-
+- fh = open(argv[1],O_RDONLY);
+- if (fh < 0) {
+- perror(argv[1]);
+- }
+-
+- totalsize = lseek(fh,0L,SEEK_END);
+- lseek(fh,0L,SEEK_SET);
+-
+- image = (unsigned char*)malloc(totalsize);
+- if (image == NULL) {
+- perror("malloc");
+- exit(1);
+- }
+-
+- if (read(fh,image, totalsize) != totalsize) {
+- perror("read");
+- exit(1);
+- }
+-
+- close(fh);
+-
+- /*
+- * Now write the output file
+- */
+-
+- fh = open(argv[2],O_RDWR |O_CREAT |O_TRUNC,
+- S_IREAD|S_IWRITE|S_IRGRP|S_IWGRP|S_IROTH);
+- if (fh < 0) {
+- perror(argv[2]);
+- exit(1);
+- }
+-
+- if (write(fh,image,totalsize) != totalsize) {
+- perror(argv[2]);
+- exit(1);
+- }
+-
+- /* Workaround DiskOnChip (TM) binary partition loader page
+- * write issue. In order for DOC to compute ECC/EDC, you need
+- * to always write a page (32K) of data (minimum). If the
+- * image is not page aligned, we simply write N bytes of zeros
+- * at the end so that the DOC ASIC controller will correctly
+- * compute the ECC syndrome bytes and all will be good.
+- * Note that the PPCBoot loader will never read these bytes,
+- * we just put them there to keep the DOC asic controller happy.
+- *
+- */
+-
+- pa = (totalsize % BOUNDARY) == 0; /* True if 32K aligned */
+- npages = (totalsize / BOUNDARY) + (totalsize % BOUNDARY > 0);
+- padbytes = (npages*BOUNDARY - totalsize);
+-
+- if(!pa){
+- padding = (char*)malloc(padbytes);
+- memset(padding, 0x0, padbytes);
+- printf("Total Size: %d bytes (%d bytes aligned [%x]),"
+- "%d bytes pad)\n",
+- totalsize + padbytes,
+- npages*BOUNDARY,
+- npages*BOUNDARY,
+- padbytes);
+-
+- if (write(fh, padding, padbytes) != padbytes) {
+- perror(argv[2]);
+- exit(2);
+- }
+-
+- free(padding);
+- totalsize += padbytes;
+- }
+-
+- printf("Wrote %d bytes to %s\n",totalsize, argv[2]);
+-
+- close(fh);
+-
+- exit(0);
+-}
+-
+diff -wurN orig/hosttools/Makefile debian/hosttools/Makefile
+--- orig/hosttools/Makefile 2003-05-23 19:19:27.000000000 +0200
++++ debian/hosttools/Makefile 2004-07-25 14:10:59.000000000 +0200
+@@ -2,13 +2,16 @@
+ CC = gcc
+ CFLAGS = -I ../include
+
+-all : mkbootimage installboot
++PROGS = mkbootimage installboot
++
++
++all: $(PROGS)
+
+ mkbootimage : mkbootimage.c
+- $(CC) $(CFLAGS) -o mkbootimage mkbootimage.c
++ $(CC) $(CFLAGS) -o $@ $<
+
+ installboot : installboot.c
+- $(CC) $(CFLAGS) -o installboot installboot.c
++ $(CC) $(CFLAGS) -o $@ $<
+
+-docprep : docprep.c
+- $(CC) $(CFLAGS) -o docprep docprep.c
++clean:
++ -rm -f $(PROGS) *~ core
+diff -wurN orig/hosttools/makereg.c debian/hosttools/makereg.c
+--- orig/hosttools/makereg.c 2003-12-06 03:37:01.000000000 +0100
++++ debian/hosttools/makereg.c 2004-07-25 14:10:59.000000000 +0200
+@@ -389,7 +389,7 @@
+ }
+
+
+-void saveincfile(char *fname, char *header)
++void saveincfile(char *fname)
+ {
+ FILE *str;
+ int idx;
+@@ -402,11 +402,6 @@
+
+ fprintf(str,"\n\n");
+
+- if (header != NULL) {
+- fprintf(str, "#include \"%s\"\n", header);
+- fprintf(str,"\n\n");
+- }
+-
+ fprintf(str,"#ifndef %s\n",constants[0].name);
+ for (idx = 0; idx < constcnt; idx++) {
+ fprintf(str,"#define %s 0x%08X\n",constants[idx].name,
+@@ -461,8 +456,8 @@
+ FILE *str;
+ int idx;
+
+- if (argc != 3 && argc != 4) {
+- fprintf(stderr,"usage: makereg inputfile outputfile [header]\n");
++ if (argc != 3) {
++ fprintf(stderr,"usage: makereg inputfile outputfile\n");
+ exit(1);
+ }
+
+@@ -479,7 +474,7 @@
+
+ fprintf(stderr,"Total registers: %d\n",regcnt);
+
+- saveincfile(argv[2], argc > 3 ? argv[3] : NULL);
++ saveincfile(argv[2]);
+
+ exit(0);
+ return 0;
+diff -wurN orig/hosttools/mkflashimage.c debian/hosttools/mkflashimage.c
+--- orig/hosttools/mkflashimage.c 2004-03-08 18:26:54.000000000 +0100
++++ debian/hosttools/mkflashimage.c 2004-07-25 14:10:59.000000000 +0200
+@@ -70,10 +70,6 @@
+ int mlong64 = 0;
+ char boardname[32];
+
+-#ifndef O_BINARY
+-#define O_BINARY 0
+-#endif
+-
+ /*
+ * This is the offset in the flash where the little-endian image goes
+ * if we're making a bi-endian flash.
+@@ -213,7 +209,7 @@
+
+ if (verbose) fprintf(stderr,"Reading: %s\n",argv[2]);
+
+- fh = open(argv[2],O_RDONLY|O_BINARY);
++ fh = open(argv[2],O_RDONLY);
+ if (fh < 0) {
+ perror(argv[2]);
+ }
+@@ -244,7 +240,7 @@
+
+ if (verbose) fprintf(stderr,"Reading: %s\n",argv[1]);
+
+- fh = open(argv[1],O_RDONLY|O_BINARY);
++ fh = open(argv[1],O_RDONLY);
+ if (fh < 0) {
+ perror(argv[1]);
+ exit(1);
+@@ -273,7 +269,7 @@
+ if (big_endian) flags |= CFE_IMAGE_EB;
+ else flags |= CFE_IMAGE_EL;
+
+- fh = open(argv[1],O_RDONLY|O_BINARY);
++ fh = open(argv[1],O_RDONLY);
+ if (fh < 0) {
+ perror(argv[1]);
+ exit(1);
+@@ -326,7 +322,7 @@
+ * Now write the output file
+ */
+
+- fh = open(outfile,O_RDWR|O_CREAT|O_TRUNC,S_IREAD|S_IWRITE|S_IRGRP|S_IWGRP|S_IROTH|O_BINARY);
++ fh = open(outfile,O_RDWR|O_CREAT|O_TRUNC,S_IREAD|S_IWRITE|S_IRGRP|S_IWGRP|S_IROTH);
+ if (fh < 0) {
+ perror(outfile);
+ exit(1);
--- sibyl-2.4.2.orig/debian/patches/03-include.dpatch
+++ sibyl-2.4.2/debian/patches/03-include.dpatch
@@ -0,0 +1,851 @@
+#! /bin/sh -e
+## include.dpatch by Thiemo Seufer <ica2_ts@csv.ica.uni-stuttgart.de>
+##
+## DP: patches to include files for building sibyl
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch ${2:+-d $2}}"
+
+if [ $# -lt 1 ]; then
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1
+fi
+
+case "$1" in
+ -patch) patch $patch_opts -p1 < $0;;
+ -unpatch) patch $patch_opts -p1 -R < $0;;
+ *)
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1;;
+esac
+
+exit 0
+@DPATCH@
+
+diff -wurN orig/include/cfe_bootblock.h debian/include/cfe_bootblock.h
+--- orig/include/cfe_bootblock.h 2004-02-09 22:24:54.000000000 +0100
++++ debian/include/cfe_bootblock.h 2004-07-25 14:10:59.000000000 +0200
+@@ -100,15 +100,15 @@
+ * Fields within the boot block
+ */
+ #define _U64(x) ((uint64_t) x)
+-#define BOOT_MAGIC_NUMBER _U64(0x43465631424f4f54ULL)
+-#define BOOT_HDR_CHECKSUM_MASK _U64(0x00000000FFFFFFFFULL)
+-#define BOOT_HDR_VER_MASK _U64(0x000000FF00000000ULL)
++#define BOOT_MAGIC_NUMBER _U64(0x43465631424f4f54)
++#define BOOT_HDR_CHECKSUM_MASK _U64(0x00000000FFFFFFFF)
++#define BOOT_HDR_VER_MASK _U64(0x000000FF00000000)
+ #define BOOT_HDR_VER_SHIFT 32
+-#define BOOT_HDR_FLAGS_MASK _U64(0xFF00000000000000ULL)
+-#define BOOT_SECSIZE_MASK _U64(0x00000000FFFFFFFFULL)
+-#define BOOT_DATA_CHECKSUM_MASK _U64(0xFFFFFFFF00000000ULL)
++#define BOOT_HDR_FLAGS_MASK _U64(0xFF00000000000000)
++#define BOOT_SECSIZE_MASK _U64(0x00000000FFFFFFFF)
++#define BOOT_DATA_CHECKSUM_MASK _U64(0xFFFFFFFF00000000)
+ #define BOOT_DATA_CHECKSUM_SHIFT 32
+-#define BOOT_ARCHINFO_MASK _U64(0x00000000FFFFFFFFULL)
++#define BOOT_ARCHINFO_MASK _U64(0x00000000FFFFFFFF)
+
+ #define BOOT_HDR_VERSION 1
+
+diff -wurN orig/include/cfe_crypto.h debian/include/cfe_crypto.h
+--- orig/include/cfe_crypto.h 2003-09-04 22:15:10.000000000 +0200
++++ debian/include/cfe_crypto.h 1970-01-01 01:00:00.000000000 +0100
+@@ -1,129 +0,0 @@
+-/* *********************************************************************
+- * Broadcom Common Firmware Environment (CFE)
+- *
+- * Crypto IOCTL definitions File: cfe_crypto.h
+- *
+- * IOCTL function numbers and I/O data structures for communicating
+- * with BlueSteel/Broadcom BCM582x crypto engines.
+- *
+- *********************************************************************
+- *
+- * Copyright 2003
+- * Broadcom Corporation. All rights reserved.
+- *
+- * This software is furnished under license and may be used and
+- * copied only in accordance with the following terms and
+- * conditions. Subject to these conditions, you may download,
+- * copy, install, use, modify and distribute modified or unmodified
+- * copies of this software in source and/or binary form. No title
+- * or ownership is transferred hereby.
+- *
+- * 1) Any source code used, modified or distributed must reproduce
+- * and retain this copyright notice and list of conditions
+- * as they appear in the source file.
+- *
+- * 2) No right is granted to use any trade name, trademark, or
+- * logo of Broadcom Corporation. The "Broadcom Corporation"
+- * name may not be used to endorse or promote products derived
+- * from this software without the prior written permission of
+- * Broadcom Corporation.
+- *
+- * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR
+- * IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED
+- * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+- * PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT
+- * SHALL BROADCOM BE LIABLE FOR ANY DAMAGES WHATSOEVER, AND IN
+- * PARTICULAR, BROADCOM SHALL NOT BE LIABLE FOR DIRECT, INDIRECT,
+- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+- * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+- * TORT (INCLUDING NEGLIGENCE OR OTHERWISE), EVEN IF ADVISED OF
+- * THE POSSIBILITY OF SUCH DAMAGE.
+- ********************************************************************* */
+-
+-#ifndef _CFE_CRYPTO_H_
+-#define _CFE_CRYPTO_H_
+-
+-#define _DD_MAKEMASK1(n) (1 << (n))
+-#define _DD_MAKEMASK(v,n) ((((1)<<(v))-1) << (n))
+-#define _DD_MAKEVALUE(v,n) ((v) << (n))
+-#define _DD_GETVALUE(v,n,m) (((v) & (m)) >> (n))
+-
+-/* *********************************************************************
+- * Crypto stuff
+- ********************************************************************* */
+-
+-#define IOCTL_CRYPTO_GETINFO 0 /* return crypto_info_t */
+-#define IOCTL_CRYPTO_CMD_1 1 /* run a 582x MCR1 command */
+-#define IOCTL_CRYPTO_CMD_2 2 /* run a 582x MCR2 command */
+-
+-typedef enum {
+- BCM5820,
+- BCM5821,
+- BCM5822,
+- BCM5823
+-} bs_chip_type;
+-
+-typedef struct crypto_info_s {
+- bs_chip_type chip;
+-} crypto_info_t;
+-
+-
+-/*
+- The CMD IOCTL's expect pointers to records describing the crypto
+- operation to be carried out. Such records are passed directly to
+- the corresponding device (see chip_type) and are limited to its
+- capabilities, which vary somewhat among the chip types.
+-
+- Formats of 582x Command Record fields follow.
+-*/
+-
+-/* Master Command Record Header Format */
+-
+-#define S_MCR_NUM_PACKETS 0
+-#define M_MCR_NUM_PACKETS _DD_MAKEMASK(16,S_MCR_NUM_PACKETS)
+-#define V_MCR_NUM_PACKETS(x) _DD_MAKEVALUE(x,S_MCR_NUM_PACKETS)
+-#define G_MCR_NUM_PACKETS(x) _DD_GETVALUE(x,S_MCR_NUM_PACKETS,M_MCR_NUM_PACKETS)
+-
+-/* Input flags */
+-
+-#define M_MCR_SUPPRESS_INTR _DD_MAKEMASK1(31)
+-
+-/* Output flags */
+-
+-#define M_MCR_DONE _DD_MAKEMASK1(16)
+-#define M_MCR_ERROR _DD_MAKEMASK1(17)
+-
+-#define S_MCR_ERROR_CODE 24
+-#define M_MCR_ERROR_CODE _DD_MAKEMASK(8,S_MCR_ERROR_CODE)
+-#define V_MCR_ERROR_CODE(x) _DD_MAKEVALUE(x,S_MCR_ERROR_CODE)
+-#define G_MCR_ERROR_CODE(x) _DD_GETVALUE(x,S_MCR_ERROR_CODE,M_MCR_ERROR_CODE)
+-#define K_MCR_ERROR_OK 0
+-#define K_MCR_ERROR_UNKNOWN_OP 1
+-#define K_MCR_ERROR_DSA_SHORT 2
+-#define K_MCR_ERROR_PKI_SHORT 3
+-#define K_MCR_ERROR_PKO_SHORT 4 /* Not 5820 */
+-#define K_MCR_ERROR_CHAIN_SHORT 5 /* Not 5820 */
+-#define K_MCR_ERROR_FIFO 6 /* Not 5820 */
+-
+-/* In both cases, the header word is followed by an array of N PD entries:
+- commandContext[0]
+- dataBuffer[0]
+- pktLen[0]
+- outputBuffer[0]
+- ...
+- commandContext[n-1]
+- dataBuffer[n-1]
+- pktLen[n-1]
+- outputBuffer[n-1]
+-*/
+-
+-#define MCR_WORDS(n) (1+8*(n))
+-#define MCR_BYTES(n) ((1+8*(n))*4)
+-
+-
+-/* Descriptions of PDs to be added. */
+-
+-#endif /* _CFE_CRYPTO_H_ */
+diff -wurN orig/include/cfe_irq.h debian/include/cfe_irq.h
+--- orig/include/cfe_irq.h 2003-12-31 22:16:20.000000000 +0100
++++ debian/include/cfe_irq.h 2004-07-25 14:10:59.000000000 +0200
+@@ -62,6 +62,8 @@
+ * Constants
+ ********************************************************************* */
+
++#define NR_IRQS 64
++
+ #define CFE_IRQ_FLAGS_SHARED 0x1
+
+ /* *********************************************************************
+diff -wurN orig/include/cfe_mem.h debian/include/cfe_mem.h
+--- orig/include/cfe_mem.h 2003-08-01 00:54:39.000000000 +0200
++++ debian/include/cfe_mem.h 2004-07-25 14:10:59.000000000 +0200
+@@ -60,8 +60,6 @@
+ #define MEMTYPE_L2CACHE 7
+ #define MEMTYPE_LDT_PCI 8
+ #define MEMTYPE_DRAM_BOOTPROGRAM 9
+-#define MEMTYPE_DRAM_MANUALLY_RESERVED 10
+-#define MEMTYPE_MAX 10
+
+ /* *********************************************************************
+ * External data
+diff -wurN orig/include/cfe_smbus.h debian/include/cfe_smbus.h
+--- orig/include/cfe_smbus.h 2003-12-03 18:23:44.000000000 +0100
++++ debian/include/cfe_smbus.h 1970-01-01 01:00:00.000000000 +0100
+@@ -1,90 +0,0 @@
+-/* *********************************************************************
+- * Broadcom Common Firmware Environment (CFE)
+- *
+- * Common SMBus definitions File: cfe_smbus.h
+- *
+- * Driver common data structures for SMBus devices. The
+- * higher-level (device-specific) SMBus drivers talk to this, and
+- * via these structures we end up at platofrm-specific SMbus
+- * handlers.
+- *
+- * Author: Mitch Lichtenberg
+- *
+- *********************************************************************
+- *
+- * Copyright 2000,2001,2002,2003
+- * Broadcom Corporation. All rights reserved.
+- *
+- * This software is furnished under license and may be used and
+- * copied only in accordance with the following terms and
+- * conditions. Subject to these conditions, you may download,
+- * copy, install, use, modify and distribute modified or unmodified
+- * copies of this software in source and/or binary form. No title
+- * or ownership is transferred hereby.
+- *
+- * 1) Any source code used, modified or distributed must reproduce
+- * and retain this copyright notice and list of conditions
+- * as they appear in the source file.
+- *
+- * 2) No right is granted to use any trade name, trademark, or
+- * logo of Broadcom Corporation. The "Broadcom Corporation"
+- * name may not be used to endorse or promote products derived
+- * from this software without the prior written permission of
+- * Broadcom Corporation.
+- *
+- * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR
+- * IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED
+- * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+- * PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT
+- * SHALL BROADCOM BE LIABLE FOR ANY DAMAGES WHATSOEVER, AND IN
+- * PARTICULAR, BROADCOM SHALL NOT BE LIABLE FOR DIRECT, INDIRECT,
+- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+- * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+- * TORT (INCLUDING NEGLIGENCE OR OTHERWISE), EVEN IF ADVISED OF
+- * THE POSSIBILITY OF SUCH DAMAGE.
+- ********************************************************************* */
+-
+-
+-typedef struct cfe_smbus_channel_s cfe_smbus_channel_t;
+-typedef struct cfe_smbus_s cfe_smbus_t;
+-
+-struct cfe_smbus_s {
+- /* Attach channel */
+- cfe_smbus_channel_t * (*attach)(cfe_smbus_t *,uint64_t probe_a,uint64_t probe_b);
+- /* initialize channel */
+- int (*init)(cfe_smbus_channel_t *chan);
+- /* Write 'n' bytes to device (stop condition after write) */
+- int (*write)(cfe_smbus_channel_t *chan,uint8_t slave,uint8_t *buf,int len);
+- /* Read 'n' bytes from device (stop condition after each read) */
+- int (*read)(cfe_smbus_channel_t *chan,uint8_t slave,uint8_t *buf,int len);
+- /* Transaction: Write 1 byte and read 'n' bytes (no stop between write and read) */
+- int (*xact)(cfe_smbus_channel_t *chan,uint8_t slave,uint8_t cmd,uint8_t *buf,int len);
+- /* Quick command */
+- int (*qcmd)(cfe_smbus_channel_t *chan,uint8_t slave,int rw);
+-};
+-
+-#define SMBUS_QCMD_R 0
+-#define SMBUS_QCMD_W 1
+-
+-struct cfe_smbus_channel_s {
+- cfe_smbus_t *ops;
+- void *softc;
+-};
+-
+-#define SMBUS_CHANNELS_MAX 4
+-
+-extern cfe_smbus_channel_t *cfe_smbus_channels[SMBUS_CHANNELS_MAX];
+-
+-#define SMBUS_CHANNEL(chanidx) cfe_smbus_channels[chanidx]
+-#define SMBUS_INIT(chan) (chan)->ops->init(chan)
+-#define SMBUS_READ(chan,slave,buf,len) (chan)->ops->read(chan,slave,buf,len)
+-#define SMBUS_WRITE(chan,slave,buf,len) (chan)->ops->write(chan,slave,buf,len)
+-#define SMBUS_XACT(chan,slave,cmd,buf,len) (chan)->ops->xact(chan,slave,cmd,buf,len)
+-#define SMBUS_QCMD(chan,slave,rw) (chan)->ops->qcmd(chan,slave,rw);
+-
+-int cfe_add_smbus(cfe_smbus_t *ops,uint64_t probe_a,uint64_t probe_b);
+-
+-
+diff -wurN orig/include/cfe_timer.h debian/include/cfe_timer.h
+--- orig/include/cfe_timer.h 2003-07-14 15:59:19.000000000 +0200
++++ debian/include/cfe_timer.h 2004-07-25 14:10:59.000000000 +0200
+@@ -59,7 +59,7 @@
+
+ void cfe_timer_init(void);
+ extern volatile int64_t cfe_ticks;
+-extern unsigned int cfe_cpu_speed;
++extern int cfe_cpu_speed;
+
+ void cfe_sleep(int ticks);
+ void cfe_usleep(int usec);
+diff -wurN orig/include/config.h debian/include/config.h
+--- orig/include/config.h 1970-01-01 01:00:00.000000000 +0100
++++ debian/include/config.h 2004-07-25 14:10:59.000000000 +0200
+@@ -0,0 +1,47 @@
++/* $Id: config.h,v 1.4 2003/05/30 00:42:38 cgd Exp $ */
++
++/*
++ * Copyright 2001, 2003
++ * Broadcom Corporation. All rights reserved.
++ *
++ * This software is furnished under license and may be used and copied only
++ * in accordance with the following terms and conditions. Subject to these
++ * conditions, you may download, copy, install, use, modify and distribute
++ * modified or unmodified copies of this software in source and/or binary
++ * form. No title or ownership is transferred hereby.
++ *
++ * 1) Any source code used, modified or distributed must reproduce and
++ * retain this copyright notice and list of conditions as they appear in
++ * the source file.
++ *
++ * 2) No right is granted to use any trade name, trademark, or logo of
++ * Broadcom Corporation. The "Broadcom Corporation" name may not be
++ * used to endorse or promote products derived from this software
++ * without the prior written permission of Broadcom Corporation.
++ *
++ * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR IMPLIED
++ * WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED WARRANTIES OF
++ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
++ * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL BROADCOM BE LIABLE
++ * FOR ANY DAMAGES WHATSOEVER, AND IN PARTICULAR, BROADCOM SHALL NOT BE
++ * LIABLE FOR DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
++ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
++ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
++ * OR OTHERWISE), EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
++ */
++
++#ifndef _CONFIG_H
++#define _CONFIG_H
++
++/* Network support */
++#ifndef CONFIG_BLOCKDEV
++#define CONFIG_NETWORK
++#endif
++
++/* Support for booting from block devices (Currently broken) */
++//#define CONFIG_BLOCKDEV
++
++#endif
++
+diff -wurN orig/include/console.h debian/include/console.h
+--- orig/include/console.h 1970-01-01 01:00:00.000000000 +0100
++++ debian/include/console.h 2004-07-25 14:10:59.000000000 +0200
+@@ -0,0 +1,41 @@
++/* $Id: console.h,v 1.3 2003/05/30 00:42:38 cgd Exp $ */
++
++/*
++ * Copyright 2001, 2003
++ * Broadcom Corporation. All rights reserved.
++ *
++ * This software is furnished under license and may be used and copied only
++ * in accordance with the following terms and conditions. Subject to these
++ * conditions, you may download, copy, install, use, modify and distribute
++ * modified or unmodified copies of this software in source and/or binary
++ * form. No title or ownership is transferred hereby.
++ *
++ * 1) Any source code used, modified or distributed must reproduce and
++ * retain this copyright notice and list of conditions as they appear in
++ * the source file.
++ *
++ * 2) No right is granted to use any trade name, trademark, or logo of
++ * Broadcom Corporation. The "Broadcom Corporation" name may not be
++ * used to endorse or promote products derived from this software
++ * without the prior written permission of Broadcom Corporation.
++ *
++ * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR IMPLIED
++ * WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED WARRANTIES OF
++ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
++ * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL BROADCOM BE LIABLE
++ * FOR ANY DAMAGES WHATSOEVER, AND IN PARTICULAR, BROADCOM SHALL NOT BE
++ * LIABLE FOR DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
++ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
++ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
++ * OR OTHERWISE), EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
++ */
++
++#ifndef _CONSOLE_H
++#define _CONSOLE_H
++
++void console_print(char *string);
++int open_console();
++
++#endif
+diff -wurN orig/include/elf.h debian/include/elf.h
+--- orig/include/elf.h 2003-07-22 17:06:00.000000000 +0200
++++ debian/include/elf.h 2004-07-25 14:10:59.000000000 +0200
+@@ -71,9 +71,6 @@
+ #define EM_88K 5 /* Motorola m88k family */
+ #define EM_860 7 /* Intel 80860 */
+ #define EM_MIPS 8 /* MIPS R3000 */
+-#define EM_PPC 20 /* PowerPC */
+-#define EM_PPC64 21 /* PowerPC (64-bit) */
+-#define EM_ARM 40 /* ARM */
+
+ /* e_version */
+ #define EV_NONE 0 /* Invalid ELF version */
+diff -wurN orig/include/env_subr.h debian/include/env_subr.h
+--- orig/include/env_subr.h 2004-01-20 02:53:44.000000000 +0100
++++ debian/include/env_subr.h 2004-07-25 14:10:59.000000000 +0200
+@@ -100,8 +100,6 @@
+ #define ENV_FLG_BUILTIN 0x01 /* builtin - not stored in flash */
+ #define ENV_FLG_READONLY 0x02 /* read-only - cannot be changed */
+
+-#define ENV_FLG_STARTUP_NORUN 0x04 /* Do not issue commands in STARTUP */
+-
+ #define ENV_FLG_MASK 0xFF /* mask of attributes we keep */
+ #define ENV_FLG_ADMIN 0x100 /* lets us internally override permissions */
+
+@@ -116,6 +114,4 @@
+ int env_save(void);
+ int env_enum(int idx,char *name,int *namelen,char *val,int *vallen);
+ int env_envtype(const char *name);
+-int env_setflags(const char *name,int flags);
+-
+
+diff -wurN orig/include/getfile.h debian/include/getfile.h
+--- orig/include/getfile.h 1970-01-01 01:00:00.000000000 +0100
++++ debian/include/getfile.h 2004-07-25 14:10:59.000000000 +0200
+@@ -0,0 +1,60 @@
++/* $Id: getfile.h,v 1.6 2003/05/30 00:42:38 cgd Exp $ */
++
++/*
++ * Copyright 2001, 2003
++ * Broadcom Corporation. All rights reserved.
++ *
++ * This software is furnished under license and may be used and copied only
++ * in accordance with the following terms and conditions. Subject to these
++ * conditions, you may download, copy, install, use, modify and distribute
++ * modified or unmodified copies of this software in source and/or binary
++ * form. No title or ownership is transferred hereby.
++ *
++ * 1) Any source code used, modified or distributed must reproduce and
++ * retain this copyright notice and list of conditions as they appear in
++ * the source file.
++ *
++ * 2) No right is granted to use any trade name, trademark, or logo of
++ * Broadcom Corporation. The "Broadcom Corporation" name may not be
++ * used to endorse or promote products derived from this software
++ * without the prior written permission of Broadcom Corporation.
++ *
++ * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR IMPLIED
++ * WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED WARRANTIES OF
++ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
++ * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL BROADCOM BE LIABLE
++ * FOR ANY DAMAGES WHATSOEVER, AND IN PARTICULAR, BROADCOM SHALL NOT BE
++ * LIABLE FOR DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
++ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
++ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
++ * OR OTHERWISE), EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
++ */
++
++#ifndef _GETFILE_H
++#define _GETFILE_H
++
++#include "port.h"
++
++typedef enum {
++ GF_SEEK_SET,
++ GF_SEEK_CUR
++} file_handler_whence_t;
++
++
++typedef struct {
++ void *(*open)(char *loc);
++ int32_t (*seek)(void *private, int32_t ofs, file_handler_whence_t whence);
++ int32_t (*read)(void *private, void *buf, int32_t amount);
++ void (*close)(void *private);
++} file_ops_t;
++
++
++int file_handler_add(file_ops_t *ops);
++void file_handler_del(file_ops_t *ops);
++file_ops_t *file_handler_find(char *name, void **data);
++void file_handler_close(file_ops_t *ops,void *priv);
++
++
++#endif
+diff -wurN orig/include/jedec.h debian/include/jedec.h
+--- orig/include/jedec.h 2003-12-13 19:18:44.000000000 +0100
++++ debian/include/jedec.h 1970-01-01 01:00:00.000000000 +0100
+@@ -1,105 +0,0 @@
+-/* *********************************************************************
+- * Broadcom Common Firmware Environment (CFE)
+- *
+- * JEDEC DRAM constants File: jedec.h
+- *
+- * Constants and macros mostly related to JEDEC serial-presence
+- * detect ROMs on DIMMs
+- *
+- * Author: Mitch Lichtenberg
+- *
+- *********************************************************************
+- *
+- * Copyright 2000,2001,2002,2003
+- * Broadcom Corporation. All rights reserved.
+- *
+- * This software is furnished under license and may be used and
+- * copied only in accordance with the following terms and
+- * conditions. Subject to these conditions, you may download,
+- * copy, install, use, modify and distribute modified or unmodified
+- * copies of this software in source and/or binary form. No title
+- * or ownership is transferred hereby.
+- *
+- * 1) Any source code used, modified or distributed must reproduce
+- * and retain this copyright notice and list of conditions
+- * as they appear in the source file.
+- *
+- * 2) No right is granted to use any trade name, trademark, or
+- * logo of Broadcom Corporation. The "Broadcom Corporation"
+- * name may not be used to endorse or promote products derived
+- * from this software without the prior written permission of
+- * Broadcom Corporation.
+- *
+- * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR
+- * IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED
+- * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+- * PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT
+- * SHALL BROADCOM BE LIABLE FOR ANY DAMAGES WHATSOEVER, AND IN
+- * PARTICULAR, BROADCOM SHALL NOT BE LIABLE FOR DIRECT, INDIRECT,
+- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+- * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+- * TORT (INCLUDING NEGLIGENCE OR OTHERWISE), EVEN IF ADVISED OF
+- * THE POSSIBILITY OF SUCH DAMAGE.
+- ********************************************************************* */
+-
+-
+-#ifndef _JEDEC_H
+-#define _JEDEC_H
+-
+-/* *********************************************************************
+- * JEDEC constants (serial presence detect offsets and bit fields)
+- ********************************************************************* */
+-
+-#define JEDEC_SPD_MEMTYPE 2 /* memory type (sdram, ddr, etc.) */
+-#define JEDEC_SPD_ROWS 3 /* row bits */
+-#define JEDEC_SPD_COLS 4 /* column bits */
+-#define JEDEC_SPD_SIDES 5 /* number of sides */
+-#define JEDEC_SPD_WIDTH 6 /* and 7, bit width of device */
+-#define JEDEC_SPD_BANKS 17 /* number of banks */
+-#define JEDEC_SPD_DENSITY 31 /* module bank density */
+-#define JEDEC_SPD_ECC_INFO 11
+-
+-#define JEDEC_SPD_tCK25 9 /* tCK @ CAS 2.5 */
+-#define JEDEC_SPD_tCK20 23 /* tCK @ CAS 2.0 */
+-#define JEDEC_SPD_tCK10 25 /* tCK @ CAS 1.0 */
+-#define JEDEC_SPD_RFSH 12 /* refresh rate */
+-#define JEDEC_SPD_CASLATENCIES 18 /* CAS Latencies supported */
+-#define JEDEC_SPD_ATTRIBUTES 21 /* module attributes */
+-#define JEDEC_SPD_tRAS 30 /* tRAS */
+-#define JEDEC_SPD_tRP 27 /* tRP */
+-#define JEDEC_SPD_tRRD 28 /* tRRD */
+-#define JEDEC_SPD_tRCD 29 /* tRCD */
+-#define JEDEC_SPD_tRFC 42 /* tRFC */
+-#define JEDEC_SPD_tRC 41 /* tRC */
+-
+-#define JEDEC_SPD_SIZE 46 /* number of SPD bytes we will read
+- (adequate for DDR SDRAM) */
+-
+-#define JEDEC_MEMTYPE_DDRSDRAM 1
+-#define JEDEC_MEMTYPE_DDRSDRAM2 7
+-#define JEDEC_MEMTYPE_SDRAM 4
+-#define SPD_MEMTYPE_FCRAM 8 /* CFE specific to support FCRAM dimms */
+-
+-#define JEDEC_CASLAT_35 0x20
+-#define JEDEC_CASLAT_30 0x10
+-#define JEDEC_CASLAT_25 0x08
+-#define JEDEC_CASLAT_20 0x04
+-#define JEDEC_CASLAT_15 0x02
+-#define JEDEC_CASLAT_10 0x01
+-
+-#define JEDEC_ATTRIB_REG 0x02
+-
+-#define JEDEC_FLG_ECC_SUPPORT 0x02
+-
+-#define JEDEC_RFSH_MASK 0x7F
+-#define JEDEC_RFSH_64khz 0
+-#define JEDEC_RFSH_256khz 1
+-#define JEDEC_RFSH_128khz 2
+-#define JEDEC_RFSH_32khz 3
+-#define JEDEC_RFSH_16khz 4
+-#define JEDEC_RFSH_8khz 5
+-
+-#endif /* _JEDEC_H */
+diff -wurN orig/include/parse_config.h debian/include/parse_config.h
+--- orig/include/parse_config.h 1970-01-01 01:00:00.000000000 +0100
++++ debian/include/parse_config.h 2004-07-25 14:10:59.000000000 +0200
+@@ -0,0 +1,53 @@
++/* $Id: parse_config.h,v 1.4 2003/05/30 00:42:38 cgd Exp $ */
++
++/*
++ * Copyright 2001, 2003
++ * Broadcom Corporation. All rights reserved.
++ *
++ * This software is furnished under license and may be used and copied only
++ * in accordance with the following terms and conditions. Subject to these
++ * conditions, you may download, copy, install, use, modify and distribute
++ * modified or unmodified copies of this software in source and/or binary
++ * form. No title or ownership is transferred hereby.
++ *
++ * 1) Any source code used, modified or distributed must reproduce and
++ * retain this copyright notice and list of conditions as they appear in
++ * the source file.
++ *
++ * 2) No right is granted to use any trade name, trademark, or logo of
++ * Broadcom Corporation. The "Broadcom Corporation" name may not be
++ * used to endorse or promote products derived from this software
++ * without the prior written permission of Broadcom Corporation.
++ *
++ * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR IMPLIED
++ * WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED WARRANTIES OF
++ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
++ * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL BROADCOM BE LIABLE
++ * FOR ANY DAMAGES WHATSOEVER, AND IN PARTICULAR, BROADCOM SHALL NOT BE
++ * LIABLE FOR DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
++ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
++ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
++ * OR OTHERWISE), EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
++ */
++
++/*
++ * Parse a config file.
++ */
++
++#ifndef _PARSE_CONFIG_H
++#define _PARSE_CONFIG_H
++
++typedef struct boot_config_struct {
++ char *kernel;
++ char *initrd;
++ char *extra_args;
++ char *root_dev;
++} boot_config_t;
++
++extern boot_config_t *boot_config;
++
++void parse_config_buf(char *buf);
++
++#endif
+diff -wurN orig/include/partition.h debian/include/partition.h
+--- orig/include/partition.h 1970-01-01 01:00:00.000000000 +0100
++++ debian/include/partition.h 2004-07-25 14:10:59.000000000 +0200
+@@ -0,0 +1,61 @@
++/* $Id: partition.h,v 1.3 2003/05/30 00:42:38 cgd Exp $ */
++
++/*
++ * Copyright 2001, 2003
++ * Broadcom Corporation. All rights reserved.
++ *
++ * This software is furnished under license and may be used and copied only
++ * in accordance with the following terms and conditions. Subject to these
++ * conditions, you may download, copy, install, use, modify and distribute
++ * modified or unmodified copies of this software in source and/or binary
++ * form. No title or ownership is transferred hereby.
++ *
++ * 1) Any source code used, modified or distributed must reproduce and
++ * retain this copyright notice and list of conditions as they appear in
++ * the source file.
++ *
++ * 2) No right is granted to use any trade name, trademark, or logo of
++ * Broadcom Corporation. The "Broadcom Corporation" name may not be
++ * used to endorse or promote products derived from this software
++ * without the prior written permission of Broadcom Corporation.
++ *
++ * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR IMPLIED
++ * WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED WARRANTIES OF
++ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
++ * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL BROADCOM BE LIABLE
++ * FOR ANY DAMAGES WHATSOEVER, AND IN PARTICULAR, BROADCOM SHALL NOT BE
++ * LIABLE FOR DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
++ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
++ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
++ * OR OTHERWISE), EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
++ */
++
++#ifndef _PARTITION_H
++#define _PARTITION_H
++
++/*
++ * Routines for dealing with partitions
++ */
++
++#include <stdint.h>
++
++typedef struct {
++ unsigned char active;
++ unsigned char start_chs[3];
++ unsigned char id;
++ unsigned char end_chs[3];
++ uint32_t start_sector;
++ uint32_t size;
++} part_entry_t;
++
++
++/* Take a CFE handle and read the partition table, returning
++ the linear offset of the desired partion or -1 for failure
++*/
++int part_get_info(int handle, int partno, part_entry_t *part_info);
++
++
++
++#endif
+diff -wurN orig/include/port.h debian/include/port.h
+--- orig/include/port.h 1970-01-01 01:00:00.000000000 +0100
++++ debian/include/port.h 2004-07-25 14:10:59.000000000 +0200
+@@ -0,0 +1,65 @@
++/* $Id: port.h,v 1.10 2003/11/17 20:54:52 kwalker Exp $ */
++
++/*
++ * Copyright 2001, 2003
++ * Broadcom Corporation. All rights reserved.
++ *
++ * This software is furnished under license and may be used and copied only
++ * in accordance with the following terms and conditions. Subject to these
++ * conditions, you may download, copy, install, use, modify and distribute
++ * modified or unmodified copies of this software in source and/or binary
++ * form. No title or ownership is transferred hereby.
++ *
++ * 1) Any source code used, modified or distributed must reproduce and
++ * retain this copyright notice and list of conditions as they appear in
++ * the source file.
++ *
++ * 2) No right is granted to use any trade name, trademark, or logo of
++ * Broadcom Corporation. The "Broadcom Corporation" name may not be
++ * used to endorse or promote products derived from this software
++ * without the prior written permission of Broadcom Corporation.
++ *
++ * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR IMPLIED
++ * WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED WARRANTIES OF
++ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
++ * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL BROADCOM BE LIABLE
++ * FOR ANY DAMAGES WHATSOEVER, AND IN PARTICULAR, BROADCOM SHALL NOT BE
++ * LIABLE FOR DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
++ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
++ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
++ * OR OTHERWISE), EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
++ */
++
++#ifndef PORT_H
++#define PORT_H
++
++#ifdef __linux__
++#include <stdint.h>
++#else /* !__linux__ */
++typedef unsigned char uint8_t;
++typedef signed char int8_t;
++typedef unsigned short uint16_t;
++typedef signed short int16_t;
++typedef unsigned int uint32_t;
++typedef signed int int32_t;
++typedef unsigned long long uint64_t;
++typedef signed long long int64_t;
++
++#define unsigned signed /* Kludge to get unsigned size-shaped type. */
++typedef __SIZE_TYPE__ intptr_t;
++#undef unsigned
++typedef __SIZE_TYPE__ uintptr_t;
++
++#define UINT64_C(arg) (arg ## ULL)
++#define UINT32_MAX (0xffffffffU)
++
++#endif /* __linux__ */
++
++
++uint16_t port_swap_16(uint16_t src);
++uint32_t port_swap_32(uint32_t src);
++uint64_t port_swap_64(uint64_t src);
++
++#endif
+diff -wurN orig/include/tftp_fileops.h debian/include/tftp_fileops.h
+--- orig/include/tftp_fileops.h 1970-01-01 01:00:00.000000000 +0100
++++ debian/include/tftp_fileops.h 2004-07-25 14:10:59.000000000 +0200
+@@ -0,0 +1,42 @@
++/* $Id: tftp_fileops.h,v 1.4 2003/05/30 00:42:38 cgd Exp $ */
++
++/*
++ * Copyright 2001, 2003
++ * Broadcom Corporation. All rights reserved.
++ *
++ * This software is furnished under license and may be used and copied only
++ * in accordance with the following terms and conditions. Subject to these
++ * conditions, you may download, copy, install, use, modify and distribute
++ * modified or unmodified copies of this software in source and/or binary
++ * form. No title or ownership is transferred hereby.
++ *
++ * 1) Any source code used, modified or distributed must reproduce and
++ * retain this copyright notice and list of conditions as they appear in
++ * the source file.
++ *
++ * 2) No right is granted to use any trade name, trademark, or logo of
++ * Broadcom Corporation. The "Broadcom Corporation" name may not be
++ * used to endorse or promote products derived from this software
++ * without the prior written permission of Broadcom Corporation.
++ *
++ * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR IMPLIED
++ * WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED WARRANTIES OF
++ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
++ * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL BROADCOM BE LIABLE
++ * FOR ANY DAMAGES WHATSOEVER, AND IN PARTICULAR, BROADCOM SHALL NOT BE
++ * LIABLE FOR DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
++ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
++ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
++ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
++ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
++ * OR OTHERWISE), EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
++ */
++
++#ifndef _TFTP_FILEOPS_H
++#define _TFTP_FILEOPS_H
++
++#include "getfile.h"
++
++extern file_ops_t tftp_ops;
++
++#endif
--- sibyl-2.4.2.orig/debian/patches/04-netboot.dpatch
+++ sibyl-2.4.2/debian/patches/04-netboot.dpatch
@@ -0,0 +1,53 @@
+#! /bin/sh -e
+## netboot.dpatch by Peter De Schrijver <p2@mind.be>
+##
+## DP: patches to enable booting via tftp
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch ${2:+-d $2}}"
+
+if [ $# -lt 1 ]; then
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1
+fi
+
+case "$1" in
+ -patch) patch $patch_opts -p1 < $0;;
+ -unpatch) patch $patch_opts -p1 -R < $0;;
+ *)
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1;;
+esac
+
+exit 0
+@DPATCH@
+
+diff -wruN sibyl-2.4.2/loader/Makefile sibyl-2.4.2.my/loader/Makefile
+--- sibyl-2.4.2/loader/Makefile 2004-07-25 22:37:59.000000000 +0200
++++ sibyl-2.4.2.my/loader/Makefile 2004-07-25 21:57:59.000000000 +0200
+@@ -43,21 +43,21 @@
+ CPPFLAGS += -I. -Ilib/c -Ilib/net -Ilib/cfe \
+ -DVERSION_MAJOR=$(VERSION_MAJOR) \
+ -DVERSION_MINOR=$(VERSION_MINOR) \
+- -DVERSION_MINUTE=$(VERSION_MINUTE)
++ -DVERSION_MINUTE=$(VERSION_MINUTE) \
++ -DCONFIG_NETWORK
++
+ LDFLAGS += -Llib/net -Llib/c -Llib/cfe
+
+ OBJCOPY = objcopy
+ OBJDUMP = objdump
+
+ # all objects built in this directory
+-OBJS = init.o main.o malloc.o stringops.o getfile.o parse_config.o port.o
++OBJS = init.o main.o malloc.o stringops.o getfile.o parse_config.o port.o tftp_fileops.o
+
+ ifeq ($(strip ${DISK_SUPPORT}),1)
+ OBJS += partition.o ext2_fileops.o
+ CPPFLAGS += -DCONFIG_BLOCKDEV -I/usr/include/ext2fs
+ LDFLAGS += -lext2fs -lstandalone -lnet -lcfe $$($(CC) -print-libgcc-file-name)
+-else
+-OBJS += tftp_fileops.o
+ endif
+
+ .PHONY: disk
--- sibyl-2.4.2.orig/debian/patches/00list
+++ sibyl-2.4.2/debian/patches/00list
@@ -0,0 +1,5 @@
+01-loader.dpatch
+02-hosttools.dpatch
+03-include.dpatch
+04-netboot.dpatch
+05-initrd.dpatch
--- sibyl-2.4.2.orig/debian/rules
+++ sibyl-2.4.2/debian/rules
@@ -0,0 +1,56 @@
+#!/usr/bin/make -f
+
+include /usr/share/dpatch/dpatch.make
+
+export DH_COMPAT=4
+
+PACKAGE=$(shell dh_listpackages)
+
+build: patch build-stamp
+
+build-stamp:
+ dh_testdir
+
+ $(MAKE) -C hosttools installboot
+ $(MAKE) -C loader
+ chmod a-x loader/sibyl.bin
+
+ touch build-stamp
+
+clean: unpatch
+ dh_testdir
+ dh_testroot
+
+ rm -f build-stamp
+ rm -f hosttools/installboot
+ -$(MAKE) -C loader clean
+ dh_clean
+
+install: build
+ dh_testdir
+ dh_testroot
+ dh_clean -k
+ dh_installdirs usr/lib/$(PACKAGE)
+
+ dh_install hosttools/installboot usr/sbin
+ dh_install loader/sibyl.bin usr/lib/$(PACKAGE)
+ dh_installchangelogs
+ dh_installman man/installboot.8
+ dh_installdeb
+
+binary-arch: build install
+ dh_testdir
+ dh_testroot
+ dh_installdocs
+ dh_compress
+ dh_strip
+ dh_fixperms
+ dh_shlibdeps
+ dh_gencontrol
+ dh_md5sums
+ dh_builddeb
+
+binary: binary-arch
+
+.PHONY: build clean binary-arch binary install patch unpatch clean1
+
--- sibyl-2.4.2.orig/debian/copyright
+++ sibyl-2.4.2/debian/copyright
@@ -0,0 +1,42 @@
+This package was debianized by Peter De Schrijver (p2) <p2@mind.be>
+Sat, 24 Jul 2004 19:56:30 +0200
+
+It was downloaded from http://sibyte.broadcom.com/public/resources/index.html
+
+Upstream Authors: Broadcom Corporation.
+ Integration with e2fslibs by
+ Thiemo Seufer <ica2_ts@csv.ica.uni-stuttgart.de>.
+
+Copyright:
+
+/*
+ * Copyright 2000, 2001, 2002, 2003
+ * Broadcom Corporation. All rights reserved.
+ *
+ * This software is furnished under license and may be used and copied only
+ * in accordance with the following terms and conditions. Subject to these
+ * conditions, you may download, copy, install, use, modify and distribute
+ * modified or unmodified copies of this software in source and/or binary
+ * form. No title or ownership is transferred hereby.
+ *
+ * 1) Any source code used, modified or distributed must reproduce and
+ * retain this copyright notice and list of conditions as they appear in
+ * the source file.
+ *
+ * 2) No right is granted to use any trade name, trademark, or logo of
+ * Broadcom Corporation. The "Broadcom Corporation" name may not be
+ * used to endorse or promote products derived from this software
+ * without the prior written permission of Broadcom Corporation.
+ *
+ * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
+ * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL BROADCOM BE LIABLE
+ * FOR ANY DAMAGES WHATSOEVER, AND IN PARTICULAR, BROADCOM SHALL NOT BE
+ * LIABLE FOR DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE), EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */