12
QEMU 平平平平平平 PowerPC 平平 SoC 平平 平 DES 平平 彭彭彭 彭彭彭

QEMU平台构建基于PowerPC单核SoC 并运行DES程序

Embed Size (px)

DESCRIPTION

QEMU平台构建基于PowerPC单核SoC 并运行DES程序. 彭会成 冯彦朝. outline. ppc405 board DMA and Timer Memory Map bootloader问题 qemu仿真ppc405运行des程序. Board. ppc405_uc.c文件(QEMU PowerPC 405 embedded processors emulation). DMA. DMA controller. DMA结构体. 定义接口,功能没有实现. Timer. - PowerPoint PPT Presentation

Citation preview

Page 1: QEMU平台构建基于PowerPC单核SoC     并运行DES程序

QEMU 平台构建基于 PowerPC 单核 SoC 并运行 DES 程序

彭会成冯彦朝

Page 2: QEMU平台构建基于PowerPC单核SoC     并运行DES程序

outline

• ppc405 board• DMA and Timer•Memory Map• bootloader 问题• qemu 仿真 ppc405 运行 des 程序

Page 3: QEMU平台构建基于PowerPC单核SoC     并运行DES程序

Boardppc405_uc.c 文件( QEMU PowerPC 405 embedded processors emulation )

CPU Memory Flash

总线

SRAM

Cache

DMA Timer

总线相关的一些模块:Peropheral local bus arbiter PLB to OPB bridgeOPB arbiter

注:PLB(peripheral local bus)OPB(on-chip peripheral bus)

Peripheral controller OCM

On chip Memory

I2C controller

Page 4: QEMU平台构建基于PowerPC单核SoC     并运行DES程序

DMA

DMA controller

DMA结构体 定义接口,功能没有实现

Page 5: QEMU平台构建基于PowerPC单核SoC     并运行DES程序

Timerppc405_uc.c 文件中有 General purpose timers该模块和 DMA 一样定义了接口没有实现功能。

Page 6: QEMU平台构建基于PowerPC单核SoC     并运行DES程序

Memory Map

* - PowerPC 405EP CPU * - SDRAM (0x00000000) * - Flash (0xFFF80000) * - SRAM (0xFFF00000) * - NVRAM (0xF0000000) * - FPGA (0xF0300000) * - GPT (General purpose timers) (0xef600000) * - Serial ports (0xef600300) * - OPB arbitrer (0xef600600) * - IIC controller(0xef600500) * - GPIO (0xef600700)

Page 7: QEMU平台构建基于PowerPC单核SoC     并运行DES程序

bootloaderram_addr_t ppc405_set_bootinfo (CPUPPCState *env, ppc4xx_bd_info_t *bd, uint32_t flags){ CPUState *cs = CPU(ppc_env_get_cpu(env)); ram_addr_t bdloc; int i, n;

/* We put the bd structure at the top of memory */ if (bd->bi_memsize >= 0x01000000UL) bdloc = 0x01000000UL - sizeof(struct ppc4xx_bd_info_t); else bdloc = bd->bi_memsize - sizeof(struct ppc4xx_bd_info_t); stl_be_phys(cs->as, bdloc + 0x00, bd->bi_memstart); stl_be_phys(cs->as, bdloc + 0x04, bd->bi_memsize); stl_be_phys(cs->as, bdloc + 0x08, bd->bi_flashstart); stl_be_phys(cs->as, bdloc + 0x0C, bd->bi_flashsize); stl_be_phys(cs->as, bdloc + 0x10, bd->bi_flashoffset); stl_be_phys(cs->as, bdloc + 0x14, bd->bi_sramstart); stl_be_phys(cs->as, bdloc + 0x18, bd->bi_sramsize); stl_be_phys(cs->as, bdloc + 0x1C, bd->bi_bootflags); stl_be_phys(cs->as, bdloc + 0x20, bd->bi_ipaddr); for (i = 0; i < 6; i++) { stb_phys(cs->as, bdloc + 0x24 + i, bd->bi_enetaddr[i]); }

Page 8: QEMU平台构建基于PowerPC单核SoC     并运行DES程序

bootloader stw_be_phys(cs->as, bdloc + 0x2A, bd->bi_ethspeed); stl_be_phys(cs->as, bdloc + 0x2C, bd->bi_intfreq); stl_be_phys(cs->as, bdloc + 0x30, bd->bi_busfreq); stl_be_phys(cs->as, bdloc + 0x34, bd->bi_baudrate); for (i = 0; i < 4; i++) { stb_phys(cs->as, bdloc + 0x38 + i, bd->bi_s_version[i]); } for (i = 0; i < 32; i++) { stb_phys(cs->as, bdloc + 0x3C + i, bd->bi_r_version[i]); } stl_be_phys(cs->as, bdloc + 0x5C, bd->bi_plb_busfreq); stl_be_phys(cs->as, bdloc + 0x60, bd->bi_pci_busfreq); for (i = 0; i < 6; i++) { stb_phys(cs->as, bdloc + 0x64 + i, bd->bi_pci_enetaddr[i]); } n = 0x6A; if (flags & 0x00000001) { for (i = 0; i < 6; i++) stb_phys(cs->as, bdloc + n++, bd->bi_pci_enetaddr2[i]); } stl_be_phys(cs->as, bdloc + n, bd->bi_opbfreq); n += 4; for (i = 0; i < 2; i++) { stl_be_phys(cs->as, bdloc + n, bd->bi_iic_fast[i]); n += 4; }

return bdloc;}

Page 9: QEMU平台构建基于PowerPC单核SoC     并运行DES程序

bootloader ppc405_boards.c 文件中调用了 ppc405_set_bootinfo 函数

bdloc = ppc405_set_bootinfo(env, &bd, 0x00000001); env->gpr[3] = bdloc; kernel_base = KERNEL_LOAD_ADDR; /* now we can load the kernel */ kernel_size = load_image_targphys(kernel_filename, kernel_base, ram_size - kernel_base); if (kernel_size < 0) { fprintf(stderr, "qemu: could not load kernel '%s'\n", kernel_filename); exit(1); } printf("Load kernel size %ld at " TARGET_FMT_lx, kernel_size, kernel_base);

Page 10: QEMU平台构建基于PowerPC单核SoC     并运行DES程序

运行 des 程序

交叉编译器 eldk-5.1 在一种计算机环境中运行的编译程序,能编译出在另外一种环境下运行的代码

,我们就称这种编译器支持交叉编译。这个编译过程就叫交叉编译。 例如在 X86 Ubuntu 操作系统下面使用 eldk-5.1 编译 c 文件,使可执行文件在

ppc405 下可执行。 1. 配置编译环境 source /opt/eldk-5.1/powerpc-4xx-softfloat/environment- setup-ppc40

5-linux 2. 编译 des.cpp 文件 powerpc-linux-g++ -static -o des405 des.cpp

Page 11: QEMU平台构建基于PowerPC单核SoC     并运行DES程序

运行 des 程序

soc@ubuntu:~$ qemu-ppc -cpu 405 des405 请输入明文 (8 个字符 ):12345678请输入密钥 (8 个字符 ):abcdefgh产生的密文为 :2 进制形式:110100001101011011010001111010010010000111111110000101111010010016 进制形式 :D0D6D1E921FE17A4字符形式:����!��请输入 16 位密文( 16 进制表示): D0D6D1E921FE17A4请输入密钥 (8 个字符 ):abcdefgh解密后结果 :12345678

Page 12: QEMU平台构建基于PowerPC单核SoC     并运行DES程序

•Thank you!