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

📄 tqm_led.patch

📁 linux交叉编译环境个软件和内核的补丁。
💻 PATCH
字号:
+ diff -u linux-2.2.13/arch/ppc/8xx_io/Makefile.ORIG linux-2.2.13/arch/ppc/8xx_io/Makefile--- linux-2.2.13/arch/ppc/8xx_io/Makefile.ORIG	Fri Oct 22 23:27:14 1999+++ linux-2.2.13/arch/ppc/8xx_io/Makefile	Sun Jan  9 00:00:14 2000@@ -36,4 +36,6 @@ O_OBJS += iic.o endif +O_OBJS += tqm_led.o+ include $(TOPDIR)/Rules.make+ diff -u linux-2.2.13/arch/ppc/8xx_io/tqm_led.c.ORIG linux-2.2.13/arch/ppc/8xx_io/tqm_led.c--- linux-2.2.13/arch/ppc/8xx_io/tqm_led.c.ORIG	Sat Jan  8 23:18:48 2000+++ linux-2.2.13/arch/ppc/8xx_io/tqm_led.c	Tue Nov 16 00:39:35 1999@@ -0,0 +1,273 @@+/*+ * Copyright (C) 1999+ * DENX Software Engineering+ * Wolfgang Denk, wd@denx.de+ * All rights reserved.+ */+++/*+ * Standard in kernel modules+ */+#include <linux/kernel.h>	/* We're doing kernel work	*/+#include <linux/module.h>	/* Specifically, a module	*/+#include <asm/uaccess.h>	/* for put_user			*/+#include <asm/init.h>		/* for __initfunc		*/+#include <asm/8xx_immap.h>+#include <asm/mpc8xx.h>++extern cpm8xx_t *cpmp;		/* Pointer to comm processor	*/++#undef	DEBUG++#ifdef	DEBUG+# define debugk(fmt,args...)	printk(fmt ,##args)+#else+# define debugk(fmt,args...)+#endif++/*+ * Deal with CONFIG_MODVERSIONS+ */+#if CONFIG_MODVERSIONS==1+# define MODVERSIONS+# include <linux/modversions.h>+#endif++/*+ * For character devices+ */+#include <linux/fs.h>		/* character device definitions	*/+#include <linux/wrapper.h>	/* wrapper for compatibility with future versions */++#ifndef KERNEL_VERSION+# define KERNEL_VERSION(a,b,c)	((a)*65536+(b)*256+(c))+#endif++#define	DEBUG	1+#define SUCCESS 0++#define	LED_MAJOR	42	/* free for demo/sample use	*/++/*+ * Device Declarations + */++/*+ * The name for our device, as it will appear in /proc/devices+ */+#define DEVICE_NAME "TQM_LED"++/*+ * prevent concurent access of the same device+ */+static int Device_Open = 0;++/*+ * Prototypes+ */+int led_init (void );+static int device_open(struct inode *, struct file *);+static int device_release(struct inode *, struct file *);+static ssize_t device_read(struct file *, char *, size_t, loff_t *);+static ssize_t device_write(struct file *, const char *, size_t, loff_t *);+int init_module(void);+void cleanup_module(void);++struct file_operations led_ops =+{+	NULL,			/* seek		*/+	device_read,+	device_write,+	NULL,			/* readdir	*/+	NULL,			/* select	*/+	NULL,			/* ioctl	*/+	NULL,			/* mmap		*/+	device_open,+	NULL,			/* flush	*/+	device_release		/* close	*/+};++static int Major;++/*+ * Initialize the driver - Register the character device+ */+__initfunc( int led_init (void) )+{+	/*+	 * Register the character device+	 */+	Major = register_chrdev (LED_MAJOR, DEVICE_NAME, &led_ops);++	/* Negative values signify an error */+	if (Major < 0) {+		printk ("TQM_LED init_module: failed with %d\n", Major);+		return Major;+	}++	printk ("TQM_LED registred: major = %d\n", LED_MAJOR);+	return 0;+}++/*+ * called whenever a process attempts to open the device+ */+static int device_open (struct inode *inode, struct file *file)+{+	volatile cpm8xx_t *cp = cpmp;++	debugk ("device_open(%p,%p)\n", inode, file);++	/*+	 * Get major / minor numbers when needed+	 */+	debugk ("Device: %d.%d\n", inode->i_rdev >> 8, inode->i_rdev & 0xFF);++	/*+	 * exclusive open only+	 */+	if (Device_Open) {+		return -EBUSY;+	}++	/*+	 * Be careful here on SMP kernels!+	 */+	Device_Open++;++	/*+	 * Make sure that the module isn't removed while+	 * the file is open by incrementing the usage count+	 */+	MOD_INC_USE_COUNT;++	debugk ("LED_OPEN: pbdir=0x%x  pbpar=0x%x  pbodr=0x%x  pbdat=0x%x\n",+		cp->cp_pbdir, cp->cp_pbpar, cp->cp_pbodr, cp->cp_pbdat);++	cp->cp_pbdat |= 0x0000003F;++	cp->cp_pbdir |= 0x0000003F;++	debugk ("LED_OPEN: pbdir=0x%x  pbpar=0x%x  pbodr=0x%x  pbdat=0x%x\n",+		cp->cp_pbdir, cp->cp_pbpar, cp->cp_pbodr, cp->cp_pbdat);++	return SUCCESS;+}+++/*+ * Called when a process closes the device.+ * Doesn't have a return value in version 2.0.x because it can't fail,+ * but in version 2.2.x it is allowed to fail+ */+static int device_release (struct inode *inode, struct file *file)+{+	volatile cpm8xx_t *cp = cpmp;++	debugk ("device_release(%p,%p)\n", inode, file);++	/* We're now ready for our next caller */+	Device_Open--;++	MOD_DEC_USE_COUNT;++	debugk ("LED_CLOSE: pbdir=0x%x  pbpar=0x%x  pbodr=0x%x  pbdat=0x%x\n",+		cp->cp_pbdir, cp->cp_pbpar, cp->cp_pbodr, cp->cp_pbdat);++	cp->cp_pbdir &= 0xFFFFFFC0;++	cp->cp_pbdat &= 0xFFFFFFC0;++	debugk ("LED_CLOSE: pbdir=0x%x  pbpar=0x%x  pbodr=0x%x  pbdat=0x%x\n",+		cp->cp_pbdir, cp->cp_pbpar, cp->cp_pbodr, cp->cp_pbdat);++	return 0;+}+++/*+ * read entry point:+ */++static ssize_t device_read (struct file *file,+			    char *buffer,	/* The buffer to fill with data */+			    size_t length,	/* The length of the buffer */+			    loff_t * offset)	/* Our offset in the file */+{+	volatile cpm8xx_t *cp = cpmp;++	unsigned char c = cp->cp_pbdat & 0x0000003F;++	put_user (c, buffer);++	debugk ("Read: value = 0x%02x\n", c);++	return (1);		/* read() always returns exactly one byte */+}+++++/*+ * write entry point: dummy here+ */+static ssize_t device_write (struct file *file,+			     const char *buffer,	/* buffer */+			     size_t length,		/* length of buffer */+			     loff_t * offset)		/* offset in the file */+{+	volatile cpm8xx_t *cp = cpmp;+	size_t len = length;+	int error;++	unsigned char c;++	while (length-- > 0) {+		unsigned int pbdat = cp->cp_pbdat & 0xFFFFFFC0;++		if ((error = get_user (c, buffer++)) != 0) {+			return (error);+		}+		c &= 0x3F;++		cp->cp_pbdat = pbdat | (unsigned int)c;+	}+	return (len);+}+++/******************************+ **** Module Declarations *****+ **************************** */++#ifdef MODULE+/*+ * Initialize the module+ */+int init_module (void)+{+	return led_init();+}++/*+ * Cleanup - unregister the appropriate file from /proc+ */+void cleanup_module (void)+{+	int ret;++	/*+	 * Unregister the device+	 */+	ret = module_unregister_chrdev (Major, DEVICE_NAME);++	/*+	 * If there's an error, report it+	 */+	if (ret < 0) {+		printk ("unregister_chrdev: error %d\n", ret);+	}+}++#endif	/* MODULE */+ diff -u linux-2.2.13/drivers/char/mem.c.ORIG linux-2.2.13/drivers/char/mem.c--- linux-2.2.13/drivers/char/mem.c.ORIG	Mon Oct 25 00:49:19 1999+++ linux-2.2.13/drivers/char/mem.c	Sat Jan  8 23:45:05 2000@@ -686,5 +686,6 @@ #ifdef CONFIG_VIDEO_DEV 	videodev_init(); #endif+	led_init();	/* initialize TQM LED driver */ 	return 0; }

⌨️ 快捷键说明

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