130 likes | 342 Views
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.
E N D
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 ppc405_uc.c 文件中有 General purpose timers 该模块和DMA一样定义了接口没有实现功能。
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)
bootloader ram_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]); }
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; }
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);
运行des程序 交叉编译器eldk-5.1 在一种计算机环境中运行的编译程序,能编译出在另外一种环境下运行的代码,我们就称这种编译器支持交叉编译。这个编译过程就叫交叉编译。 例如在X86 Ubuntu操作系统下面使用eldk-5.1编译c文件,使可执行文件在ppc405下可执行。 1.配置编译环境 source /opt/eldk-5.1/powerpc-4xx-softfloat/environment- setup-ppc405-linux 2.编译des.cpp文件 powerpc-linux-g++ -static -o des405 des.cpp
运行des程序 soc@ubuntu:~$ qemu-ppc -cpu 405 des405 请输入明文(8个字符):12345678 请输入密钥(8个字符):abcdefgh 产生的密文为: 2进制形式: 11010000 11010110 11010001 11101001 00100001 11111110 00010111 10100100 16进制形式: D0D6D1E921FE17A4 字符形式: ����!�� 请输入16位密文(16进制表示):D0D6D1E921FE17A4 请输入密钥(8个字符):abcdefgh 解密后结果: 12345678