?? s3c2410nor.c
字號:
#define WINDOW_ADDR 0x01000000 /* NOR FLASH物理地址 */
#define WINDOW_SIZE 0x800000 /* NOR FLASH大小 */
#define BUSWIDTH 2
/* 探測的接口類型,可以是"cfi_probe", "jedec_probe", "map_rom", NULL }; */
#define PROBETYPES { "cfi_probe", NULL }
#define MSG_PREFIX "S3C2410-NOR:" /* prefix for our printk()'s */
#define MTDID "s3c2410-nor" /* for mtdparts= partitioning */
static struct mtd_info *mymtd;
struct map_info s3c2410nor_map = // map_info
{
.name = "NOR flash on S3C2410",
.size = WINDOW_SIZE,
.bankwidth = BUSWIDTH,
.phys = WINDOW_ADDR,
};
#ifdef CONFIG_MTD_PARTITIONS
/* MTD分區(qū)信息 */
static struct mtd_partition static_partitions[] =
{
{
.name = "BootLoader", .size = 0x040000, .offset = 0x0 //bootloader存放的區(qū)域
} ,
{
.name = "Kernel", .size = 0x0100000, .offset = 0x40000 //內(nèi)核映像存放的區(qū)域
}
,
{
.name = "RamDisk", .size = 0x400000, .offset = 0x140000 //ramdisk存放的區(qū)域
}
,
{
.name = "cramfs(2MB)", .size = 0x200000, .offset = 0x540000 //只讀的cramfs區(qū)域
}
,
{
.name = "jffs2(0.75MB)", .size = 0xc0000, .offset = 0x740000 //可讀寫的jffs2區(qū)域
}
,
};
#endif
static int mtd_parts_nb = 0;
static struct mtd_partition *mtd_parts = 0;
int __init init_s3c2410nor(void)
{
static const char *rom_probe_types[] = PROBETYPES;
const char **type;
const char *part_type = 0;
printk(KERN_NOTICE MSG_PREFIX "0x%08x at 0x%08x\n", WINDOW_SIZE, WINDOW_ADDR);
s3c2410nor_map.virt = ioremap(WINDOW_ADDR, WINDOW_SIZE);//物理->虛擬地址
if (!s3c2410nor_map.virt)
{
printk(MSG_PREFIX "failed to ioremap\n");
return - EIO;
}
simple_map_init(&s3c2410nor_map);
mymtd = 0;
type = rom_probe_types;
for (; !mymtd && *type; type++)
{
mymtd = do_map_probe(*type, &s3c2410nor_map);//探測NOR FLASH
}
if (mymtd)
{
mymtd->owner = THIS_MODULE;
#ifdef CONFIG_MTD_PARTITIONS
mtd_parts_nb = parse_mtd_partitions(mymtd, NULL, &mtd_parts, MTDID);//探測分區(qū)信息
if (mtd_parts_nb > 0)
part_type = "detected";
if (mtd_parts_nb == 0) //未探測到,使用數(shù)組定義的分區(qū)信息
{
mtd_parts = static_partitions;
mtd_parts_nb = ARRAY_SIZE(static_partitions);
part_type = "static";
}
#endif
add_mtd_device(mymtd);
if (mtd_parts_nb == 0)
printk(KERN_NOTICE MSG_PREFIX "no partition info available\n");
else
{
printk(KERN_NOTICE MSG_PREFIX "using %s partition definition\n",
part_type);
add_mtd_partitions(mymtd, mtd_parts, mtd_parts_nb);//添加分區(qū)信息
}
return 0;
}
iounmap((void*)s3c2410nor_map.virt);
return - ENXIO;
}
static void __exit cleanup_s3c2410nor(void)
{
if (mymtd)
{
del_mtd_partitions(mymtd); //刪除分區(qū)
del_mtd_device(mymtd); //刪除設(shè)備
map_destroy(mymtd);
}
if (s3c2410nor_map.virt)
{
iounmap((void*)s3c2410nor_map.virt);
s3c2410nor_map.virt = 0;
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -