linux2.4.18 MIZI下IO端口、内存寻址的具体实现
分析由serial_8250.c串口驱动源代码serial_in()函数出发:
一:mizi linux2.4.18 inb、inbw、inl
static _INLINE_ unsigned int serial_in(struct uart_port *port, int offset)
{
offset <<= port->regshift;
switch (port->iotype) {
#ifdef CONFIG_SERIAL_8250_HUB6
case SERIAL_IO_HUB6:
outb(port->hub6 - 1 + offset, port->iobase);
return inb(port->iobase + 1);
#endif
case SERIAL_IO_MEM:
return readb((unsigned long)port->membase + offset);
default:
return inb(port->iobase + offset);
}
}
先分析inb(port->iobase+offset),inb函数的定义为:
/*
* Now, pick up the machine-defined IO definitions
*/
#include <asm/arch/io.h>
/*
* IO definitions. We define {out,in,outs,ins}[bwl] if __io is defined
* by the machine. Otherwise, these definitions are left for the machine
* specific header files to pick up.
*
* Note that we prevent GCC re-ordering or caching values in expressions
* by introducing sequence points into the in*() definitions. Note that
* __raw_* do not guarantee this behaviour.
*/
#ifdef __io
#define outb(v,p) __raw_writeb(v,__io(p))
#define outw(v,p) __raw_writew(v,__io(p))
#define outl(v,p) __raw_writel(v,__io(p))
#define inb(p) ({ unsigned int __v = __raw_readb(__io(p)); __v; })
#define inw(p) ({ unsigned int __v = __raw_readw(__io(p)); __v; })
#define inl(p) ({ unsigned int __v = __raw_readl(__io(p)); __v; })
#define outsb(p,d,l) __raw_writesb(__io(p),d,l)
#define outsw(p,d,l) __raw_writesw(__io(p),d,l)
#define outsl(p,d,l) __raw_writesl(__io(p),d,l)
#define insb(p,d,l) __raw_readsb(__io(p),d,l)
#define insw(p,d,l) __raw_readsw(__io(p),d,l)
#define insl(p,d,l) __raw_readsl(__io(p),d,l)
#endif
其中,__io(p)定义为:
/*
* We don't actually have real ISA nor PCI buses, but there is so many
* drivers out there that might just work if we fake them...
*/ 兼容问题
#define __io(a) (PCIO_BASE + (a))
#define __mem_pci(a) ((unsigned long)(a))
#define __mem_isa(a) ((unsigned long)(a))
而PCIO_BASE定义为:#define PCIO_BASE 0
__raw_readb()定义为:
#define __raw_readb(a) __arch_getb(a)
#define __arch_getb(a) (*(volatile unsigned char *)(a))
同理inw,inl。
linux2.4.18 MIZI下IO端口、内存寻址的具体实现
来源:/blog.chinaunix.net
作者:xiezheng
时间:2007-12-03
Tag:
点击:
0
最新评论共有 4 位网友发表了评论
查看所有评论
发表评论
热点关注
- 移植uClinux-2.6.9到S3C44
- 基于Qt/Embedded和Qtopia
- 华恒ColdFire系列嵌入式Li
- Linux-2.6.20内核移植到AT
- qtopia-2.2.0的交叉编译以
- 我的MiniGUI移植之路
- Qtopia安装简要入门
- 嵌入式常用IC芯片索引
- skyeye安装移植uclinux
- 嵌入式系统开发学习如何起
- linux 2.6 下基于yl2440板
- The Linux MTD, JFFS HOWT
- 嵌入式 用户图形接口uC/GU
- QT/Embedded-3.3.8初步交
- LEOS嵌入式系统地实现过程
- 构造arm-linux交叉编译工
- 学会做嵌入式Linux操作系
- armlinux启动配置文件 /et
- 常见的嵌入式操作系统都有
- uC/OS-II系统应用开发
