map_info

    map_info结构体用于描述一个FLASH的信息。

    它在map.h中定义:

/* The map stuff is very simple. You fill in your struct map_info with
   a handful of routines for accessing the device, making sure they handle
   paging etc. correctly if your device needs it. Then you pass it off
   to a chip probe routine -- either JEDEC or CFI probe or both -- via
   do_map_probe(). If a chip is recognised, the probe code will invoke the
   appropriate chip driver (if present) and return a struct mtd_info.
   At which point, you fill in the mtd->module with your own module
   address, and register it with the MTD core code. Or you could partition
   it and register the partitions instead, or keep it for your own private
   use; whatever.

   The mtd->priv field will point to the struct map_info, and any further
   private data required by the chip driver is linked from the
   mtd->priv->fldrv_priv field. This allows the map driver to get at
   the destructor function map->fldrv_destroy() when it's tired
   of living.
*/

struct map_info {
	const char *name;//驱动名称
	unsigned long size;//FLASH的大小
	resource_size_t phys;//访问FLASH的物理地址
#define NO_XIP (-1UL)

	void __iomem *virt;//IO映射后的访问地址
	void *cached;

	int bankwidth; //位宽  /* in octets. This isn't necessarily the width
		       of actual bus cycles -- it's the repeat interval
		      in bytes, before you are talking to the first chip again.
		      */

#ifdef CONFIG_MTD_COMPLEX_MAPPINGS
	map_word (*read)(struct map_info *, unsigned long);
	void (*copy_from)(struct map_info *, void *, unsigned long, ssize_t);

	void (*write)(struct map_info *, const map_word, unsigned long);
	void (*copy_to)(struct map_info *, unsigned long, const void *, ssize_t);

	/* We can perhaps put in 'point' and 'unpoint' methods, if we really
	   want to enable XIP for non-linear mappings. Not yet though. */
#endif
	/* It's possible for the map driver to use cached memory in its
	   copy_from implementation (and _only_ with copy_from).  However,
	   when the chip driver knows some flash area has changed contents,
	   it will signal it to the map driver through this routine to let
	   the map driver invalidate the corresponding cache as needed.
	   If there is no cache to care about this can be set to NULL. */
	void (*inval_cache)(struct map_info *, unsigned long, ssize_t);

	/* set_vpp() must handle being reentered -- enable, enable, disable
	   must leave it enabled. */
	void (*set_vpp)(struct map_info *, int);

	unsigned long pfow_base;
	unsigned long map_priv_1;
	unsigned long map_priv_2;
	void *fldrv_priv;
	struct mtd_chip_driver *fldrv;
};


例如:

struct map_info SST39VF6401_map = {
	.name = "NOR flash on SST39VF6401",//驱动的名称
	.size = WINDOW_SIZE,//FLASH的大小
	.bankwidth = BUSWIDTH,//位宽
	.phys = WINDOW_ADDR,//物理地址
};

 

map_info中有几个对FLASH的操作函数:read,copy_form,write,copy_to,驱动开发人员可以自己定义这几个函数。但是mtd提供的现成的函数可用,只要调用sample_map_init函数即可完成它们的赋值:

Map_funcs.c中的代码:

void simple_map_init(struct map_info *map)
{
	BUG_ON(!map_bankwidth_supported(map->bankwidth));

	map->read = simple_map_read;
	map->write = simple_map_write;
	map->copy_from = simple_map_copy_from;
	map->copy_to = simple_map_copy_to;
}



 

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
这段命令是 Keil uVision5 软件的 armclang 编译器的链接命令,用于将目标文件链接成可执行文件。这个命令包含了以下参数: - `--cpu Cortex-M7.fp.dp`:指定链接器使用的目标处理器。 - `*.o`:指定链接器需要链接的目标文件,`*.o` 表示链接当前目录下所有的 `.o` 目标文件。 - `--library_type=microlib`:指定链接器使用的库类型为 `microlib`。 - `--strict`:启用严格模式。 - `--scatter "STM32H747I_DISCO_CM7\Exe\STM32H747I_DISCO_CM7.sct"`:指定链接器使用的链接脚本文件。 - `--summary_stderr`:将链接器的摘要信息输出到标准错误流。 - `--info summarysizes`:输出链接器的摘要信息。 - `--map`:生成链接器映射文件。 - `--load_addr_map_info`:生成可加载地址映射信息。 - `--xref`:生成交叉引用表。 - `--callgraph`:生成函数调用图。 - `--symbols`:生成符号表。 - `--info sizes`:输出每个目标文件的大小信息。 - `--info totals`:输出总大小信息。 - `--info unused`:输出未使用的符号信息。 - `--info veneers`:输出使用的 Veneer 信息。 - `--list "STM32H747I_DISCO_CM7.map"`:将链接器的详细信息输出到指定的文件中。 - `-o STM32H747I_DISCO_CM7\Exe\STM32H747I_DISCO_CM7.axf`:指定链接器生成的可执行文件的名称和路径。 你可以根据需要进行调整,例如,修改链接器使用的目标处理器、库类型、链接脚本文件等。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值