linux中S3C2440的物理地址映射到虚拟地址详解

linux中S3C2440的物理地址映射到虚拟地址详解

标签: 虚拟地址映射
1527人阅读 评论(0) 收藏 举报
本文章已收录于:
分类:
  1. linux-2.6.30.4\arch\arm\plat-s3c\include\plat\ map-base.h  
  2.   
  3. #defineS3C_ADDR_BASE (0xF4000000)  
  4. #ifndef __ASSEMBLY__  
  5. #define S3C_ADDR(x)  ((void__iomem __force *)S3C_ADDR_BASE+ (x))  
  6. #else  
  7. #defineS3C_ADDR(x) (S3C_ADDR_BASE+ (x))  
  8. #endif  
  9. #define S3C_VA_IRQ    S3C_ADDR(0x00000000)     /* irq controller(s) */  
  10. #define S3C_VA_SYS   S3C_ADDR(0x00100000)     /* system control   Clock and Power management*/  
  11. #define S3C_VA_MEM S3C_ADDR(0x00200000)     /* system control  memoery*/  
  12. #define S3C_VA_TIMER      S3C_ADDR(0x00300000)     /* timer block --PWM Timer*/  
  13. #define S3C_VA_WATCHDOG     S3C_ADDR(0x00400000)     /* watchdog */  
  14. #define S3C_VA_UART      S3C_ADDR(0x01000000)    /*UART */  
  15. linux-2.6.30.4\arch\arm\plat-s3c24xx\include\plat\ map.h  
  16.   
  17. /* UARTs */  
  18. #defineS3C24XX_VA_UART        S3C_VA_UART  
  19. #define S3C2410_PA_UART    (0x50000000)  
  20. #define S3C24XX_SZ_UART          SZ_1M  
  21. #define S3C_UART_OFFSET         (0x4000)  
  22. UART映射后的虚拟地址是0xF4000000+0x01000000  
  23. linux-2.6.30.4\arch\arm\plat-s3c24xx\include\plat\ map.h  
  24.   
  25. /* GPIO ports */  
  26. #define S3C2410_PA_GPIO     (0x56000000)  
  27. #defineS3C24XX_VA_GPIO       ((S3C24XX_PA_GPIO- S3C24XX_PA_UART) + S3C24XX_VA_UART)//GPIO的虚拟地址  
  28. #define S3C24XX_SZ_GPIO          SZ_1M  
linux-2.6.30.4\arch\arm\plat-s3c\include\plat\ map-base.h

#defineS3C_ADDR_BASE (0xF4000000)
#ifndef __ASSEMBLY__
#define S3C_ADDR(x)  ((void__iomem __force *)S3C_ADDR_BASE+ (x))
#else
#defineS3C_ADDR(x) (S3C_ADDR_BASE+ (x))
#endif
#define S3C_VA_IRQ    S3C_ADDR(0x00000000)     /* irq controller(s) */
#define S3C_VA_SYS   S3C_ADDR(0x00100000)     /* system control   Clock and Power management*/
#define S3C_VA_MEM S3C_ADDR(0x00200000)     /* system control  memoery*/
#define S3C_VA_TIMER      S3C_ADDR(0x00300000)     /* timer block --PWM Timer*/
#define S3C_VA_WATCHDOG     S3C_ADDR(0x00400000)     /* watchdog */
#define S3C_VA_UART      S3C_ADDR(0x01000000)    /*UART */
linux-2.6.30.4\arch\arm\plat-s3c24xx\include\plat\ map.h

/* UARTs */
#defineS3C24XX_VA_UART        S3C_VA_UART
#define S3C2410_PA_UART    (0x50000000)
#define S3C24XX_SZ_UART          SZ_1M
#define S3C_UART_OFFSET         (0x4000)
UART映射后的虚拟地址是0xF4000000+0x01000000
linux-2.6.30.4\arch\arm\plat-s3c24xx\include\plat\ map.h

/* GPIO ports */
#define S3C2410_PA_GPIO     (0x56000000)
#defineS3C24XX_VA_GPIO       ((S3C24XX_PA_GPIO- S3C24XX_PA_UART) + S3C24XX_VA_UART)//GPIO的虚拟地址
#define S3C24XX_SZ_GPIO          SZ_1M

Linux内核中,只能访问虚拟地址空间,所以访问硬件寄存器,常常需要采用物理地址映射为虚拟地址的方式。

在定时器中寄存器访问,采用如下方式

  1. #define S3C_TIMERREG(x) (S3C_VA_TIMER + (x))  
  2. #define S3C_TIMERREG2(tmr,reg) S3C_TIMERREG((reg)+0x0c+((tmr)*0x0c))  
  3.   
  4. #define S3C2410_TCFG0         S3C_TIMERREG(0x00)  
  5. #define S3C2410_TCFG1         S3C_TIMERREG(0x04)  
  6. #define S3C2410_TCON          S3C_TIMERREG(0x08)  
  7.   
  8. #define S3C64XX_TINT_CSTAT    S3C_TIMERREG(0x44)  
  9.   
  10. #define S3C2410_TCFG_PRESCALER0_MASK (255<<0)  
  11. #define S3C2410_TCFG_PRESCALER1_MASK (255<<8)  
#define S3C_TIMERREG(x) (S3C_VA_TIMER + (x))
#define S3C_TIMERREG2(tmr,reg) S3C_TIMERREG((reg)+0x0c+((tmr)*0x0c))

#define S3C2410_TCFG0         S3C_TIMERREG(0x00)
#define S3C2410_TCFG1         S3C_TIMERREG(0x04)
#define S3C2410_TCON          S3C_TIMERREG(0x08)

#define S3C64XX_TINT_CSTAT    S3C_TIMERREG(0x44)

#define S3C2410_TCFG_PRESCALER0_MASK (255<<0)
#define S3C2410_TCFG_PRESCALER1_MASK (255<<8)



0
0
 
 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值