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

📄 dmc405.c

📁 linux下的MTD设备驱动源代码,配合jffs2 yaffss2文件系统.
💻 C
字号:
/* * $Id: dmc405.c,v 1.15 2001/10/02 15:05:14 dwmw2 Exp $ * * Handle mapping of the flash on the NEXTREAM DMC board */#include <linux/module.h>#include <linux/init.h>#include <linux/types.h>#include <linux/kernel.h>#include <asm/io.h>#include <linux/mtd/mtd.h>#include <linux/mtd/map.h>#define BOOT_WINDOW_ADDR 0xff800000#define BOOT_WINDOW_SIZE 0x800000#define SPARE_WINDOW_ADDR 0xff000000#define SPARE_WINDOW_SIZE 0x800000static struct mtd_info *dmc405_boot, *dmc405_spare;struct map_info dmc405_boot_map = {	name: "DMC Boot",	size: BOOT_WINDOW_SIZE,	buswidth: 2,};int __init init_dmc405_boot(void){	printk(KERN_NOTICE "DMC boot flash device: %x at %x\n", 	       BOOT_WINDOW_SIZE, BOOT_WINDOW_ADDR);	dmc405_boot_map.virt = (unsigned long)ioremap(BOOT_WINDOW_ADDR, 						      BOOT_WINDOW_SIZE);	dmc405_boot_map.phys = BOOT_WINDOW_ADDR;	if (!dmc405_boot_map.virt) {		printk("Failed to ioremap\n");		return -EIO;	}	simple_map_init(&dmc405_boot_map);	dmc405_boot = do_map_probe("cfi_probe", &dmc405_boot_map);	if (dmc405_boot) {		dmc405_boot->owner = THIS_MODULE;		add_mtd_device(dmc405_boot);		return 0;	}	iounmap((void *)dmc405_boot_map.virt);	return -ENXIO;}static void __exit cleanup_dmc405_boot(void){	if (dmc405_boot) {		del_mtd_device(dmc405_boot);		map_destroy(dmc405_boot);	}	if (dmc405_boot_map.virt) {		iounmap((void *)dmc405_boot_map.virt);		dmc405_boot_map.virt = 0;	}}struct map_info dmc405_spare_map = {	name: "DMC Spare",	size: SPARE_WINDOW_SIZE,	buswidth: 2,};int __init init_dmc405_spare(void){	printk(KERN_NOTICE "DMC spare flash device: %x at %x\n", 	       SPARE_WINDOW_SIZE, SPARE_WINDOW_ADDR);	dmc405_spare_map.virt = (unsigned long)ioremap(SPARE_WINDOW_ADDR, 						       SPARE_WINDOW_SIZE);	dmc405_spare_map.phys = SPARE_WINDOW_ADDR;	if (!dmc405_spare_map.virt) {		printk("Failed to ioremap\n");		return -EIO;	}	simple_map_init(&dmc405_spare_map);	dmc405_spare = do_map_probe("cfi_probe", &dmc405_spare_map);	if (dmc405_spare) {		dmc405_spare->owner = THIS_MODULE;		add_mtd_device(dmc405_spare);		return 0;	}	iounmap((void *)dmc405_spare_map.virt);	return -ENXIO;}static void __exit cleanup_dmc405_spare(void){	if (dmc405_spare) {		del_mtd_device(dmc405_spare);		map_destroy(dmc405_spare);	}	if (dmc405_spare_map.virt) {		iounmap((void *)dmc405_spare_map.virt);		dmc405_spare_map.virt = 0;	}}int __init init_dmc405(void){	init_dmc405_boot();	init_dmc405_spare();}static void __exit cleanup_dmc405(void){	cleanup_dmc405_boot();	cleanup_dmc405_spare();}module_init(init_dmc405);module_exit(cleanup_dmc405);MODULE_LICENSE("GPL");MODULE_DESCRIPTION("MTD map driver for NEXTREAM DMC board");

⌨️ 快捷键说明

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