一些相关函数的说明。供自己日后参考。
--------------------------------------------------------------------------------------
int __init s3c24xx_dma_init_map(struct s3c24xx_dma_selection *sel)
初始化全局变量dma_sel结构,在此函数中大家可能疑惑的是
nmap = kmalloc(map_sz, GFP_KERNEL);
if (nmap == NULL)
return -ENOMEM;
memcpy(nmap, sel->map, map_sz);
memcpy(&dma_sel, sel, sizeof(*sel));
dma_sel.map = nmap;
这
几条语句,为什么用memcpy初始化为了dma_sel,而又要用再分配的nmap结构去给dma_sel赋值。其答案是为了保险,因为dma_sel
中的map成员是个指针。对指针的操作是要很小心的。这里在此函数中重新定义一个指针变量,并指向它,就是为了防止别处定义的指针被撤消而造成越界。其实我认为这没有必要的。
dma_sel的定义为struct s3c24xx_dma_selection dma_sel;
而struct s3c24xx_dma_selection的定义为
struct s3c24xx_dma_selection {
struct s3c24xx_dma_map *map;
unsigned long map_size;
unsigned long dcon_mask;
void (*select)(struct s3c2410_dma_chan *chan,
struct s3c24xx_dma_map *map);
};
--------------------------------------------------------------------------------------------------------
struct s3c2410_dma_chan *s3c2410_dma_map_channel(int channel)
此函数是: turn the virtual channel number into a real, and un-used hardware channel.完成通道的虚实映射
在s3c2440_dma_mappings数组中查找相应channel对应的通道(0--4,有效未使用),并将映射关系记入dma_chan_map[channel]数组中。
---------------------------------------------------------------------------------------------------------
static int __init s3c2410_init_dma(void)
用于初始化s3c2410_dma_chan结构,并完成映射。
-----------------------------------------------------------------------------------------------------------
static struct s3c2410_dma_chan *lookup_dma_channel(unsigned int channel)
DMA通道虚实转换
-----------------------------------------------------------------------------------------------------------
int s3c2410_dma_request(unsigned int channel,
struct s3c2410_dma_client *client,
void *dev)
通过s3c2410_dma_map_channel函数找到channel对应的通道,并相应的通道状态,申请中断
-----------------------------------------------------------------------------------------------------------
int s3c2410_dma_started(struct s3c2410_dma_chan *chan)
/* if we've only loaded one buffer onto the channel, then chec
* to see if we have another, and if so, try and load it so when
* the first buffer is finished, the new one will be loaded onto
* the channel */
-----------------------------------------------------------------------------------------------------------
int s3c2410_dma_free(dmach_t channel, struct s3c2410_dma_client *client)
/* s3c2410_dma_free
*
* release the given channel back to the system, will stop and flush
* any outstanding transfers, and ensure the channel is ready for the
* next claimant.
*
* Note, although a warning is currently printed if the freeing client
* info is not the same as the registrant's client info, the free is still
* allowed to go through.
*/
--------------------------------------------------------------------------------------------------------------
static int s3c2410_dma_flush(struct s3c2410_dma_chan *chan)
* stop the channel, and remove all current and pending transfers
--------------------------------------------------------------------------------------------------------------
int s3c2410_dma_config(dmach_t channel,
int xferunit,
int dcon)
根据xferunit设置通道的控制寄存器
--------------------------------------------------------------------------------------------------------------
int s3c2410_dma_setflags(dmach_t channel, unsigned int flags)
根据flags设置通道的flags
--------------------------------------------------------------------------------------------------------------
int s3c2410_dma_devconfig(int channel,
enum s3c2410_dmasrc source,
int hwcfg,
unsigned long devaddr)
参数意义:
* source: S3C2410_DMASRC_HW: source is hardware
* S3C2410_DMASRC_MEM: source is memory
*
* hwcfg: the value for xxxSTCn register,
* bit 0: 0=increment pointer, 1=leave pointer
* bit 1: 0=soucre is AHB, 1=soucre is APB
*
* devaddr: physical address of the source
如果source为S3C2410_DMASRC_HW(外设), 配置它的S3C2410_DMA_DISRCC,S3C2410_DMA_DISRC,S3C2410_DMA_DIDSTC
如果source为S3C2410_DMASRC_MEM(内存),配置它的S3C2410_DMA_DISRCC,S3C2410_DMA_DIDST,S3C2410_DMA_DIDSTC
由此可见,地址方面,只配置涉及外设的地址
----------------------------------------------------------------------------------------------------------------
阅读(1348) | 评论(0) | 转发(0) |