📄 mba44b0.c
字号:
/* * * Normal mappings of chips in physical memory */#include <linux/module.h>#include <linux/types.h>#include <linux/kernel.h>#include <asm/io.h>#include <linux/mtd/mtd.h>#include <linux/mtd/map.h>#include <linux/mtd/partitions.h>#include <linux/config.h>#define WINDOW_ADDR 0x00000000#define WINDOW_SIZE 0x00080000#define BUSWIDTH 1static struct mtd_info *mymtd;__u8 mba44b0_read8(struct map_info *map, unsigned long ofs){ return __raw_readb(map->map_priv_1 + ofs);}__u16 mba44b0_read16(struct map_info *map, unsigned long ofs){ return __raw_readw(map->map_priv_1 + ofs);}__u32 mba44b0_read32(struct map_info *map, unsigned long ofs){ return __raw_readl(map->map_priv_1 + ofs);}void mba44b0_copy_from(struct map_info *map, void *to, unsigned long from, ssize_t len){ memcpy_fromio(to, map->map_priv_1 + from, len);}void mba44b0_write8(struct map_info *map, __u8 d, unsigned long adr){ __raw_writeb(d, map->map_priv_1 + adr); mb();}void mba44b0_write16(struct map_info *map, __u16 d, unsigned long adr){ __raw_writew(d, map->map_priv_1 + adr); mb();}void mba44b0_write32(struct map_info *map, __u32 d, unsigned long adr){ __raw_writel(d, map->map_priv_1 + adr); mb();}void mba44b0_copy_to(struct map_info *map, unsigned long to, const void *from, ssize_t len){ memcpy_toio(map->map_priv_1 + to, from, len);}struct map_info mba44b0_map = { name: "MBA-44B0 flash device", size: WINDOW_SIZE, buswidth: BUSWIDTH, read8: mba44b0_read8, read16: mba44b0_read16, read32: mba44b0_read32, copy_from: mba44b0_copy_from, write8: mba44b0_write8, write16: mba44b0_write16, write32: mba44b0_write32, copy_to: mba44b0_copy_to};/* * MTD 'PARTITIONING' STUFF */static struct mtd_partition mba44b0_partitions[] = { { name: "bootloader", size: 0x10000, offset: 0x00000 }, { name: "rootfs (1024K)", size: 0x70000, offset: 0x10000 }};int __init init_mba44b0(void){ printk(KERN_NOTICE "mba44b0 flash device: %x at %x\n", WINDOW_SIZE, WINDOW_ADDR); mymtd = do_map_probe("cfi_probe", &mba44b0_map); if (mymtd) { mymtd->module = THIS_MODULE; return add_mtd_partitions(mymtd, mba44b0_partitions, sizeof(mba44b0_partitions) / sizeof(struct mtd_partition)); } return -ENXIO;}static void __exit cleanup_mba44b0(void){ if (mymtd) { del_mtd_partitions(mymtd); map_destroy(mymtd); }}module_init(init_mba44b0);module_exit(cleanup_mba44b0);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -