色婷婷AⅤ一区二区三区|亚洲精品第一国产综合亚AV|久久精品官方网视频|日本28视频香蕉

          新聞中心

          EEPW首頁(yè) > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > 內(nèi)存管理單元MMU 地址映射一

          內(nèi)存管理單元MMU 地址映射一

          作者: 時(shí)間:2016-11-28 來(lái)源:網(wǎng)絡(luò) 收藏

          本文引用地址:http://cafeforensic.com/article/201611/322695.htm

          virtuladdr = 0xA0000000;

          physicaladdr = 0x56000000;

          *(mmu_tlb_base + (virtuladdr >> 20)) = (physicaladdr & 0xFFF00000) |

          MMU_SECDESC;

          virtuladdr = 0xB0000000;

          physicaladdr = 0x30000000;

          while (virtuladdr < 0xB4000000)

          {

          *(mmu_tlb_base + (virtuladdr >> 20)) = (physicaladdr & 0xFFF00000) |

          MMU_SECDESC_WB;

          virtuladdr += 0x100000;//右移20位就是1

          physicaladdr += 0x100000;//右移20位就是1

          }

          }

          void mmu_init(void)

          {

          unsigned long ttb = 0x30000000;

          __asm__(

          "mov r0, #0"

          "mcr p15, 0, r0, c7, c7, 0"

          "mcr p15, 0, r0, c7, c10, 4"

          "mcr p15, 0, r0, c8, c7, 0"

          "mov r4, %0"

          "mcr p15, 0, r4, c2, c0, 0"

          "mvn r0, #0"

          "mcr p15, 0, r0, c3, c0, 0"

          "mrc p15, 0, r0, c1, c0, 0"

          "bic r0, r0, #0x3000"

          "bic r0, r0, #0x0300"

          "bic r0, r0, #0x0087"

          "orr r0, r0, #0x0002"

          "orr r0, r0, #0x0004"

          "orr r0, r0, #0x1000"

          "orr r0, r0, #0x0001"

          "mcr p15, 0, r0, c1, c0, 0"

          :

          : "r" (ttb) );

          }

          #define GPBCON (*(volatile unsigned long *)0xA0000010) // 物理地址0x56000010

          #define GPBDAT (*(volatile unsigned long *)0xA0000014) // 物理地址0x56000014

          #define GPB5_out (1<<(5*2))

          #define GPB6_out (1<<(6*2))

          #define GPB7_out (1<<(7*2))

          #define GPB8_out (1<<(8*2))

          static inline void wait(unsigned long dly)

          {

          for(; dly > 0; dly--);

          }

          int main(void)

          {

          unsigned long i = 0;

          // 將LED1-4對(duì)應(yīng)的GPB5/6/7/8四個(gè)引腳設(shè)為輸出

          GPBCON = GPB5_out|GPB6_out|GPB7_out|GPB8_out;

          while(1){

          wait(30000);

          GPBDAT = (~(i<<5)); // 根據(jù)i的值,點(diǎn)亮LED1-4

          if(++i == 16)

          i = 0;

          }

          return 0;

          }

          最后是Makefile

          objs := head.o init.o leds.o

          mmu.bin : $(objs)

          arm-linux-ld -Tmmu.lds -o mmu_elf $^

          arm-linux-objcopy -O binary -S mmu_elf $@

          arm-linux-objdump -D -m arm mmu_elf > mmu.dis

          %.o:%.c

          arm-linux-gcc -Wall -O2 -c -o $@ $<

          %.o:%.S

          arm-linux-gcc -Wall -O2 -c -o $@ $<

          clean:

          rm -f mmu.bin mmu_elf mmu.dis *.o


          上一頁(yè) 1 2 下一頁(yè)

          評(píng)論


          技術(shù)專區(qū)

          關(guān)閉