mmu转换表

prettyboybaoxiaopeng 2011-04-22 03:12:31
请教一下这段代码什么意思
程序中将mmu_table的地址赋给了TTB register,然后打开了mmu,
而且知道它将50000000映射到了c0000000,。
想问一下,.set .rept .endr 是做什么的,对GUN汇编不是很了解呵~

mmu_table:
.set __base,0
// 1:1 mapping for debugging
.rept 0xA00
FL_SECTION_ENTRY __base,3,0,0,0
.set __base,__base+1
.endr

// access is not allowed.
.rept 0xC00 - 0xA00
.word 0x00000000
.endr

// 128MB for SDRAM 0xC0000000 -> 0x50000000
.set __base, 0x500
.rept 0xC80 - 0xC00
FL_SECTION_ENTRY __base,3,0,1,1
.set __base,__base+1
.endr

// access is not allowed.
.rept 0x1000 - 0xc80
.word 0x00000000
.endr

...全文
185 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
当我遇上-你 2011-05-02
  • 打赏
  • 举报
回复
[Quote=引用楼主 prettyboybaoxiaopeng 的回复:]
请教一下这段代码什么意思
程序中将mmu_table的地址赋给了TTB register,然后打开了mmu,
而且知道它将50000000映射到了c0000000,。
想问一下,.set .rept .endr 是做什么的,对GUN汇编不是很了解呵~

Assembly code

mmu_table:
.set __base,0
// 1:1 m……
[/Quote]
.rept:重复定义伪操作, 格式如下:
.rept 重复次数
数据定义
.endr @结束重复定义
例如:
.rept 3
.byte 0x23
.endr

----------------------
.equ/.set: 赋值语句, 格式如下:
.equ(.set) 变量名,表达式
例如:
.equ abc 3 @让abc=3
------------------------
.endr @结束重复定义
liumingzong 2011-05-02
  • 打赏
  • 举报
回复
是不是简单内存管理,把上端内存给系统用,地段内存直接映射到物理地址给应用程序
  • 打赏
  • 举报
回复
版主:请问这怎么结贴呀
  • 打赏
  • 举报
回复
Fill the data into the mmu_table

code in hal_platform_extras.h
Notes: In this code, the physical address for every access is equle to its virtual address,This is known as a "flat address mapping".

code explains:

// 64MB SDRAM
.set __base,0x000 ;; set a symbol __base as value 0
.rept 0x040 - 0x000 ;; repeat the next data (FL_SECTION_ENTRY __base,0,3,0,0,1,0) from 0x000 to 0x040
FL_SECTION_ENTRY __base,0,3,0,0,1,0 ;; this is 32bit value as "First Level descriptor format"
.set __base,__base+1 ;; __base++ until 0x40
.endr

// 202MB Unused
.rept 0x100 - 0x080
.word 0
.set __base,__base+1
.endr

So this code fill 0x40*32bit (0x100Byte) mmu_table buffer.
Every entry mapping/translate 1Mbyte memory.

// form a first-level section entry
.macro FL_SECTION_ENTRY base,x,ap,p,d,c,b
.word (\base << 20) | (\x << 12) | (\ap << 10) | (\p << 9) |\
(\d << 5) | (\c << 3) | (\b << 2) | 2
.endm

base: section base address
x: not used
ap: access permission, 3 -- Read/Write
p: not used
d: Domain 0 -- No access
c: Cachable 1 -- enable 0 -- disable
b: Bufferable 1 -- enable 0 -- disable
Bit[1:0]: Identify the type of descriptor 2 -- section descriptor


The total mapping like this,
// This page table sets up the preferred mapping:
//
// Virtual Address Physical Address XCB Size (MB) Description
// --------------- ---------------- --- --------- -----------
// 0x00000000 0x00000000 010 32 SDRAM (cached)
// 0x10000000 0x10000000 000 32 SDRAM (alias)
// 0x20000000 0x00000000 000 32 SDRAM (uncached)
// 0x48000000 0x48000000 000 64 PCI Data
// 0x50000000 0x50000000 010 16 Flash (CS0)
// 0x51000000 0x51000000 000 112 CS1 - CS7
// 0x60000000 0x60000000 000 64 Queue Manager
// 0xC0000000 0xC0000000 000 1 PCI Controller
// 0xC4000000 0xC4000000 000 1 Exp. Bus Config
// 0xC8000000 0xC8000000 000 1 Misc IXP425 IO
// 0xCC000000 0xCC000000 000 1 SDRAM Config
I thinks there is only thing changes that is the 0x20000000 mapping to 0x00000000 as uncached buffer.
// 32MB SDRAM (uncached)
.set __base,0x000 ;; map to 0x0000000
.rept 0x240 - 0x200 ;; virtual from 0x20000000 -- 0x24000000
FL_SECTION_ENTRY __base,0,3,0,0,0,0 ;; c = 0 uncached
.set __base,__base+1
.endr

19,504

社区成员

发帖
与我相关
我的任务
社区描述
硬件/嵌入开发 嵌入开发(WinCE)
社区管理员
  • 嵌入开发(WinCE)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧