5 extern void tgt_putchar(char c
);
7 #include "zlib_pmon.bin.c"
13 #include <linux/zlib.h>
14 typedef unsigned int u32
;
15 typedef unsigned char u8
;
17 static void *inflate_workspace
;
19 char printerr(char *msg
,int value
)
21 static char buf
[0x100];
25 if(value
<0)btoa(buf
+1,value
,-10);
26 else btoa(buf
+1,value
,10);
43 * strcat - Append one %NUL-terminated string to another
44 * @dest: The string to be appended to
45 * @src: The string to append to it
47 char * strcat(char * dest
, const char * src
)
53 while ((*dest
++ = *src
++) != '\0')
61 * char *btoa(dst,value,base)
62 * converts value to ascii, result in dst
65 btoa(char *dst
, unsigned int value
, int base
)
79 if (value
& (1L << 31)) {
85 for (i
= 0; value
!= 0; i
++) {
88 if (rem
>= 0 && rem
<= 9)
90 else if (rem
>= 10 && rem
<= 36)
91 digit
= (rem
- 10) + 'a';
99 /* reverse the string */
100 for (i
= 0, j
= strlen (buf
) - 1; j
>= 0; i
++, j
--)
107 compress_gunzip(const u8
*old
, u32 oldsize
,u8
*new)
109 /* error code and dump stream */
111 z_stream dump_stream
;
113 dump_stream
.workspace
= inflate_workspace
;
115 if ((err
= zlib_inflateInit(&dump_stream
)) != Z_OK
) {
116 /* fall back to RLE compression */
117 printerr("compress_gunzip(): zlib_inflateInit() "
122 dump_stream
.next_in
= (u8
*) old
;
123 dump_stream
.avail_in
= oldsize
;
126 dump_stream
.next_out
= new;
128 dump_stream
.avail_out
=0x8000;
130 err
= zlib_inflate(&dump_stream
, Z_FINISH
);
131 if(err
==Z_STREAM_END
)break;
132 else if(err
<0 && (err
!=Z_BUF_ERROR
))
134 /* zero is return code here */
135 (void)zlib_inflateEnd(&dump_stream
);
136 printerr("compress_gunzip(): zlib_inflate() failed",err
);
143 /* let's end the deflated compression stream */
144 if ((err
= zlib_inflateEnd(&dump_stream
)) != Z_OK
) {
145 printerr("compress_gunzip(): zlib_inflateEnd() "
149 /* return the compressed byte total (if it's smaller) */
155 static int __init
run_unzip(char *start
,int to
)
159 inflate_workspace
= (void *)end
;
160 err
=compress_gunzip(start
,sizeof(biosdata
),to
);
161 if(err
<0){stringserial("retry\n");goto again
;}
165 int main(int argc
,char **argv
)
167 fpw
=fopen("tmp.txt","wb");
168 run_unzip(biosdata
,0x80010000);
172 #include "initmips.c"
173 int read
,write
,open
,close
,printf
,vsprintf
,getenv
,tgt_reboot
,CpuTertiaryCacheSize
;