OpenCores
URL https://opencores.org/ocsvn/or1k_old/or1k_old/trunk

Subversion Repositories or1k_old

[/] [or1k_old/] [trunk/] [rc203soc/] [sw/] [uClinux/] [arch/] [i386/] [boot/] [compressed/] [piggyback.c] - Blame information for rev 1782

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1623 jcastillo
/*
2
 *      linux/zBoot/piggyback.c
3
 *
4
 *      (C) 1993 Hannu Savolainen
5
 */
6
 
7
/*
8
 *      This program reads the compressed system image from stdin and
9
 *      encapsulates it into an object file written to the stdout.
10
 */
11
 
12
#include <stdio.h>
13
#include <unistd.h>
14
#include <a.out.h>
15
 
16
int main(int argc, char *argv[])
17
{
18
        int c, n=0, len=0;
19
        char tmp_buf[512*1024];
20
 
21
        struct exec obj = {0x00640107}; /* object header */
22
        char string_names[] = {"_input_data\0_input_len\0"};
23
 
24
        struct nlist var_names[2] = /* Symbol table */
25
                {
26
                        {       /* _input_data  */
27
                                (char *)4, 7, 0, 0, 0
28
                        },
29
                        {       /* _input_len */
30
                                (char *)16, 7, 0, 0, 0
31
                        }
32
                };
33
 
34
 
35
        len = 0;
36
        while ((n = read(0, &tmp_buf[len], sizeof(tmp_buf)-len+1)) > 0)
37
              len += n;
38
 
39
        if (n==-1)
40
        {
41
                perror("stdin");
42
                exit(-1);
43
        }
44
 
45
        if (len >= sizeof(tmp_buf))
46
        {
47
                fprintf(stderr, "%s: Input too large\n", argv[0]);
48
                exit(-1);
49
        }
50
 
51
        fprintf(stderr, "Compressed size %d.\n", len);
52
 
53
/*
54
 *      Output object header
55
 */
56
        obj.a_data = len + sizeof(long);
57
        obj.a_syms = sizeof(var_names);
58
        write(1, (char *)&obj, sizeof(obj));
59
 
60
/*
61
 *      Output data segment (compressed system & len)
62
 */
63
        write(1, tmp_buf, len);
64
        write(1, (char *)&len, sizeof(len));
65
 
66
/*
67
 *      Output symbol table
68
 */
69
        var_names[1].n_value = len;
70
        write(1, (char *)&var_names, sizeof(var_names));
71
 
72
/*
73
 *      Output string table
74
 */
75
        len = sizeof(string_names) + sizeof(len);
76
        write(1, (char *)&len, sizeof(len));
77
        write(1, string_names, sizeof(string_names));
78
 
79
        exit(0);
80
 
81
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.