axisflashmap.c

来自「linux-2.4.29操作系统的源码」· C语言 代码 · 共 549 行 · 第 1/2 页

C
549
字号
/* * Physical mapping layer for MTD using the Axis partitiontable format * * Copyright (c) 2001, 2002 Axis Communications AB * * This file is under the GPL. * * First partition is always sector 0 regardless of if we find a partitiontable * or not. In the start of the next sector, there can be a partitiontable that * tells us what other partitions to define. If there isn't, we use a default * partition split defined below. * * $Log: axisflashmap.c,v $ * Revision 1.31  2003/11/14 16:55:27  jonashg * Made it possible to RAM boot without any flash drivers present. * * Revision 1.30  2003/09/29 06:37:18  mikaelp * Exported master mtd device as axisflash_mtd. * * Revision 1.29  2003/04/01 14:12:06  starvik * Added loglevel for lots of printks * * Revision 1.28  2002/10/01 08:08:43  jonashg * The first partition ends at the start of the partition table. * * Revision 1.27  2002/08/21 09:23:13  jonashg * Speling. * * Revision 1.26  2002/08/21 08:35:20  jonashg * Cosmetic change to printouts. * * Revision 1.25  2002/08/21 08:15:42  jonashg * Made it compile even without CONFIG_MTD_CONCAT defined. * * Revision 1.24  2002/08/20 13:12:35  jonashg * * New approach to probing. Probe cse0 and cse1 separately and (mtd)concat *   the results. * * Removed compile time tests concerning how the mtdram driver has been *   configured. The user will know about the misconfiguration at runtime *   instead. (The old approach made it impossible to use mtdram for anything *   else than RAM boot). * * Revision 1.23  2002/05/13 12:12:28  johana * Allow compile without CONFIG_MTD_MTDRAM but warn at compiletime and * be informative at runtime. * * Revision 1.22  2002/05/13 10:24:44  johana * Added #if checks on MTDRAM CONFIG * * Revision 1.21  2002/05/06 16:05:20  johana * Removed debug printout. * * Revision 1.20  2002/05/06 16:03:00  johana * No more cramfs as root hack in generic code. * It's handled by axisflashmap using mtdram. * * Revision 1.19  2002/03/15 17:10:28  bjornw * Changed comment about cached access since we changed this before * * Revision 1.18  2002/03/05 17:06:15  jonashg * Try amd_flash probe before cfi_probe since amd_flash driver can handle two * (or more) flash chips of different model and the cfi driver cannot. * * Revision 1.17  2001/11/12 19:42:38  pkj * Fixed compiler warnings. * * Revision 1.16  2001/11/08 11:18:58  jonashg * Always read from uncached address to avoid problems with flushing * cachelines after write and MTD-erase. No performance loss have been * seen yet. * * Revision 1.15  2001/10/19 12:41:04  jonashg * Name of probe has changed in MTD. * * Revision 1.14  2001/09/21 07:14:10  jonashg * Made root filesystem (cramfs) use mtdblock driver when booting from flash. * * Revision 1.13  2001/08/15 13:57:35  jonashg * Entire MTD updated to the linux 2.4.7 version. * * Revision 1.12  2001/06/11 09:50:30  jonashg * Oops, 2MB is 0x200000 bytes. * * Revision 1.11  2001/06/08 11:39:44  jonashg * Changed sizes and offsets in axis_default_partitions to use * CONFIG_ETRAX_PTABLE_SECTOR. * * Revision 1.10  2001/05/29 09:42:03  jonashg * Use macro for end marker length instead of sizeof. * * Revision 1.9  2001/05/29 08:52:52  jonashg * Gave names to the magic fours (size of the ptable end marker). * * Revision 1.8  2001/05/28 15:36:20  jonashg * * Removed old comment about ptable location in flash (it's a CONFIG_ option). * * Variable ptable was initialized twice to the same value. * * Revision 1.7  2001/04/05 13:41:46  markusl * Updated according to review remarks * * Revision 1.6  2001/03/07 09:21:21  bjornw * No need to waste .data * * Revision 1.5  2001/03/06 16:27:01  jonashg * Probe the entire flash area for flash devices. * * Revision 1.4  2001/02/23 12:47:15  bjornw * Uncached flash in LOW_MAP moved from 0xe to 0x8 * * Revision 1.3  2001/02/16 12:11:45  jonashg * MTD driver amd_flash is now included in MTD CVS repository. * (It's now in drivers/mtd). * * Revision 1.2  2001/02/09 11:12:22  jonashg * Support for AMD compatible non-CFI flash chips. * Only tested with Toshiba TC58FVT160 so far. * * Revision 1.1  2001/01/12 17:01:18  bjornw * * Added axisflashmap.c, a physical mapping for MTD that reads and understands *   Axis partition-table format. * * */#include <linux/module.h>#include <linux/types.h>#include <linux/kernel.h>#include <linux/config.h>#include <linux/mtd/concat.h>#include <linux/mtd/map.h>#include <linux/mtd/mtd.h>#include <linux/mtd/mtdram.h>#include <linux/mtd/partitions.h>#include <asm/axisflashmap.h>#include <asm/mmu.h>#include <asm/sv_addr_ag.h>#ifdef CONFIG_CRIS_LOW_MAP#define FLASH_UNCACHED_ADDR  KSEG_8#define FLASH_CACHED_ADDR    KSEG_5#else#define FLASH_UNCACHED_ADDR  KSEG_E#define FLASH_CACHED_ADDR    KSEG_F#endif/* From head.S */extern unsigned long romfs_start, romfs_length, romfs_in_flash;/* The master mtd for the entire flash. */struct mtd_info* axisflash_mtd = NULL;/* Map driver functions. */static __u8 flash_read8(struct map_info *map, unsigned long ofs){	return *(__u8 *)(map->map_priv_1 + ofs);}static __u16 flash_read16(struct map_info *map, unsigned long ofs){	return *(__u16 *)(map->map_priv_1 + ofs);}static __u32 flash_read32(struct map_info *map, unsigned long ofs){	return *(volatile unsigned int *)(map->map_priv_1 + ofs);}static void flash_copy_from(struct map_info *map, void *to,			    unsigned long from, ssize_t len){	memcpy(to, (void *)(map->map_priv_1 + from), len);}static void flash_write8(struct map_info *map, __u8 d, unsigned long adr){	*(__u8 *)(map->map_priv_1 + adr) = d;}static void flash_write16(struct map_info *map, __u16 d, unsigned long adr){	*(__u16 *)(map->map_priv_1 + adr) = d;}static void flash_write32(struct map_info *map, __u32 d, unsigned long adr){	*(__u32 *)(map->map_priv_1 + adr) = d;}/* * The map for chip select e0. * * We run into tricky coherence situations if we mix cached with uncached * accesses to we only use the uncached version here. * * The size field is the total size where the flash chips may be mapped on the * chip select. MTD probes should find all devices there and it does not matter * if there are unmapped gaps or aliases (mirrors of flash devices). The MTD * probes will ignore them. * * The start address in map_priv_1 is in virtual memory so we cannot use * MEM_CSE0_START but must rely on that FLASH_UNCACHED_ADDR is the start * address of cse0. */static struct map_info map_cse0 = {	name: "cse0",	size: MEM_CSE0_SIZE,	buswidth: CONFIG_ETRAX_FLASH_BUSWIDTH,	read8: flash_read8,	read16: flash_read16,	read32: flash_read32,	copy_from: flash_copy_from,	write8: flash_write8,	write16: flash_write16,	write32: flash_write32,	map_priv_1: FLASH_UNCACHED_ADDR};/* * The map for chip select e1. * * If there was a gap between cse0 and cse1, map_priv_1 would get the wrong * address, but there isn't. */static struct map_info map_cse1 = {	name: "cse1",	size: MEM_CSE1_SIZE,	buswidth: CONFIG_ETRAX_FLASH_BUSWIDTH,	read8: flash_read8,	read16: flash_read16,	read32: flash_read32,	copy_from: flash_copy_from,	write8: flash_write8,	write16: flash_write16,	write32: flash_write32,	map_priv_1: FLASH_UNCACHED_ADDR + MEM_CSE0_SIZE};/* If no partition-table was found, we use this default-set. */#define MAX_PARTITIONS         7  #define NUM_DEFAULT_PARTITIONS 3/* * Default flash size is 2MB. CONFIG_ETRAX_PTABLE_SECTOR is most likely the * size of one flash block and "filesystem"-partition needs 5 blocks to be able * to use JFFS. */static struct mtd_partition axis_default_partitions[NUM_DEFAULT_PARTITIONS] = {	{		name: "boot firmware",		size: CONFIG_ETRAX_PTABLE_SECTOR,		offset: 0	},	{		name: "kernel",		size: 0x200000 - (6 * CONFIG_ETRAX_PTABLE_SECTOR),		offset: CONFIG_ETRAX_PTABLE_SECTOR	},	{		name: "filesystem",		size: 5 * CONFIG_ETRAX_PTABLE_SECTOR,		offset: 0x200000 - (5 * CONFIG_ETRAX_PTABLE_SECTOR)	}};/* Initialize the ones normally used. */static struct mtd_partition axis_partitions[MAX_PARTITIONS] = {	{		name: "part0",		size: CONFIG_ETRAX_PTABLE_SECTOR,		offset: 0	},	{

⌨️ 快捷键说明

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