You can subscribe to this list here.
2001 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(79) |
Aug
(27) |
Sep
(64) |
Oct
(202) |
Nov
(31) |
Dec
(59) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2002 |
Jan
(125) |
Feb
(173) |
Mar
(13) |
Apr
(140) |
May
(75) |
Jun
(1) |
Jul
(37) |
Aug
(14) |
Sep
|
Oct
(20) |
Nov
(9) |
Dec
(2) |
2003 |
Jan
(51) |
Feb
(12) |
Mar
(18) |
Apr
(24) |
May
(1) |
Jun
|
Jul
|
Aug
(72) |
Sep
(12) |
Oct
(18) |
Nov
(60) |
Dec
(26) |
2004 |
Jan
(1) |
Feb
(40) |
Mar
(3) |
Apr
(3) |
May
|
Jun
(1) |
Jul
(4) |
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
(1) |
2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
(1) |
Dec
(5) |
2006 |
Jan
(13) |
Feb
(5) |
Mar
(8) |
Apr
(13) |
May
(7) |
Jun
(6) |
Jul
(10) |
Aug
(6) |
Sep
(6) |
Oct
(35) |
Nov
(20) |
Dec
(10) |
2007 |
Jan
(13) |
Feb
(9) |
Mar
(2) |
Apr
(1) |
May
(1) |
Jun
(2) |
Jul
(2) |
Aug
(3) |
Sep
(1) |
Oct
|
Nov
(1) |
Dec
(1) |
2008 |
Jan
|
Feb
|
Mar
(1) |
Apr
(4) |
May
(1) |
Jun
|
Jul
|
Aug
(2) |
Sep
(1) |
Oct
|
Nov
|
Dec
|
2009 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(54) |
Jun
(78) |
Jul
(35) |
Aug
(21) |
Sep
(21) |
Oct
(29) |
Nov
(10) |
Dec
(5) |
2010 |
Jan
|
Feb
|
Mar
(26) |
Apr
(55) |
May
(73) |
Jun
(63) |
Jul
(38) |
Aug
(39) |
Sep
(19) |
Oct
(2) |
Nov
(1) |
Dec
(1) |
2011 |
Jan
(2) |
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2013 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
|
Dec
|
From: Erik M. <er...@us...> - 2002-02-17 19:54:51
|
Update of /cvsroot/blob/blob/src/lib In directory usw-pr-cvs1:/tmp/cvs-serv26300/src/lib Modified Files: Makefile.am reboot.c Removed Files: terminal.c Log Message: Move "reset" and "reboot" commands to lib/commands/ Index: Makefile.am =================================================================== RCS file: /cvsroot/blob/blob/src/lib/Makefile.am,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- Makefile.am 17 Feb 2002 15:41:54 -0000 1.13 +++ Makefile.am 17 Feb 2002 19:54:47 -0000 1.14 @@ -45,7 +45,6 @@ strlen.c \ strncmp.c \ strtou32.c \ - terminal.c \ time.c \ util.c Index: reboot.c =================================================================== RCS file: /cvsroot/blob/blob/src/lib/reboot.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- reboot.c 13 Feb 2002 00:10:57 -0000 1.3 +++ reboot.c 17 Feb 2002 19:54:47 -0000 1.4 @@ -27,27 +27,14 @@ # include <blob/config.h> #endif -#include <blob/serial.h> #include <blob/sa1100.h> #include <blob/util.h> -char reboothelp[] = "reboot\n" -"Reboot system\n"; - - - - -int reboot(int argc, char *argv[]) +void reboot_system(void) { - printf("Rebooting...\n\n"); - serial_flush_output(); - RCSR = 0; RSRR = 1; - - /* never reached, but anyway... */ - return 0; } --- terminal.c DELETED --- |
From: Erik M. <er...@us...> - 2002-02-17 19:54:51
|
Update of /cvsroot/blob/blob/src/commands In directory usw-pr-cvs1:/tmp/cvs-serv26300/src/commands Added Files: terminal.c reboot.c Log Message: Move "reset" and "reboot" commands to lib/commands/ --- NEW FILE: terminal.c --- /* * terminal.c: terminal reset functions * * Copyright (C) 1999 2000 2001 2002 Erik Mouw (J.A...@it...) * * $Id: terminal.c,v 1.1 2002/02/17 19:54:47 erikm Exp $ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ #ident "$Id: terminal.c,v 1.1 2002/02/17 19:54:47 erikm Exp $" #ifdef HAVE_CONFIG_H # include <blob/config.h> #endif #include <blob/serial.h> #include <blob/util.h> int reset_cmd(int argc, char *argv[]) { int i; serial_flush_output(); printf("c"); serial_flush_output(); for(i = 0; i < 100; i++) serial_write('\n'); serial_flush_output(); printf("c"); serial_flush_output(); serial_flush_input(); return 0; } char reset_help[] = "reset\n" "Reset terminal\n"; --- NEW FILE: reboot.c --- /* * reboot.c: Reboot board * * Copyright (C) 2001 Erik Mouw (J.A...@it...) * * $Id: reboot.c,v 1.1 2002/02/17 19:54:47 erikm Exp $ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ #ident "$Id: reboot.c,v 1.1 2002/02/17 19:54:47 erikm Exp $" #ifdef HAVE_CONFIG_H # include <blob/config.h> #endif #include <blob/serial.h> #include <blob/util.h> int reboot_cmd(int argc, char *argv[]) { printf("Rebooting...\n\n"); serial_flush_output(); reboot_system(); /* never reached, but anyway... */ return 0; } char reboot_help[] = "reboot\n" "Reboot system\n"; |
From: Erik M. <er...@us...> - 2002-02-17 19:54:51
|
Update of /cvsroot/blob/blob/include/blob In directory usw-pr-cvs1:/tmp/cvs-serv26300/include/blob Modified Files: Makefile.am Removed Files: terminal.h reboot.h Log Message: Move "reset" and "reboot" commands to lib/commands/ Index: Makefile.am =================================================================== RCS file: /cvsroot/blob/blob/include/blob/Makefile.am,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- Makefile.am 16 Feb 2002 00:43:59 -0000 1.16 +++ Makefile.am 17 Feb 2002 19:54:47 -0000 1.17 @@ -39,11 +39,9 @@ mini_inflate.h \ param_block.h \ partition.h \ - reboot.h \ sa1100.h \ sa1111.h \ serial.h \ - terminal.h \ time.h \ types.h \ util.h \ --- terminal.h DELETED --- --- reboot.h DELETED --- |
From: Erik M. <er...@us...> - 2002-02-17 15:41:57
|
Update of /cvsroot/blob/blob/src/lib In directory usw-pr-cvs1:/tmp/cvs-serv889/src/lib Modified Files: Makefile.am Added Files: mini_inflate.c Log Message: - cleanup configure.in and Makefile.am - make uudecode and xmodem conditionally compiled sources - make cramfs and jffs2 really conditionally compiled - move mini_inflate to libblob --- NEW FILE: mini_inflate.c --- /*------------------------------------------------------------------------- * Filename: mini_inflate.c * Version: $Id: mini_inflate.c,v 1.1 2002/02/17 15:41:54 erikm Exp $ * Copyright: Copyright (C) 2001, Russ Dill * Author: Russ Dill <Rus...@as...> * Description: Mini inflate implementation (RFC 1951) *-----------------------------------------------------------------------*/ /* * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ #ident "$Id: mini_inflate.c,v 1.1 2002/02/17 15:41:54 erikm Exp $" #ifdef HAVE_CONFIG_H # include <blob/config.h> #endif #include <blob/mini_inflate.h> #include <blob/util.h> #define NO_ERROR 0 #define COMP_UNKNOWN 1 /* The specififed bytype is invalid */ #define CODE_NOT_FOUND 2 /* a huffman code in the stream could not be decoded */ #define TOO_MANY_BITS 3 /* pull_bits was passed an argument that is too * large */ /* This struct represents an entire huffman code set. It has various lookup * tables to speed decoding */ struct huffman_set { int bits; /* maximum bit length */ int num_symbols; /* Number of symbols this code can represent */ int *lengths; /* The bit length of symbols */ int *symbols; /* All of the symbols, sorted by the huffman code */ int *count; /* the number of codes of this bit length */ int *first; /* the first code of this bit length */ int *pos; /* the symbol that first represents (in the symbols * array) */ }; struct bitstream { unsigned char *data; /* increments as we move from byte to byte */ unsigned char bit; /* 0 to 7 */ unsigned long decoded; /* The number of bytes decoded */ int error; int distance_count[16]; int distance_first[16]; int distance_pos[16]; int distance_lengths[32]; int distance_symbols[32]; int code_count[8]; int code_first[8]; int code_pos[8]; int code_lengths[19]; int code_symbols[19]; int length_count[16]; int length_first[16]; int length_pos[16]; int length_lengths[288]; int length_symbols[288]; struct huffman_set codes; struct huffman_set lengths; struct huffman_set distance; }; #define NO_COMP 0 #define FIXED_COMP 1 #define DYNAMIC_COMP 2 /* The order that the code lengths in section 3.2.7 are in */ static unsigned char huffman_order[] = {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; /* associate a stream with a block of data and reset the stream */ static void init_stream(struct bitstream *stream, unsigned char *data) { stream->error = NO_ERROR; stream->decoded = 0; stream->data = data; stream->bit = 0; /* The first bit of the stream is the lsb of the * first byte */ /* really sorry about all this initialization, think of a better way, * let me know and it will get cleaned up */ stream->codes.bits = 8; stream->codes.num_symbols = 19; stream->codes.lengths = stream->code_lengths; stream->codes.symbols = stream->code_symbols; stream->codes.count = stream->code_count; stream->codes.first = stream->code_first; stream->codes.pos = stream->code_pos; stream->lengths.bits = 16; stream->lengths.num_symbols = 288; stream->lengths.lengths = stream->length_lengths; stream->lengths.symbols = stream->length_symbols; stream->lengths.count = stream->length_count; stream->lengths.first = stream->length_first; stream->lengths.pos = stream->length_pos; stream->distance.bits = 16; stream->distance.num_symbols = 32; stream->distance.lengths = stream->distance_lengths; stream->distance.symbols = stream->distance_symbols; stream->distance.count = stream->distance_count; stream->distance.first = stream->distance_first; stream->distance.pos = stream->distance_pos; } /* pull 'bits' bits out of the stream. The last bit pulled it returned as the * msb. (section 3.1.1) */ static unsigned long pull_bits(struct bitstream *stream, const unsigned int bits) { unsigned long ret; int i; ret = 0; for (i = 0; i < bits; i++) { ret += ((*(stream->data) >> stream->bit) & 1) << i; /* if, before incrementing, we are on bit 7, * go to the lsb of the next byte */ if (stream->bit++ == 7) { stream->bit = 0; stream->data++; } } return ret; } static int pull_bit(struct bitstream *stream) { int ret = ((*(stream->data) >> stream->bit) & 1); if (stream->bit++ == 7) { stream->bit = 0; stream->data++; } return ret; } /* discard bits up to the next whole byte */ static void discard_bits(struct bitstream *stream) { if (stream->bit != 0) { stream->bit = 0; stream->data++; } } /* No decompression, the data is all literals (section 3.2.4) */ static void decompress_none(struct bitstream *stream, unsigned char *dest) { unsigned int length; discard_bits(stream); length = *(stream->data++); length += *(stream->data++) << 8; pull_bits(stream, 16); /* throw away the inverse of the size */ stream->decoded += length; memcpy(dest, stream->data, length); stream->data += length; } /* Read in a symbol from the stream (section 3.2.2) */ static int read_symbol(struct bitstream *stream, struct huffman_set *set) { int bits = 0; int code = 0; while (!(set->count[bits] && code < set->first[bits] + set->count[bits])) { code = (code << 1) + pull_bit(stream); if (++bits > set->bits) { /* error decoding (corrupted data?) */ stream->error = CODE_NOT_FOUND; return -1; } } return set->symbols[set->pos[bits] + code - set->first[bits]]; } /* decompress a stream of data encoded with the passed length and distance * huffman codes */ static void decompress_huffman(struct bitstream *stream, unsigned char *dest) { struct huffman_set *lengths = &(stream->lengths); struct huffman_set *distance = &(stream->distance); int symbol, length, dist, i; do { if ((symbol = read_symbol(stream, lengths)) < 0) return; if (symbol < 256) { *(dest++) = symbol; /* symbol is a literal */ stream->decoded++; } else if (symbol > 256) { /* Determine the length of the repitition * (section 3.2.5) */ if (symbol < 265) length = symbol - 254; else if (symbol == 285) length = 258; else { length = pull_bits(stream, (symbol - 261) >> 2); length += (4 << ((symbol - 261) >> 2)) + 3; length += ((symbol - 1) % 4) << ((symbol - 261) >> 2); } /* Determine how far back to go */ if ((symbol = read_symbol(stream, distance)) < 0) return; if (symbol < 4) dist = symbol + 1; else { dist = pull_bits(stream, (symbol - 2) >> 1); dist += (2 << ((symbol - 2) >> 1)) + 1; dist += (symbol % 2) << ((symbol - 2) >> 1); } stream->decoded += length; for (i = 0; i < length; i++) *(dest++) = dest[-dist]; } } while (symbol != 256); /* 256 is the end of the data block */ } /* Fill the lookup tables (section 3.2.2) */ static void fill_code_tables(struct huffman_set *set) { int code = 0, i, length; /* fill in the first code of each bit length, and the pos pointer */ set->pos[0] = 0; for (i = 1; i < set->bits; i++) { code = (code + set->count[i - 1]) << 1; set->first[i] = code; set->pos[i] = set->pos[i - 1] + set->count[i - 1]; } /* Fill in the table of symbols in order of their huffman code */ for (i = 0; i < set->num_symbols; i++) { if ((length = set->lengths[i])) set->symbols[set->pos[length]++] = i; } /* reset the pos pointer */ for (i = 1; i < set->bits; i++) set->pos[i] -= set->count[i]; } static void init_code_tables(struct huffman_set *set) { memset(set->lengths, 0, set->num_symbols); memset(set->count, 0, set->bits); memset(set->first, 0, set->bits); } /* read in the huffman codes for dynamic decoding (section 3.2.7) */ static void decompress_dynamic(struct bitstream *stream, unsigned char *dest) { /* I tried my best to minimize the memory footprint here, while still * keeping up performance. I really dislike the _lengths[] tables, but * I see no way of eliminating them without a sizable performance * impact. The first struct table keeps track of stats on each bit * length. The _length table keeps a record of the bit length of each * symbol. The _symbols table is for looking up symbols by the huffman * code (the pos element points to the first place in the symbol table * where that bit length occurs). I also hate the initization of these * structs, if someone knows how to compact these, lemme know. */ struct huffman_set *codes = &(stream->codes); struct huffman_set *lengths = &(stream->lengths); struct huffman_set *distance = &(stream->distance); int hlit = pull_bits(stream, 5) + 257; int hdist = pull_bits(stream, 5) + 1; int hclen = pull_bits(stream, 4) + 4; int length, curr_code, symbol, i, last_code; last_code = 0; init_code_tables(codes); init_code_tables(lengths); init_code_tables(distance); /* fill in the count of each bit length' as well as the lengths * table */ for (i = 0; i < hclen; i++) { length = pull_bits(stream, 3); codes->lengths[huffman_order[i]] = length; if (length) codes->count[length]++; } fill_code_tables(codes); /* Do the same for the length codes, being carefull of wrap through * to the distance table */ curr_code = 0; while (curr_code < hlit) { if ((symbol = read_symbol(stream, codes)) < 0) return; if (symbol == 0) { curr_code++; last_code = 0; } else if (symbol < 16) { /* Literal length */ lengths->lengths[curr_code] = last_code = symbol; lengths->count[symbol]++; curr_code++; } else if (symbol == 16) { /* repeat the last symbol 3 - 6 * times */ length = 3 + pull_bits(stream, 2); for (;length; length--, curr_code++) if (curr_code < hlit) { lengths->lengths[curr_code] = last_code; lengths->count[last_code]++; } else { /* wrap to the distance table */ distance->lengths[curr_code - hlit] = last_code; distance->count[last_code]++; } } else if (symbol == 17) { /* repeat a bit length 0 */ curr_code += 3 + pull_bits(stream, 3); last_code = 0; } else { /* same, but more times */ curr_code += 11 + pull_bits(stream, 7); last_code = 0; } } fill_code_tables(lengths); /* Fill the distance table, don't need to worry about wrapthrough * here */ curr_code -= hlit; while (curr_code < hdist) { if ((symbol = read_symbol(stream, codes)) < 0) return; if (symbol == 0) { curr_code++; last_code = 0; } else if (symbol < 16) { distance->lengths[curr_code] = last_code = symbol; distance->count[symbol]++; curr_code++; } else if (symbol == 16) { length = 3 + pull_bits(stream, 2); for (;length; length--, curr_code++) { distance->lengths[curr_code] = last_code; distance->count[last_code]++; } } else if (symbol == 17) { curr_code += 3 + pull_bits(stream, 3); last_code = 0; } else { curr_code += 11 + pull_bits(stream, 7); last_code = 0; } } fill_code_tables(distance); decompress_huffman(stream, dest); } /* fill in the length and distance huffman codes for fixed encoding * (section 3.2.6) */ static void decompress_fixed(struct bitstream *stream, unsigned char *dest) { /* let gcc fill in the initial values */ struct huffman_set *lengths = &(stream->lengths); struct huffman_set *distance = &(stream->distance); memset(lengths->count, 0, 16); memset(lengths->first, 0, 16); memset(lengths->lengths, 8, 144); memset(lengths->lengths + 144, 9, 112); memset(lengths->lengths + 256, 7, 24); memset(lengths->lengths + 280, 8, 8); lengths->count[7] = 24; lengths->count[8] = 152; lengths->count[9] = 112; memset(distance->count, 0, 16); memset(distance->first, 0, 16); memset(distance->lengths, 5, 32); distance->count[5] = 32; fill_code_tables(lengths); fill_code_tables(distance); decompress_huffman(stream, dest); } /* returns the number of bytes decoded, < 0 if there was an error. Note that * this function assumes that the block starts on a byte boundry * (non-compliant, but I don't see where this would happen). section 3.2.3 */ long decompress_block(unsigned char *dest, unsigned char *source) { int bfinal, btype; struct bitstream stream; init_stream(&stream, source); do { bfinal = pull_bit(&stream); btype = pull_bits(&stream, 2); if (btype == NO_COMP) decompress_none(&stream, dest + stream.decoded); else if (btype == DYNAMIC_COMP) decompress_dynamic(&stream, dest + stream.decoded); else if (btype == FIXED_COMP) decompress_fixed(&stream, dest + stream.decoded); else stream.error = COMP_UNKNOWN; } while (!bfinal && !stream.error); return stream.error ? -stream.error : stream.decoded; } Index: Makefile.am =================================================================== RCS file: /cvsroot/blob/blob/src/lib/Makefile.am,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- Makefile.am 15 Feb 2002 23:08:20 -0000 1.12 +++ Makefile.am 17 Feb 2002 15:41:54 -0000 1.13 @@ -36,6 +36,7 @@ md5support.c \ memcpy.c \ memset.c \ + mini_inflate.c \ printf.c \ reboot.c \ serial.c \ |
From: Erik M. <er...@us...> - 2002-02-17 15:41:57
|
Update of /cvsroot/blob/blob/src/blob In directory usw-pr-cvs1:/tmp/cvs-serv889/src/blob Modified Files: Makefile.am main.c uucodec.c xmodem.c Removed Files: mini_inflate.c Log Message: - cleanup configure.in and Makefile.am - make uudecode and xmodem conditionally compiled sources - make cramfs and jffs2 really conditionally compiled - move mini_inflate to libblob Index: Makefile.am =================================================================== RCS file: /cvsroot/blob/blob/src/blob/Makefile.am,v retrieving revision 1.24 retrieving revision 1.25 diff -u -d -r1.24 -r1.25 --- Makefile.am 16 Feb 2002 00:43:59 -0000 1.24 +++ Makefile.am 17 Feb 2002 15:41:53 -0000 1.25 @@ -63,8 +63,8 @@ start-sa11x0.S blob_start_elf32_DEPENDENCIES = \ - @MEMSETUP@ \ - @STARTCODE@ \ + @BLOB_MEMSETUP_OBJS@ \ + @BLOB_STARTCODE_OBJS@ \ start-ld-script blob_start_elf32_LDFLAGS += \ @@ -72,8 +72,8 @@ -Wl,-Map,blob-start-elf32.map blob_start_elf32_LDADD += \ - @MEMSETUP@ \ - @STARTCODE@ \ + @BLOB_MEMSETUP_OBJS@ \ + @BLOB_STARTCODE_OBJS@ \ -lgcc @@ -133,14 +133,7 @@ param_block.c \ partition.c \ reboot.c \ - uucodec.c \ - xmodem.c \ load_kernel.c \ - mini_inflate.c \ - jffs2.c \ - compr_rtime.c \ - compr_rubin.c \ - cramfs.c \ zImage.c @@ -149,48 +142,46 @@ chkmem.c \ clock.c \ debug.c \ - amd32.c \ - intel16.c \ - intel32.c \ - nullflash.c \ - accelent_sa.c \ - assabet.c \ - brutus.c \ - badge4.c \ - clart.c \ - frodo.c \ - h3600.c \ - idr.c \ - jornada720.c \ - lart.c \ - nesa.c \ - pleb.c \ - shannon.c \ + amd32.c intel16.c intel32.c nullflash.c \ + cramfs.c \ + compr_rtime.c compr_rubin.c jffs2.c \ + uucodec.c \ + xmodem.c \ + accelent_sa.c assabet.c brutus.c badge4.c clart.c frodo.c \ + h3600.c idr.c jornada720.c lart.c nesa.c pleb.c shannon.c \ system3.c blob_rest_elf32_DEPENDENCIES = \ - @BLOB_PLATFORM_OBJ@ \ + @BLOB_CHKMEM_OBJS@ \ + @BLOB_CLOCK_OBJS@ \ + @BLOB_CRAMFS_OBJS@ \ + @BLOB_DEBUG_OBJS@ \ @BLOB_FLASH_OBJS@ \ - @CHKMEM@ \ - @DEBUG@ \ - @CLOCK@ \ + @BLOB_JFFS2_OBJS@ \ + @BLOB_PLATFORM_OBJS@ \ + @BLOB_UUCODEC_OBJS@ \ + @BLOB_XMODEM_OBJS@ \ ${top_builddir}/src/commands/libcommands.a \ ${top_builddir}/src/lib/libblob.a \ rest-ld-script blob_rest_elf32_LDFLAGS += \ + @BLOB_CHKMEM_OBJS@ \ + @BLOB_CLOCK_OBJS@ \ + @BLOB_CRAMFS_OBJS@ \ + @BLOB_DEBUG_OBJS@ \ + @BLOB_FLASH_OBJS@ \ + @BLOB_JFFS2_OBJS@ \ + @BLOB_PLATFORM_OBJS@ \ + @BLOB_UUCODEC_OBJS@ \ + @BLOB_XMODEM_OBJS@ \ -Wl,-T,rest-ld-script \ -Wl,-Map,blob-rest-elf32.map blob_rest_elf32_LDADD += \ - @BLOB_PLATFORM_OBJ@ \ - @BLOB_FLASH_OBJS@ \ - @CHKMEM@ \ - @DEBUG@ \ - @CLOCK@ \ -L${top_builddir}/src/commands -L${top_builddir}/src/lib \ -lcommands -lblob \ -lgcc Index: main.c =================================================================== RCS file: /cvsroot/blob/blob/src/blob/main.c,v retrieving revision 1.34 retrieving revision 1.35 diff -u -d -r1.34 -r1.35 --- main.c 16 Feb 2002 00:43:59 -0000 1.34 +++ main.c 17 Feb 2002 15:41:54 -0000 1.35 @@ -188,6 +188,7 @@ +#if (defined CONFIG_XMODEM_SUPPORT) || (defined CONFIG_UUCODEC_SUPPORT) static int set_download_parameters(char *name, u32 *startAddress, int *bufLen, int **numRead, u32 **digest) @@ -229,6 +230,7 @@ return 0; } +#endif Index: uucodec.c =================================================================== RCS file: /cvsroot/blob/blob/src/blob/uucodec.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- uucodec.c 5 Feb 2002 14:47:54 -0000 1.4 +++ uucodec.c 17 Feb 2002 15:41:54 -0000 1.5 @@ -37,8 +37,6 @@ # include <blob/config.h> #endif -#ifdef CONFIG_UUCODEC_SUPPORT - #include <blob/errno.h> #include <blob/serial.h> #include <blob/util.h> @@ -197,6 +195,3 @@ } /* UUEncode */ #endif - -#endif /* #ifdef CONFIG_UUCODEC_SUPPORT */ - Index: xmodem.c =================================================================== RCS file: /cvsroot/blob/blob/src/blob/xmodem.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- xmodem.c 4 Feb 2002 12:14:16 -0000 1.3 +++ xmodem.c 17 Feb 2002 15:41:54 -0000 1.4 @@ -35,8 +35,6 @@ # include <blob/config.h> #endif -#ifdef CONFIG_XMODEM_SUPPORT - #include <blob/errno.h> #include <blob/serial.h> #include <blob/util.h> @@ -266,6 +264,3 @@ done: return length; } - -#endif /* #ifdef CONFIG_XMODEM_SUPPORT */ - --- mini_inflate.c DELETED --- |
From: Erik M. <er...@us...> - 2002-02-17 15:41:57
|
Update of /cvsroot/blob/blob/src/diag In directory usw-pr-cvs1:/tmp/cvs-serv889/src/diag Modified Files: Makefile.am Log Message: - cleanup configure.in and Makefile.am - make uudecode and xmodem conditionally compiled sources - make cramfs and jffs2 really conditionally compiled - move mini_inflate to libblob Index: Makefile.am =================================================================== RCS file: /cvsroot/blob/blob/src/diag/Makefile.am,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- Makefile.am 7 Feb 2002 23:59:37 -0000 1.12 +++ Makefile.am 17 Feb 2002 15:41:54 -0000 1.13 @@ -60,8 +60,8 @@ system3.c diag_elf32_DEPENDENCIES = \ - @LCD@ \ - @DIAG_PLATFORM_OBJ@ \ + @DIAG_LCD_OBJS@ \ + @DIAG_PLATFORM_OBJS@ \ ${top_builddir}/src/commands/libcommands.a \ ${top_builddir}/src/lib/libblob.a \ ld-script @@ -72,8 +72,8 @@ diag_elf32_LDADD += \ - @LCD@ \ - @DIAG_PLATFORM_OBJ@ \ + @DIAG_LCD_OBJS@ \ + @DIAG_PLATFORM_OBJS@ \ -L${top_builddir}/src/commands -L${top_builddir}/src/lib \ -lcommands -lblob \ -lgcc |
From: Erik M. <er...@us...> - 2002-02-17 15:41:56
|
Update of /cvsroot/blob/blob In directory usw-pr-cvs1:/tmp/cvs-serv889 Modified Files: configure.in Log Message: - cleanup configure.in and Makefile.am - make uudecode and xmodem conditionally compiled sources - make cramfs and jffs2 really conditionally compiled - move mini_inflate to libblob Index: configure.in =================================================================== RCS file: /cvsroot/blob/blob/configure.in,v retrieving revision 1.44 retrieving revision 1.45 diff -u -d -r1.44 -r1.45 --- configure.in 8 Feb 2002 12:49:03 -0000 1.44 +++ configure.in 17 Feb 2002 15:41:53 -0000 1.45 @@ -98,19 +98,19 @@ accelent_sa) board_name="Accelent IDP" AC_DEFINE(ACCELENT_SA) - BLOB_PLATFORM_OBJ="accelent_sa.o" + BLOB_PLATFORM_OBJS="accelent_sa.o" BLOB_FLASH_OBJS="intel32.o" - DIAG_PLATFORM_OBJ="accelent_sa.o" + DIAG_PLATFORM_OBJS="accelent_sa.o" use_cpu="sa1110" use_lcd="no" ;; assabet) board_name="Intel Assabet" AC_DEFINE(ASSABET) - BLOB_PLATFORM_OBJ="assabet.o" + BLOB_PLATFORM_OBJS="assabet.o" AC_MSG_WARN([Please check assabet memory config in arch/assabet.h]) BLOB_FLASH_OBJS="intel32.o" - DIAG_PLATFORM_OBJ="assabet.o" + DIAG_PLATFORM_OBJS="assabet.o" use_cpu="sa1110" use_lcd="no" ;; @@ -118,124 +118,124 @@ board_name="Intel Assabet with Neponset Expansion Board" AC_DEFINE(ASSABET) AC_DEFINE(NEPONSET) - BLOB_PLATFORM_OBJ="assabet.o" + BLOB_PLATFORM_OBJS="assabet.o" AC_MSG_WARN([Please check assabet memory config in arch/assabet.h]) BLOB_FLASH_OBJS="intel32.o" - DIAG_PLATFORM_OBJ="assabet.o" + DIAG_PLATFORM_OBJS="assabet.o" use_cpu="sa1110" use_lcd="no" ;; badge4) board_name="Hewlett-Packard Laboratories Badge-4" AC_DEFINE(BADGE4) - BLOB_PLATFORM_OBJ="badge4.o" + BLOB_PLATFORM_OBJS="badge4.o" BLOB_FLASH_OBJS="intel16.o" - DIAG_PLATFORM_OBJ="badge4.o" + DIAG_PLATFORM_OBJS="badge4.o" use_cpu="sa1110" use_lcd="no" ;; brutus) board_name="Intel Brutus" AC_DEFINE(BRUTUS) - BLOB_PLATFORM_OBJ="brutus.o" + BLOB_PLATFORM_OBJS="brutus.o" AC_MSG_WARN([Please check Brutus flash]) BLOB_FLASH_OBJS="nullflash.o" - DIAG_PLATFORM_OBJ="brutus.o" + DIAG_PLATFORM_OBJS="brutus.o" use_cpu="sa1100" use_lcd="no" ;; creditlart) board_name="Delft University of Technology CreditLART" AC_DEFINE(CLART) - BLOB_PLATFORM_OBJ="clart.o" + BLOB_PLATFORM_OBJS="clart.o" AC_MSG_WARN([Please check creditlart memory config in arch/clart.h]) BLOB_FLASH_OBJS="intel16.o" - DIAG_PLATFORM_OBJ="clart.o" + DIAG_PLATFORM_OBJS="clart.o" use_cpu="sa1110" use_lcd="no" ;; frodo) board_name="2d3D, Inc. SA-1110 Development Board" AC_DEFINE(FRODO) - BLOB_PLATFORM_OBJ="frodo.o" + BLOB_PLATFORM_OBJS="frodo.o" BLOB_FLASH_OBJS="intel32.o" - DIAG_PLATFORM_OBJ="frodo.o" + DIAG_PLATFORM_OBJS="frodo.o" use_cpu="sa1110" use_lcd="no" ;; h3600) board_name="Compaq Ipaq H3600 series" AC_DEFINE(H3600) - BLOB_PLATFORM_OBJ="h3600.o" + BLOB_PLATFORM_OBJS="h3600.o" AC_MSG_WARN([Warning: untested platform!]) AC_MSG_WARN([Please check h3600 memory config in arch/h3600.h]) BLOB_FLASH_OBJS="intel32.o" - DIAG_PLATFORM_OBJ="h3600.o" + DIAG_PLATFORM_OBJS="h3600.o" use_cpu="sa1110" use_lcd="no" ;; idr) board_name="Vercel UD-1 (IDR)" AC_DEFINE(IDR) - BLOB_PLATFORM_OBJ="idr.o" + BLOB_PLATFORM_OBJS="idr.o" BLOB_FLASH_OBJS="intel16.o" - DIAG_PLATFORM_OBJ="idr.o" + DIAG_PLATFORM_OBJS="idr.o" use_cpu="sa1110" use_lcd="no" ;; jornada720) board_name="Hewlett-Packard Jornada 720 with flash daughter board" AC_DEFINE(JORNADA720) - BLOB_PLATFORM_OBJ="jornada720.o" + BLOB_PLATFORM_OBJS="jornada720.o" AC_MSG_WARN([Warning: untested platform!]) BLOB_FLASH_OBJS="intel32.o" - DIAG_PLATFORM_OBJ="jornada720.o" + DIAG_PLATFORM_OBJS="jornada720.o" use_cpu="sa1110" use_lcd="no" ;; lart) board_name="Delft University of Technology LART" AC_DEFINE(LART) - BLOB_PLATFORM_OBJ="lart.o" + BLOB_PLATFORM_OBJS="lart.o" BLOB_FLASH_OBJS="intel32.o" - DIAG_PLATFORM_OBJ="lart.o" + DIAG_PLATFORM_OBJS="lart.o" use_cpu="sa1100" use_lcd="no" ;; nesa) board_name="NESA" AC_DEFINE(NESA) - BLOB_PLATFORM_OBJ="nesa.o" + BLOB_PLATFORM_OBJS="nesa.o" BLOB_FLASH_OBJS="amd32.o" - DIAG_PLATFORM_OBJ="nesa.o" + DIAG_PLATFORM_OBJS="nesa.o" use_cpu="sa1100" use_lcd="no" ;; pleb) board_name="University of New South Wales PLEB" AC_DEFINE(PLEB) - BLOB_PLATFORM_OBJ="pleb.o" + BLOB_PLATFORM_OBJS="pleb.o" AC_MSG_WARN([Please check PLEB flash]) BLOB_FLASH_OBJS="nullflash.o" - DIAG_PLATFORM_OBJ="pleb.o" + DIAG_PLATFORM_OBJS="pleb.o" use_cpu="sa1100" use_lcd="no" ;; shannon) board_name="TuxScreen (Shannon)" AC_DEFINE(SHANNON) - BLOB_PLATFORM_OBJ="shannon.o" + BLOB_PLATFORM_OBJS="shannon.o" BLOB_FLASH_OBJS="amd32.o" - DIAG_PLATFORM_OBJ="shannon.o" + DIAG_PLATFORM_OBJS="shannon.o" use_cpu="sa1100" use_lcd="no" ;; system3) board_name="Prueftechnik Digital Board" AC_DEFINE(PT_SYSTEM3) - BLOB_PLATFORM_OBJ="system3.o" + BLOB_PLATFORM_OBJS="system3.o" BLOB_FLASH_OBJS="intel32.o" - DIAG_PLATFORM_OBJ="system3.o" + DIAG_PLATFORM_OBJS="system3.o" use_cpu="sa1110" use_lcd="yes" ;; @@ -245,6 +245,13 @@ ;; esac +AC_SUBST(BLOB_FLASH_OBJS) +AC_SUBST(BLOB_PLATFORM_OBJS) +AC_SUBST(DIAG_PLATFORM_OBJS) + + + + dnl define board name and CPU in configuration AC_MSG_RESULT("${board_name}") AC_DEFINE_UNQUOTED(BOARD_NAME, "${board_name}") @@ -255,13 +262,13 @@ case "$use_cpu" in sa1100) dnl SA1100 CPU: EDORAM memory setup code - STARTCODE="start-sa11x0.o" - MEMSETUP="memsetup-sa1100.o" + BLOB_STARTCODE_OBJS="start-sa11x0.o" + BLOB_MEMSETUP_OBJS="memsetup-sa1100.o" ;; sa1110) dnl SA1110 CPU: SDRAM memory setup code - STARTCODE="start-sa11x0.o" - MEMSETUP="memsetup-sa1110.o" + BLOB_STARTCODE_OBJS="start-sa11x0.o" + BLOB_MEMSETUP_OBJS="memsetup-sa1110.o" ;; *) AC_MSG_ERROR([Unknown CPU name \"$use_cpu\", bailing out]); @@ -269,8 +276,8 @@ esac dnl Define in configuration -AC_SUBST(STARTCODE) -AC_SUBST(MEMSETUP) +AC_SUBST(BLOB_STARTCODE_OBJS) +AC_SUBST(BLOB_MEMSETUP_OBJS) @@ -300,6 +307,7 @@ + dnl Check for individual features AC_ARG_ENABLE(clock-scaling, [ --enable-clock-scaling Enable support for clock scaling (SA1100 only)], @@ -347,6 +355,8 @@ [cramfs_flag=no]) + + dnl Check if the user wants *all* features AC_ARG_ENABLE(all-features, [ --enable-all-features Enable all features], @@ -367,40 +377,47 @@ + dnl Check wether or not clock scaling code is wanted if test "x$clock_scaling_flag" = "xyes" ; then if test "x$use_cpu" = "xsa1100"; then - CLOCK="clock.o" + BLOB_CLOCK_OBJS="clock.o" else AC_MSG_WARN([No clock scaling support for SA1110 CPUs, disabling]) clock_scaling_flag=no - CLOCK="" + BLOB_CLOCK_OBJS="" fi fi -AC_SUBST(CLOCK) +AC_SUBST(BLOB_CLOCK_OBJS) dnl Check wether or not memtest code is wanted if test "x$chkmem_flag" = "xyes" ; then - CHKMEM="chkmem.o" + BLOB_CHKMEM_OBJS="chkmem.o" fi -AC_SUBST(CHKMEM) +AC_SUBST(BLOB_CHKMEM_OBJS) + + + dnl Check wether or not debug code is wanted if test "x$debug_flag" = "xyes" ; then - DEBUG="debug.o" + BLOB_DEBUG_OBJS="debug.o" fi -AC_SUBST(DEBUG) +AC_SUBST(BLOB_DEBUG_OBJS) + + + dnl Check wether or not lcd support code is wanted if test "x$lcd_flag" = "xyes" ; then if test "x$use_lcd" = "xyes" ; then - LCD="lcd.o" + DIAG_LCD_OBJS="lcd.o" AC_DEFINE(CONFIG_LCD_SUPPORT) else AC_MSG_WARN([No LCD support for ${board_name}, disabling]) @@ -409,40 +426,66 @@ fi fi -AC_SUBST(LCD) +AC_SUBST(DIAG_LCD_OBJS) + + + dnl Check wether or not MD5 support is wanted if test "x$md5_flag" = "xyes" ; then AC_DEFINE(CONFIG_MD5_SUPPORT) fi + + + dnl Check wether or not Xmodem support is wanted if test "x$xmodem_flag" = "xyes" ; then AC_DEFINE(CONFIG_XMODEM_SUPPORT) + BLOB_XMODEM_OBJS="xmodem.o" fi +AC_SUBST(BLOB_XMODEM_OBJS) + + + + dnl Check wether or not UU Codec support is wanted if test "x$uucodec_flag" = "xyes"; then AC_DEFINE(CONFIG_UUCODEC_SUPPORT) + BLOB_UUCODEC_OBJS="uucodec.o" fi +AC_SUBST(BLOB_UUCODEC_OBJS) + + + + dnl Check wether or not JFFS2 support is wanted if test "x$jffs2_flag" = "xyes" ; then - AC_MSG_WARN("JFFS2 support is only dummy code") + BLOB_JFFS2_OBJS="compr_rtime.o compr_rubin.o jffs2.o" AC_DEFINE(CONFIG_JFFS2_SUPPORT) fi +AC_SUBST(BLOB_JFFS2_OBJS) + + + + dnl Check wether or not cramfs support is wanted if test "x$cramfs_flag" = "xyes" ; then - AC_MSG_WARN("cramfs support is only dummy code") + BLOB_CRAMFS_OBJS="cramfs.o" AC_DEFINE(CONFIG_CRAMFS_SUPPORT) fi +AC_SUBST(BLOB_CRAMFS_OBJS) + + + + dnl Check wether or not additional platform source code dnl for is needed -AC_SUBST(BLOB_FLASH_OBJS) -AC_SUBST(BLOB_PLATFORM_OBJ) -AC_SUBST(DIAG_PLATFORM_OBJ) + |
Update of /cvsroot/blob/blob/src/blob In directory usw-pr-cvs1:/tmp/cvs-serv23847/src/blob Modified Files: Makefile.am compr_rtime.c compr_rubin.c cramfs.c jffs2.c load_kernel.c main.c mini_inflate.c zImage.c Removed Files: compr_zlib.c Log Message: cramfs+JFFS2 cleanup part one (code size got almost 2K smaller) Index: Makefile.am =================================================================== RCS file: /cvsroot/blob/blob/src/blob/Makefile.am,v retrieving revision 1.23 retrieving revision 1.24 diff -u -d -r1.23 -r1.24 --- Makefile.am 14 Feb 2002 09:59:34 -0000 1.23 +++ Makefile.am 16 Feb 2002 00:43:59 -0000 1.24 @@ -135,12 +135,11 @@ reboot.c \ uucodec.c \ xmodem.c \ - load_kernel.c \ + load_kernel.c \ mini_inflate.c \ jffs2.c \ compr_rtime.c \ compr_rubin.c \ - compr_zlib.c \ cramfs.c \ zImage.c Index: compr_rtime.c =================================================================== RCS file: /cvsroot/blob/blob/src/blob/compr_rtime.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- compr_rtime.c 14 Feb 2002 09:59:34 -0000 1.1 +++ compr_rtime.c 16 Feb 2002 00:43:59 -0000 1.2 @@ -45,19 +45,27 @@ * */ -#include "blob/types.h" +#ident "$Id$" + +#ifdef HAVE_CONFIG_H +# include <blob/config.h> +#endif + +#include <blob/types.h> +#include <blob/util.h> + +static int positions[256]; void rtime_decompress(unsigned char *data_in, unsigned char *cpage_out, - u32 srclen, u32 destlen) + u32 srclen, u32 destlen) { - int positions[256]; int outpos; int pos; int i; outpos = pos = 0; - for (i = 0; i < 256; positions[i++] = 0); + memset(positions, 0, 256 * sizeof(int)); while (outpos<destlen) { unsigned char value; Index: compr_rubin.c =================================================================== RCS file: /cvsroot/blob/blob/src/blob/compr_rubin.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- compr_rubin.c 14 Feb 2002 09:59:34 -0000 1.1 +++ compr_rubin.c 16 Feb 2002 00:43:59 -0000 1.2 @@ -38,12 +38,18 @@ * */ - -#include "blob/types.h" -#include "blob/compr_rubin.h" +#ident "$Id$" -void rubin_do_decompress(unsigned char *bits, unsigned char *in, - unsigned char *page_out, u32 destlen) +#ifdef HAVE_CONFIG_H +# include <blob/config.h> +#endif + +#include <blob/types.h> +#include <blob/compr_rubin.h> + + +static void rubin_do_decompress(unsigned char *bits, unsigned char *in, + unsigned char *page_out, u32 destlen) { register char *curr = page_out; char *end = page_out + destlen; Index: cramfs.c =================================================================== RCS file: /cvsroot/blob/blob/src/blob/cramfs.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- cramfs.c 14 Feb 2002 10:17:59 -0000 1.2 +++ cramfs.c 16 Feb 2002 00:43:59 -0000 1.3 @@ -26,10 +26,16 @@ /* note: this module doesn't currently support symlinks, but because of the * nature of cramfs, this shouldn't be a big deal */ -#include "blob/types.h" -#include "blob/main.h" -#include "blob/load_kernel.h" -#include "blob/mini_inflate.h" +#ident "$Id$" + +#ifdef HAVE_CONFIG_H +# include <blob/config.h> +#endif + +#include <blob/types.h> +#include <blob/load_kernel.h> +#include <blob/mini_inflate.h> +#include <blob/util.h> #define CRAMFS_MAGIC 0x28cd3d45 /* some random number */ @@ -74,7 +80,7 @@ src++; /* *src == 0x78 method */ src++; /* *src == 0x9C flags (!PRESET_DICT) */ - size = decompress_block(dest, src, ldr_memcpy); + size = decompress_block(dest, src); return size; } @@ -84,7 +90,7 @@ { long int curr_block; - unsigned long *block_ptrs; + u32 *block_ptrs; long size, total_size = 0; int i; @@ -128,7 +134,7 @@ /* does it have 5 to 8 characters? */ if (!inode->namelen == 2) continue; name = (char *) (inode + 1); - if (!ldr_strncmp("linux\0\0", name, 8)) { + if (!strncmp("linux\0\0", name, 8)) { size = cramfs_load_file(dest, part, inode); break; } Index: jffs2.c =================================================================== RCS file: /cvsroot/blob/blob/src/blob/jffs2.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- jffs2.c 14 Feb 2002 10:17:59 -0000 1.2 +++ jffs2.c 16 Feb 2002 00:43:59 -0000 1.3 @@ -63,21 +63,29 @@ * */ +#ident "$Id$" + +#ifdef HAVE_CONFIG_H +# include <blob/config.h> +#endif + +#include <blob/crc32.h> +#include <blob/compr_rubin.h> +#include <blob/jffs2.h> +#include <blob/load_kernel.h> +#include <blob/main.h> +#include <blob/mini_inflate.h> +#include <blob/types.h> +#include <blob/util.h> + + -#include "blob/types.h" -#include "blob/main.h" -#include "blob/load_kernel.h" -#include "blob/jffs2.h" -#include "blob/crc32.h" static struct jffs2_raw_dirent *find_inode(struct part_info *part, char *name, u32 pino); -void rtime_decompress (unsigned char *data_in, unsigned char *cpage_out, - u32 srclen, u32 destlen); -void dynrubin_decompress(unsigned char *data_in, unsigned char *cpage_out, - u32 srclen, u32 destlen); -void zlib_decompress (unsigned char *data_in, unsigned char *cpage_out, - u32 srclen, u32 destlen); +extern void rtime_decompress(unsigned char *data_in, unsigned char *cpage_out, + u32 srclen, u32 destlen); + struct data_strip { struct jffs2_raw_inode *inode; @@ -87,14 +95,25 @@ struct data_strip *next; }; -inline int hdr_crc(struct jffs2_unknown_node *node) + +static inline void zlib_decompress(unsigned char *data_in, + unsigned char *cpage_out, + u32 srclen, u32 destlen) +{ + /* FIXME: we *totally* ignore the srclen and destlen + * parameters over here -- Erik */ + decompress_block(cpage_out, data_in + 2); +} + + +static int hdr_crc(struct jffs2_unknown_node *node) { if(node->hdr_crc != crc32(0, node, sizeof(struct jffs2_unknown_node) - 4)) return 0; else return 1; } -inline int dirent_crc(struct jffs2_raw_dirent *node) +static int dirent_crc(struct jffs2_raw_dirent *node) { if (node->node_crc != crc32(0, node, sizeof(struct jffs2_raw_dirent) - 8)) { UDEBUG("bad dirent_crc\n"); @@ -102,7 +121,7 @@ } else return 1; } -inline int dirent_name_crc(struct jffs2_raw_dirent *node) +static int dirent_name_crc(struct jffs2_raw_dirent *node) { if (node->name_crc != crc32(0, &(node->name), node->nsize)) { UDEBUG("bad dirent_name_crc\n"); @@ -110,7 +129,7 @@ } else return 1; } -inline int inode_crc(struct jffs2_raw_inode *node) +static int inode_crc(struct jffs2_raw_inode *node) { if (node->node_crc != crc32(0, node, sizeof(struct jffs2_raw_inode) - 8)) { UDEBUG("bad inode_crc\n"); @@ -139,13 +158,13 @@ src = ((char *) first->inode) + sizeof(struct jffs2_raw_inode); if (first->inode->data_crc != crc32(0, src, first->inode->csize)) { - ldr_output_string("CRC Error!"); + printf("CRC Error!"); return 0; } switch (first->inode->compr) { case JFFS2_COMPR_NONE: - ldr_memcpy(dest, src, first->length); + memcpy(dest, src, first->length); break; case JFFS2_COMPR_ZERO: for (i = 0; i < first->length; i++) *(dest++) = 0; @@ -198,7 +217,8 @@ /* Fill the list of nodes pertaining to this file */ while (offset < part->size - sizeof(struct jffs2_raw_inode)) { inode = (struct jffs2_raw_inode *) (part->offset + offset); - if (inode->magic == JFFS2_MAGIC_BITMASK && hdr_crc(inode)) { + if (inode->magic == JFFS2_MAGIC_BITMASK && + hdr_crc((struct jffs2_unknown_node *)inode)) { if (inode->nodetype == JFFS2_NODETYPE_INODE && inode->ino == inode_num && inode_crc(inode)) { /* add it in newest first order to our list */ @@ -289,7 +309,7 @@ curr_name[len] = '\0'; /* go up an inode if its a '..' */ - up = (len == 2 && !ldr_strncmp("..", curr_name, 2)); + up = (len == 2 && !strncmp("..", curr_name, 2)); UDEBUG("\nlooking for '%s' ...", curr_name); @@ -300,7 +320,7 @@ while (off < part->size - sizeof(struct jffs2_raw_inode)) { curr = (struct jffs2_raw_dirent *)(part->offset + off); if (curr->magic == JFFS2_MAGIC_BITMASK && - hdr_crc(curr)) { + hdr_crc((struct jffs2_unknown_node*)curr)) { if (curr->nodetype == JFFS2_NODETYPE_DIRENT && up && curr->ino == pino && dirent_crc(curr) && curr->version > version) { @@ -310,7 +330,7 @@ !up && curr->pino == pino && curr->nsize == len && dirent_crc(curr) && dirent_name_crc(curr) && - !ldr_strncmp(curr_name, curr->name, len) && + !strncmp(curr_name, curr->name, len) && curr->version > version) { UDEBUG("found matching dirent\n"); version = curr->version; Index: load_kernel.c =================================================================== RCS file: /cvsroot/blob/blob/src/blob/load_kernel.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- load_kernel.c 14 Feb 2002 10:17:59 -0000 1.2 +++ load_kernel.c 16 Feb 2002 00:43:59 -0000 1.3 @@ -26,14 +26,16 @@ * */ -#include "types.h" -#include "config.h" -#include "serial.h" -#include "util.h" -#include "main.h" -#include "load_kernel.h" +#ident "$Id$" + +#ifdef HAVE_CONFIG_H +# include <blob/config.h> +#endif #include <blob/arch.h> +#include <blob/error.h> +#include <blob/load_kernel.h> +#include <blob/util.h> #ifdef CONFIG_CRAMFS_SUPPORT extern struct kernel_loader cramfs_load; @@ -64,36 +66,17 @@ const void *fodder_ram_base = (void *) FODDER_RAM_BASE; /* function calls for blob */ -inline void ldr_update_progress(void) +void ldr_update_progress(void) { printf("."); } -inline int ldr_strncmp(char *a, char *b, size_t n) -{ - return strncmp(a, b, n); -} -inline void *ldr_memcpy(void *dst, void *src, size_t n) -{ - memcpy(dst, src, n); - return dst; -} - -inline void ldr_output_string(char *str) -{ - SerialOutputString(str); -} - -inline void ldr_output_hex(u32 hex) -{ - SerialOutputHex(hex); -} void load_kernel(blob_status_t *blob_status) { int i; - unsigned long size; + u32 size; struct part_info part; /* FIXME this is hardcoded, should use flash[].size */ @@ -101,26 +84,26 @@ part.erasesize = MAIN_BLOCK_SIZE; part.size = KERNEL_FLASH_LEN; part.offset = (char *) KERNEL_FLASH_BASE; - for (i = 0; loader[i] && !loader[i]->check_magic(&part); i++); + + for (i = 0; loader[i] && !loader[i]->check_magic(&part); i++) + ; + if (!loader[i]) { - SerialOutputString("unable to find kernel, loading raw data " - "and hoping for the best!\rloading"); + eprintf("unable to find kernel, loading raw data " + "and hoping for the best!\n"); size = KERNEL_FLASH_LEN; MyMemCpy((u32 *)KERNEL_RAM_BASE, (u32 *)KERNEL_FLASH_BASE, size >> 2); - } else { - SerialOutputString("loading kernel from "); - SerialOutputString(loader[i]->name); + printf("loading kernel from %s ...", loader[i]->name); if ((size = loader[i]->load_kernel((u32 *)KERNEL_RAM_BASE, &part)) == 0) { - SerialOutputString(" error loading kernel!\r"); + eprintf("error loading kernel!\n"); return; } } - SerialOutputString("loaded 0x"); - SerialOutputHex(size); - SerialOutputString(" bytes\r"); + blob_status->kernelSize = size; blob_status->kernelType = fromFlash; -} + printf("loaded 0x%08x (%d) bytes\n", size, size); +} Index: main.c =================================================================== RCS file: /cvsroot/blob/blob/src/blob/main.c,v retrieving revision 1.33 retrieving revision 1.34 diff -u -d -r1.33 -r1.34 --- main.c 14 Feb 2002 10:17:59 -0000 1.33 +++ main.c 16 Feb 2002 00:43:59 -0000 1.34 @@ -45,6 +45,7 @@ #include <blob/flash.h> #include <blob/init.h> #include <blob/led.h> +#include <blob/load_kernel.h> #include <blob/main.h> #include <blob/md5.h> #include <blob/md5support.h> @@ -57,7 +58,6 @@ #include <blob/uucodec.h> #include <blob/xmodem.h> -#include "load_kernel.h" static int do_reload(char *what); Index: mini_inflate.c =================================================================== RCS file: /cvsroot/blob/blob/src/blob/mini_inflate.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- mini_inflate.c 14 Feb 2002 09:59:34 -0000 1.1 +++ mini_inflate.c 16 Feb 2002 00:43:59 -0000 1.2 @@ -22,25 +22,81 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ -#include "blob/mini_inflate.h" +#ident "$Id$" + +#ifdef HAVE_CONFIG_H +# include <blob/config.h> +#endif + +#include <blob/mini_inflate.h> +#include <blob/util.h> + + + +#define NO_ERROR 0 +#define COMP_UNKNOWN 1 /* The specififed bytype is invalid */ +#define CODE_NOT_FOUND 2 /* a huffman code in the stream could not be decoded */ +#define TOO_MANY_BITS 3 /* pull_bits was passed an argument that is too + * large */ + +/* This struct represents an entire huffman code set. It has various lookup + * tables to speed decoding */ +struct huffman_set { + int bits; /* maximum bit length */ + int num_symbols; /* Number of symbols this code can represent */ + int *lengths; /* The bit length of symbols */ + int *symbols; /* All of the symbols, sorted by the huffman code */ + int *count; /* the number of codes of this bit length */ + int *first; /* the first code of this bit length */ + int *pos; /* the symbol that first represents (in the symbols + * array) */ +}; + +struct bitstream { + unsigned char *data; /* increments as we move from byte to byte */ + unsigned char bit; /* 0 to 7 */ + unsigned long decoded; /* The number of bytes decoded */ + int error; + + int distance_count[16]; + int distance_first[16]; + int distance_pos[16]; + int distance_lengths[32]; + int distance_symbols[32]; + + int code_count[8]; + int code_first[8]; + int code_pos[8]; + int code_lengths[19]; + int code_symbols[19]; + + int length_count[16]; + int length_first[16]; + int length_pos[16]; + int length_lengths[288]; + int length_symbols[288]; + + struct huffman_set codes; + struct huffman_set lengths; + struct huffman_set distance; +}; + +#define NO_COMP 0 +#define FIXED_COMP 1 +#define DYNAMIC_COMP 2 + + + /* The order that the code lengths in section 3.2.7 are in */ static unsigned char huffman_order[] = {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; -inline void cramfs_memset(int *s, const int c, size n) -{ - n--; - for (;n > 0; n--) s[n] = c; - s[0] = c; -} /* associate a stream with a block of data and reset the stream */ -static void init_stream(struct bitstream *stream, unsigned char *data, - void *(*inflate_memcpy)(void *, void *, size)) +static void init_stream(struct bitstream *stream, unsigned char *data) { stream->error = NO_ERROR; - stream->memcpy = inflate_memcpy; stream->decoded = 0; stream->data = data; stream->bit = 0; /* The first bit of the stream is the lsb of the @@ -77,7 +133,7 @@ /* pull 'bits' bits out of the stream. The last bit pulled it returned as the * msb. (section 3.1.1) */ -inline unsigned long pull_bits(struct bitstream *stream, +static unsigned long pull_bits(struct bitstream *stream, const unsigned int bits) { unsigned long ret; @@ -97,7 +153,7 @@ return ret; } -inline int pull_bit(struct bitstream *stream) +static int pull_bit(struct bitstream *stream) { int ret = ((*(stream->data) >> stream->bit) & 1); if (stream->bit++ == 7) { @@ -127,7 +183,7 @@ pull_bits(stream, 16); /* throw away the inverse of the size */ stream->decoded += length; - stream->memcpy(dest, stream->data, length); + memcpy(dest, stream->data, length); stream->data += length; } @@ -214,9 +270,9 @@ static void init_code_tables(struct huffman_set *set) { - cramfs_memset(set->lengths, 0, set->num_symbols); - cramfs_memset(set->count, 0, set->bits); - cramfs_memset(set->first, 0, set->bits); + memset(set->lengths, 0, set->num_symbols); + memset(set->count, 0, set->bits); + memset(set->first, 0, set->bits); } /* read in the huffman codes for dynamic decoding (section 3.2.7) */ @@ -332,19 +388,19 @@ struct huffman_set *lengths = &(stream->lengths); struct huffman_set *distance = &(stream->distance); - cramfs_memset(lengths->count, 0, 16); - cramfs_memset(lengths->first, 0, 16); - cramfs_memset(lengths->lengths, 8, 144); - cramfs_memset(lengths->lengths + 144, 9, 112); - cramfs_memset(lengths->lengths + 256, 7, 24); - cramfs_memset(lengths->lengths + 280, 8, 8); + memset(lengths->count, 0, 16); + memset(lengths->first, 0, 16); + memset(lengths->lengths, 8, 144); + memset(lengths->lengths + 144, 9, 112); + memset(lengths->lengths + 256, 7, 24); + memset(lengths->lengths + 280, 8, 8); lengths->count[7] = 24; lengths->count[8] = 152; lengths->count[9] = 112; - cramfs_memset(distance->count, 0, 16); - cramfs_memset(distance->first, 0, 16); - cramfs_memset(distance->lengths, 5, 32); + memset(distance->count, 0, 16); + memset(distance->first, 0, 16); + memset(distance->lengths, 5, 32); distance->count[5] = 32; @@ -358,13 +414,12 @@ /* returns the number of bytes decoded, < 0 if there was an error. Note that * this function assumes that the block starts on a byte boundry * (non-compliant, but I don't see where this would happen). section 3.2.3 */ -long decompress_block(unsigned char *dest, unsigned char *source, - void *(*inflate_memcpy)(void *, void *, size)) +long decompress_block(unsigned char *dest, unsigned char *source) { int bfinal, btype; struct bitstream stream; - init_stream(&stream, source, inflate_memcpy); + init_stream(&stream, source); do { bfinal = pull_bit(&stream); btype = pull_bits(&stream, 2); Index: zImage.c =================================================================== RCS file: /cvsroot/blob/blob/src/blob/zImage.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- zImage.c 14 Feb 2002 10:17:59 -0000 1.2 +++ zImage.c 16 Feb 2002 00:43:59 -0000 1.3 @@ -23,9 +23,19 @@ * */ -#include "blob/types.h" -#include "blob/main.h" -#include "blob/load_kernel.h" +#ident "$Id$" + +#ifdef HAVE_CONFIG_H +# include <blob/config.h> +#endif + +#include <blob/load_kernel.h> +#include <blob/main.h> +#include <blob/types.h> +#include <blob/util.h> + + + #define ZIMAGE_MAGIC 0x016f2818 @@ -44,9 +54,9 @@ * ldr_update_progress */ for (i = 0; i <= size - 0x40000; i += 0x40000) { ldr_update_progress(); - ldr_memcpy((char *) dest + i, part->offset + i, 0x40000); + memcpy((char *) dest + i, part->offset + i, 0x40000); } - ldr_memcpy((char *) dest + i, part->offset + i, size - i); + memcpy((char *) dest + i, part->offset + i, size - i); return size; } --- compr_zlib.c DELETED --- |
From: Erik M. <er...@us...> - 2002-02-16 00:44:03
|
Update of /cvsroot/blob/blob/include/blob In directory usw-pr-cvs1:/tmp/cvs-serv23847/include/blob Modified Files: Makefile.am compr_rubin.h load_kernel.h mini_inflate.h util.h Log Message: cramfs+JFFS2 cleanup part one (code size got almost 2K smaller) Index: Makefile.am =================================================================== RCS file: /cvsroot/blob/blob/include/blob/Makefile.am,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- Makefile.am 12 Feb 2002 23:55:24 -0000 1.15 +++ Makefile.am 16 Feb 2002 00:43:59 -0000 1.16 @@ -18,6 +18,7 @@ arch.h \ command.h \ command_hist.h \ + compr_rubin.h \ crc32.h \ debug.h \ errno.h \ @@ -25,14 +26,17 @@ flash.h \ icache.h \ init.h \ + jffs2.h \ lcd.h \ led.h \ linux.h \ + load_kernel.h \ main.h \ md5.h \ md5support.h \ memory.h \ memsetup.h \ + mini_inflate.h \ param_block.h \ partition.h \ reboot.h \ Index: compr_rubin.h =================================================================== RCS file: /cvsroot/blob/blob/include/blob/compr_rubin.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- compr_rubin.h 14 Feb 2002 09:59:34 -0000 1.1 +++ compr_rubin.h 16 Feb 2002 00:43:59 -0000 1.2 @@ -3,6 +3,11 @@ /* last modification : aug 15, 1994 */ /* $Id$ */ +#ident "$Id$" + +#ifndef BLOB_COMPR_RUBIN_H +#define BLOB_COMPR_RUBIN_H + #define RUBIN_REG_SIZE 16 #define UPPER_BIT_RUBIN (((long) 1)<<(RUBIN_REG_SIZE-1)) #define LOWER_BITS_RUBIN ((((long) 1)<<(RUBIN_REG_SIZE-1))-1) @@ -10,3 +15,5 @@ void dynrubin_decompress(unsigned char *data_in, unsigned char *cpage_out, unsigned long sourcelen, unsigned long dstlen); + +#endif Index: load_kernel.h =================================================================== RCS file: /cvsroot/blob/blob/include/blob/load_kernel.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- load_kernel.h 14 Feb 2002 10:17:59 -0000 1.2 +++ load_kernel.h 16 Feb 2002 00:43:59 -0000 1.3 @@ -23,6 +23,14 @@ * */ +#ident "$Id$" + +#ifndef BLOB_LOAD_KERNEL_H +#define BLOB_LOAD_KERNEL_H + +#include <blob/main.h> +#include <blob/types.h> + /* this struct is very similar to mtd_info */ struct part_info { u32 size; // Total size of the Partition @@ -64,12 +72,6 @@ /* the modules call this every 0x40000 bytes to update a progress bar */ inline void ldr_update_progress(void); -/* self explanitory */ -inline int ldr_strncmp(char *a, char *b, size_t n); -inline void *ldr_memcpy(void *dst, void *src, size_t n); - -/* the first one outputs a string to the serial port, the second a u32 hex # */ -inline void ldr_output_string(char *str); -inline void ldr_output_hex(u32 hex); - void load_kernel(blob_status_t *blob_status); + +#endif Index: mini_inflate.h =================================================================== RCS file: /cvsroot/blob/blob/include/blob/mini_inflate.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- mini_inflate.h 14 Feb 2002 09:59:34 -0000 1.1 +++ mini_inflate.h 16 Feb 2002 00:43:59 -0000 1.2 @@ -22,61 +22,14 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ - -typedef __SIZE_TYPE__ size; - -#define NO_ERROR 0 -#define COMP_UNKNOWN 1 /* The specififed bytype is invalid */ -#define CODE_NOT_FOUND 2 /* a huffman code in the stream could not be decoded */ -#define TOO_MANY_BITS 3 /* pull_bits was passed an argument that is too - * large */ -/* This struct represents an entire huffman code set. It has various lookup - * tables to speed decoding */ -struct huffman_set { - int bits; /* maximum bit length */ - int num_symbols; /* Number of symbols this code can represent */ - int *lengths; /* The bit length of symbols */ - int *symbols; /* All of the symbols, sorted by the huffman code */ - int *count; /* the number of codes of this bit length */ - int *first; /* the first code of this bit length */ - int *pos; /* the symbol that first represents (in the symbols - * array) */ -}; +#ident "$Id$" -struct bitstream { - unsigned char *data; /* increments as we move from byte to byte */ - unsigned char bit; /* 0 to 7 */ - void *(*memcpy)(void *, void *, size); - unsigned long decoded; /* The number of bytes decoded */ - int error; +#ifndef BLOB_MINI_INFLATE_H +#define BLOB_MINI_INFLATE_H + - int distance_count[16]; - int distance_first[16]; - int distance_pos[16]; - int distance_lengths[32]; - int distance_symbols[32]; +long decompress_block(unsigned char *dest, unsigned char *source); - int code_count[8]; - int code_first[8]; - int code_pos[8]; - int code_lengths[19]; - int code_symbols[19]; - - int length_count[16]; - int length_first[16]; - int length_pos[16]; - int length_lengths[288]; - int length_symbols[288]; - - struct huffman_set codes; - struct huffman_set lengths; - struct huffman_set distance; -}; - -#define NO_COMP 0 -#define FIXED_COMP 1 -#define DYNAMIC_COMP 2 -long decompress_block(unsigned char *dest, unsigned char *source, - void *(*inflate_memcpy)(void *dest, void *src, size n)); +#endif Index: util.h =================================================================== RCS file: /cvsroot/blob/blob/include/blob/util.h,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- util.h 12 Feb 2002 23:59:41 -0000 1.9 +++ util.h 16 Feb 2002 00:43:59 -0000 1.10 @@ -42,6 +42,8 @@ void *memcpy(void *dest, const void *src, size_t n); +void *memset(void *dest, int c, size_t n); + int strncmp(const char *s1, const char *s2, size_t maxlen); int strlen(const char *s); |
From: Erik M. <er...@us...> - 2002-02-16 00:41:11
|
Update of /cvsroot/blob/blob In directory usw-pr-cvs1:/tmp/cvs-serv23300 Modified Files: RELEASE-NOTES Log Message: Commit it before I forget to mention it. Index: RELEASE-NOTES =================================================================== RCS file: /cvsroot/blob/blob/RELEASE-NOTES,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- RELEASE-NOTES 7 Jan 2002 20:16:49 -0000 1.7 +++ RELEASE-NOTES 16 Feb 2002 00:41:06 -0000 1.8 @@ -1,5 +1,12 @@ $Id$ +Release notes for blob-2.0.5-pre3 +================================= + +License for src/blob/testmem.S and src/blob/testmem2.S changed from +GPLv2+later to GPLv2 only. + + Release notes for blob-2.0.5-pre2 ================================= |
From: Erik M. <er...@us...> - 2002-02-15 23:08:25
|
Update of /cvsroot/blob/blob/src/lib In directory usw-pr-cvs1:/tmp/cvs-serv681 Modified Files: Makefile.am Added Files: memset.c Log Message: Add memset() implementation. --- NEW FILE: memset.c --- /* * memset.c: fill memory with a constant byte * * Copyright (C) 2002 Erik Mouw (J.A...@it...) * * $Id: memset.c,v 1.1 2002/02/15 23:08:20 erikm Exp $ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ #ident "$Id: memset.c,v 1.1 2002/02/15 23:08:20 erikm Exp $" #ifdef HAVE_CONFIG_H # include <blob/config.h> #endif #include <blob/util.h> #include <blob/types.h> void *memset(void *dest, int c, size_t n) { u8 *tmp = (u8 *)dest; while(n-- > 0) *tmp++ = (u8)c; return dest; } Index: Makefile.am =================================================================== RCS file: /cvsroot/blob/blob/src/lib/Makefile.am,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- Makefile.am 8 Feb 2002 12:49:03 -0000 1.11 +++ Makefile.am 15 Feb 2002 23:08:20 -0000 1.12 @@ -35,6 +35,7 @@ md5.c \ md5support.c \ memcpy.c \ + memset.c \ printf.c \ reboot.c \ serial.c \ |
From: Abraham vd M. <ab...@us...> - 2002-02-15 14:15:48
|
Update of /cvsroot/blob/blob/include/blob/arch In directory usw-pr-cvs1:/tmp/cvs-serv16285 Modified Files: frodo.h Log Message: Enabled nCS3 for accessing CPLDs Index: frodo.h =================================================================== RCS file: /cvsroot/blob/blob/include/blob/arch/frodo.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- frodo.h 8 Feb 2002 10:19:56 -0000 1.2 +++ frodo.h 15 Feb 2002 14:15:45 -0000 1.3 @@ -84,7 +84,7 @@ #define USE_SERIAL2 /* GPIO for the LED */ -#define LED_GPIO (0x00000000) /* no led (for now) */ +#define LED_GPIO (0x00000000) /* no led (for now) */ /* the base address were BLOB is loaded by the first stage loader */ #define BLOB_ABS_BASE_ADDR (0xc0200400) @@ -106,7 +106,7 @@ #define RAMDISK_FLASH_LEN (4 * 1024 * 1024) /* the position of the kernel boot parameters */ -#define BOOT_PARAMS (0xc0000100) +#define BOOT_PARAMS (0xc0000100) /* the size (in kbytes) to which the compressed ramdisk expands */ #define RAMDISK_SIZE (8 * 1024) @@ -114,7 +114,7 @@ /* Memory configuration */ #ifdef BLOB_NEED_MEMCONFIG -#define SMCNFG_VALUE 0x00000000 +#define SMCNFG_VALUE 0x00000000 #if (CPU_SPEED >= CPU_CORE_SPEED_206mhz) @@ -128,6 +128,7 @@ # define MDCAS01_VALUE 0x55555555 # define MDCAS02_VALUE 0x55555555 # define MSC0_VALUE 0x00004770 +# define MSC1_VALUE 0x4f750000 #else /* #if (CPU_SPEED >= CPU_CORE_SPEED_206mhz) */ @@ -141,6 +142,7 @@ # define MDCAS01_VALUE 0xaaaaaaaa # define MDCAS02_VALUE 0xaaaaaaaa # define MSC0_VALUE 0x00004668 +# define MSC1_VALUE /* FIXME: calculate this */ #endif /* #if (CPU_SPEED >= CPU_CORE_SPEED_206mhz) */ @@ -151,7 +153,6 @@ * MDCAS20_VALUE * MDCAS21_VALUE * MDCAS22_VALUE - * MSC1_VALUE * MSC2_VALUE */ |
> A couple of remarks: > > - Be *extremely* careful with inline functions, they can really bloat > the generated code. > - We already have quite some functions available. For example: I'd > rather have a generic memset() function in src/lib/ and #define > cramfs_memset as memset. feel free, just as long as the memset() in src/lib operates on u8's and not u32's. There are a lot of generic functions in there that can be replaced. > - What is ZIMAGE support supposed to do? I guess it's to load directly > from flash partitions, but in that case the name is wrong. A zImage contains information on its length, this can be exploited for slightly faster load times. > - Checking for the ZIMAGE magic is a bad idea. It doesn't allow you to > load diag anymore, for example (yes, it has a hack to look like a > kernel, but that's ugly). Oh, and the so called "magic value" is > nowhere documented so don't rely on it. The plan was to allow partitions to be identified in some way, the fallback behavior being load a raw image from a default area. |
On Thu, Feb 14, 2002 at 01:59:36AM -0800, Tim Riker wrote: > Update of /cvsroot/blob/blob/src/blob > In directory usw-pr-cvs1:/tmp/cvs-serv27294/src/blob > > Modified Files: > Makefile.am main.c > Added Files: > compr_rtime.c compr_rubin.c compr_zlib.c cramfs.c jffs2.c > load_kernel.c mini_inflate.c zImage.c > Log Message: > most of Russ's jffs2 code updated A couple of remarks: - Be *extremely* careful with inline functions, they can really bloat the generated code. - We already have quite some functions available. For example: I'd rather have a generic memset() function in src/lib/ and #define cramfs_memset as memset. - What is ZIMAGE support supposed to do? I guess it's to load directly from flash partitions, but in that case the name is wrong. - Checking for the ZIMAGE magic is a bad idea. It doesn't allow you to load diag anymore, for example (yes, it has a hack to look like a kernel, but that's ugly). Oh, and the so called "magic value" is nowhere documented so don't rely on it. Erik -- J.A.K. (Erik) Mouw, Information and Communication Theory Group, Faculty of Information Technology and Systems, Delft University of Technology, PO BOX 5031, 2600 GA Delft, The Netherlands Phone: +31-15-2783635 Fax: +31-15-2781843 Email: J.A...@it... WWW: http://www-ict.its.tudelft.nl/~erik/ |
From: Tim R. <tim...@us...> - 2002-02-14 10:18:03
|
Update of /cvsroot/blob/blob/src/blob In directory usw-pr-cvs1:/tmp/cvs-serv32523/src/blob Modified Files: compr_zlib.c cramfs.c jffs2.c load_kernel.c main.c zImage.c Log Message: move load_kernel to load_kernel.c Index: compr_zlib.c =================================================================== RCS file: /cvsroot/blob/blob/src/blob/compr_zlib.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- compr_zlib.c 14 Feb 2002 09:59:34 -0000 1.1 +++ compr_zlib.c 14 Feb 2002 10:17:59 -0000 1.2 @@ -36,6 +36,7 @@ */ #include "blob/types.h" +#include "blob/main.h" #include "blob/load_kernel.h" #include "blob/mini_inflate.h" Index: cramfs.c =================================================================== RCS file: /cvsroot/blob/blob/src/blob/cramfs.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- cramfs.c 14 Feb 2002 09:59:34 -0000 1.1 +++ cramfs.c 14 Feb 2002 10:17:59 -0000 1.2 @@ -27,6 +27,7 @@ * nature of cramfs, this shouldn't be a big deal */ #include "blob/types.h" +#include "blob/main.h" #include "blob/load_kernel.h" #include "blob/mini_inflate.h" Index: jffs2.c =================================================================== RCS file: /cvsroot/blob/blob/src/blob/jffs2.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- jffs2.c 14 Feb 2002 09:59:34 -0000 1.1 +++ jffs2.c 14 Feb 2002 10:17:59 -0000 1.2 @@ -65,6 +65,7 @@ #include "blob/types.h" +#include "blob/main.h" #include "blob/load_kernel.h" #include "blob/jffs2.h" #include "blob/crc32.h" Index: load_kernel.c =================================================================== RCS file: /cvsroot/blob/blob/src/blob/load_kernel.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- load_kernel.c 14 Feb 2002 09:59:34 -0000 1.1 +++ load_kernel.c 14 Feb 2002 10:17:59 -0000 1.2 @@ -27,11 +27,13 @@ */ #include "types.h" -#include "load_kernel.h" #include "config.h" #include "serial.h" #include "util.h" #include "main.h" +#include "load_kernel.h" + +#include <blob/arch.h> #ifdef CONFIG_CRAMFS_SUPPORT extern struct kernel_loader cramfs_load; @@ -87,3 +89,38 @@ { SerialOutputHex(hex); } + +void load_kernel(blob_status_t *blob_status) +{ + int i; + unsigned long size; + struct part_info part; + +/* FIXME this is hardcoded, should use flash[].size */ +#define MAIN_BLOCK_SIZE 2 * 64 * 1024 + part.erasesize = MAIN_BLOCK_SIZE; + part.size = KERNEL_FLASH_LEN; + part.offset = (char *) KERNEL_FLASH_BASE; + for (i = 0; loader[i] && !loader[i]->check_magic(&part); i++); + if (!loader[i]) { + SerialOutputString("unable to find kernel, loading raw data " + "and hoping for the best!\rloading"); + size = KERNEL_FLASH_LEN; + MyMemCpy((u32 *)KERNEL_RAM_BASE, (u32 *)KERNEL_FLASH_BASE, size >> 2); + + } else { + SerialOutputString("loading kernel from "); + SerialOutputString(loader[i]->name); + if ((size = loader[i]->load_kernel((u32 *)KERNEL_RAM_BASE, + &part)) == 0) { + SerialOutputString(" error loading kernel!\r"); + return; + } + } + SerialOutputString("loaded 0x"); + SerialOutputHex(size); + SerialOutputString(" bytes\r"); + blob_status->kernelSize = size; + blob_status->kernelType = fromFlash; +} + Index: main.c =================================================================== RCS file: /cvsroot/blob/blob/src/blob/main.c,v retrieving revision 1.32 retrieving revision 1.33 diff -u -d -r1.32 -r1.33 --- main.c 14 Feb 2002 09:59:34 -0000 1.32 +++ main.c 14 Feb 2002 10:17:59 -0000 1.33 @@ -70,40 +70,6 @@ blob_status_t blob_status; static char *version_str = PACKAGE " version " VERSION " for " BOARD_NAME "\n"; -void load_kernel(blob_status_t *blob_status) -{ - int i; - unsigned long size; - struct part_info part; - -/* FIXME this is hardcoded, should use flash[].size */ -#define MAIN_BLOCK_SIZE 2 * 64 * 1024 - part.erasesize = MAIN_BLOCK_SIZE; - part.size = KERNEL_FLASH_LEN; - part.offset = (char *) KERNEL_FLASH_BASE; - for (i = 0; loader[i] && !loader[i]->check_magic(&part); i++); - if (!loader[i]) { - SerialOutputString("unable to find kernel, loading raw data " - "and hoping for the best!\rloading"); - size = KERNEL_FLASH_LEN; - MyMemCpy((u32 *)KERNEL_RAM_BASE, (u32 *)KERNEL_FLASH_BASE, size >> 2); - - } else { - SerialOutputString("loading kernel from "); - SerialOutputString(loader[i]->name); - if ((size = loader[i]->load_kernel((u32 *)KERNEL_RAM_BASE, - &part)) == 0) { - SerialOutputString(" error loading kernel!\r"); - return; - } - } - SerialOutputString("loaded 0x"); - SerialOutputHex(size); - SerialOutputString(" bytes\r"); - blob_status->kernelSize = size; - blob_status->kernelType = fromFlash; -} - int main(void) { int numRead = 0; Index: zImage.c =================================================================== RCS file: /cvsroot/blob/blob/src/blob/zImage.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- zImage.c 14 Feb 2002 09:59:34 -0000 1.1 +++ zImage.c 14 Feb 2002 10:17:59 -0000 1.2 @@ -24,6 +24,7 @@ */ #include "blob/types.h" +#include "blob/main.h" #include "blob/load_kernel.h" #define ZIMAGE_MAGIC 0x016f2818 |
From: Tim R. <tim...@us...> - 2002-02-14 10:18:02
|
Update of /cvsroot/blob/blob/include/blob In directory usw-pr-cvs1:/tmp/cvs-serv32523/include/blob Modified Files: load_kernel.h Log Message: move load_kernel to load_kernel.c Index: load_kernel.h =================================================================== RCS file: /cvsroot/blob/blob/include/blob/load_kernel.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- load_kernel.h 14 Feb 2002 09:59:34 -0000 1.1 +++ load_kernel.h 14 Feb 2002 10:17:59 -0000 1.2 @@ -58,7 +58,6 @@ #define UDEBUG(str, args...) #else extern void *fodder_ram_base; -extern int printf(const char *, ...); #define UDEBUG(str, args...) printf(str, ## args) #endif @@ -72,3 +71,5 @@ /* the first one outputs a string to the serial port, the second a u32 hex # */ inline void ldr_output_string(char *str); inline void ldr_output_hex(u32 hex); + +void load_kernel(blob_status_t *blob_status); |
Update of /cvsroot/blob/blob/src/blob In directory usw-pr-cvs1:/tmp/cvs-serv27294/src/blob Modified Files: Makefile.am main.c Added Files: compr_rtime.c compr_rubin.c compr_zlib.c cramfs.c jffs2.c load_kernel.c mini_inflate.c zImage.c Log Message: most of Russ's jffs2 code updated --- NEW FILE: compr_rtime.c --- /* * JFFS2 -- Journalling Flash File System, Version 2. * * Copyright (C) 2001 Red Hat, Inc. * * Created by Arjan van de Ven <ar...@re...> * * The original JFFS, from which the design for JFFS2 was derived, * was designed and implemented by Axis Communications AB. * * The contents of this file are subject to the Red Hat eCos Public * License Version 1.1 (the "Licence"); you may not use this file * except in compliance with the Licence. You may obtain a copy of * the Licence at http://www.redhat.com/ * * Software distributed under the Licence is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. * See the Licence for the specific language governing rights and * limitations under the Licence. * * The Original Code is JFFS2 - Journalling Flash File System, version 2 * * Alternatively, the contents of this file may be used under the * terms of the GNU General Public License version 2 (the "GPL"), in * which case the provisions of the GPL are applicable instead of the * above. If you wish to allow the use of your version of this file * only under the terms of the GPL and not to allow others to use your * version of this file under the RHEPL, indicate your decision by * deleting the provisions above and replace them with the notice and * other provisions required by the GPL. If you do not delete the * provisions above, a recipient may use your version of this file * under either the RHEPL or the GPL. * * $Id: compr_rtime.c,v 1.1 2002/02/14 09:59:34 timriker Exp $ * * * Very simple lz77-ish encoder. * * Theory of operation: Both encoder and decoder have a list of "last * occurances" for every possible source-value; after sending the * first source-byte, the second byte indicated the "run" length of * matches * * The algorithm is intended to only send "whole bytes", no bit-messing. * */ #include "blob/types.h" void rtime_decompress(unsigned char *data_in, unsigned char *cpage_out, u32 srclen, u32 destlen) { int positions[256]; int outpos; int pos; int i; outpos = pos = 0; for (i = 0; i < 256; positions[i++] = 0); while (outpos<destlen) { unsigned char value; int backoffs; int repeat; value = data_in[pos++]; cpage_out[outpos++] = value; /* first the verbatim copied byte */ repeat = data_in[pos++]; backoffs = positions[value]; positions[value]=outpos; if (repeat) { if (backoffs + repeat >= outpos) { while(repeat) { cpage_out[outpos++] = cpage_out[backoffs++]; repeat--; } } else { for (i = 0; i < repeat; i++) *(cpage_out + outpos + i) = *(cpage_out + backoffs + i); outpos+=repeat; } } } } --- NEW FILE: compr_rubin.c --- /* * JFFS2 -- Journalling Flash File System, Version 2. * * Copyright (C) 2001 Red Hat, Inc. * * Created by Arjan van de Ven <ar...@re...> * * Heavily modified by Russ Dill <Rus...@as...> in an attempt at * a little more speed. * * The original JFFS, from which the design for JFFS2 was derived, * was designed and implemented by Axis Communications AB. * * The contents of this file are subject to the Red Hat eCos Public * License Version 1.1 (the "Licence"); you may not use this file * except in compliance with the Licence. You may obtain a copy of * the Licence at http://www.redhat.com/ * * Software distributed under the Licence is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. * See the Licence for the specific language governing rights and * limitations under the Licence. * * The Original Code is JFFS2 - Journalling Flash File System, version 2 * * Alternatively, the contents of this file may be used under the * terms of the GNU General Public License version 2 (the "GPL"), in * which case the provisions of the GPL are applicable instead of the * above. If you wish to allow the use of your version of this file * only under the terms of the GPL and not to allow others to use your * version of this file under the RHEPL, indicate your decision by * deleting the provisions above and replace them with the notice and * other provisions required by the GPL. If you do not delete the * provisions above, a recipient may use your version of this file * under either the RHEPL or the GPL. * * $Id: compr_rubin.c,v 1.1 2002/02/14 09:59:34 timriker Exp $ * */ #include "blob/types.h" #include "blob/compr_rubin.h" void rubin_do_decompress(unsigned char *bits, unsigned char *in, unsigned char *page_out, u32 destlen) { register char *curr = page_out; char *end = page_out + destlen; register unsigned long temp; register unsigned long result; register unsigned long p; register unsigned long q; register unsigned long rec_q; register unsigned long bit; register long i0; unsigned long i; /* init_pushpull */ temp = *(u32 *) in; bit = 16; /* init_rubin */ q = 0; p = (long) (2 * UPPER_BIT_RUBIN); /* init_decode */ rec_q = (in[0] << 8) | in[1]; while (curr < end) { /* in byte */ result = 0; for (i = 0; i < 8; i++) { /* decode */ while ((q & UPPER_BIT_RUBIN) || ((p + q) <= UPPER_BIT_RUBIN)) { q &= ~UPPER_BIT_RUBIN; q <<= 1; p <<= 1; rec_q &= ~UPPER_BIT_RUBIN; rec_q <<= 1; rec_q |= (temp >> (bit++ ^ 7)) & 1; if (bit > 31) { bit = 0; temp = *(++((u32 *) in)); } } i0 = (bits[i] * p) >> 8; if (i0 <= 0) i0 = 1; /* if it fails, it fails, we have our crc if (i0 >= p) i0 = p - 1; */ result >>= 1; if (rec_q < q + i0) { /* result |= 0x00; */ p = i0; } else { result |= 0x80; p -= i0; q += i0; } } *(curr++) = result; } } void dynrubin_decompress(unsigned char *data_in, unsigned char *cpage_out, unsigned long sourcelen, unsigned long dstlen) { unsigned char bits[8]; int c; for (c=0; c<8; c++) bits[c] = (256 - data_in[c]); rubin_do_decompress(bits, data_in+8, cpage_out, dstlen); } --- NEW FILE: compr_zlib.c --- /* * JFFS2 -- Journalling Flash File System, Version 2. * * Copyright (C) 2001 Red Hat, Inc. * * Created by David Woodhouse <dw...@ca...> * * The original JFFS, from which the design for JFFS2 was derived, * was designed and implemented by Axis Communications AB. * * The contents of this file are subject to the Red Hat eCos Public * License Version 1.1 (the "Licence"); you may not use this file * except in compliance with the Licence. You may obtain a copy of * the Licence at http://www.redhat.com/ * * Software distributed under the Licence is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. * See the Licence for the specific language governing rights and * limitations under the Licence. * * The Original Code is JFFS2 - Journalling Flash File System, version 2 * * Alternatively, the contents of this file may be used under the * terms of the GNU General Public License version 2 (the "GPL"), in * which case the provisions of the GPL are applicable instead of the * above. If you wish to allow the use of your version of this file * only under the terms of the GPL and not to allow others to use your * version of this file under the RHEPL, indicate your decision by * deleting the provisions above and replace them with the notice and * other provisions required by the GPL. If you do not delete the * provisions above, a recipient may use your version of this file * under either the RHEPL or the GPL. * * $Id: compr_zlib.c,v 1.1 2002/02/14 09:59:34 timriker Exp $ * */ #include "blob/types.h" #include "blob/load_kernel.h" #include "blob/mini_inflate.h" void zlib_decompress(unsigned char *data_in, unsigned char *cpage_out, u32 srclen, u32 destlen) { decompress_block(cpage_out, data_in + 2, ldr_memcpy); } --- NEW FILE: cramfs.c --- /*------------------------------------------------------------------------- * Filename: cramfs.c * Version: $Id: cramfs.c,v 1.1 2002/02/14 09:59:34 timriker Exp $ * Copyright: Copyright (C) 2001, Russ Dill * Author: Russ Dill <Rus...@as...> * Description: Module to load kernel from a cramfs *-----------------------------------------------------------------------*/ /* * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ /* note: this module doesn't currently support symlinks, but because of the * nature of cramfs, this shouldn't be a big deal */ #include "blob/types.h" #include "blob/load_kernel.h" #include "blob/mini_inflate.h" #define CRAMFS_MAGIC 0x28cd3d45 /* some random number */ struct cramfs_inode { /* sizeof == 12*/ u32 mode:16, uid:16; /* SIZE for device files is i_rdev */ u32 size:24, gid:8; /* NAMELEN is the length of the file name, divided by 4 and rounded up. (cramfs doesn't support hard links.) */ /* OFFSET: For symlinks and non-empty regular files, this contains the offset (divided by 4) of the file data in compressed form (starting with an array of block pointers; see README). For non-empty directories it is the offset (divided by 4) of the inode of the first file in that directory. For anything else, offset is zero. */ u32 namelen:6, offset:26; }; /* * Superblock information at the beginning of the FS. */ struct cramfs_super { /* sizeof == 62 == 0x40 + 12 */ u32 magic; /* 0x28cd3d45 - random number */ u32 size; /* Not used. mkcramfs currently writes a constant 1<<16 here. */ u32 flags; /* 0 */ u32 future; /* 0 */ u8 signature[16]; /* "Compressed ROMFS" */ u8 fsid[16]; /* random number */ u8 name[16]; /* user-defined name */ struct cramfs_inode root; /* Root inode data */ }; static int cramfs_check_magic(struct part_info *part) { return *((u32 *) part->offset) == CRAMFS_MAGIC; } static long cramfs_uncompress_page(char *dest, char *src, u32 srclen) { long size; src++; /* *src == 0x78 method */ src++; /* *src == 0x9C flags (!PRESET_DICT) */ size = decompress_block(dest, src, ldr_memcpy); return size; } static long cramfs_load_file(u32 *dest, struct part_info *part, struct cramfs_inode *inode) { long int curr_block; unsigned long *block_ptrs; long size, total_size = 0; int i; ldr_update_progress(); block_ptrs = ((u32 *) part->offset) + inode->offset; curr_block = (inode->offset + ((inode->size + 4095) >> 12)) << 2; for (i = 0; i < ((inode->size + 4095) >> 12); i++) { size = cramfs_uncompress_page((char *) dest, curr_block + part->offset, block_ptrs[i] - curr_block); if (size < 0) return size; ((char *) dest) += size; /* Print a '.' every 0x40000 bytes */ if (((total_size + size) & ~0x3ffff) - (total_size & ~0x3ffff)) ldr_update_progress(); total_size += size; curr_block = block_ptrs[i]; } return total_size; } static u32 cramfs_load_kernel(u32 *dest, struct part_info *part) { struct cramfs_super *super; struct cramfs_inode *inode; unsigned long next_inode; char *name; long size; size = -1; super = (struct cramfs_super *) part->offset; next_inode = super->root.offset << 2; while (next_inode < (super->root.offset << 2) + super->root.size) { inode = (struct cramfs_inode *) (next_inode + part->offset); next_inode += (inode->namelen << 2) + sizeof(struct cramfs_inode); if (!(inode->mode & 0x8000)) continue; /* Is it a file? */ /* does it have 5 to 8 characters? */ if (!inode->namelen == 2) continue; name = (char *) (inode + 1); if (!ldr_strncmp("linux\0\0", name, 8)) { size = cramfs_load_file(dest, part, inode); break; } } return size <= 0 ? 0 : size; } struct kernel_loader cramfs_load = { check_magic: cramfs_check_magic, load_kernel: cramfs_load_kernel, name: "cramfs" }; --- NEW FILE: jffs2.c --- /* ------------------------------------------------------------------------- * Filename: jffs2.c * Version: $Id: jffs2.c,v 1.1 2002/02/14 09:59:34 timriker Exp $ * Copyright: Copyright (C) 2001, Russ Dill * Author: Russ Dill <Rus...@as...> * Description: Module to load kernel from jffs2 *-----------------------------------------------------------------------*/ /* * some portions of this code are taken from jffs2, and as such, the * following copyright notice is included. * * JFFS2 -- Journalling Flash File System, Version 2. * * Copyright (C) 2001 Red Hat, Inc. * * Created by David Woodhouse <dw...@ca...> * * The original JFFS, from which the design for JFFS2 was derived, * was designed and implemented by Axis Communications AB. * * The contents of this file are subject to the Red Hat eCos Public * License Version 1.1 (the "Licence"); you may not use this file * except in compliance with the Licence. You may obtain a copy of * the Licence at http://www.redhat.com/ * * Software distributed under the Licence is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. * See the Licence for the specific language governing rights and * limitations under the Licence. * * The Original Code is JFFS2 - Journalling Flash File System, version 2 * * Alternatively, the contents of this file may be used under the * terms of the GNU General Public License version 2 (the "GPL"), in * which case the provisions of the GPL are applicable instead of the * above. If you wish to allow the use of your version of this file * only under the terms of the GPL and not to allow others to use your * version of this file under the RHEPL, indicate your decision by * deleting the provisions above and replace them with the notice and * other provisions required by the GPL. If you do not delete the * provisions above, a recipient may use your version of this file * under either the RHEPL or the GPL. * * $Id: jffs2.c,v 1.1 2002/02/14 09:59:34 timriker Exp $ * */ /* Ok, so anyone who knows the jffs2 code will probably want to get a papar * bag to throw up into before reading this code. I looked through the jffs2 * code, the caching scheme is very elegant. I tried to keep the version * for a bootloader as small and simple as possible. Instead of worring about * unneccesary data copies, node scans, etc, I just optimized for the known * common case, a kernel, which looks like: * (1) most pages are 4096 bytes * (2) version numbers are somewhat sorted in acsending order * (3) multiple compressed blocks making up one page is uncommon * * So I create a linked list of decending version numbers (insertions at the * head), and then for each page, walk down the list, until a matching page * with 4096 bytes is found, and then decompress the watching pages in * reverse order. * */ #include "blob/types.h" #include "blob/load_kernel.h" #include "blob/jffs2.h" #include "blob/crc32.h" static struct jffs2_raw_dirent *find_inode(struct part_info *part, char *name, u32 pino); void rtime_decompress (unsigned char *data_in, unsigned char *cpage_out, u32 srclen, u32 destlen); void dynrubin_decompress(unsigned char *data_in, unsigned char *cpage_out, u32 srclen, u32 destlen); void zlib_decompress (unsigned char *data_in, unsigned char *cpage_out, u32 srclen, u32 destlen); struct data_strip { struct jffs2_raw_inode *inode; long int version; long int page; long int length; struct data_strip *next; }; inline int hdr_crc(struct jffs2_unknown_node *node) { if(node->hdr_crc != crc32(0, node, sizeof(struct jffs2_unknown_node) - 4)) return 0; else return 1; } inline int dirent_crc(struct jffs2_raw_dirent *node) { if (node->node_crc != crc32(0, node, sizeof(struct jffs2_raw_dirent) - 8)) { UDEBUG("bad dirent_crc\n"); return 0; } else return 1; } inline int dirent_name_crc(struct jffs2_raw_dirent *node) { if (node->name_crc != crc32(0, &(node->name), node->nsize)) { UDEBUG("bad dirent_name_crc\n"); return 0; } else return 1; } inline int inode_crc(struct jffs2_raw_inode *node) { if (node->node_crc != crc32(0, node, sizeof(struct jffs2_raw_inode) - 8)) { UDEBUG("bad inode_crc\n"); return 0; } else return 1; } /* decompress a page from the flash, first contains a linked list of references * all the nodes of this file, sorted is decending order (newest first) */ static int jffs2_uncompress_page(char *dest, struct data_strip *first, u32 page) { int i; char *src; /* look for the next reference to this page */ for (; first && first->page != page; first = first->next); if (!first) return 1; /* if we aren't covering what's behind us, uncompress that first */ if (first->length != 4096) if (!(jffs2_uncompress_page(dest, first->next, page))) return 0; dest += first->inode->offset; src = ((char *) first->inode) + sizeof(struct jffs2_raw_inode); if (first->inode->data_crc != crc32(0, src, first->inode->csize)) { ldr_output_string("CRC Error!"); return 0; } switch (first->inode->compr) { case JFFS2_COMPR_NONE: ldr_memcpy(dest, src, first->length); break; case JFFS2_COMPR_ZERO: for (i = 0; i < first->length; i++) *(dest++) = 0; break; case JFFS2_COMPR_RTIME: rtime_decompress(src, dest, first->inode->csize, first->length); break; case JFFS2_COMPR_DYNRUBIN: dynrubin_decompress(src, dest, first->inode->csize, first->length); break; case JFFS2_COMPR_ZLIB: zlib_decompress(src, dest, first->inode->csize, first->length); break; default: /* unknown */ } return 1; } static int jffs2_check_magic(struct part_info *part) { unsigned long offset; struct jffs2_unknown_node *node; /* search the start of each erase block for a magic number */ offset = 0; for (offset = 0; offset < part->size; offset += part->erasesize) { node = (struct jffs2_unknown_node *) (part->offset + offset); if (node->magic == JFFS2_MAGIC_BITMASK && hdr_crc(node)) return 1; } return 0; } /* read in the data for inode inode_num */ static u32 read_inode(struct part_info *part, u32 *dest, u32 inode_num, int type) { unsigned long size; struct jffs2_raw_inode *inode; unsigned long offset, inode_version, version, page; struct data_strip *free, *curr, *prev, *first, *new; free = (struct data_strip *) fodder_ram_base; first = NULL; offset = size = inode_version = 0; /* Fill the list of nodes pertaining to this file */ while (offset < part->size - sizeof(struct jffs2_raw_inode)) { inode = (struct jffs2_raw_inode *) (part->offset + offset); if (inode->magic == JFFS2_MAGIC_BITMASK && hdr_crc(inode)) { if (inode->nodetype == JFFS2_NODETYPE_INODE && inode->ino == inode_num && inode_crc(inode)) { /* add it in newest first order to our list */ prev = NULL; curr = first; version = inode->version; while (curr && curr->version > version) { prev = curr; curr = curr->next; } new = free++; new->version = version; new->inode = inode; new->page = (inode->offset / 4096); new->length = inode->dsize; if (!prev) { new->next = first; first = new; } else { new->next = prev->next; prev->next = new; } if (version > inode_version) { inode_version = version; size = type == DT_LNK ? inode->dsize : inode->isize; } } offset += ((inode->totlen + 3) & ~3); } else offset += 4; } if (!first) UDEBUG("could not find any nodes!\n"); for (page = 0; page <= size / 4096; page++) { /* Print a '.' every 0x40000 bytes */ if (!(page & 0x3F)) ldr_update_progress(); if ((jffs2_uncompress_page((char *) dest, first, page)) <= 0) { UDEBUG("jffs2_uncompress_page failed on page 0x%lx\n", page); return 0; } } return size; } /* follow a symlink */ static struct jffs2_raw_dirent *do_symlink(struct part_info *part, struct jffs2_raw_dirent *node) { char name[JFFS2_MAX_NAME_LEN + 1]; unsigned long size; UDEBUG(" finding symlink "); /* read in the symlink */ if((size = read_inode(part, (u32 *) name, node->ino, DT_LNK))) { name[size] = '\0'; UDEBUG(" '%s'\n", name); /* if it points to /, start over at inode 1, otherwise, stay * in the same directory */ if (name[0] == '/') return find_inode(part, name + 1, 1); else return find_inode(part, name, node->pino); } else { UDEBUG("could not load symlink!"); return NULL; } } /* find a dirent with the name "name", and parent "pino" return NULL on * error */ static struct jffs2_raw_dirent *find_inode(struct part_info *part, char *name, u32 pino) { char curr_name[JFFS2_MAX_NAME_LEN + 1]; int len, i, up = 0; struct jffs2_raw_dirent *node, *curr; unsigned long version, off; i = 0; do { /* parse the next dir/file/symlink */ len = 0; while (name[i] != '\0' && name[i] != '/') curr_name[len++] = name[i++]; curr_name[len] = '\0'; /* go up an inode if its a '..' */ up = (len == 2 && !ldr_strncmp("..", curr_name, 2)); UDEBUG("\nlooking for '%s' ...", curr_name); /* start again...at the beginning */ version = off = 0; node = NULL; while (off < part->size - sizeof(struct jffs2_raw_inode)) { curr = (struct jffs2_raw_dirent *)(part->offset + off); if (curr->magic == JFFS2_MAGIC_BITMASK && hdr_crc(curr)) { if (curr->nodetype == JFFS2_NODETYPE_DIRENT && up && curr->ino == pino && dirent_crc(curr) && curr->version > version) { version = curr->version; node = curr; } else if (curr->nodetype == JFFS2_NODETYPE_DIRENT && !up && curr->pino == pino && curr->nsize == len && dirent_crc(curr) && dirent_name_crc(curr) && !ldr_strncmp(curr_name, curr->name, len) && curr->version > version) { UDEBUG("found matching dirent\n"); version = curr->version; node = curr; } off += (curr->totlen + 3) & ~3; } else off += 4; } if (!node) return NULL; if (node->type == DT_LNK) if (!(node = do_symlink(part, node))) return NULL; /* if we are going up a dir, we want to look for the parent */ if (up) { pino = node->pino; up = 0; } else pino = node->ino; UDEBUG(" '%s' found at ino %ld\n", curr_name, pino); } while (name[i++] == '/'); return node; } static u32 jffs2_load_kernel(u32 *dest, struct part_info *part) { struct jffs2_raw_dirent *node; if (!(node = find_inode(part, "linux", 1))) { UDEBUG("could not find /linux\n"); return 0; } if (node->type != DT_REG) { UDEBUG("/linux is not a regular file\n"); return 0; } return read_inode(part, dest, node->ino, DT_REG); } struct kernel_loader jffs2_load = { check_magic: jffs2_check_magic, load_kernel: jffs2_load_kernel, name: "jffs2" }; --- NEW FILE: load_kernel.c --- /*------------------------------------------------------------------------- * Filename: load_kernel.c * Version: $Id: load_kernel.c,v 1.1 2002/02/14 09:59:34 timriker Exp $ * Copyright: Copyright (C) 2001, Russ Dill * Author: Russ Dill <Rus...@as...> * Description: interface between kernel loaders and boot loader. if everything was done right, this *should be the only file that needs changing for porting to different boot loaders. *-----------------------------------------------------------------------*/ /* * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ #include "types.h" #include "load_kernel.h" #include "config.h" #include "serial.h" #include "util.h" #include "main.h" #ifdef CONFIG_CRAMFS_SUPPORT extern struct kernel_loader cramfs_load; #endif #ifdef CONFIG_ZIMAGE_SUPPORT extern struct kernel_loader zImage_load; #endif #ifdef CONFIG_JFFS2_SUPPORT extern struct kernel_loader jffs2_load; #endif #define FODDER_RAM_BASE (0xC0F00000) const struct kernel_loader *loader[] = { #ifdef CONFIG_CRAMFS_SUPPORT &cramfs_load, #endif #ifdef CONFIG_ZIMAGE_SUPPORT &zImage_load, #endif #ifdef CONFIG_JFFS2_SUPPORT &jffs2_load, #endif NULL }; const void *fodder_ram_base = (void *) FODDER_RAM_BASE; /* function calls for blob */ inline void ldr_update_progress(void) { printf("."); } inline int ldr_strncmp(char *a, char *b, size_t n) { return strncmp(a, b, n); } inline void *ldr_memcpy(void *dst, void *src, size_t n) { memcpy(dst, src, n); return dst; } inline void ldr_output_string(char *str) { SerialOutputString(str); } inline void ldr_output_hex(u32 hex) { SerialOutputHex(hex); } --- NEW FILE: mini_inflate.c --- /*------------------------------------------------------------------------- * Filename: mini_inflate.c * Version: $Id: mini_inflate.c,v 1.1 2002/02/14 09:59:34 timriker Exp $ * Copyright: Copyright (C) 2001, Russ Dill * Author: Russ Dill <Rus...@as...> * Description: Mini inflate implementation (RFC 1951) *-----------------------------------------------------------------------*/ /* * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ #include "blob/mini_inflate.h" /* The order that the code lengths in section 3.2.7 are in */ static unsigned char huffman_order[] = {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; inline void cramfs_memset(int *s, const int c, size n) { n--; for (;n > 0; n--) s[n] = c; s[0] = c; } /* associate a stream with a block of data and reset the stream */ static void init_stream(struct bitstream *stream, unsigned char *data, void *(*inflate_memcpy)(void *, void *, size)) { stream->error = NO_ERROR; stream->memcpy = inflate_memcpy; stream->decoded = 0; stream->data = data; stream->bit = 0; /* The first bit of the stream is the lsb of the * first byte */ /* really sorry about all this initialization, think of a better way, * let me know and it will get cleaned up */ stream->codes.bits = 8; stream->codes.num_symbols = 19; stream->codes.lengths = stream->code_lengths; stream->codes.symbols = stream->code_symbols; stream->codes.count = stream->code_count; stream->codes.first = stream->code_first; stream->codes.pos = stream->code_pos; stream->lengths.bits = 16; stream->lengths.num_symbols = 288; stream->lengths.lengths = stream->length_lengths; stream->lengths.symbols = stream->length_symbols; stream->lengths.count = stream->length_count; stream->lengths.first = stream->length_first; stream->lengths.pos = stream->length_pos; stream->distance.bits = 16; stream->distance.num_symbols = 32; stream->distance.lengths = stream->distance_lengths; stream->distance.symbols = stream->distance_symbols; stream->distance.count = stream->distance_count; stream->distance.first = stream->distance_first; stream->distance.pos = stream->distance_pos; } /* pull 'bits' bits out of the stream. The last bit pulled it returned as the * msb. (section 3.1.1) */ inline unsigned long pull_bits(struct bitstream *stream, const unsigned int bits) { unsigned long ret; int i; ret = 0; for (i = 0; i < bits; i++) { ret += ((*(stream->data) >> stream->bit) & 1) << i; /* if, before incrementing, we are on bit 7, * go to the lsb of the next byte */ if (stream->bit++ == 7) { stream->bit = 0; stream->data++; } } return ret; } inline int pull_bit(struct bitstream *stream) { int ret = ((*(stream->data) >> stream->bit) & 1); if (stream->bit++ == 7) { stream->bit = 0; stream->data++; } return ret; } /* discard bits up to the next whole byte */ static void discard_bits(struct bitstream *stream) { if (stream->bit != 0) { stream->bit = 0; stream->data++; } } /* No decompression, the data is all literals (section 3.2.4) */ static void decompress_none(struct bitstream *stream, unsigned char *dest) { unsigned int length; discard_bits(stream); length = *(stream->data++); length += *(stream->data++) << 8; pull_bits(stream, 16); /* throw away the inverse of the size */ stream->decoded += length; stream->memcpy(dest, stream->data, length); stream->data += length; } /* Read in a symbol from the stream (section 3.2.2) */ static int read_symbol(struct bitstream *stream, struct huffman_set *set) { int bits = 0; int code = 0; while (!(set->count[bits] && code < set->first[bits] + set->count[bits])) { code = (code << 1) + pull_bit(stream); if (++bits > set->bits) { /* error decoding (corrupted data?) */ stream->error = CODE_NOT_FOUND; return -1; } } return set->symbols[set->pos[bits] + code - set->first[bits]]; } /* decompress a stream of data encoded with the passed length and distance * huffman codes */ static void decompress_huffman(struct bitstream *stream, unsigned char *dest) { struct huffman_set *lengths = &(stream->lengths); struct huffman_set *distance = &(stream->distance); int symbol, length, dist, i; do { if ((symbol = read_symbol(stream, lengths)) < 0) return; if (symbol < 256) { *(dest++) = symbol; /* symbol is a literal */ stream->decoded++; } else if (symbol > 256) { /* Determine the length of the repitition * (section 3.2.5) */ if (symbol < 265) length = symbol - 254; else if (symbol == 285) length = 258; else { length = pull_bits(stream, (symbol - 261) >> 2); length += (4 << ((symbol - 261) >> 2)) + 3; length += ((symbol - 1) % 4) << ((symbol - 261) >> 2); } /* Determine how far back to go */ if ((symbol = read_symbol(stream, distance)) < 0) return; if (symbol < 4) dist = symbol + 1; else { dist = pull_bits(stream, (symbol - 2) >> 1); dist += (2 << ((symbol - 2) >> 1)) + 1; dist += (symbol % 2) << ((symbol - 2) >> 1); } stream->decoded += length; for (i = 0; i < length; i++) *(dest++) = dest[-dist]; } } while (symbol != 256); /* 256 is the end of the data block */ } /* Fill the lookup tables (section 3.2.2) */ static void fill_code_tables(struct huffman_set *set) { int code = 0, i, length; /* fill in the first code of each bit length, and the pos pointer */ set->pos[0] = 0; for (i = 1; i < set->bits; i++) { code = (code + set->count[i - 1]) << 1; set->first[i] = code; set->pos[i] = set->pos[i - 1] + set->count[i - 1]; } /* Fill in the table of symbols in order of their huffman code */ for (i = 0; i < set->num_symbols; i++) { if ((length = set->lengths[i])) set->symbols[set->pos[length]++] = i; } /* reset the pos pointer */ for (i = 1; i < set->bits; i++) set->pos[i] -= set->count[i]; } static void init_code_tables(struct huffman_set *set) { cramfs_memset(set->lengths, 0, set->num_symbols); cramfs_memset(set->count, 0, set->bits); cramfs_memset(set->first, 0, set->bits); } /* read in the huffman codes for dynamic decoding (section 3.2.7) */ static void decompress_dynamic(struct bitstream *stream, unsigned char *dest) { /* I tried my best to minimize the memory footprint here, while still * keeping up performance. I really dislike the _lengths[] tables, but * I see no way of eliminating them without a sizable performance * impact. The first struct table keeps track of stats on each bit * length. The _length table keeps a record of the bit length of each * symbol. The _symbols table is for looking up symbols by the huffman * code (the pos element points to the first place in the symbol table * where that bit length occurs). I also hate the initization of these * structs, if someone knows how to compact these, lemme know. */ struct huffman_set *codes = &(stream->codes); struct huffman_set *lengths = &(stream->lengths); struct huffman_set *distance = &(stream->distance); int hlit = pull_bits(stream, 5) + 257; int hdist = pull_bits(stream, 5) + 1; int hclen = pull_bits(stream, 4) + 4; int length, curr_code, symbol, i, last_code; last_code = 0; init_code_tables(codes); init_code_tables(lengths); init_code_tables(distance); /* fill in the count of each bit length' as well as the lengths * table */ for (i = 0; i < hclen; i++) { length = pull_bits(stream, 3); codes->lengths[huffman_order[i]] = length; if (length) codes->count[length]++; } fill_code_tables(codes); /* Do the same for the length codes, being carefull of wrap through * to the distance table */ curr_code = 0; while (curr_code < hlit) { if ((symbol = read_symbol(stream, codes)) < 0) return; if (symbol == 0) { curr_code++; last_code = 0; } else if (symbol < 16) { /* Literal length */ lengths->lengths[curr_code] = last_code = symbol; lengths->count[symbol]++; curr_code++; } else if (symbol == 16) { /* repeat the last symbol 3 - 6 * times */ length = 3 + pull_bits(stream, 2); for (;length; length--, curr_code++) if (curr_code < hlit) { lengths->lengths[curr_code] = last_code; lengths->count[last_code]++; } else { /* wrap to the distance table */ distance->lengths[curr_code - hlit] = last_code; distance->count[last_code]++; } } else if (symbol == 17) { /* repeat a bit length 0 */ curr_code += 3 + pull_bits(stream, 3); last_code = 0; } else { /* same, but more times */ curr_code += 11 + pull_bits(stream, 7); last_code = 0; } } fill_code_tables(lengths); /* Fill the distance table, don't need to worry about wrapthrough * here */ curr_code -= hlit; while (curr_code < hdist) { if ((symbol = read_symbol(stream, codes)) < 0) return; if (symbol == 0) { curr_code++; last_code = 0; } else if (symbol < 16) { distance->lengths[curr_code] = last_code = symbol; distance->count[symbol]++; curr_code++; } else if (symbol == 16) { length = 3 + pull_bits(stream, 2); for (;length; length--, curr_code++) { distance->lengths[curr_code] = last_code; distance->count[last_code]++; } } else if (symbol == 17) { curr_code += 3 + pull_bits(stream, 3); last_code = 0; } else { curr_code += 11 + pull_bits(stream, 7); last_code = 0; } } fill_code_tables(distance); decompress_huffman(stream, dest); } /* fill in the length and distance huffman codes for fixed encoding * (section 3.2.6) */ static void decompress_fixed(struct bitstream *stream, unsigned char *dest) { /* let gcc fill in the initial values */ struct huffman_set *lengths = &(stream->lengths); struct huffman_set *distance = &(stream->distance); cramfs_memset(lengths->count, 0, 16); cramfs_memset(lengths->first, 0, 16); cramfs_memset(lengths->lengths, 8, 144); cramfs_memset(lengths->lengths + 144, 9, 112); cramfs_memset(lengths->lengths + 256, 7, 24); cramfs_memset(lengths->lengths + 280, 8, 8); lengths->count[7] = 24; lengths->count[8] = 152; lengths->count[9] = 112; cramfs_memset(distance->count, 0, 16); cramfs_memset(distance->first, 0, 16); cramfs_memset(distance->lengths, 5, 32); distance->count[5] = 32; fill_code_tables(lengths); fill_code_tables(distance); decompress_huffman(stream, dest); } /* returns the number of bytes decoded, < 0 if there was an error. Note that * this function assumes that the block starts on a byte boundry * (non-compliant, but I don't see where this would happen). section 3.2.3 */ long decompress_block(unsigned char *dest, unsigned char *source, void *(*inflate_memcpy)(void *, void *, size)) { int bfinal, btype; struct bitstream stream; init_stream(&stream, source, inflate_memcpy); do { bfinal = pull_bit(&stream); btype = pull_bits(&stream, 2); if (btype == NO_COMP) decompress_none(&stream, dest + stream.decoded); else if (btype == DYNAMIC_COMP) decompress_dynamic(&stream, dest + stream.decoded); else if (btype == FIXED_COMP) decompress_fixed(&stream, dest + stream.decoded); else stream.error = COMP_UNKNOWN; } while (!bfinal && !stream.error); return stream.error ? -stream.error : stream.decoded; } --- NEW FILE: zImage.c --- /*------------------------------------------------------------------------- * Filename: zimage.c * Version: $Id: zImage.c,v 1.1 2002/02/14 09:59:34 timriker Exp $ * Copyright: Copyright (C) 2001, Russ Dill * Author: Russ Dill <Rus...@as...> * Description: Module to load kernel straight from flash *-----------------------------------------------------------------------*/ /* * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ #include "blob/types.h" #include "blob/load_kernel.h" #define ZIMAGE_MAGIC 0x016f2818 static int zImage_check_magic(struct part_info *part) { return ((u32 *) part->offset)[9] == ZIMAGE_MAGIC; } static u32 zImage_load_kernel(u32 *dest, struct part_info *part) { unsigned long size; int i; size = ((u32 *) part->offset)[11] - ((u32 *) part->offset)[10]; /* yes, it could be copied all at once, but I wanted to call * ldr_update_progress */ for (i = 0; i <= size - 0x40000; i += 0x40000) { ldr_update_progress(); ldr_memcpy((char *) dest + i, part->offset + i, 0x40000); } ldr_memcpy((char *) dest + i, part->offset + i, size - i); return size; } struct kernel_loader zImage_load = { check_magic: zImage_check_magic, load_kernel: zImage_load_kernel, name: "zImage" }; Index: Makefile.am =================================================================== RCS file: /cvsroot/blob/blob/src/blob/Makefile.am,v retrieving revision 1.22 retrieving revision 1.23 diff -u -d -r1.22 -r1.23 --- Makefile.am 7 Feb 2002 22:56:22 -0000 1.22 +++ Makefile.am 14 Feb 2002 09:59:34 -0000 1.23 @@ -48,8 +48,6 @@ $(CC) -x c-header -undef -nostdinc ${INCLUDES} -E $< | sed 's/^#.*//' > $@ - - # ---- Blob first stage loader --------------------------------------- # WARNING: start.S *must* be the first file, otherwise the target will @@ -136,7 +134,15 @@ partition.c \ reboot.c \ uucodec.c \ - xmodem.c + xmodem.c \ + load_kernel.c \ + mini_inflate.c \ + jffs2.c \ + compr_rtime.c \ + compr_rubin.c \ + compr_zlib.c \ + cramfs.c \ + zImage.c # conditionally compiled sources Index: main.c =================================================================== RCS file: /cvsroot/blob/blob/src/blob/main.c,v retrieving revision 1.31 retrieving revision 1.32 diff -u -d -r1.31 -r1.32 --- main.c 8 Feb 2002 12:55:16 -0000 1.31 +++ main.c 14 Feb 2002 09:59:34 -0000 1.32 @@ -57,7 +57,7 @@ #include <blob/uucodec.h> #include <blob/xmodem.h> - +#include "load_kernel.h" static int do_reload(char *what); @@ -70,8 +70,39 @@ blob_status_t blob_status; static char *version_str = PACKAGE " version " VERSION " for " BOARD_NAME "\n"; +void load_kernel(blob_status_t *blob_status) +{ + int i; + unsigned long size; + struct part_info part; - +/* FIXME this is hardcoded, should use flash[].size */ +#define MAIN_BLOCK_SIZE 2 * 64 * 1024 + part.erasesize = MAIN_BLOCK_SIZE; + part.size = KERNEL_FLASH_LEN; + part.offset = (char *) KERNEL_FLASH_BASE; + for (i = 0; loader[i] && !loader[i]->check_magic(&part); i++); + if (!loader[i]) { + SerialOutputString("unable to find kernel, loading raw data " + "and hoping for the best!\rloading"); + size = KERNEL_FLASH_LEN; + MyMemCpy((u32 *)KERNEL_RAM_BASE, (u32 *)KERNEL_FLASH_BASE, size >> 2); + + } else { + SerialOutputString("loading kernel from "); + SerialOutputString(loader[i]->name); + if ((size = loader[i]->load_kernel((u32 *)KERNEL_RAM_BASE, + &part)) == 0) { + SerialOutputString(" error loading kernel!\r"); + return; + } + } + SerialOutputString("loaded 0x"); + SerialOutputHex(size); + SerialOutputString(" bytes\r"); + blob_status->kernelSize = size; + blob_status->kernelType = fromFlash; +} int main(void) { |
From: Tim R. <tim...@us...> - 2002-02-14 09:59:37
|
Update of /cvsroot/blob/blob/utils/test In directory usw-pr-cvs1:/tmp/cvs-serv27294/utils/test Added Files: .cvsignore Makefile load_kernel.c load_kernel_test.c Log Message: most of Russ's jffs2 code updated --- NEW FILE: .cvsignore --- load_kernel_test --- NEW FILE: Makefile --- DEFS = -DHAVE_CONFIG_H -I/usr/include -I. -I../../include load_kernel_test_OBJECTS = \ load_kernel.o \ load_kernel_test.o \ mini_inflate.o \ jffs2.o \ compr_rtime.o \ compr_rubin.o \ compr_zlib.o \ cramfs.o zImage.o crc32.o load_kernel_test_extra_SOURCES = \ mini_inflate.c \ jffs2.c \ compr_rtime.c \ compr_rubin.c \ compr_zlib.c \ cramfs.c zImage.c crc32.c CC=gcc #CFLAGS = -O2 -Wall -fomit-frame-pointer -g CFLAGS = -O2 -Wall -g COMPILE = $(CC) $(DEFS) $(CFLAGS) -DUSER_SPACE_TEST LINK = $(CC) $(CFLAGS) $(LDFLAGS) -o $@ all: load_kernel_test load_kernel_test: $(load_kernel_test_OBJECTS) @rm -f load_kernel_test $(LINK) $(load_kernel_test_OBJECTS) -o $@ $(load_kernel_test_extra_SOURCES): ln -s ../../src/*/$@ .c.o: $(COMPILE) -c $< maintainer-clean: clean rm -f $(load_kernel_test_extra_SOURCES) clean: @rm -f *.o load_kernel_test --- NEW FILE: load_kernel.c --- /*------------------------------------------------------------------------- * Filename: load_kernel.c * Version: $Id: load_kernel.c,v 1.1 2002/02/14 09:59:34 timriker Exp $ * Copyright: Copyright (C) 2001, Russ Dill * Author: Russ Dill <Rus...@as...> * Description: interface between kernel loaders and boot loader. if everything was done right, this *should be the only file that needs changing for porting to different boot loaders. *-----------------------------------------------------------------------*/ /* * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ #include <stdio.h> #include <string.h> typedef unsigned long u32; typedef unsigned short u16; typedef unsigned char u8; #include "blob/load_kernel.h" #include "blob/config.h" extern struct kernel_loader cramfs_load; extern struct kernel_loader zImage_load; extern struct kernel_loader jffs2_load; const struct kernel_loader *loader[] = { &cramfs_load, &zImage_load, &jffs2_load, NULL }; void *fodder_ram_base; /* function calls for the user space testing app */ inline void ldr_update_progress(void) { putchar('.'); } inline int ldr_strncmp(char *a, char *b, size_t n) { return strncmp(a, b, n); } inline void *ldr_memcpy(void *dst, void *src, size_t n) { return memcpy(dst, src, n); } inline void ldr_output_string(char *str) { printf("%s", str); fflush(stdout); } inline void ldr_output_hex(u32 hex) { printf("%lx", hex); fflush(stdout); } --- NEW FILE: load_kernel_test.c --- typedef unsigned long u32; typedef unsigned short u16; typedef unsigned char u8; #include <stdio.h> #include <stdlib.h> #include <sys/stat.h> #include <unistd.h> #include <libgen.h> #include "blob/load_kernel.h" int main(int argc, char *argv[]) { char *out; FILE *fp; struct stat st; struct part_info part; int i; unsigned long size = 0; part.erasesize = 0x20000; fodder_ram_base = malloc(0x1000); out = malloc(0xe00000); if (argc < 2) { printf("not enough arguments usage:\n"); printf("%s: <fs_image> <outfile>\n", basename(argv[0])); return 0; } if (stat(argv[1], &st)) { perror("could not stat fs_image"); return 0; } if (!(fp = fopen(argv[1], "r"))) { perror("could not open fs_image"); return 0; } part.size = st.st_size + part.erasesize - ((st.st_size - 1) % part.erasesize) - 1; part.offset = malloc(part.size); fread(part.offset, 1, st.st_size, fp); memset(part.offset + st.st_size, 0xff, part.size - st.st_size); fclose(fp); printf("flash emulation region is 0x%lx bytes\n", part.size); for (i = 0; loader[i] && !loader[i]->check_magic(&part); i++); if (!loader[i]) { printf("unable to find magic\n"); } else { printf("loading kernel from "); printf(loader[i]->name); if ((size = loader[i]->load_kernel((u32 *) out, &part)) == 0) { printf(" error loading kernel!\n"); return 0; } } printf("loaded 0x%08lx bytes\n", size); if (!(fp = fopen(argv[2], "w"))) { perror("could not open outfile"); return 0; } fwrite(out, 1, size, fp); fclose(fp); return 0; } |
From: Tim R. <tim...@us...> - 2002-02-14 09:59:37
|
Update of /cvsroot/blob/blob/include/blob In directory usw-pr-cvs1:/tmp/cvs-serv27294/include/blob Added Files: compr_rubin.h jffs2.h load_kernel.h mini_inflate.h Log Message: most of Russ's jffs2 code updated --- NEW FILE: compr_rubin.h --- /* Rubin encoder/decoder header */ /* work started at : aug 3, 1994 */ /* last modification : aug 15, 1994 */ /* $Id: compr_rubin.h,v 1.1 2002/02/14 09:59:34 timriker Exp $ */ #define RUBIN_REG_SIZE 16 #define UPPER_BIT_RUBIN (((long) 1)<<(RUBIN_REG_SIZE-1)) #define LOWER_BITS_RUBIN ((((long) 1)<<(RUBIN_REG_SIZE-1))-1) void dynrubin_decompress(unsigned char *data_in, unsigned char *cpage_out, unsigned long sourcelen, unsigned long dstlen); --- NEW FILE: jffs2.h --- /* * JFFS2 -- Journalling Flash File System, Version 2. * * Copyright (C) 2001 Red Hat, Inc. * * Created by David Woodhouse <dw...@ca...> * * The original JFFS, from which the design for JFFS2 was derived, * was designed and implemented by Axis Communications AB. * * The contents of this file are subject to the Red Hat eCos Public * License Version 1.1 (the "Licence"); you may not use this file * except in compliance with the Licence. You may obtain a copy of * the Licence at http://www.redhat.com/ * * Software distributed under the Licence is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. * See the Licence for the specific language governing rights and * limitations under the Licence. * * The Original Code is JFFS2 - Journalling Flash File System, version 2 * * Alternatively, the contents of this file may be used under the * terms of the GNU General Public License version 2 (the "GPL"), in * which case the provisions of the GPL are applicable instead of the * above. If you wish to allow the use of your version of this file * only under the terms of the GPL and not to allow others to use your * version of this file under the RHEPL, indicate your decision by * deleting the provisions above and replace them with the notice and * other provisions required by the GPL. If you do not delete the * provisions above, a recipient may use your version of this file * under either the RHEPL or the GPL. * * $Id: jffs2.h,v 1.1 2002/02/14 09:59:34 timriker Exp $ * */ #ifndef __LINUX_JFFS2_H__ #define __LINUX_JFFS2_H__ #include "blob/types.h" #define JFFS2_SUPER_MAGIC 0x72b6 /* Values we may expect to find in the 'magic' field */ #define JFFS2_OLD_MAGIC_BITMASK 0x1984 #define JFFS2_MAGIC_BITMASK 0x1985 #define KSAMTIB_CIGAM_2SFFJ 0x5981 /* For detecting wrong-endian fs */ #define JFFS2_EMPTY_BITMASK 0xffff #define JFFS2_DIRTY_BITMASK 0x0000 /* We only allow a single char for length, and 0xFF is empty flash so we don't want it confused with a real length. Hence max 254. */ #define JFFS2_MAX_NAME_LEN 254 /* How small can we sensibly write nodes? */ #define JFFS2_MIN_DATA_LEN 128 #define JFFS2_COMPR_NONE 0x00 #define JFFS2_COMPR_ZERO 0x01 #define JFFS2_COMPR_RTIME 0x02 #define JFFS2_COMPR_RUBINMIPS 0x03 #define JFFS2_COMPR_COPY 0x04 #define JFFS2_COMPR_DYNRUBIN 0x05 #define JFFS2_COMPR_ZLIB 0x06 /* Compatibility flags. */ #define JFFS2_COMPAT_MASK 0xc000 /* What do to if an unknown nodetype is found */ #define JFFS2_NODE_ACCURATE 0x2000 /* INCOMPAT: Fail to mount the filesystem */ #define JFFS2_FEATURE_INCOMPAT 0xc000 /* ROCOMPAT: Mount read-only */ #define JFFS2_FEATURE_ROCOMPAT 0x8000 /* RWCOMPAT_COPY: Mount read/write, and copy the node when it's GC'd */ #define JFFS2_FEATURE_RWCOMPAT_COPY 0x4000 /* RWCOMPAT_DELETE: Mount read/write, and delete the node when it's GC'd */ #define JFFS2_FEATURE_RWCOMPAT_DELETE 0x0000 #define JFFS2_NODETYPE_DIRENT (JFFS2_FEATURE_INCOMPAT | JFFS2_NODE_ACCURATE | 1) #define JFFS2_NODETYPE_INODE (JFFS2_FEATURE_INCOMPAT | JFFS2_NODE_ACCURATE | 2) #define JFFS2_NODETYPE_CLEANMARKER (JFFS2_FEATURE_RWCOMPAT_DELETE | JFFS2_NODE_ACCURATE | 3) // Maybe later... //#define JFFS2_NODETYPE_CHECKPOINT (JFFS2_FEATURE_RWCOMPAT_DELETE | JFFS2_NODE_ACCURATE | 3) //#define JFFS2_NODETYPE_OPTIONS (JFFS2_FEATURE_RWCOMPAT_COPY | JFFS2_NODE_ACCURATE | 4) /* Same as the non_ECC versions, but with extra space for real * ECC instead of just the checksum. For use on NAND flash */ //#define JFFS2_NODETYPE_DIRENT_ECC (JFFS2_FEATURE_INCOMPAT | JFFS2_NODE_ACCURATE | 5) //#define JFFS2_NODETYPE_INODE_ECC (JFFS2_FEATURE_INCOMPAT | JFFS2_NODE_ACCURATE | 6) #define JFFS2_INO_FLAG_PREREAD 1 /* Do read_inode() for this one at mount time, don't wait for it to happen later */ #define JFFS2_INO_FLAG_USERCOMPR 2 /* User has requested a specific compression type */ struct jffs2_unknown_node { /* All start like this */ u16 magic; u16 nodetype; u32 totlen; /* So we can skip over nodes we don't grok */ u32 hdr_crc; } __attribute__((packed)); struct jffs2_raw_dirent { u16 magic; u16 nodetype; /* == JFFS_NODETYPE_DIRENT */ u32 totlen; u32 hdr_crc; u32 pino; u32 version; u32 ino; /* == zero for unlink */ u32 mctime; u8 nsize; u8 type; u8 unused[2]; u32 node_crc; u32 name_crc; u8 name[0]; } __attribute__((packed)); /* The JFFS2 raw inode structure: Used for storage on physical media. */ /* The uid, gid, atime, mtime and ctime members could be longer, but are left like this for space efficiency. If and when people decide they really need them extended, it's simple enough to add support for a new type of raw node. */ struct jffs2_raw_inode { u16 magic; /* A constant magic number. */ u16 nodetype; /* == JFFS_NODETYPE_INODE */ u32 totlen; /* Total length of this node (inc data, etc.) */ u32 hdr_crc; u32 ino; /* Inode number. */ u32 version; /* Version number. */ u32 mode; /* The file's type or mode. */ u16 uid; /* The file's owner. */ u16 gid; /* The file's group. */ u32 isize; /* Total resultant size of this inode (used for truncations) */ u32 atime; /* Last access time. */ u32 mtime; /* Last modification time. */ u32 ctime; /* Change time. */ u32 offset; /* Where to begin to write. */ u32 csize; /* (Compressed) data size */ u32 dsize; /* Size of the node's data. (after decompression) */ u8 compr; /* Compression algorithm used */ u8 usercompr; /* Compression algorithm requested by the user */ u16 flags; /* See JFFS2_INO_FLAG_* */ u32 data_crc; /* CRC for the (compressed) data. */ u32 node_crc; /* CRC for the raw inode (excluding data) */ // u8 data[dsize]; } __attribute__((packed)); union jffs2_node_union { struct jffs2_raw_inode i; struct jffs2_raw_dirent d; struct jffs2_unknown_node u; } __attribute__((packed)); enum { DT_UNKNOWN = 0, # define DT_UNKNOWN DT_UNKNOWN DT_FIFO = 1, # define DT_FIFO DT_FIFO DT_CHR = 2, # define DT_CHR DT_CHR DT_DIR = 4, # define DT_DIR DT_DIR DT_BLK = 6, # define DT_BLK DT_BLK DT_REG = 8, # define DT_REG DT_REG DT_LNK = 10, # define DT_LNK DT_LNK DT_SOCK = 12, # define DT_SOCK DT_SOCK DT_WHT = 14 # define DT_WHT DT_WHT }; #endif /* __LINUX_JFFS2_H__ */ --- NEW FILE: load_kernel.h --- /*------------------------------------------------------------------------- * Filename: load_kernel.h * Version: $Id: load_kernel.h,v 1.1 2002/02/14 09:59:34 timriker Exp $ * Copyright: Copyright (C) 2001, Russ Dill * Author: Russ Dill <Rus...@as...> * Description: header for load kernel modules *-----------------------------------------------------------------------*/ /* * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ /* this struct is very similar to mtd_info */ struct part_info { u32 size; // Total size of the Partition /* "Major" erase size for the device. Naïve users may take this * to be the only erase size available, or may use the more detailed * information below if they desire */ u32 erasesize; /* Where in memory does this partition start? */ char *offset; }; struct kernel_loader { /* Return true if there is a kernel contained at src */ int (* check_magic)(struct part_info *part); /* load the kernel from the partition part to dst, return the number * of bytes copied if successful, zero if not */ u32 (* load_kernel)(u32 *dst, struct part_info *part); /* A brief description of the module (ie, "cramfs") */ char *name; }; extern const struct kernel_loader *loader[]; #ifndef USER_SPACE_TEST /* this is a large area of ram for the loaders to use as a scratchpad */ extern const void *fodder_ram_base; #define UDEBUG(str, args...) #else extern void *fodder_ram_base; extern int printf(const char *, ...); #define UDEBUG(str, args...) printf(str, ## args) #endif /* the modules call this every 0x40000 bytes to update a progress bar */ inline void ldr_update_progress(void); /* self explanitory */ inline int ldr_strncmp(char *a, char *b, size_t n); inline void *ldr_memcpy(void *dst, void *src, size_t n); /* the first one outputs a string to the serial port, the second a u32 hex # */ inline void ldr_output_string(char *str); inline void ldr_output_hex(u32 hex); --- NEW FILE: mini_inflate.h --- /*------------------------------------------------------------------------- * Filename: mini_inflate.h * Version: $Id: mini_inflate.h,v 1.1 2002/02/14 09:59:34 timriker Exp $ * Copyright: Copyright (C) 2001, Russ Dill * Author: Russ Dill <Rus...@as...> * Description: Mini deflate implementation *-----------------------------------------------------------------------*/ /* * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ typedef __SIZE_TYPE__ size; #define NO_ERROR 0 #define COMP_UNKNOWN 1 /* The specififed bytype is invalid */ #define CODE_NOT_FOUND 2 /* a huffman code in the stream could not be decoded */ #define TOO_MANY_BITS 3 /* pull_bits was passed an argument that is too * large */ /* This struct represents an entire huffman code set. It has various lookup * tables to speed decoding */ struct huffman_set { int bits; /* maximum bit length */ int num_symbols; /* Number of symbols this code can represent */ int *lengths; /* The bit length of symbols */ int *symbols; /* All of the symbols, sorted by the huffman code */ int *count; /* the number of codes of this bit length */ int *first; /* the first code of this bit length */ int *pos; /* the symbol that first represents (in the symbols * array) */ }; struct bitstream { unsigned char *data; /* increments as we move from byte to byte */ unsigned char bit; /* 0 to 7 */ void *(*memcpy)(void *, void *, size); unsigned long decoded; /* The number of bytes decoded */ int error; int distance_count[16]; int distance_first[16]; int distance_pos[16]; int distance_lengths[32]; int distance_symbols[32]; int code_count[8]; int code_first[8]; int code_pos[8]; int code_lengths[19]; int code_symbols[19]; int length_count[16]; int length_first[16]; int length_pos[16]; int length_lengths[288]; int length_symbols[288]; struct huffman_set codes; struct huffman_set lengths; struct huffman_set distance; }; #define NO_COMP 0 #define FIXED_COMP 1 #define DYNAMIC_COMP 2 long decompress_block(unsigned char *dest, unsigned char *source, void *(*inflate_memcpy)(void *dest, void *src, size n)); |
From: Tim R. <tim...@us...> - 2002-02-14 09:50:28
|
Update of /cvsroot/blob/blob/utils/test In directory usw-pr-cvs1:/tmp/cvs-serv25542/utils/test Log Message: Directory /cvsroot/blob/blob/utils/test added to the repository |
From: Erik M. <er...@us...> - 2002-02-13 00:22:26
|
Update of /cvsroot/blob/blob/src/blob In directory usw-pr-cvs1:/tmp/cvs-serv17309/src/blob Modified Files: lart.c Log Message: - Make flash_descriptors const - Add a default flash partition table - Rename a couple of functions Index: lart.c =================================================================== RCS file: /cvsroot/blob/blob/src/blob/lart.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- lart.c 3 Jan 2002 16:07:18 -0000 1.6 +++ lart.c 13 Feb 2002 00:22:24 -0000 1.7 @@ -25,16 +25,17 @@ # include <blob/config.h> #endif +#include <blob/arch.h> #include <blob/flash.h> #include <blob/init.h> +#include <blob/partition.h> #include <blob/serial.h> - /* flash descriptor for LART flash */ /* 2x Intel 28F160F3B fast boot block flash (4MB) */ -static flash_descriptor_t lart_flash_descriptors[] = +static const flash_descriptor_t lart_flash_descriptors[] = { { size: 2 * 8 * 1024, @@ -52,27 +53,94 @@ -static void init_lart_flash_driver(void) +/* default partition table for LART */ +static const blob_partition_t lart_default_partition_table[] = { + { + /* start of table */ + magic: BLOB_DEFAULT_PART_TABLE_MAGIC, + next: sizeof(blob_partition_t), + offset: 0x00000000, /* absolute base address */ + size: 4 * 1024 * 1024 /* total size of the flash */ + }, + { + /* blob itself */ + magic: BLOB_PART_VALID_MAGIC, + next: sizeof(blob_partition_t), + offset: BLOB_FLASH_BASE, + size: BLOB_FLASH_LEN, + name: "blob", + mem_base: BLOB_RAM_BASE + }, + { + /* parameter block */ + magic: BLOB_PART_VALID_MAGIC, + next: sizeof(blob_partition_t), + offset: PARAM_FLASH_BASE, + size: PARAM_FLASH_LEN, + name: "parameters", + flags: BLOB_PART_FLAG_PTABLE + }, + { + /* kernel */ + magic: BLOB_PART_VALID_MAGIC, + next: sizeof(blob_partition_t), + offset: KERNEL_FLASH_BASE, + size: KERNEL_FLASH_LEN, + name: "kernel", + flags: BLOB_PART_FLAG_LOAD | BLOB_PART_FLAG_EXEC, + mem_base: KERNEL_RAM_BASE, + entry_point: KERNEL_RAM_BASE + }, + { + /* ramdisk */ + magic: BLOB_PART_VALID_MAGIC, + next: sizeof(blob_partition_t), + offset: RAMDISK_FLASH_BASE, + size: RAMDISK_FLASH_LEN, + name: "ramdisk", + flags: BLOB_PART_FLAG_LOAD, + mem_base: RAMDISK_RAM_BASE + }, + { + /* last entry */ + magic: BLOB_PART_LAST_MAGIC + } +}; + + + + +static void lart_set_partition_table(void) { - /* we could do funky detection over here, because the LART can - * have both internal and external flash with different - * properties. for the time being we just ignore that fact. - * -- Erik + /* the default partition table */ + default_partition_table = lart_default_partition_table; + + /* we don't know where the flash partition table will live, so + * put the pointer at 0x0000000 and let the partition table + * parser figure out. */ - - flash_descriptors = lart_flash_descriptors; - flash_driver = &intel32_flash_driver; + flash_partition_table = (blob_partition_t*)0x00000000; } -__initlist(init_lart_flash_driver, INIT_LEVEL_DRIVER_SELECTION); - +__initlist(lart_set_partition_table, INIT_LEVEL_OTHER_STUFF); +/* FIXME: need to think if this is the correct init level, we might + * want to have this before the param list stuff starts running */ -static void lart_init_hardware(void) +static void lart_select_drivers(void) { /* select serial driver */ serial_driver = &sa11x0_serial_driver; + + /* we could do funky detection over here, because the LART can + * have both internal and external flash with different + * properties. for the time being we just ignore that fact. + * -- Erik + */ + + flash_descriptors = lart_flash_descriptors; + flash_driver = &intel32_flash_driver; } -__initlist(lart_init_hardware, INIT_LEVEL_DRIVER_SELECTION); +__initlist(lart_select_drivers, INIT_LEVEL_DRIVER_SELECTION); |
From: Erik M. <er...@us...> - 2002-02-13 00:20:00
|
Update of /cvsroot/blob/blob/src/blob In directory usw-pr-cvs1:/tmp/cvs-serv16728/src/blob Modified Files: partition.c Log Message: The new partition table code, initial part. Next on the list are functions to manipulate the table. Index: partition.c =================================================================== RCS file: /cvsroot/blob/blob/src/blob/partition.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- partition.c 3 Jan 2002 16:07:18 -0000 1.2 +++ partition.c 13 Feb 2002 00:19:57 -0000 1.3 @@ -27,49 +27,295 @@ # include <blob/config.h> #endif +#include <blob/command.h> +#include <blob/errno.h> +#include <blob/error.h> #include <blob/flash.h> +#include <blob/init.h> #include <blob/partition.h> #include <blob/serial.h> -#include <blob/error.h> +#include <blob/util.h> +#include <blob/debug.h> +#define next_ptable_entry(s) \ + (blob_partition_t *)((u32)s + s->next) -static partition_table_t flash_partition_table; +/* pointers to the partition tables */ +const blob_partition_t *default_partition_table; +blob_partition_t *flash_partition_table; -/* FIXME: this is for the time being */ -extern int read_bootldr_partition_table(partition_table_t *ptable); +/* copy of the flash partition table in RAM */ +#define MAX_PARTITIONS (64) +static blob_partition_t ptable[MAX_PARTITIONS]; -static int read_partition_table(void) + + +static int check_ptable_magic(const blob_partition_t *entry, u32 magic) { - int rv; - int i; + if(entry->magic != magic) { + deprintf("magic failed at 0x%08x (0x%08x != 0x%08x)\n", + (unsigned int)entry, + entry->magic, + magic); + return -EMAGIC; + } else { + return 0; + } +} - /* so far we only know about bootldr flash partitions */ - rv = read_bootldr_partition_table(&flash_partition_table); + + +/* find the flash partition table */ +static void find_flash_ptable(void) +{ + u32 old_a, a; + int rv; + + /* assume that the architecture dependent code has set + * the flash_partition_table pointer to something valid + */ + if(flash_partition_table->magic == BLOB_FLASH_PART_TABLE_MAGIC) { + dprintf("Immediately found flash partition table at 0x%08x\n", + (unsigned int)flash_partition_table); + return; + } + + /* apparently not. we now assume that the architecture + * dependent code has put the flash_partition_table pointer at + * the start of the flash, so we start scanning the start of + * all flash blocks until we find a partition table. + */ + dprintf("Searching flash partition table... \n"); + rv = flash_get_first_block_address(&a); if(rv < 0) { - printerror(rv, "can't get partition table\n"); - return rv; + dprintf("first block not found\n"); + return; } - SerialOutputString("Flash partition layout:\n"); - for(i = 0; i < flash_partition_table.numpartitions; i++) { - SerialOutputString(" 0x"); - SerialOutputHex(flash_partition_table.partition[i].size); - SerialOutputString(" @ 0x"); - SerialOutputHex(flash_partition_table.partition[i].offset); + dprintf(" block at 0x%08x...\n", a); - if(flash_partition_table.partition[i].flags & PART_LOAD) { - SerialOutputString(", load at 0x"); - SerialOutputHex(flash_partition_table.partition[i].mem_base); - SerialOutputString(", entry point at 0x"); - SerialOutputHex(flash_partition_table.partition[i].entry_point); + while(((blob_partition_t *)a)->magic != BLOB_FLASH_PART_TABLE_MAGIC) { + old_a = a; + rv = flash_get_next_block_address(&a, old_a); + + if(rv < 0){ + dprintf("not found\n"); + return; + } + + dprintf(" block at 0x%08x...\n", a); + } + + dprintf("found at 0x%08x\n", + (unsigned int)a); + flash_partition_table = (blob_partition_t *)a; +} + + + + +/* copy partition table from src to dst. dst can only contain max_dst + * entries. src must be of type magic. also copy invalidated entries + * if copy_invalid != 0 */ +static int copy_ptable(const blob_partition_t *src, blob_partition_t *dst, + u32 magic, int max_dst, int copy_invalid) +{ + int i = 1, rv = 0; + + dprintf("copy from 0x%08x to 0x%08x,\n", + (u32)src, (u32)dst); + dprintf("magic = 0x%08x, max_dst = %d, copy_invalid = %d\n", + magic, max_dst, copy_invalid); + + /* sanity check */ + if(max_dst < 2) { + deprintf("max_dst too small (%i < 2)\n", max_dst); + return -EINVAL; + } + + if(src->magic != magic) { + deprintf("src not of requested type (0x%08x != 0x%08x)\n", + src->magic, magic); + return -EINVAL; + } + + /* copy start of partition table and go to next entry*/ + memcpy(dst, src, src->next); + src = next_ptable_entry(src); + dst = next_ptable_entry(dst); + i++; + + for(;;) { + /* we're at the last one */ + if(i == max_dst) { + rv = -ERANGE; + break; + } + + /* check for a valid entry and copy it */ + rv = check_ptable_magic(src, BLOB_PART_VALID_MAGIC); + if(rv == 0) + goto do_copy; + + /* check for an invalidated entry */ + rv = check_ptable_magic(src, BLOB_PART_INVALID_MAGIC); + if(rv == 0) { + /* only copy when asked */ + if(copy_invalid) + goto do_copy; + else + continue; } + + /* check for a last partition entry and stop if found */ + rv = check_ptable_magic(src, BLOB_PART_LAST_MAGIC); + if(rv == 0) { + rv = 0; + } else { + /* we should NEVER reach this point */ + dprintf("unknown entry at 0x%08x (08%08x)\n", + (unsigned int)src, src->magic); + dprintf("this should not happen, bailing out\n"); + rv = -EMAGIC; + } + break; + + do_copy: + memcpy(dst, src, src->next); + src = next_ptable_entry(src); + dst = next_ptable_entry(dst); + i++; + } + + /* fill out last entry */ + dst->magic = BLOB_PART_LAST_MAGIC; + + dprintf("%d entries copied, returning %d\n", i, rv); + + return rv; +} + + + + +void ptable_print(const blob_partition_t *t) +{ + printf("Partition table for %d kB flash @ 0x%08x:\n", + t->size / 1024, t->offset); + + for(;;) { + t = next_ptable_entry(t); - serial_write('\n'); + switch(t->magic) { + case BLOB_PART_LAST_MAGIC: + return; + + case BLOB_PART_VALID_MAGIC: + printf(" 0x%08x @ 0x%08x (%d kB): '%s'\n", + t->size, t->offset, t->size, t->name); + + if(t->flags & BLOB_PART_FLAG_PTABLE) + printf(" contains partition table\n"); + + if(t->mem_base) + printf(" %sload at 0x%08x\n", + (t->flags & BLOB_PART_FLAG_LOAD) ? + "automatically " : "", + t->mem_base); + + if(t->entry_point) { + printf(" entry point at 0x%08x", + t->entry_point); + if(t->flags & BLOB_PART_FLAG_EXEC) + printf(", automatically execute\n"); + else + printf("\n"); + } + + if(t->flags & BLOB_PART_FLAG_JFFS2) + printf(" contains JFFS2\n"); + + if(t->flags & BLOB_PART_FLAG_CRAMFS) + printf(" contains cramfs\n"); + break; + + case BLOB_PART_INVALID_MAGIC: + dprintf("invalidated entry\n"); + break; + + default: + eprintf("ptable magic failed at 0x%08x\n", (u32)t); + return; + } } +} + + + + +static void ptable_init(void) +{ + int rv; + + /* try to copy the default partition table */ + rv = copy_ptable(default_partition_table, ptable, + BLOB_DEFAULT_PART_TABLE_MAGIC, MAX_PARTITIONS, 0); + + if(rv == 0) { + ptable->magic = BLOB_COPY_PART_TABLE_MAGIC; + dprintf("found default partition table at 0x%08x\n", + (unsigned int)default_partition_table); + } + + /* try to find the flash partition table and try to copy it. + * flash partition table overrides a default partition table. + */ + find_flash_ptable(); + rv = copy_ptable(flash_partition_table, ptable, + BLOB_FLASH_PART_TABLE_MAGIC, MAX_PARTITIONS, 1); + + if(rv == 0) { + ptable->magic = BLOB_COPY_PART_TABLE_MAGIC; + dprintf("found flash partition table at 0x%08x\n", + (unsigned int)flash_partition_table); + } + + /* FIXME: if there is still no flash partition table found we + * could check for a bootldr partition table over here */ + + if(check_ptable_magic(ptable, BLOB_COPY_PART_TABLE_MAGIC) != 0) { + dprintf("no valid partition table found\n"); + + /* construct a minimal partition table */ + ptable[0].magic = BLOB_COPY_PART_TABLE_MAGIC; + ptable[0].next = sizeof(blob_partition_t); + ptable[0].offset = 0; + ptable[0].size = 0; + ptable[1].magic = BLOB_PART_LAST_MAGIC; + } + +#ifdef BLOB_DEBUG + ptable_print(ptable); +#endif +} + +__initlist(ptable_init, INIT_LEVEL_OTHER_STUFF + 2); + + + + +static int ptprint(int argc, char *argv[]) +{ + ptable_print(ptable); return 0; } + +static char ptprint_help[] = "ptprint\n" +"print flash partition table\n"; + +__commandlist(ptprint, "ptprint", ptprint_help); |
From: Erik M. <er...@us...> - 2002-02-13 00:20:00
|
Update of /cvsroot/blob/blob/include/blob In directory usw-pr-cvs1:/tmp/cvs-serv16728/include/blob Modified Files: partition.h Log Message: The new partition table code, initial part. Next on the list are functions to manipulate the table. Index: partition.h =================================================================== RCS file: /cvsroot/blob/blob/include/blob/partition.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- partition.h 26 Dec 2001 23:38:36 -0000 1.2 +++ partition.h 13 Feb 2002 00:19:57 -0000 1.3 @@ -1,7 +1,7 @@ /* * partition.h: flash paritioning * - * Copyright (C) 2001 Erik Mouw (J.A...@it...) + * Copyright (C) 2001 2002 Erik Mouw (J.A...@it...) * * $Id$ * @@ -29,30 +29,89 @@ #include <blob/types.h> -#define PART_PARTITION_NAMELEN (32) +/* A partition table can contain three types of entries: + * - The last entry + * - A valid entry + * - An invalid entry + * + * A last entry can be changed into a valid entry by changing the + * second last bit (with mask 0x00000002) from 1 to 0, or into an + * invalid entry by changing the last two bits (with mask 0x00000003) + * from 1 to 0. By doing it like this we can avoid erasing a flash + * block. + * + * Flash chips wear from erase operations (that's why flash lifetime + * is specified in erase cycles), so we try to limit the number of + * erase operations. Luckily the flash helps us a little bit with + * this, because it only allows you to change a '1' bit into a '0' + * during a write operation. This means that 0xffff can be changed + * into 0x1010, and 0x1010 into 0x0000, but 0x0000 can't be changed + * into anything else anymore because there are no '1' bits left. + * + * The magic values have been carefully choosen to allow changing a + * partition entry without having to erase the flash. For a "last" + * entry, it is best to keep all other fields except the magic + * unitialised: chances are high that the other fields are still at + * 0xffffffff so we can reuse them when we change the partition type. + */ + +#define BLOB_PART_LAST_MAGIC (0x42504533) /* BPE3, Blob Partition Entry 3 */ +#define BLOB_PART_VALID_MAGIC (0x42504531) /* BPE1, Blob Partition Entry 1 */ +#define BLOB_PART_INVALID_MAGIC (0x42504530) /* BPE0, Blob Partition Entry 0 */ +#define BLOB_PART_NAMELEN (32) + typedef struct { - u32 offset; /* offset wrt start of flash */ - u32 size; /* partition size */ + /* generic (i.e.: blob independent) data */ + u32 magic; /* magic value */ + u32 next; /* offset (in bytes) to next partition entry */ + u32 offset; /* offset (in bytes) wrt start of flash */ + u32 size; /* partition size (in bytes) */ + char name[BLOB_PART_NAMELEN]; + + /* blob specific items, can be changed for other bootloaders */ + u32 flags; /* blob specific flags */ u32 mem_base; /* load address in RAM */ u32 entry_point; /* entry point in RAM */ - u32 flags; - char name[PART_PARTITION_NAMELEN]; -} partition_t; +} blob_partition_t; -#define PART_VALID (1<<0) -#define PART_LOAD (1<<1) -#define PART_EXPAND (1<<2) +#define BLOB_PART_FLAG_PTABLE (1<<0) /* contains a partition table */ +#define BLOB_PART_FLAG_LOAD (1<<1) /* load partition into RAM */ +#define BLOB_PART_FLAG_EXEC (1<<2) /* partition/target is executable */ +#define BLOB_PART_FLAG_JFFS2 (1<<3) /* contains a JFFS2 */ +#define BLOB_PART_FLAG_CRAMFS (1<<4) /* contains a cramfs */ -#define PART_MAGIC (0x50727420) /* "Prt " */ -#define PART_MAX_PARTITIONS (16) /* 16 partitions ought to be enough */ +/* A partition table is marked with a special entry that marks the + * start of the table. + * + * There are two kinds of blob partition tables: the first one is the + * regular partition table that can be changed by the bootloader. The + * second one is a default partition table that can be put into the + * bootloader binary so it can avoid to waste a flash block for the + * partition table. The partition table parser first tries to find a + * regular partition table and will fall back on the default table if + * it can't find one. + * + * A partition table entry point has to specify the total size of the + * flash (in the size member), and the offset has to specify the + * absolute base address. + */ -typedef struct { - int magic; - int numpartitions; - partition_t partition[PART_MAX_PARTITIONS]; -} partition_table_t; +#define BLOB_FLASH_PART_TABLE_MAGIC (0x42465054) /* BFPT, Blob Flash + * Partition Table */ +#define BLOB_DEFAULT_PART_TABLE_MAGIC (0x42445054) /* BDPT, Blob Default + * Partition Table */ +#define BLOB_COPY_PART_TABLE_MAGIC (0x42435054) /* BCPT, Blob Copy + * Partition Table */ + + + + +/* flash functions */ + +extern const blob_partition_t *default_partition_table; +extern blob_partition_t *flash_partition_table; |
From: Erik M. <er...@us...> - 2002-02-13 00:17:35
|
Update of /cvsroot/blob/blob/src/blob In directory usw-pr-cvs1:/tmp/cvs-serv16266/src/blob Modified Files: bootldrpart.c Log Message: Temporary disable bootldr partition parsing Index: bootldrpart.c =================================================================== RCS file: /cvsroot/blob/blob/src/blob/bootldrpart.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- bootldrpart.c 26 Dec 2001 23:38:36 -0000 1.2 +++ bootldrpart.c 13 Feb 2002 00:17:32 -0000 1.3 @@ -38,6 +38,9 @@ #include <blob/util.h> +/* FIXME: don't do bootldr partitions for the time being -- Erik */ +#if 0 + #define BOOTLDR_PARTITION_NAMELEN 32 enum LFR_FLAGS { @@ -203,3 +206,4 @@ return 0; } +#endif |
From: Erik M. <er...@us...> - 2002-02-13 00:11:00
|
Update of /cvsroot/blob/blob/src/lib In directory usw-pr-cvs1:/tmp/cvs-serv14201 Modified Files: command.c init.c reboot.c terminal.c Log Message: Convert SerialOutput*() functions to printf() and friends Index: command.c =================================================================== RCS file: /cvsroot/blob/blob/src/lib/command.c,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- command.c 8 Feb 2002 12:55:16 -0000 1.11 +++ command.c 13 Feb 2002 00:10:57 -0000 1.12 @@ -37,6 +37,7 @@ #include <blob/command.h> +#include <blob/debug.h> #include <blob/errno.h> #include <blob/error.h> #include <blob/init.h> @@ -124,10 +125,8 @@ *argc = i; #ifdef BLOB_DEBUG - for(i = 0; i < *argc; i++) { - printerrprefix(); - printf("argv[%i] = %s\n", i, argv[i]); - } + for(i = 0; i < *argc; i++) + dprintf("argv[%i] = %s\n", i, argv[i]); #endif } @@ -145,11 +144,9 @@ for(cmd = commands; cmd != NULL; cmd = cmd->next) { if(cmd->magic != COMMAND_MAGIC) { -#ifdef BLOB_DEBUG - printerrprefix(); - printf(__FUNCTION__ "(): Magic failed at 0x%08x\n", - (unsigned int)cmd); -#endif + deprintf("command magic failed at 0x%08x\n", + (unsigned int)cmd); + return -EMAGIC; } @@ -194,11 +191,8 @@ /* single command, go for it */ for(cmd = commands; cmd != NULL; cmd = cmd->next) { if(cmd->magic != COMMAND_MAGIC) { -#ifdef BLOB_DEBUG - printerrprefix(); - printf(__FUNCTION__ "(): magic faild at 0x%08x\n", - (unsigned int)cmd); -#endif + deprintf("command magic failed at 0x%08x\n", + (unsigned int)cmd); return -EMAGIC; } Index: init.c =================================================================== RCS file: /cvsroot/blob/blob/src/lib/init.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- init.c 8 Feb 2002 12:55:16 -0000 1.4 +++ init.c 13 Feb 2002 00:10:57 -0000 1.5 @@ -27,6 +27,7 @@ # include <blob/config.h> #endif +#include <blob/debug.h> #include <blob/errno.h> #include <blob/error.h> #include <blob/init.h> @@ -48,12 +49,10 @@ for(item = start; item != end; item++) { if(item->magic != magic) { + deprintf("init magic failed at 0x%08x\n", + (unsigned int)item); printerror(EMAGIC, NULL); -#ifdef BLOB_DEBUG - printerrprefix(); - printf(__FUNCTION__ "(): magic failed at 0x%08x\n", - (unsigned int)item); -#endif + return; } Index: reboot.c =================================================================== RCS file: /cvsroot/blob/blob/src/lib/reboot.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- reboot.c 6 Jan 2002 15:46:17 -0000 1.2 +++ reboot.c 13 Feb 2002 00:10:57 -0000 1.3 @@ -29,6 +29,7 @@ #include <blob/serial.h> #include <blob/sa1100.h> +#include <blob/util.h> @@ -41,7 +42,7 @@ int reboot(int argc, char *argv[]) { - SerialOutputString("Rebooting...\n\n"); + printf("Rebooting...\n\n"); serial_flush_output(); RCSR = 0; Index: terminal.c =================================================================== RCS file: /cvsroot/blob/blob/src/lib/terminal.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- terminal.c 3 Jan 2002 16:07:18 -0000 1.5 +++ terminal.c 13 Feb 2002 00:10:57 -0000 1.6 @@ -29,6 +29,7 @@ #include <blob/serial.h> #include <blob/terminal.h> +#include <blob/util.h> @@ -43,11 +44,11 @@ { int i; - SerialOutputString(" c"); + printf(" c"); for(i = 0; i < 100; i++) serial_write('\n'); - SerialOutputString("c"); + printf("c"); return 0; } |