scb9328.c
来自「优龙2410linux2.6.8内核源代码」· C语言 代码 · 共 122 行
C
122 行
/* * $Id: scb9328.c,v 1.2 2004/01/29 17:37:19 sascha Exp $ * * Map driver for the Lubbock developer platform. * * Author: Sascha Hauer * Copyright: (C) 2004 Sascha Hauer, Synertronix GmbH * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */#include <linux/module.h>#include <linux/types.h>#include <linux/kernel.h>#include <linux/init.h>#include <asm/io.h>#include <linux/mtd/mtd.h>#include <linux/mtd/map.h>#include <linux/mtd/partitions.h>#include <asm/hardware.h>//#define FLASH_ADDR 0x04000000//#define WINDOW_SIZE 16*1024*1024static struct map_info scb9328_map = { .size = SCB9328_FLASH_SIZE, .virt = SCB9328_FLASH_BASE, .phys = SCB9328_FLASH_PHYS, .name = "scb9328_flash", .bankwidth = 2};static struct mtd_partition scb9328_partitions[] = { { .name = "Bootloader", .size = 0x00020000, .offset = 0, .mask_flags = MTD_WRITEABLE /* force read-only */ },{ .name = "Bootloader env", .size = 0x00020000, .offset = 0x00020000, },{ .name = "Kernel", .size = 0x00100000, .offset = 0x00040000, },{ .name = "Rootfs", .size = 0x00400000, .offset = 0x00140000, },{ .name = "Filesystem", .size = MTDPART_SIZ_FULL, .offset = 0x00540000 }};static struct mtd_info *mymtds;static struct mtd_partition *parsed_parts;static int nr_parsed_parts;static const char *probes[] = { "cmdlinepart", NULL };static int __init init_scb9328(void){ int ret = 0; simple_map_init(&scb9328_map); printk(KERN_NOTICE "Probing %s at physical address 0x%08lx (%d-bit buswidth)\n", scb9328_map.name, scb9328_map.phys, scb9328_map.buswidth * 8); mymtds = do_map_probe("cfi_probe", &scb9328_map); if (!mymtds) { iounmap((void *)scb9328_map.virt); if (!ret) return -EIO; } mymtds->owner = THIS_MODULE; nr_parsed_parts = parse_mtd_partitions(mymtds, probes, &parsed_parts, 0); if (nr_parsed_parts > 0) { add_mtd_partitions(mymtds, parsed_parts, nr_parsed_parts); } else { printk("Using static partitions on %s\n", scb9328_map.name); add_mtd_partitions(mymtds, scb9328_partitions, ARRAY_SIZE(scb9328_partitions)); } return 0;}static void __exit cleanup_scb9328(void){ if (nr_parsed_parts) del_mtd_partitions(mymtds); else del_mtd_device(mymtds); map_destroy(mymtds); iounmap((void *)scb9328_map.virt); if (parsed_parts) kfree(parsed_parts);}module_init(init_scb9328);module_exit(cleanup_scb9328);MODULE_LICENSE("GPL");MODULE_AUTHOR("Sascha Hauer <saschahauer@web.de>");MODULE_DESCRIPTION("MTD map driver for scb9328");
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?