⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 zimage.patch

📁 patches for linux-2.6.
💻 PATCH
📖 第 1 页 / 共 3 页
字号:
+}++int getc(void)+{+	while (1) {+		if (serial_tstc(com_port))+			return (serial_getc(com_port));+	}+}++void +putc(const char c)+{+	serial_putc(com_port, c);+	if ( c == '\n' )+		serial_putc(com_port, '\r');+}++void puts(const char *s)+{+	char c;+	while ( ( c = *s++ ) != '\0' ) {+	        serial_putc(com_port, c);+	        if ( c == '\n' ) serial_putc(com_port, '\r');+	}+}++void error(char *x)+{+	puts("\n\n");+	puts(x);+	puts("\n\n -- System halted");++	while(1);	/* Halt */+}++static void *zalloc(unsigned size)+{+	void *p = avail_ram;++	size = (size + 7) & -8;+	avail_ram += size;+	if (avail_ram > end_avail) {+		puts("oops... out of memory\n");+		pause();+	}+	return p;+}+++#define HEAD_CRC	2+#define EXTRA_FIELD	4+#define ORIG_NAME	8+#define COMMENT		0x10+#define RESERVED	0xe0++#define DEFLATED	8++void gunzip(void *dst, int dstlen, unsigned char *src, int *lenp)+{+	z_stream s;+	int r, i, flags;++	/* skip header */+	i = 10;+	flags = src[3];+	if (src[2] != Z_DEFLATED || (flags & RESERVED) != 0) {+		puts("bad gzipped data\n");+		exit();+	}+	if ((flags & EXTRA_FIELD) != 0)+		i = 12 + src[10] + (src[11] << 8);+	if ((flags & ORIG_NAME) != 0)+		while (src[i++] != 0)+			;+	if ((flags & COMMENT) != 0)+		while (src[i++] != 0)+			;+	if ((flags & HEAD_CRC) != 0)+		i += 2;+	if (i >= *lenp) {+		puts("gunzip: ran out of data in header\n");+		exit();+	}++	/* Initialize ourself. */+	s.workspace = zalloc(zlib_inflate_workspacesize());+	r = zlib_inflateInit2(&s, -MAX_WBITS);+	if (r != Z_OK) {+		puts("zlib_inflateInit2 returned "); puthex(r); puts("\n");+		exit();+	}+	s.next_in = src + i;+	s.avail_in = *lenp - i;+	s.next_out = dst;+	s.avail_out = dstlen;+	r = zlib_inflate(&s, Z_FINISH);+	if (r != Z_OK && r != Z_STREAM_END) {+		puts("inflate returned "); puthex(r); puts("\n");+		exit();+	}+	*lenp = s.next_out - (unsigned char *) dst;+	zlib_inflateEnd(&s);+}++void+puthex(unsigned long val)+{++	unsigned char buf[10];+	int i;+	for (i = 7;  i >= 0;  i--)+	{+		buf[i] = "0123456789ABCDEF"[val & 0x0F];+		val >>= 4;+	}+	buf[8] = '\0';+	puts(buf);+}++#define FALSE 0+#define TRUE  1++void+_printk(char const *fmt, ...)+{+	va_list ap;++	va_start(ap, fmt);+	_vprintk(putc, fmt, ap);+	va_end(ap);+	return;+}++#define is_digit(c) ((c >= '0') && (c <= '9'))++void+_vprintk(void(*putc)(const char), const char *fmt0, va_list ap)+{+	char c, sign, *cp = 0;+	int left_prec, right_prec, zero_fill, length = 0, pad, pad_on_right;+	char buf[32];+	long val;+	while ((c = *fmt0++))+	{+		if (c == '%')+		{+			c = *fmt0++;+			left_prec = right_prec = pad_on_right = 0;+			if (c == '-')+			{+				c = *fmt0++;+				pad_on_right++;+			}+			if (c == '0')+			{+				zero_fill = TRUE;+				c = *fmt0++;+			} else+			{+				zero_fill = FALSE;+			}+			while (is_digit(c))+			{+				left_prec = (left_prec * 10) + (c - '0');+				c = *fmt0++;+			}+			if (c == '.')+			{+				c = *fmt0++;+				zero_fill++;+				while (is_digit(c))+				{+					right_prec = (right_prec * 10) + (c - '0');+					c = *fmt0++;+				}+			} else+			{+				right_prec = left_prec;+			}+			sign = '\0';+			switch (c)+			{+			case 'd':+			case 'x':+			case 'X':+				val = va_arg(ap, long);+				switch (c)+				{+				case 'd':+					if (val < 0)+					{+						sign = '-';+						val = -val;+					}+					length = _cvt(val, buf, 10, "0123456789");+					break;+				case 'x':+					length = _cvt(val, buf, 16, "0123456789abcdef");+					break;+				case 'X':+					length = _cvt(val, buf, 16, "0123456789ABCDEF");+					break;+				}+				cp = buf;+				break;+			case 's':+				cp = va_arg(ap, char *);+				length = strlen(cp);+				break;+			case 'c':+				c = va_arg(ap, long /*char*/);+				(*putc)(c);+				continue;+			default:+				(*putc)('?');+			}+			pad = left_prec - length;+			if (sign != '\0')+			{+				pad--;+			}+			if (zero_fill)+			{+				c = '0';+				if (sign != '\0')+				{+					(*putc)(sign);+					sign = '\0';+				}+			} else+			{+				c = ' ';+			}+			if (!pad_on_right)+			{+				while (pad-- > 0)+				{+					(*putc)(c);+				}+			}+			if (sign != '\0')+			{+				(*putc)(sign);+			}+			while (length-- > 0)+			{+				(*putc)(c = *cp++);+				if (c == '\n')+				{+					(*putc)('\r');+				}+			}+			if (pad_on_right)+			{+				while (pad-- > 0)+				{+					(*putc)(c);+				}+			}+		} else+		{+			(*putc)(c);+			if (c == '\n')+			{+				(*putc)('\r');+			}+		}+	}+}++int+_cvt(unsigned long val, char *buf, long radix, char *digits)+{+	char temp[80];+	char *cp = temp;+	int length = 0;+	if (val == 0)+	{ /* Special case */+		*cp++ = '0';+	} else+		while (val)+		{+			*cp++ = digits[val % radix];+			val /= radix;+		}+	while (cp != temp)+	{+		*buf++ = *--cp;+		length++;+	}+	*buf = '\0';+	return (length);+}++void+_dump_buf_with_offset(unsigned char *p, int s, unsigned char *base)+{+	int i, c;+	if ((unsigned int)s > (unsigned int)p)+	{+		s = (unsigned int)s - (unsigned int)p;+	}+	while (s > 0)+	{+		if (base)+		{+			_printk("%06X: ", (int)p - (int)base);+		} else+		{+			_printk("%06X: ", p);+		}+		for (i = 0;  i < 16;  i++)+		{+			if (i < s)+			{+				_printk("%02X", p[i] & 0xFF);+			} else+			{+				_printk("  ");+			}+			if ((i % 2) == 1) _printk(" ");+			if ((i % 8) == 7) _printk(" ");+		}+		_printk(" |");+		for (i = 0;  i < 16;  i++)+		{+			if (i < s)+			{+				c = p[i] & 0xFF;+				if ((c < 0x20) || (c >= 0x7F)) c = '.';+			} else+			{+				c = ' ';+			}+			_printk("%c", c);+		}+		_printk("|\n");+		s -= 16;+		p += 16;+	}+}++void+_dump_buf(unsigned char *p, int s)+{+	_printk("\n");+	_dump_buf_with_offset(p, s, 0);+}++/*+ * Local variables:+ *  c-indent-level: 8+ *  c-basic-offset: 8+ *  tab-width: 8+ * End:+ */diff -Naur --exclude=CVS linux-2.6-orig/arch/mips/boot/compressed/common/misc-simple.c linux-2.6-dev/arch/mips/boot/compressed/common/misc-simple.c--- linux-2.6-orig/arch/mips/boot/compressed/common/misc-simple.c	1969-12-31 16:00:00.000000000 -0800+++ linux-2.6-dev/arch/mips/boot/compressed/common/misc-simple.c	2004-12-13 00:00:42.000000000 -0800@@ -0,0 +1,122 @@+/*+ * arch/mips/zboot/common/misc-simple.c+ *+ * Misc. bootloader code for many machines.  This assumes you have are using+ * a 6xx/7xx/74xx CPU in your machine.  This assumes the chunk of memory+ * below 8MB is free.  Finally, it assumes you have a NS16550-style uart for + * your serial console.  If a machine meets these requirements, it can quite+ * likely use this code during boot.+ * + * Author: Matt Porter <mporter@mvista.com>+ * Derived from arch/ppc/boot/prep/misc.c+ *+ * Copyright 2001 MontaVista Software Inc.+ *+ * 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.+ */++#include <linux/types.h>+#include <linux/elf.h>+#include <linux/config.h>++#include <asm/page.h>++#include "zlib.h"++extern struct NS16550 *com_port;++char *avail_ram;+char *end_avail;+extern char _end[];+char *zimage_start;++#ifdef CONFIG_CMDLINE+#define CMDLINE CONFIG_CMDLINE+#else+#define CMDLINE ""+#endif+char cmd_preset[] = CMDLINE;+char cmd_buf[256];+char *cmd_line = cmd_buf;++/* The linker tells us where the image is.+*/+extern unsigned char __image_begin, __image_end;+extern unsigned char __ramdisk_begin, __ramdisk_end;+unsigned long initrd_size;++extern void puts(const char *);+extern void putc(const char c);+extern void puthex(unsigned long val);+extern void *memcpy(void * __dest, __const void * __src,+			    __kernel_size_t __n);+extern void gunzip(void *, int, unsigned char *, int *);+extern void udelay(long delay);+extern int tstc(void);+extern int getc(void);+extern volatile struct NS16550 *serial_init(int chan);++void+decompress_kernel(unsigned long load_addr, int num_words, +		unsigned long cksum, unsigned long *sp)+{+	extern unsigned long start;+	int	zimage_size;++	com_port = (struct NS16550 *)serial_init(0);++	initrd_size = (unsigned long)(&__ramdisk_end) -+		(unsigned long)(&__ramdisk_begin);++	/*+	 * Reveal where we were loaded at and where we+	 * were relocated to.+	 */+	puts("loaded at:     "); puthex(load_addr);+	puts(" "); puthex((unsigned long)(load_addr + (4*num_words))); puts("\n");+	if ( (unsigned long)load_addr != (unsigned long)&start )+	{+		puts("relocated to:  "); puthex((unsigned long)&start);+		puts(" ");+		puthex((unsigned long)((unsigned long)&start + (4*num_words)));+		puts("\n");+	}++	/*+	 * We link ourself to an arbitrary low address.  When we run, we+	 * relocate outself to that address.  __image_being points to

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -