Changeset 63a045c in mainline for boot/generic/src/inflate.c


Ignore:
Timestamp:
2018-10-10T17:41:44Z (6 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
9286475
Parents:
63c1dd5
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-10-10 17:11:15)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-10-10 17:41:44)
Message:

Unify handling of compressed init data and use regular tar + gzip to achieve it

There are two issues this commit solves.

First is that architecture-specific code duplicates most of the init binary
handling in each architecture, each with miniscule and confusing variations.
After this commit, the init binary expansion is almost entirely handled by
unified generic code.

Second is that the way we used to generate the incorporated data is somewhat
convoluted. Previously we have a Python script which generates a zip archive
with individual deflate-compressed files and accompanying header and C files
which contain structures describing the archive contents.
The zip file is then extracted and the individual deflate-compressed files are
included in the binary via assembler code.
Since gas doesn't take particular care to be consistent between architectures,
the assembly portions are also not uniform and the build script needs to know
particulars of the architecture's assembly.

Instead of doing that, after this commit we first gzip each included file, then
we pack the gzipped files into a tar archive, and then we include the archive
into the binary using objcopy.
Linker script provides symbols for the start and end of the archive,
and the payload is in a self-describing format, so there is no need for any
generated code.

Note that we are doing the opposite of the conventional .tar.gz format.
It would be somewhat inconvenient to use .tar.gz since the uncompressed files
need to be aligned to page size, so we'd have to first decompress the entire
payload to determine the final position of the files (and hence the required
amount of memory).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • boot/generic/src/inflate.c

    r63c1dd5 r63a045c  
    104104        size_t destcnt;   /**< Position in the output buffer */
    105105
    106         uint8_t *src;     /**< Input buffer */
     106        const uint8_t *src;     /**< Input buffer */
    107107        size_t srclen;    /**< Input buffer size */
    108108        size_t srccnt;    /**< Position in the input buffer */
     
    319319    uint16_t *symbol)
    320320{
    321         /* Decoded bits */
     321        /* Decode bits */
    322322        uint16_t code = 0;
    323323
     
    331331        size_t index = 0;
    332332
    333         size_t len;  /* Current number of bits in the code */
     333        /* Current number of bits in the code */
     334        size_t len;
     335
    334336        for (len = 1; len <= MAX_HUFFMAN_BIT; len++) {
    335337                /* Get next bit */
     
    625627 *
    626628 */
    627 int inflate(void *src, size_t srclen, void *dest, size_t destlen)
     629int inflate(const void *src, size_t srclen, void *dest, size_t destlen)
    628630{
    629631        /* Initialize the state */
     
    634636        state.destcnt = 0;
    635637
    636         state.src = (uint8_t *) src;
     638        state.src = (const uint8_t *) src;
    637639        state.srclen = srclen;
    638640        state.srccnt = 0;
Note: See TracChangeset for help on using the changeset viewer.