Chinaunix首页 | 论坛 | 博客
  • 博客访问: 45292
  • 博文数量: 5
  • 博客积分: 1410
  • 博客等级: 上尉
  • 技术积分: 135
  • 用 户 组: 普通用户
  • 注册时间: 2007-11-03 20:33
文章分类

全部博文(5)

文章存档

2008年(5)

我的朋友

分类: LINUX

2008-04-29 10:16:31

物理地址空间资源
内核用 struct resource 来管理系统的物理地址空间资源(RAM、controler register 、device register/memory  etc.)。
按映射方式分为 IO port maping 和IO memory maping
struct resource ioport_resource =
{
.name = "PCI IO",
.start = 0,
.end = IO_SPACE_LIMIT,
.flags = IORESOURCE_IO,
};
struct resource iomem_resource =
{
.name = "PCI mem",
.start = 0,
.end = -1,
.flags = IORESOURCE_MEM,
};
/proc # cat ioports
a8000000-a80fffff : PCI io
/proc # cat iomem
00000000-01ffffff : System RAM
   0003f000-001eaf57 : Kernel code
   001eaf58-00233bab : Kernel data
10000000-107fffff : flash
b0000000-b03fffff : PCI non-prefetchable
b0400000-b07fffff : PCI prefetchable
regioi申请
#define request_region(start,n,name) __request_region(&ioport_resource, (start), (n), (name))
#define request_mem_region(start,n,name) __request_region(&iomem_resource, (start), (n), (name))
I/O物理地址到内核虚地址映射
静态映射:
struct map_desc {
unsigned long virtual;
unsigned long pfn;
unsigned long length;
unsigned int type;
 };
paging_init(struct meminfo *mi, struct machine_desc *mdesc)
    +->devicemaps_init(struct machine_desc *mdesc)
        +->create_mapping(struct map_desc *md)
        +->mdesc->map_io()
           +->iotable_init(struct map_desc *io_desc, int nr)
               +->create_mapping(struct map_desc *md)
动态映射: ioremap()
 
struct machine_desc 每个target board 都要定义一个该结构体实例。
struct machine_desc {
 /*
  * Note! The first four elements are used
  * by assembler code in
arch/arm/kernel/heard.S
  */
 unsigned int  nr;  /* architecture number */
 unsigned int  phys_io; /* start of physical io */ debug
 unsigned int  io_pg_offst; /* byte offset for io
   
/* Map in IO space for serial debugging.
 * This allows debug messages to be output
* via a serial console before paging_init.
* page tabe entry 
*/
 const char  *name;  /* architecture name */
 unsigned long  boot_params; /* tagged list  */
 unsigned int  video_start; /* start of video RAM */
 unsigned int  video_end; /* end of video RAM */
 unsigned int  reserve_lp0 :1; /* never has lp0 */
 unsigned int  reserve_lp1 :1; /* never has lp1 */
 unsigned int  reserve_lp2 :1; /* never has lp2 */
 unsigned int  soft_reboot :1; /* soft reboot  */
 void   (*fixup)(struct machine_desc *,
      struct tag *, char **,
      struct meminfo *);
 void   (*map_io)(void);/* IO mapping function */
 void   (*init_irq)(void);
 struct sys_timer *timer;  /* system tick timer */
 void   (*init_machine)(void);
};
 
阅读(1488) | 评论(0) | 转发(0) |
0

上一篇:没有了

下一篇:files change for linux porting

给主人留下些什么吧!~~