linux的boot/compressed/misc.c
{
if (insize != 0)
error(“ran out of input data”);
inbuf = input_data; /*注意这里的input_data和input_data_end就是在piggy.S里面定义的。所有解压缩函数不需要zimage映象的起始地址和长度。*/
insize = &input_data_end[0] – &input_data[0];
inptr = 1;
return inbuf[0];
}
/* ===========================================================================
* Write the output window window[0..outcnt-1] and update crc and bytes_out.
* (Used for the decompressed data only.)
*/
void flush_window(void)
{
ulg c = crc;
unsigned n;
uch *in, *out, ch;
in = window;
out = &output_data[output_ptr];
for (n = 0; n < outcnt; n++) {
ch = *out++ = *in++;
c = crc_32_tab[((int)c ^ ch) & 0xff] ^ (c >> 8);
}
crc = c;
bytes_out += (ulg)outcnt;
output_ptr += (ulg)outcnt;
outcnt = 0;
putstr(“.”);
}
#ifndef arch_error
#define arch_error(x)
#endif
static void error(char *x)
{
arch_error(x);
putstr(“\n\n”);
putstr(x);
putstr(“\n\n — System halted”);
while(1); /* Halt */
}
#ifndef STANDALONE_DEBUG
ulg
decompress_kernel(ulg output_start, ulg free_mem_ptr_p, ulg free_mem_ptr_end_p,
int arch_id) /*有head.S调用的解压缩函数,就是解压缩gzip的方式。*/
{
output_data = (uch *)output_start; /* Points to kernel start */
free_mem_ptr = free_mem_ptr_p;
free_mem_end_ptr = free_mem_ptr_end_p;
__machine_arch_type = arch_id;
arch_decomp_setup();
makecrc();
putstr(“Uncompressing Linux…”);
gunzip();
putstr(” done, booting the kernel.\n”);
return output_ptr;
}