From fca17e44d9f7a113259e3976ef18b121cbf83978 Mon Sep 17 00:00:00 2001 From: Edgar Hucek Date: Wed, 26 Oct 2005 08:19:09 +0000 Subject: Fix cdrom boot (Portage version: 2.0.51.22-r3) --- .../cromwell/files/cromwell-2.40-cvs-fixes.patch | 539 +++++++++++++++++++++ sys-boot/cromwell/files/digest-cromwell-2.40-r2 | 1 + 2 files changed, 540 insertions(+) create mode 100644 sys-boot/cromwell/files/cromwell-2.40-cvs-fixes.patch create mode 100644 sys-boot/cromwell/files/digest-cromwell-2.40-r2 (limited to 'sys-boot/cromwell/files') diff --git a/sys-boot/cromwell/files/cromwell-2.40-cvs-fixes.patch b/sys-boot/cromwell/files/cromwell-2.40-cvs-fixes.patch new file mode 100644 index 000000000000..b84de440a940 --- /dev/null +++ b/sys-boot/cromwell/files/cromwell-2.40-cvs-fixes.patch @@ -0,0 +1,539 @@ +diff -uNr cromwell-2.40/boot/LoadLinux.c cromwell-2.40-r2/boot/LoadLinux.c +--- cromwell-2.40/boot/LoadLinux.c 2004-12-05 02:14:26.000000000 +0000 ++++ cromwell-2.40-r2/boot/LoadLinux.c 2005-10-26 09:28:44.000000000 +0000 +@@ -33,10 +33,12 @@ + + + void ExittoLinux(CONFIGENTRY *config); +-void startLinux(void* initrdStart, unsigned long initrdSize, const char* appendLine); ++void startLinux(void* initrdStart, unsigned long initrdSize, const char* appendLine, unsigned int entry); + void setup(void* KernelPos, void* PhysInitrdPos, unsigned long InitrdSize, const char* kernel_cmdline); + void I2CRebootSlow(void); + ++void try_elf_boot (char* data, int len); ++ + + void BootPrintConfig(CONFIGENTRY *config) { + int CharsProcessed=0, CharsSinceNewline=0, Length=0; +@@ -69,6 +71,10 @@ + unsigned int nSizeHeader=((*(kernelOrg + 0x01f1))+1)*512; + memcpy((u8 *)KERNEL_SETUP, kernelOrg, nSizeHeader); + memcpy((u8 *)KERNEL_PM_CODE,(kernelOrg+nSizeHeader),kernelSize-nSizeHeader); ++ ++ /* Try to execute a pure ELF binary here, using the etherboot ++ * code. This is required for ELF kernels, such as FreeBSD */ ++ try_elf_boot ((char*)kernelOrg, kernelSize); + } + + +@@ -313,9 +319,15 @@ + configLoaded=1; + break; + } ++ dwConfigSize = BootIso9660GetFile(cdromId,"/linuxboot.cfg", (u8 *)KERNEL_SETUP, 0x800); ++ if (dwConfigSize>0) { ++ configLoaded=1; ++ break; ++ } + wait_ms(250); + } + ++ //We couldn't read the disk, so we eject the drive so the user can insert one. + if (!configLoaded) { + //Needs to be changed for non-xbox drives, which don't have an eject line + //Need to send ATA eject command. +@@ -326,20 +338,29 @@ + printk("\2Please insert CD and press Button A\n\n"); + + while(1) { ++ // Make button 'A' close the DVD tray + if (risefall_xpad_BUTTON(TRIGGER_XPAD_KEY_A) == 1) { +- I2CTransmitWord(0x10, 0x0c01); // close DVD tray ++ I2CTransmitWord(0x10, 0x0c01); + wait_ms(500); + break; + } +- wait_ms(10); +- +- //Keep trying to read, in case somebody puts the tray in manually, without pressing A +- dwConfigSize = BootIso9660GetFile(cdromId,"/linuxboo.cfg", (u8 *)KERNEL_SETUP, 0x800); +- if (dwConfigSize>0) { +- configLoaded=1; ++ else if (DVD_TRAY_STATE == DVD_CLOSING) { ++ //It's an xbox drive, and somebody pushed the tray in manually ++ wait_ms(500); + break; + } +- } ++ else if (BootIso9660GetFile(cdromId,"/linuxboo.cfg", (u8 *)KERNEL_SETUP, 0x800)>0) { ++ //It isnt an xbox drive, and somebody pushed the tray in manually, and ++ //the cd is valid. ++ break; ++ } ++ else if (BootIso9660GetFile(cdromId,"/linuxboot.cfg", (u8 *)KERNEL_SETUP, 0x800)>0) { ++ break; ++ } ++ wait_ms(10); ++ } ++ ++ wait_ms(250); + + VIDEO_ATTR=0xffffffff; + +@@ -351,6 +372,11 @@ + configLoaded=1; + break; + } ++ dwConfigSize = BootIso9660GetFile(cdromId,"/linuxboot.cfg", (u8 *)KERNEL_SETUP, 0x800); ++ if (dwConfigSize>0) { ++ configLoaded=1; ++ break; ++ } + wait_ms(250); + } + } +@@ -423,7 +449,7 @@ + //Try for 4 seconds. + I2CTransmitWord(0x10, 0x0c01); // close DVD tray + for (n=0;n<16;++n) { +- if((BootIso9660GetFile(cdromId,"/image.bin", (u8 *)KERNEL_SETUP, 0x10)) >=0 ) { ++ if((BootIso9660GetFile(cdromId,"/image.bin", (u8 *)KERNEL_PM_CODE, 0x10)) >=0 ) { + cdPresent=1; + break; + } +@@ -454,7 +480,7 @@ + + // wait until the media is readable + while(1) { +- if((BootIso9660GetFile(cdromId,"/image.bin", (u8 *)KERNEL_SETUP, 0x10)) >=0 ) { ++ if((BootIso9660GetFile(cdromId,"/image.bin", (u8 *)KERNEL_PM_CODE, 0x10)) >=0 ) { + break; + } + wait_ms(200); +@@ -462,7 +488,7 @@ + } + printk("CDROM: "); + printk("Loading bios image from CDROM:/image.bin. \n"); +- dwConfigSize=BootIso9660GetFile(cdromId, "/image.bin", (u8 *)KERNEL_PM_CODE, 256*1024); ++ dwConfigSize=BootIso9660GetFile(cdromId, "/image.bin", (u8 *)KERNEL_PM_CODE, 256*1024); + + if( dwConfigSize < 0 ) { //It's not there + printk("image.bin not found on CDROM... Halting\n"); +@@ -508,12 +534,12 @@ + VIDEO_ATTR=0xff9f9fbf; + printk(sz); + } +- I2cSetFrontpanelLed(I2C_LED_RED0 | I2C_LED_RED1 | I2C_LED_RED2 | I2C_LED_RED3 ); +- startLinux((void*)INITRD_START, dwInitrdSize, config->szAppend); ++ setLED("rrrr"); ++ startLinux((void*)INITRD_START, dwInitrdSize, config->szAppend, 0x100000); + } + + +-void startLinux(void* initrdStart, unsigned long initrdSize, const char* appendLine) ++void startLinux(void* initrdStart, unsigned long initrdSize, const char* appendLine, unsigned int entry) + { + int nAta=0; + // turn off USB +@@ -535,10 +561,7 @@ + BootIdeSetTransferMode(1, 0x40 | nAta); + + // orange, people seem to like that colour +- I2cSetFrontpanelLed( +- I2C_LED_GREEN0 | I2C_LED_GREEN1 | I2C_LED_GREEN2 | I2C_LED_GREEN3 | +- I2C_LED_RED0 | I2C_LED_RED1 | I2C_LED_RED2 | I2C_LED_RED3 +- ); ++ setLED("oooo"); + + // Set framebuffer address to final location (for vesafb driver) + (*(unsigned int*)0xFD600800) = (0xf0000000 | ((xbox_ram*0x100000) - FB_SIZE)); +@@ -549,6 +572,8 @@ + // clear idt area + memset((void*)IDT_LOC,0x0,1024*8); + ++ __asm__ ("movl %0,%%ebx" : : "a" (entry)); /* ebx = entry */ ++ + __asm __volatile__ ( + "wbinvd\n" + +@@ -597,13 +622,15 @@ + // Set the stack pointer to give us a valid stack + "movl $0x03BFFFFC, %esp \n" + +- "xor %ebx, %ebx \n" + "xor %eax, %eax \n" + "xor %ecx, %ecx \n" + "xor %edx, %edx \n" + "xor %edi, %edi \n" + "movl $0x90000, %esi\n" // kernel setup area +- "ljmp $0x10, $0x100000\n" // Jump to Kernel protected mode entry ++ "pushl $0x10\n" ++ "pushl %ebx\n" // 0x10:ebx is the entry point ++ "xor %ebx,%ebx\n" // clean leftover ebx (held entry point) ++ ".byte 0xcb\n " // retf + ); + + // We are not longer here, we are already in the Linux loader, we never come back here +diff -uNr cromwell-2.40/boot_rom/bootrom.ld cromwell-2.40-r2/boot_rom/bootrom.ld +--- cromwell-2.40/boot_rom/bootrom.ld 2003-09-08 11:04:06.000000000 +0000 ++++ cromwell-2.40-r2/boot_rom/bootrom.ld 2005-10-26 09:27:16.000000000 +0000 +@@ -45,6 +45,7 @@ + .rodata ( RAM_CODE + SIZEOF(.text) + SIZEOF(.data) ) : AT ( SIZEOF(.low_rom) + SIZEOF(.text) + SIZEOF(.data)) { + *(.rodata); + *(.rodata.str1.1); ++ *(.rodata.str1.4); + *(.rodata.str1.32); + *(.rodata.cst4); + *(.rodata.cst8); +diff -uNr cromwell-2.40/etherboot/core/exec_elf.c cromwell-2.40-r2/etherboot/core/exec_elf.c +--- cromwell-2.40/etherboot/core/exec_elf.c 1970-01-01 00:00:00.000000000 +0000 ++++ cromwell-2.40-r2/etherboot/core/exec_elf.c 2005-10-26 09:31:32.000000000 +0000 +@@ -0,0 +1,22 @@ ++#include "etherboot.h" ++ ++/* ++ * This is a helper function; it tries to execute an ELF image using ++ * the Etherboot code. This is because *BSD kernels are raw ELF files, ++ * which are unsupported when booting from CD-ROM or disk. ++ */ ++void ++try_elf_boot (char* image, int len) ++{ ++ os_download_t os_download; ++ ++ /* do nothing if the ELF magic mismatches */ ++ if (*(int*)image != 0x464c457f) ++ return; ++ ++ os_download = probe_image (image, len); ++ if (os_download == 0) ++ return; ++ ++ os_download (image, len, 1); ++} +diff -uNr cromwell-2.40/etherboot/core/Makefile cromwell-2.40-r2/etherboot/core/Makefile +--- cromwell-2.40/etherboot/core/Makefile 2004-03-26 23:29:21.000000000 +0000 ++++ cromwell-2.40-r2/etherboot/core/Makefile 2005-10-26 09:31:47.000000000 +0000 +@@ -1,4 +1,4 @@ + +-O_TARGET := nfs.o nic.o osloader.o proto_tftm.o xbox_misc.o xbox_pci.o etherboot_config.o xbox_main.o ++O_TARGET := nfs.o nic.o osloader.o proto_tftm.o xbox_misc.o xbox_pci.o etherboot_config.o xbox_main.o exec_elf.o + + include $(TOPDIR)/Rules.make +diff -uNr cromwell-2.40/fs/cdrom/iso9660.c cromwell-2.40-r2/fs/cdrom/iso9660.c +--- cromwell-2.40/fs/cdrom/iso9660.c 2004-11-09 23:52:43.000000000 +0000 ++++ cromwell-2.40-r2/fs/cdrom/iso9660.c 2005-10-26 09:29:06.000000000 +0000 +@@ -10,7 +10,11 @@ + 2004-07-22 "Edgar Hucek" Created + */ + ++#ifndef STANDALONE + #include "boot.h" ++#else ++# define printk printf ++#endif + #include "iso_fs.h" + + int isupper( int ch ) +@@ -96,25 +100,31 @@ + sprintf(newfilename, "%s/",filename); + iso9660_name_translate(newfilename + strlen(newfilename), + dir->name, (unsigned char)dir->name_len[0]); +-// printk("Read : Sector %d Filename %s %d\n", +-// *((unsigned long *)(dir->extent)), newfilename, +-// (unsigned char)dir->ext_attr_length[0]); ++#ifdef DEBUG_ISO ++ printk("Read : Sector %d Filename %s %d\n", ++ *((unsigned long *)(dir->extent)), newfilename, ++ (unsigned char)dir->ext_attr_length[0]); ++#endif + } + + if(strlen(newfilename) <= strlen(search)) { + if(memcmp(newfilename, search, strlen(search)) == 0) { + sect = *((unsigned long *)(dir->extent)); + memcpy(dir_found, dir, sizeof(struct iso_directory_record)); +-// printk("Found : Sector %d Directory %s Filename %s %d %d \n", +-// sect, newfilename, search, +-// strlen(newfilename), strlen(search)); ++#ifdef DEBUG_ISO ++ printk("Found : Sector %d Directory %s Filename %s %d %d \n", ++ sect, newfilename, search, ++ strlen(newfilename), strlen(search)); ++#endif + // free(newfilename); + // free(buffer); + return sect; + } + } + if((*((char *)(dir->flags)) & IS_DIR) && (*((unsigned char *)(dir->name_len)) > 1)) { +-// printk("Directory %s Filename %s\n", newfilename, search); ++#ifdef DEBUG_ISO ++ printk("Directory %s Filename %s\n", newfilename, search); ++#endif + if (strlen(newfilename) < strlen(search) && !memcmp(search,newfilename, + strlen(newfilename)) && search[strlen(newfilename)]=='/') { + sect = read_dir(driveId, dir, search, newfilename, dir_found); +@@ -131,35 +141,46 @@ + return sect; + } + +-void read_file(int driveId, struct iso_directory_record *dir_read, char *buffer) { ++unsigned long read_file(int driveId, struct iso_directory_record *dir_read, char *buffer, unsigned int max_bytes_to_read) { + unsigned long read_size; ++ unsigned long bytes_read; + unsigned long offset; + int i; + char *tmpbuff; + ++ + offset = *((unsigned long *)(dir_read->extent)); + tmpbuff = (char *) malloc(ISO_BLOCKSIZE); ++ ++ if (max_bytes_to_read > *((unsigned int *)(dir_read->size)) ) { ++ read_size = *(unsigned long *)dir_read->size; ++ } ++ else read_size = *(unsigned long *)max_bytes_to_read; ++ ++ bytes_read = read_size; + +- read_size = *((unsigned long *)(dir_read->size)); + if(read_size <= ISO_BLOCKSIZE) { + read_size = ISO_BLOCKSIZE; + } else { + read_size+=(ISO_BLOCKSIZE - (read_size % ISO_BLOCKSIZE)); + } + +-// printk(" read_file sector %d %d\n", offset, read_size); +- ++#ifdef DEBUG_ISO ++ printk(" read_file sector %d %d\n", offset, read_size); ++#endif + for(i = 0; i < (read_size >> ISOFS_BLOCK_BITS) ; i++) { + memset(tmpbuff, 0x0, ISO_BLOCKSIZE); + BootIdeReadSector(driveId, tmpbuff, offset , 0, ISO_BLOCKSIZE); + offset++; + if(((i+1) * ISO_BLOCKSIZE) > read_size) { +- memcpy(&buffer[i * ISO_BLOCKSIZE], tmpbuff, (i * ISO_BLOCKSIZE) - *((unsigned long *)(dir_read->size))); ++ memcpy(&buffer[i * ISO_BLOCKSIZE], tmpbuff, (i * ISO_BLOCKSIZE) - read_size); + } else { + memcpy(&buffer[i * ISO_BLOCKSIZE], tmpbuff, ISO_BLOCKSIZE); + } + } + free(tmpbuff); ++ ++ return bytes_read; + } + + int BootIso9660GetFile(int driveId, char *szcPath, unsigned char *pbaFile, unsigned int dwFileLengthMax) { +@@ -177,7 +198,9 @@ + memset(dir,0x0,sizeof(struct iso_directory_record)); + + if(BootIdeReadSector(driveId, pvd, 16 , 0, ISO_BLOCKSIZE)) { +-// printk("BootIso9660GetFile : Error read Sector\n"); ++#ifdef DEBUG_ISO ++ printk("BootIso9660GetFile : Error read Sector\n"); ++#endif + free(pvd); + free(dir); + return -1; +@@ -187,14 +210,9 @@ + offset = read_dir(driveId, rootd, szcPath, "", dir); + + if(offset > 0) { +- if(*((unsigned long *)(dir->size)) > dwFileLengthMax) { +- free(pvd); +- free(dir); +- return -1; +- } +- read_file(driveId, dir, pbaFile); +- return *((unsigned long *)(dir->size)); ++ return read_file(driveId, dir, pbaFile, dwFileLengthMax); + } else { ++ //Not found + free(pvd); + free(dir); + return -1; +diff -uNr cromwell-2.40/fs/grub/fsys_reiserfs.c cromwell-2.40-r2/fs/grub/fsys_reiserfs.c +--- cromwell-2.40/fs/grub/fsys_reiserfs.c 2004-06-06 14:50:43.000000000 +0000 ++++ cromwell-2.40-r2/fs/grub/fsys_reiserfs.c 2005-10-26 09:27:16.000000000 +0000 +@@ -367,7 +367,7 @@ + + + static __inline__ unsigned long +-log2 (unsigned long word) ++reiser_log2 (unsigned long word) + { + __asm__ ("bsfl %1,%0" + : "=r" (word) +@@ -609,7 +609,7 @@ + + INFO->version = super.s_version; + INFO->blocksize = super.s_blocksize; +- INFO->fullblocksize_shift = log2 (super.s_blocksize); ++ INFO->fullblocksize_shift = reiser_log2 (super.s_blocksize); + INFO->blocksize_shift = INFO->fullblocksize_shift - SECTOR_BITS; + INFO->cached_slots = + (FSYSREISER_CACHE_SIZE >> INFO->fullblocksize_shift) - 1; +diff -uNr cromwell-2.40/include/boot.h cromwell-2.40-r2/include/boot.h +--- cromwell-2.40/include/boot.h 2004-11-26 00:39:31.000000000 +0000 ++++ cromwell-2.40-r2/include/boot.h 2005-10-26 09:29:24.000000000 +0000 +@@ -331,8 +331,8 @@ + unsigned char *text1, int text1_length, + unsigned char *text2, int text2_length ); + +-char *HelpGetLine(char *ptr); +-void HelpGetParm(char *szBuffer, char *szOrig); + char *strrchr0(char *string, char ch); + ++void setLED(void *pattern); ++ + #endif // _Boot_H_ +diff -uNr cromwell-2.40/include/config.h cromwell-2.40-r2/include/config.h +--- cromwell-2.40/include/config.h 2004-12-08 21:51:21.000000000 +0000 ++++ cromwell-2.40-r2/include/config.h 2005-10-26 09:38:00.000000000 +0000 +@@ -1,7 +1,7 @@ + ////////////////////// compile-time options //////////////////////////////// + + //Cromwell version number +-#define VERSION "2.40" ++#define VERSION "2.40-r2" + + // selects between the supported video modes, see boot.h for enum listing those available + //#define VIDEO_PREFERRED_MODE VIDEO_MODE_800x600 +diff -uNr cromwell-2.40/lib/gzip/misc.c cromwell-2.40-r2/lib/gzip/misc.c +--- cromwell-2.40/lib/gzip/misc.c 2004-06-06 14:27:26.000000000 +0000 ++++ cromwell-2.40-r2/lib/gzip/misc.c 2005-10-26 09:27:16.000000000 +0000 +@@ -29,8 +29,6 @@ + * + * Incomprehensible are the ways of bootloaders. + */ +-static void* memset(void *, int, size_t); +-static void* memcpy(void *, __const void *, size_t); + #define memzero(s, n) memset ((s), 0, (n)) + + typedef unsigned char uch; +@@ -138,25 +136,6 @@ + free_mem_ptr = (long) *ptr; + } + +-static void* memset(void* s, int c, size_t n) +-{ +- int i; +- char *ss = (char*)s; +- +- for (i=0;i