├── .gitignore ├── .gitmodules ├── Makefile ├── README.md ├── common ├── guest │ ├── core │ │ ├── c_start.c │ │ ├── exception.c │ │ ├── gic.c │ │ ├── gic.h │ │ └── guest.S │ ├── loader │ │ ├── cli.c │ │ ├── cli.h │ │ ├── guestloader_common.c │ │ ├── guestloader_common.h │ │ ├── linuxloader.c │ │ ├── linuxloader.h │ │ └── monitor │ │ │ ├── gdb_stub.c │ │ │ ├── gdb_stub.h │ │ │ ├── guest_monitor.c │ │ │ ├── guest_monitor.h │ │ │ ├── monitor_cli.c │ │ │ └── monitor_cli.h │ └── test │ │ ├── test_vdev_sample.c │ │ ├── test_vtimer.c │ │ ├── test_vtimer.h │ │ └── tests.h ├── include │ ├── a15_cp15_sysregs.h │ ├── arch_types.h │ ├── armv7_p15.h │ ├── asm-arm_inline.h │ ├── asm_io.h │ ├── gic_regs.h │ ├── hvmm_trace.h │ ├── hvmm_types.h │ ├── smp.h │ └── version.h ├── log │ ├── format.c │ ├── format.h │ ├── print.c │ ├── print.h │ ├── sscanf.c │ ├── sscanf.h │ ├── string.c │ ├── string.h │ └── uart_print.h └── test │ ├── tests.c │ ├── tests.h │ ├── tests_gic_timer.c │ ├── tests_gic_timer.h │ ├── tests_malloc.c │ ├── tests_malloc.h │ ├── tests_vdev.c │ └── tests_vdev.h ├── hypervisor ├── hardware │ ├── arm32ve │ │ ├── guest_hw.c │ │ ├── include │ │ │ └── guest_hw.h │ │ ├── interrupt_hw.c │ │ ├── libhw │ │ │ ├── gic.c │ │ │ ├── gic.h │ │ │ ├── lpae.c │ │ │ ├── lpae.h │ │ │ ├── trap.c │ │ │ ├── trap.h │ │ │ ├── vector.S │ │ │ ├── vgic.c │ │ │ └── vgic.h │ │ ├── memory_hw.c │ │ ├── timer_hw.c │ │ └── vdev │ │ │ ├── vdev_cp.c │ │ │ ├── vdev_gicd.c │ │ │ ├── vdev_hvc_ping.c │ │ │ ├── vdev_hvc_stay.c │ │ │ ├── vdev_hvc_yield.c │ │ │ ├── vdev_monitor │ │ │ ├── vdev_hvc_monitor.c │ │ │ ├── vdev_monitor.c │ │ │ └── vdev_monitor_utils.c │ │ │ ├── vdev_sample.c │ │ │ └── vdev_timer.c │ └── pc │ │ └── README.md ├── include │ ├── interrupt.h │ ├── memory.h │ ├── monitor.h │ ├── timer.h │ ├── vcpu.h │ └── vdev.h ├── interrupt.c ├── memory.c ├── monitor.c ├── timer.c ├── vcpu.c └── vdev.c ├── platform-device ├── cortex_a15x2_arndale │ ├── Makefile │ ├── README.md │ ├── boot.S │ ├── build │ │ ├── bmguest_bmguest.sh │ │ ├── linaro_bmguest.sh │ │ ├── linaro_ucos-ii.sh │ │ ├── linux_bmguest.sh │ │ └── linux_ucos-ii.sh │ ├── config-default.mk │ ├── drivers │ │ ├── gpio │ │ │ └── gpio.c │ │ ├── mct │ │ │ ├── mct.c │ │ │ └── mct_priv.h │ │ ├── pwm │ │ │ ├── pwm.c │ │ │ └── pwm_priv.h │ │ └── uart │ │ │ ├── exynos-uart.h │ │ │ └── uart_print.c │ ├── flash_bmguest.sh │ ├── guestimages │ │ └── zImage │ ├── guestos │ │ ├── android-linaro │ │ │ ├── .config │ │ │ ├── README │ │ │ ├── board.dtb │ │ │ ├── build-linaro-kernel.sh │ │ │ ├── get-android.sh │ │ │ ├── get-builded-bootfile.sh │ │ │ ├── get_linaro_kernel.sh │ │ │ ├── initrd.cpio │ │ │ ├── input │ │ │ ├── linaro_kernel_config │ │ │ └── upload-sdcard.sh │ │ ├── bmguest │ │ │ ├── .gitignore │ │ │ ├── Makefile │ │ │ ├── README.md │ │ │ ├── boot.S │ │ │ ├── config-default.mk │ │ │ ├── drivers │ │ │ │ ├── exynos-uart.h │ │ │ │ ├── io-exynos.h │ │ │ │ ├── pwm_timer.c │ │ │ │ ├── pwm_timer.h │ │ │ │ └── uart.c │ │ │ ├── main.c │ │ │ └── model.lds.S │ │ ├── guestloader │ │ │ ├── Makefile │ │ │ ├── README.md │ │ │ ├── boot.S │ │ │ ├── config-default.mk │ │ │ ├── drivers │ │ │ │ ├── gpio.c │ │ │ │ ├── gpio.h │ │ │ │ ├── serial_s5p.c │ │ │ │ ├── serial_s5p.h │ │ │ │ ├── timer.c │ │ │ │ ├── timer.h │ │ │ │ └── uart.c │ │ │ ├── guestloader.h │ │ │ ├── main.c │ │ │ ├── memmap.cfg │ │ │ └── model.lds.S │ │ └── ucos-ii │ │ │ ├── Makefile │ │ │ ├── README.md │ │ │ ├── arch │ │ │ ├── Makefile │ │ │ └── arm │ │ │ │ ├── Makefile │ │ │ │ ├── entry.S │ │ │ │ ├── irq.c │ │ │ │ ├── os_cpu_a.S │ │ │ │ ├── os_cpu_c.c │ │ │ │ ├── setup.S │ │ │ │ └── timer.c │ │ │ ├── drivers │ │ │ ├── Makefile │ │ │ ├── gpio.c │ │ │ └── serial.c │ │ │ ├── include │ │ │ ├── asm-arm │ │ │ │ ├── arch_types.h │ │ │ │ ├── armv7_p15.h │ │ │ │ ├── asm-arm_inline.h │ │ │ │ ├── board.h │ │ │ │ ├── gic_regs.h │ │ │ │ ├── io-exynos.h │ │ │ │ ├── irq.h │ │ │ │ ├── irqs.h │ │ │ │ ├── os_cpu.h │ │ │ │ ├── ptrace.h │ │ │ │ ├── pwm_priv.h │ │ │ │ └── timer.h │ │ │ ├── errno.h │ │ │ ├── includes.h │ │ │ ├── list.h │ │ │ ├── os_cfg.h │ │ │ ├── stdarg.h │ │ │ ├── stdio.h │ │ │ ├── string.h │ │ │ ├── types.h │ │ │ └── ucos_ii.h │ │ │ ├── init │ │ │ ├── Makefile │ │ │ ├── hyp-mortor.c │ │ │ ├── main.c │ │ │ └── native-mortor.c │ │ │ ├── kernel │ │ │ ├── Makefile │ │ │ ├── README.md │ │ │ └── kernel.a │ │ │ ├── ld-script │ │ │ └── lib │ │ │ ├── Makefile │ │ │ ├── printf.c │ │ │ ├── string.c │ │ │ ├── vscanf.c │ │ │ └── vsprintf.c │ ├── include │ │ ├── io-exynos.h │ │ ├── mct.h │ │ └── pwm.h │ ├── k-hypervisor-config.h │ ├── main.c │ ├── model.lds.S │ └── patch │ │ ├── arndale-change-kernel-sdram-address-uart-port-2-1.patch │ │ ├── linaro-android-ttysac1-formortor-diff.config │ │ ├── linux-arndale-config-add-minimal-linux-config.patch │ │ ├── u-boot-arndale-2console.patch │ │ ├── u-boot-arndale-motorcontrol.patch │ │ ├── u-boot-bootz.patch │ │ └── u-boot_arndale.patch ├── cortex_a15x2_rtsm │ ├── Makefile │ ├── README.md │ ├── boot.S │ ├── build │ │ ├── android_bmguest.sh │ │ ├── bmguest_bmguest.sh │ │ ├── bmguest_bmguest_bmguest_bmguest.sh │ │ ├── linux_bmguest.sh │ │ ├── linux_bmguest_bmguest.sh │ │ └── linux_bmguest_bmguest_bmguest.sh │ ├── config-default.mk │ ├── drivers │ │ └── uart │ │ │ └── uart_print.c │ ├── guestimages │ │ └── zImage │ ├── guestos │ │ ├── android_boot │ │ │ ├── linaro_kernel_build_cmds.sh │ │ │ └── uInitrd │ │ ├── bmguest │ │ │ ├── .gitignore │ │ │ ├── Makefile │ │ │ ├── README.md │ │ │ ├── boot.S │ │ │ ├── config-default.mk │ │ │ ├── drivers │ │ │ │ ├── sp804_timer.c │ │ │ │ ├── sp804_timer.h │ │ │ │ └── uart.c │ │ │ ├── main.c │ │ │ ├── model.lds.S │ │ │ └── trap.h │ │ └── guestloader │ │ │ ├── Makefile │ │ │ ├── README.md │ │ │ ├── boot.S │ │ │ ├── config-default.mk │ │ │ ├── drivers │ │ │ ├── pl011.c │ │ │ ├── pl011.h │ │ │ ├── timer.c │ │ │ ├── timer.h │ │ │ └── uart.c │ │ │ ├── guestloader.h │ │ │ ├── main.c │ │ │ ├── memmap.cfg │ │ │ └── model.lds.S │ ├── k-hypervisor-config.h │ ├── main.c │ ├── model.lds.S │ └── patch │ │ ├── README.md │ │ ├── fs.cpio │ │ ├── host-a15.dtb │ │ ├── host-a15x1.dtb │ │ ├── host-a15x2.dtb │ │ ├── linux-fastmodels-config-add-minimal-linux-config.patch │ │ ├── rtsm_ve-cortex_a15x1.dtb │ │ ├── u-boot_fastmodel.patch │ │ ├── vexpress_android │ │ ├── vexpress_defconfig.md │ │ ├── vexpress_defconfig_minhw │ │ └── vm_hwresources.md └── pc │ ├── Makefile │ ├── README.md │ ├── config-default.mk │ ├── k-hypervisor-config.h │ ├── main.c │ ├── timer.c │ └── timer.h └── scripts ├── apply_patch.sh ├── build.py ├── build_android_vexpress_mmc.sh ├── build_tags.sh ├── checkpatch.pl ├── ci ├── README.md ├── __init__.py ├── archive.py ├── checkpatch.py ├── command.py ├── cros_subprocess.py ├── extract.py ├── result_parser.py ├── simulator.py ├── tests │ ├── README.md │ ├── __init__.py │ ├── test_code_quality.py │ ├── test_installation.py │ ├── test_integration.py │ ├── test_load.py │ ├── test_performance.py │ ├── test_release.py │ └── test_smoke.py └── upload.py ├── clean.py ├── cleanpatch ├── run_mmc_rtsm.sh ├── run_rtsm.sh └── uboot_rtsm.sh /.gitignore: -------------------------------------------------------------------------------- 1 | uImage 2 | model.lds 3 | config.mk 4 | *.o 5 | *.swp 6 | *.pyc 7 | *.bin 8 | *.axf 9 | *.log 10 | *.map 11 | *.rej 12 | *.cpio.gz 13 | tags 14 | modelsemi.lds 15 | TAGS 16 | cscope.out 17 | cscope.in.out 18 | cscope.po.out 19 | .cproject 20 | .project 21 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "platform-device/cortex_a15x2_arndale/u-boot-native"] 2 | path = platform-device/cortex_a15x2_arndale/u-boot-native 3 | url = git://git.linaro.org/boot/u-boot-linaro-stable.git 4 | [submodule "platform-device/cortex_a15x2_rtsm/u-boot-native"] 5 | path = platform-device/cortex_a15x2_rtsm/u-boot-native 6 | url = git://git.denx.de/u-boot.git 7 | [submodule "platform-device/cortex_a15x2_rtsm/guestos/linux"] 8 | path = platform-device/cortex_a15x2_rtsm/guestos/linux 9 | url = git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 10 | [submodule "platform-device/cortex_a15x2_arndale/guestos/linux"] 11 | path = platform-device/cortex_a15x2_arndale/guestos/linux 12 | url = git://git.insignal.co.kr/samsung/exynos/android/kernel/samsung/exynos3.0 13 | [submodule "platform-device/cortex_a15x2_arndale/guestos/linaro"] 14 | path = platform-device/cortex_a15x2_arndale/guestos/linaro 15 | url = git://git.linaro.org/landing-teams/working/samsung/kernel 16 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | 2 | SHELL := /bin/bash 3 | PWD := $(shell pwd) 4 | 5 | all: build 6 | 7 | .PHONY: build 8 | build: 9 | python scripts/build.py all 10 | 11 | .PHONY: clean 12 | clean: 13 | echo "clean all" 14 | python scripts/clean.py all 15 | 16 | .PHONY: hypervisor 17 | hypervisor: 18 | echo "build hypervisor" 19 | python scripts/build.py hypervisor 20 | 21 | .PHONY: hypervisorclean 22 | hypervisorclean: 23 | echo "clean hypervisor" 24 | python scripts/clean.py hypervisor 25 | 26 | .PHONY: guest 27 | guest: 28 | echo "build guest" 29 | python scripts/build.py guest 30 | 31 | .PHONY: guestclean 32 | guestclean: 33 | echo "clean guest" 34 | python scripts/clean.py guest 35 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Hypervisor for ARMv7 Virtualization Extensions 2 | 3 | ## Basic directory structure 4 | - hypervisor Contains the real time hypervisor source code. 5 | - hvc call for manual guest switching 6 | - LPAE stage 2 address translation 7 | - Interrupt Handling through GICv2 8 | - Generic Timer and Scheduler (Round-robin) 9 | 10 | - platform-device Contains the device starting point. 11 | - common common interface source code. 12 | - cortex_a15x2_arndale based on arndale board code. 13 | - config Contains the platform specific configuration files. 14 | - drivers Contains the platform specific driver for hypervisor. 15 | - guestbl Contains the guest bootloader. 16 | - guestimages Contains the guest images. 17 | - guestos Contains the guest os source code. 18 | - cortex_a15x2_rtsm based on rtsm fastmodels code. 19 | - config Contains the platform specific configuration files. 20 | - drivers Contains the platform specific drivers for hypervisor. 21 | - guestbl Contains the guest bootloader. 22 | - guestimages Contains the guest images. 23 | - guestos Contains the guest os source code. 24 | 25 | The easiest way to use k-hypervisor is to start with one of the pre-configured 26 | platform-device projects (locate in the platform-device/ directory). 27 | 28 | See also - 29 | arndale port : https://github.com/kesl/khypervisor/tree/v1/platform-device/cortex_a15x2_arndale 30 | rtsm port : https://github.com/kesl/khypervisor/tree/v1/platform-device/cortex_a15x2_rtsm 31 | 32 | -------------------------------------------------------------------------------- /common/guest/core/exception.c: -------------------------------------------------------------------------------- 1 | 2 | #define ARCH_REGS_NUM_GPR 13 3 | struct arch_regs { 4 | unsigned int cpsr; 5 | unsigned int pc; 6 | unsigned int gpr[ARCH_REGS_NUM_GPR]; 7 | } __attribute((packed)); 8 | 9 | 10 | void _except_unhandled(struct arch_regs *regs) 11 | { 12 | } 13 | 14 | void _except_svc(struct arch_regs *regs) 15 | { 16 | } 17 | 18 | void _except_irq(struct arch_regs *regs) 19 | { 20 | gic_interrupt(0, regs); 21 | } 22 | 23 | -------------------------------------------------------------------------------- /common/guest/core/gic.h: -------------------------------------------------------------------------------- 1 | #ifndef __GIC_H__ 2 | #define __GIC_H__ 3 | 4 | #include "hvmm_types.h" 5 | #include "arch_types.h" 6 | 7 | #define GIC_INT_PRIORITY_DEFAULT 0xa0 8 | 9 | enum gic_int_polarity { 10 | GIC_INT_POLARITY_LEVEL = 0, 11 | GIC_INT_POLARITY_EDGE = 1 12 | }; 13 | 14 | typedef void (*gic_irq_handler_t)(int irq, void *regs, void *pdata); 15 | 16 | void gic_interrupt(int fiq, void *regs); 17 | hvmm_status_t gic_enable_irq(uint32_t irq); 18 | hvmm_status_t gic_disable_irq(uint32_t irq); 19 | hvmm_status_t gic_init(void); 20 | volatile uint32_t *gic_vgic_baseaddr(void); 21 | 22 | hvmm_status_t gic_set_irq_handler(int irq, gic_irq_handler_t handler, 23 | void *pdata); 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /common/guest/core/guest.S: -------------------------------------------------------------------------------- 1 | /* 2 | * guest.S - Secure/Non-Secure Switching Monitor 3 | * 4 | * Copyright (C) 2013 KESL. All rights reserved. 5 | * 6 | */ 7 | 8 | .syntax unified 9 | .arch_extension sec 10 | .arch_extension virt 11 | .text 12 | .global common_guest_entry 13 | common_guest_entry: 14 | /* Stack pointer initialization for svc, irq, and system/user modes */ 15 | @ sp for guest svc mode 16 | ldr sp, = guest_stacklimit_svc 17 | 18 | @ sp_irq 19 | msr cpsr_c, #0xd2 20 | ldr sp, = guest_stacklimit_irq 21 | 22 | @ sp for guest(system / user) 23 | msr cpsr_c, #0xdf 24 | ldr sp, = guest_stacklimit 25 | 26 | @ exception vector 27 | ldr r0, = nonsecure_vector 28 | mcr p15, 0, r0, c12, c0, 0 @ VBAR 29 | 30 | @ And call the C entrypoint 31 | bl nrm_loop 32 | 33 | @ 34 | @ Function for C code to make semihosting calls: 35 | @ 36 | .globl __semi_call 37 | __semi_call: 38 | #if defined(MACH_MPS) 39 | @ M profile semihosting is via bpkt 40 | bkpt 0xab 41 | #elif defined(__thumb__) 42 | @ Otherwise, different SVC numbers for ARM or Thumb mode 43 | svc 0xab 44 | #else 45 | svc 0x123456 46 | #endif 47 | mov pc, lr 48 | 49 | .align 5 50 | nonsecure_vector: 51 | .word 0 /* reset */ 52 | b except_unhandled /* undefined instruction */ 53 | b except_svc /* svc */ 54 | b except_pabort /* pabort */ 55 | b except_dabort /* dabort */ 56 | b except_unhandled /* unused */ 57 | b except_irq /* irq*/ 58 | b except_fiq /* fiq*/ 59 | 60 | except_unhandled: 61 | @ Push registers 62 | push {r0 - r12} 63 | mrs r0, spsr /* CPSR */ 64 | push {r0, lr} 65 | 66 | mov r0, sp 67 | bl _except_unhandled 68 | 69 | @ Pop registers 70 | pop {r0, lr} /* CPSR, LR */ 71 | msr spsr, r0 72 | pop {r0 - r12} 73 | movs pc, lr 74 | 75 | except_svc: 76 | @ Push registers 77 | push {r0 - r12} 78 | mrs r0, spsr /* CPSR */ 79 | push {r0, lr} 80 | 81 | mov r0, sp 82 | bl _except_svc 83 | 84 | @ Pop registers 85 | pop {r0, lr} /* CPSR, LR */ 86 | msr spsr, r0 87 | pop {r0 - r12} 88 | movs pc, lr 89 | 90 | except_irq: 91 | @ Push registers 92 | push {r0 - r12} 93 | mrs r0, spsr /* CPSR */ 94 | push {r0, lr} 95 | 96 | mov r0, sp 97 | bl _except_irq 98 | 99 | @ Pop registers 100 | pop {r0, lr} /* CPSR, LR */ 101 | msr spsr, r0 102 | pop {r0 - r12} 103 | 104 | @ movs pc, lr 105 | subs pc, lr, #4 106 | 107 | except_pabort: 108 | except_dabort: 109 | except_fiq: 110 | b except_unhandled 111 | -------------------------------------------------------------------------------- /common/guest/loader/cli.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #define NUM_CMD 4 7 | /* Guest Loader's command line interface command type. */ 8 | enum cmd_type { 9 | HELP, 10 | BOOT, 11 | MONITOR, 12 | GDB, 13 | NOINPUT 14 | }; 15 | 16 | /* For converting a string to command type. */ 17 | struct cmd { 18 | char *input_cmd; 19 | enum cmd_type cmd_type; 20 | }; 21 | 22 | /* Command type mapping table. */ 23 | static struct cmd cmd_type_map_tbl[NUM_CMD] = { 24 | {"help", HELP}, 25 | {"boot", BOOT}, 26 | {"monitor", MONITOR}, 27 | {"gdb", GDB} 28 | }; 29 | 30 | /** @brief Converts input command to a command type. 31 | * @param input Input command that will be converted to command type 32 | * @return Command type. If input is wrong, then returns help. 33 | */ 34 | static enum cmd_type convert_to_cmd_type(char *input_cmd) 35 | { 36 | int i; 37 | 38 | for (i = 0; i < NUM_CMD; i++) { 39 | if (strcmp(cmd_type_map_tbl[i].input_cmd, input_cmd) == 0) 40 | return cmd_type_map_tbl[i].cmd_type; 41 | } 42 | return HELP; 43 | } 44 | 45 | /** @brief Prints commands and their usage. 46 | */ 47 | static void print_cli_usage(void) 48 | { 49 | uart_print("help - List commands and their usage\n" 50 | "boot - Boot guestos\n" 51 | "monitor - Set Monitoring mode\n" 52 | "gdb - Set gdb stub mode\n"); 53 | } 54 | 55 | #define SPACE ' ' 56 | static enum cmd_type get_cmd_type(char *input_cmd) 57 | { 58 | int pos = 0; 59 | while (input_cmd[pos]) { 60 | if ((input_cmd[pos] == '\r') || (input_cmd[pos] == '\n')) 61 | break; 62 | else if (input_cmd[pos] != SPACE) 63 | return convert_to_cmd_type(&input_cmd[pos]); 64 | pos++; 65 | } 66 | return NOINPUT; 67 | } 68 | 69 | void cli_exec_cmd(char *cmd) 70 | { 71 | switch (get_cmd_type(cmd)) { 72 | case HELP: 73 | print_cli_usage(); 74 | break; 75 | case BOOT: 76 | loader_boot_guest(GUEST_TYPE); 77 | break; 78 | case MONITOR: 79 | #ifdef _MON_ 80 | set_guest_mode(MONITORSTUB); 81 | monitoring_cmd(); 82 | break; 83 | #endif 84 | print_cli_usage(); 85 | break; 86 | case GDB: 87 | #ifdef _GDB_ 88 | set_guest_mode(GDBSTUB); 89 | gdb(); 90 | #endif 91 | break; 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /common/guest/loader/cli.h: -------------------------------------------------------------------------------- 1 | #ifndef __CLI_H__ 2 | #define __CLI_H__ 3 | 4 | /** 5 | * @brief Executes command. 6 | * @param cmd Input command. 7 | */ 8 | void cli_exec_cmd(char *cmd); 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /common/guest/loader/guestloader_common.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #define SET_MACHINE_TYPE_TO_R1() \ 7 | asm volatile ("mov r1, %0" : : "r" (MACHINE_TYPE) : "memory", "cc") 8 | #define SET_ATAGS_TO_R2() \ 9 | asm volatile \ 10 | ("mov r2, %0" : : "r" (linuxloader_get_atags_addr()) : "memory", "cc") 11 | #define JUMP_TO_ADDRESS(addr) \ 12 | asm volatile ("mov pc, %0" : : "r" (addr) : "memory", "cc") 13 | #define ADD_PC_TO_OFFSET(offset) \ 14 | asm volatile ("add %0, pc, %0" : : "r" (offset) : "memory", "cc") 15 | 16 | enum guest_image_type { 17 | LOADER, 18 | GUEST 19 | }; 20 | 21 | 22 | /* 23 | * @brief Copies a guest to address. 24 | * @param img_type Guest Image type you want to copy. LOADER or GUEST. 25 | * @param dst_addr Destination address. 26 | */ 27 | 28 | void copy_image_to(uint32_t *src_addr, uint32_t *end_addr, uint32_t *dst_addr) 29 | { 30 | uint32_t *src = src_addr; 31 | uint32_t *end = end_addr; 32 | uint32_t *dst = dst_addr; 33 | while (src < end) 34 | *dst++ = *src++; 35 | } 36 | 37 | void loader_boot_guest(uint32_t guest_os_type) 38 | { 39 | uart_print("Booting guest os...\n"); 40 | 41 | uint32_t offset; 42 | uint32_t pc; 43 | 44 | if (guest_os_type == GUEST_TYPE_LINUX) { 45 | 46 | linuxloader_setup_atags(START_ADDR_LINUX); 47 | /* r1 : machine type 48 | * r2 : atags address 49 | */ 50 | SET_MACHINE_TYPE_TO_R1(); 51 | SET_ATAGS_TO_R2(); 52 | } else { 53 | /* Copies loader to next to guest */ 54 | copy_image_to(&loader_start, &loader_end, &guest_end); 55 | /* Jump pc to (pc + offset). */ 56 | offset = ((uint32_t)(&guest_end - &loader_start) * sizeof(uint32_t)); 57 | ADD_PC_TO_OFFSET(offset); 58 | JUMP_TO_ADDRESS(offset); 59 | /* Copies guest to start address */ 60 | copy_image_to(&guest_start, &guest_end, (uint32_t *)START_ADDR); 61 | } 62 | /* Jump to start address of guest */ 63 | JUMP_TO_ADDRESS(START_ADDR); 64 | 65 | /* The code must not reach here */ 66 | uart_print("[loadbmguest] ERROR: CODE MUST NOT REACH HERE\n\r"); 67 | while (1) 68 | ; 69 | } 70 | -------------------------------------------------------------------------------- /common/guest/loader/guestloader_common.h: -------------------------------------------------------------------------------- 1 | #ifndef __GUESTLOADER_COMMON__ 2 | #define __GUESTLOADER_COMMON_H_ 3 | #include 4 | #include 5 | 6 | #define GUEST_TYPE_BM 0 7 | #define GUEST_TYPE_LINUX 1 8 | 9 | #define START_ADDR_BM GUEST_START_ADDR 10 | 11 | #define START_ADDR_LINUX GUEST_START_ADDR 12 | #define START_ADDR_ZIMAGE ZIMAGE_PHYS_ADDR 13 | 14 | #if defined(LINUX_GUEST) 15 | #define START_ADDR START_ADDR_ZIMAGE 16 | #define GUEST_TYPE GUEST_TYPE_LINUX 17 | #else 18 | #define START_ADDR START_ADDR_BM 19 | #define GUEST_TYPE GUEST_TYPE_BM 20 | #endif 21 | 22 | extern uint32_t guest_start; 23 | extern uint32_t guest_end; 24 | extern uint32_t loader_start; 25 | extern uint32_t loader_end; 26 | extern uint32_t shared_memory_start; 27 | extern uint32_t shared_memory_end; 28 | /** 29 | * @brief Loads a guest os. 30 | * @param guest_os_type Guest os type. 31 | * Types of guest OS are bmguest, Linux guest and RTOS guest. 32 | */ 33 | void loader_boot_guest(uint32_t guest_os_type); 34 | void copy_image_to(uint32_t *src_addr, uint32_t *end_addr, uint32_t *dst_addr); 35 | 36 | #endif 37 | 38 | -------------------------------------------------------------------------------- /common/guest/loader/linuxloader.h: -------------------------------------------------------------------------------- 1 | #ifndef __LINUXLOADER_H__ 2 | #define __LINUXLOADER_H__ 3 | #include "arch_types.h" 4 | 5 | extern unsigned initrd_start; 6 | extern unsigned initrd_end; 7 | 8 | /** 9 | * @brief Sets tags that linux uses for booting. 10 | * @param *src Base address of tags. 11 | */ 12 | void linuxloader_setup_atags(uint32_t src); 13 | 14 | /** 15 | * @brief Returns atags address. 16 | * @return Atags address. 17 | */ 18 | uint32_t *linuxloader_get_atags_addr(void); 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /common/guest/loader/monitor/gdb_stub.h: -------------------------------------------------------------------------------- 1 | #ifndef _GDB_STUB_H__ 2 | #define _GDB_STUB_H__ 3 | 4 | void gdb(void); 5 | void reply_signal_from_break(void); 6 | #endif 7 | -------------------------------------------------------------------------------- /common/guest/loader/monitor/monitor_cli.h: -------------------------------------------------------------------------------- 1 | #ifndef __MONITOR_LOADER_H__ 2 | #define __MONITOR_LOADER_H__ 3 | #include 4 | #define NUM_DEBUG_CMD 5 5 | 6 | int monitoring_cmd(void); 7 | void monitoring_reboot(void); 8 | void monitoring_allset(uint32_t va); 9 | void monitoring_register(void); 10 | #endif 11 | -------------------------------------------------------------------------------- /common/guest/test/test_vdev_sample.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #define VDEV_SAMPLE_BASE 0x3FFFF000 5 | #define VDEV_OFFSET_REGA 0x00 6 | #define VDEV_OFFSET_REGB (0x04 / 4) 7 | #define VDEV_OFFSET_REGC (0x08 / 4) 8 | #define VDEV_OFFSET_REGD (0x0C / 4) 9 | 10 | void test_vdev_sample() 11 | { 12 | volatile uint32_t *base = (uint32_t *) VDEV_SAMPLE_BASE; 13 | volatile uint32_t *reg_a = base + VDEV_OFFSET_REGA; 14 | volatile uint32_t *reg_b = base + VDEV_OFFSET_REGB; 15 | volatile uint32_t *reg_c = base + VDEV_OFFSET_REGC; 16 | int i; 17 | int v1, v2, r; 18 | uart_print("vdev_sample: Starting test..., base:"); 19 | uart_print_hex32((uint32_t) base); 20 | uart_print("\n\r"); 21 | for (i = 0; i < 10; i++) { 22 | v1 = (1 + i) * 2; 23 | v2 = (1 + i) * 3; 24 | uart_print("v1("); 25 | uart_print_hex32(v1); 26 | uart_print(")+v2("); 27 | uart_print_hex32(v2); 28 | uart_print(")\n\r"); 29 | *reg_a = v1; 30 | *reg_b = v2; 31 | r = *reg_c; 32 | uart_print(" = r("); 33 | uart_print_hex32(r); 34 | if (r == (v1 + v2)) 35 | uart_print(") - OK"); 36 | else 37 | uart_print(") - FAILED"); 38 | 39 | uart_print("\n\r"); 40 | } 41 | uart_print("vdev_sample: End\n\r"); 42 | } 43 | -------------------------------------------------------------------------------- /common/guest/test/test_vtimer.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "test_vtimer.h" 3 | #include 4 | 5 | #define VDEV_TIMER_BASE 0x3FFFE000 6 | volatile uint32_t *base = (uint32_t *) VDEV_TIMER_BASE; 7 | 8 | void vtimer_mask(uint32_t value) 9 | { 10 | *base = value; 11 | } 12 | -------------------------------------------------------------------------------- /common/guest/test/test_vtimer.h: -------------------------------------------------------------------------------- 1 | #ifndef __VDEV_TIMER_H__ 2 | #define __VDEV_TIMER_H__ 3 | #include 4 | void vtimer_mask(uint32_t value); 5 | #endif 6 | -------------------------------------------------------------------------------- /common/guest/test/tests.h: -------------------------------------------------------------------------------- 1 | #ifndef __TESTS_H__ 2 | #define __TESTS_H__ 3 | 4 | void test_vdev_sample(); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /common/include/a15_cp15_sysregs.h: -------------------------------------------------------------------------------- 1 | #ifndef __A15_CP15_SYSREGS_H_ 2 | #define __A15_CP15_SYSREGS_H_ 3 | 4 | #include "arch_types.h" 5 | 6 | /* 7 | * Cortex-A15 Implementation Defined Registers 8 | * ACTLR 9 | * L2CTLR 10 | * L3ECTLR 11 | * IL1DATA0 12 | * IL1DATA1 13 | * IL1DATA2 14 | * DL1DATA0 15 | * DL1DATA1 16 | * DL1DATA2 17 | * DL1DATA3 18 | * RAMINDEX 19 | * L2ACTLR 20 | * L2PFR 21 | * CBAR - read_cbar() - Configuration Base Address Register 22 | * CPUMERRSR 23 | * L2MERRSR 24 | */ 25 | 26 | #define read_cbar() ({ uint32_t rval; asm volatile(\ 27 | " mrc p15, 4, %0, c15, c0, 0\n\t" \ 28 | : "=r" (rval) : : "memory", "cc"); rval; }) 29 | #endif 30 | -------------------------------------------------------------------------------- /common/include/arch_types.h: -------------------------------------------------------------------------------- 1 | #ifndef __ARCH_TYPES_H__ 2 | #define __ARCH_TYPES_H__ 3 | 4 | typedef int int32_t; 5 | typedef unsigned int uint32_t; 6 | typedef unsigned short uint16_t; 7 | typedef unsigned long long uint64_t; 8 | typedef unsigned char uint8_t; 9 | #endif 10 | -------------------------------------------------------------------------------- /common/include/asm-arm_inline.h: -------------------------------------------------------------------------------- 1 | #ifndef __ASM_ARM_INLINE__ 2 | #define __ASM_ARM_INLINE__ 3 | 4 | #define sev() __asm__ __volatile__ ("sev" : : : "memory") 5 | #define wfe() __asm__ __volatile__ ("wfe" : : : "memory") 6 | #define wfi() __asm__ __volatile__ ("wfi" : : : "memory") 7 | 8 | #define isb() __asm__ __volatile__ ("isb" : : : "memory") 9 | #define dsb() __asm__ __volatile__ ("dsb" : : : "memory") 10 | #define dmb() __asm__ __volatile__ ("dmb" : : : "memory") 11 | 12 | /* 13 | * CP15 Barrier instructions 14 | * Please note that we have separate barrier instructions in ARMv7 15 | * However, we use the CP15 based instructtions because we use 16 | * -march=armv5 in U-Boot 17 | */ 18 | #define CP15ISB asm volatile ("mcr p15, 0, %0, c7, c5, 4" : : "r" (0)) 19 | #define CP15DSB asm volatile ("mcr p15, 0, %0, c7, c10, 4" : : "r" (0)) 20 | #define CP15DMB asm volatile ("mcr p15, 0, %0, c7, c10, 5" : : "r" (0)) 21 | 22 | #define irq_enable() asm volatile("cpsie i" : : : "memory") 23 | #define asm_clz(x) ({ uint32_t rval; asm volatile(\ 24 | " clz %0, %1\n\t" \ 25 | : "=r" (rval) : "r" (x) : ); rval; }) 26 | 27 | 28 | #define irq_disable() asm volatile ("cpsid i" : : : "memory") 29 | 30 | #define irq_disabled() ({ unsigned long tf; \ 31 | asm volatile (" mrs %0, cpsr\n\t" \ 32 | : "=r" (tf) \ 33 | : \ 34 | : "memory", "cc"); \ 35 | (tf & CPSR_IRQ_DISABLED) ? TRUE : FALSE; \ 36 | }) 37 | 38 | 39 | #define irq_save(flags) do { \ 40 | asm volatile ( \ 41 | "mrs %0, cpsr\n\t" \ 42 | "cpsid i\n\t" \ 43 | : "=r" ((flags)) : : "memory", "cc"); \ 44 | } while (0) 45 | 46 | 47 | #define irq_restore(flags) do { \ 48 | asm volatile (" msr cpsr_c, %0" \ 49 | : : "r" ((flags)) : "memory", "cc"); \ 50 | } while (0) 51 | 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /common/include/asm_io.h: -------------------------------------------------------------------------------- 1 | #ifndef __ASM_IO_H__ 2 | #define __ASM_IO_H__ 3 | 4 | #define putw(v, a) (*(volatile unsigned short *)(a) = (v)) 5 | #define putb(v, a) (*(volatile unsigned char *)(a) = (v)) 6 | #define getw(a) (*(volatile unsigned short *)(a)) 7 | #define getb(a) (*(volatile unsigned char *)(a)) 8 | #define putl(v, a) (*(volatile unsigned int *)(a) = (v)) 9 | #define getl(a) (*(volatile unsigned int *)(a)) 10 | #define writel(v, a) ({ uint32_t vl = v; putl(vl, a); }) 11 | #define readl(a) ({ uint32_t vl = getl(a); vl; }) 12 | #define writew(v, a) ({ uint16_t vl = v; putw(vl, a); }) 13 | #define readw(a) ({ uint16_t vl = getw(a); vl; }) 14 | #define writeb(v, a) ({ uint8_t vl = v; putb(vl, a); }) 15 | #define readb(a) ({ uint8_t vl = getb(a); vl; }) 16 | #endif 17 | -------------------------------------------------------------------------------- /common/include/hvmm_trace.h: -------------------------------------------------------------------------------- 1 | #ifndef __HVMM_TRACE_H__ 2 | #define __HVMM_TRACE_H__ 3 | 4 | #include 5 | 6 | #ifdef DEBUG 7 | #define HVMM_TRACE_ENTER() \ 8 | do { \ 9 | uart_print(__func__); \ 10 | uart_print("() - enter\n\r"); \ 11 | } while (0) 12 | 13 | #define HVMM_TRACE_EXIT() \ 14 | do { \ 15 | uart_print(__func__); \ 16 | uart_print("() - exit\n\r"); \ 17 | } while (0) 18 | 19 | #define HVMM_TRACE_HEX32(label, value) \ 20 | do { \ 21 | uart_print(label); \ 22 | uart_print_hex32(value); \ 23 | uart_print("\n\r"); \ 24 | } while (0) 25 | #else 26 | #define HVMM_TRACE_ENTER() 27 | #define HVMM_TRACE_EXIT() 28 | #define HVMM_TRACE_HEX32(label, value) 29 | #endif 30 | 31 | #define hyp_abort_infinite() { while (1) ; } 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /common/include/hvmm_types.h: -------------------------------------------------------------------------------- 1 | #ifndef __HVMM_TYPES_H__ 2 | #define __HVMM_TYPES_H__ 3 | 4 | #include 5 | #define VMID_INVALID 0xFF 6 | #define PIRQ_INVALID 0xFFFFFFFF 7 | #define VIRQ_INVALID PIRQ_INVALID 8 | 9 | typedef enum hvmm_status { 10 | HVMM_STATUS_SUCCESS = 0, 11 | HVMM_STATUS_UNKNOWN_ERROR = -1, 12 | HVMM_STATUS_UNSUPPORTED_FEATURE = -2, 13 | HVMM_STATUS_BUSY = -3, 14 | HVMM_STATUS_BAD_ACCESS = -4, 15 | HVMM_STATUS_NOT_FOUND = -5, 16 | HVMM_STATUS_IGNORED = -6, 17 | } hvmm_status_t; 18 | 19 | typedef enum vcpu_state_t { 20 | VCPU_RUNNING = 1, 21 | VCPU_WAIT = 2, 22 | VCPU_BLOCKED = 3 23 | } vcpu_state_t; 24 | 25 | 26 | typedef uint8_t vmcbid_t; 27 | typedef uint8_t vcpuid_t; 28 | 29 | #endif 30 | 31 | -------------------------------------------------------------------------------- /common/include/version.h: -------------------------------------------------------------------------------- 1 | #ifndef _VERSION_H__ 2 | #define _VERSION_H__ 3 | 4 | #define BANNER_STRING "\n" \ 5 | " _ __ _ ___ ______ _____ ______ _____ ____ ___ ____ \r\n" \ 6 | "| |/ / | | | \\ \\ / / _ \\| ____| _ \\ \\ / /_ _/ ___| / _ \\| _ \\ "\ 7 | "\r\n" \ 8 | "| ' /_____| |_| |\\ V /| |_) | _| | |_) \\ \\ / / | |\\___ \\| | | | |_) | " \ 9 | "\r\n" \ 10 | "| . \\_____| _ | | | | __/| |___| _ < \\ V / | | ___) | |_| | _ < \r\n"\ 11 | "|_|\\_\\ |_| |_| |_| |_| |_____|_| \\_\\ \\_/ |___|____/ \\___/|_| "\ 12 | "\\_\\ \r\n" \ 13 | "\n" 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /common/log/format.c: -------------------------------------------------------------------------------- 1 | #include "format.h" 2 | #include "arch_types.h" 3 | #ifdef _SMP_ 4 | #include "smp.h" 5 | #endif 6 | 7 | #define PRINT_BUF_LEN 12 8 | 9 | enum numerical { 10 | DECIMAL = 10, 11 | HEXADECIMAL = 16 12 | }; 13 | 14 | static format_puts_t format_puts; 15 | static format_putc_t format_putc; 16 | 17 | #ifdef _SMP_ 18 | static DEFINE_SPINLOCK(format_lock); 19 | #endif 20 | 21 | static void format_printi(uint32_t v, enum numerical numerical, char base) 22 | { 23 | char print_buf[PRINT_BUF_LEN]; 24 | char *s; 25 | unsigned int mask8 = 0xF; 26 | unsigned int c; 27 | int i; 28 | switch (numerical) { 29 | case DECIMAL: 30 | s = print_buf + PRINT_BUF_LEN - 1; 31 | *s = '\0'; 32 | if (v == 0UL) 33 | *--s = '0'; 34 | else { 35 | for (; v != 0UL;) { 36 | *--s = ((v % 10) + '0'); 37 | v /= 10; 38 | } 39 | } 40 | format_puts(s); 41 | break; 42 | case HEXADECIMAL: 43 | for (i = 7; i >= 0; i--) { 44 | c = ((v >> (i * 4)) & mask8); 45 | if (c < 10) 46 | c += '0'; 47 | else 48 | c += base - 10; 49 | format_putc((char) c); 50 | } 51 | break; 52 | } 53 | } 54 | 55 | int format_print(const char *format, __builtin_va_list ap) 56 | { 57 | const char *p; 58 | unsigned long flags; 59 | #ifdef _SMP_ 60 | smp_spin_lock(&format_lock, flags); 61 | #endif 62 | for (p = format; *p != '\0'; p++) { 63 | if (*p == '%') { 64 | ++p; 65 | if (*p == 'd') 66 | format_printi(va_arg(ap, int), DECIMAL, 0); 67 | if (*p == 's') 68 | format_puts(va_arg(ap, char *)); 69 | if (*p == 'c') 70 | format_putc(va_arg(ap, int)); 71 | if (*p == 'x') 72 | format_printi(va_arg(ap, unsigned int), HEXADECIMAL, 'a'); 73 | if (*p == 'X') 74 | format_printi(va_arg(ap, unsigned int), HEXADECIMAL, 'A'); 75 | } else { 76 | if (*p == '\n') { 77 | format_putc(*p); 78 | format_putc('\r'); 79 | } else 80 | format_putc(*p); 81 | } 82 | } 83 | #ifdef _SMP_ 84 | smp_spin_unlock(&format_lock, flags); 85 | #endif 86 | 87 | return 0; 88 | } 89 | 90 | void format_reg_puts(format_puts_t s) 91 | { 92 | format_puts = s; 93 | } 94 | 95 | void format_reg_putc(format_putc_t c) 96 | { 97 | format_putc = c; 98 | } 99 | -------------------------------------------------------------------------------- /common/log/format.h: -------------------------------------------------------------------------------- 1 | #ifndef __FORMAT_H__ 2 | #define __FORMAT_H__ 3 | 4 | #define va_start(v, l) __builtin_va_start((v), l) 5 | #define va_end __builtin_va_end 6 | #define va_arg __builtin_va_arg 7 | 8 | typedef void(*format_puts_t)(const char *str); 9 | typedef void(*format_putc_t)(const char character); 10 | 11 | int format_print(const char *format, __builtin_va_list ap); 12 | void format_reg_puts(format_puts_t s); 13 | void format_reg_putc(format_putc_t c); 14 | #endif 15 | 16 | -------------------------------------------------------------------------------- /common/log/print.c: -------------------------------------------------------------------------------- 1 | #include "print.h" 2 | #include "format.h" 3 | #include "uart_print.h" 4 | 5 | void init_print() 6 | { 7 | format_reg_putc(&uart_putc); 8 | format_reg_puts(&uart_print); 9 | } 10 | 11 | void printH(const char *format, ...) 12 | { 13 | __builtin_va_list ap; 14 | va_start(ap, format); 15 | format_print(format, ap); 16 | va_end(ap); 17 | } 18 | 19 | -------------------------------------------------------------------------------- /common/log/print.h: -------------------------------------------------------------------------------- 1 | #ifndef __PRINT_H__ 2 | #define __PRINT_H__ 3 | 4 | void init_print(); 5 | 6 | void printH(const char *format, ...); 7 | 8 | #ifdef DEBUG 9 | #define printh printH 10 | #else 11 | #define printh(format, args...) ((void)0) 12 | #endif 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /common/log/sscanf.h: -------------------------------------------------------------------------------- 1 | #ifndef __SSCANF_H__ 2 | #define __SSCANF_H__ 3 | 4 | #include 5 | #include 6 | 7 | int sscanf(const char *s, const char *fmt, ...); 8 | #endif 9 | 10 | -------------------------------------------------------------------------------- /common/log/string.h: -------------------------------------------------------------------------------- 1 | #ifndef STRING_H 2 | #define STRING_H 3 | 4 | #include 5 | 6 | extern void *(memcpy)(void *__dest, __const void *__src, size_t __n); 7 | extern void *(memmove)(void *__dest, __const void *__src, size_t __n); 8 | extern void *(memchr)(void const *s, int c, size_t n); 9 | extern size_t (strlen)(const char *s); 10 | extern void *(memset)(void *s, int c, size_t count); 11 | extern int (memcmp)(void const *p1, void const *p2, size_t n); 12 | extern int (strcmp)(char const *s1, char const *s2); 13 | extern int (strncmp)(char const *s1, char const *s2, size_t n); 14 | extern char *(strchr)(char const *s, int c); 15 | extern char *(strcpy)(char *dest, const char *src); 16 | extern unsigned int arm_hexstr2uint(char *src); 17 | extern char *(strcat)(char *dest, const char *src); 18 | extern void arm_uint2hexstr(char *dst, unsigned int src); 19 | extern int arm_str2int(char *src); 20 | #endif 21 | -------------------------------------------------------------------------------- /common/log/uart_print.h: -------------------------------------------------------------------------------- 1 | #ifndef __UART_PRINT_H__ 2 | #define __UART_PRINT_H__ 3 | #include "arch_types.h" 4 | 5 | /** @brief Writes a character to the uart. 6 | * @param v Character for print. 7 | */ 8 | void uart_putc(const char c); 9 | 10 | /** @brief Writes the C string pointed by str to the uart. 11 | * @param v Strints for print. 12 | */ 13 | void uart_print(const char *str); 14 | 15 | /** @brief Prints hex number(32bit). 16 | * @param v Number for print. 17 | */ 18 | void uart_print_hex32(uint32_t v); 19 | 20 | /** @brief Prints hex number(64bit). 21 | * @param v Number for print. 22 | */ 23 | void uart_print_hex64(uint64_t v); 24 | 25 | /** @brief Prints decimal number. 26 | * @param v Number for print 27 | */ 28 | void uart_print_dec(uint32_t v); 29 | 30 | /** @brief Reads character from the uart. 31 | * @return Character from the uart's FIFO. 32 | */ 33 | char uart_getc(void); 34 | 35 | /** @brief Likes gets. Reads characters from the uart(stdin). 36 | * and stores them as a string into s 37 | * @param s Return string from the uart. 38 | * @param max_length Max length of read 39 | */ 40 | void uart_gets(char *s, int max_column); 41 | 42 | /** @brief Initializes uart. 43 | * @tobo Implemented about rtsm, not arndale yet. 44 | */ 45 | void uart_init(void); 46 | 47 | /** @brief Checks whether there is a data or not in the FIFO 48 | * @return There is a data in the FIFO then returns 1, otherwise returns 0. 49 | */ 50 | int uart_tst_fifo(void); 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /common/test/tests.c: -------------------------------------------------------------------------------- 1 | #include "tests.h" 2 | #include "tests_gic_timer.h" 3 | #include "tests_vdev.h" 4 | #include "tests_malloc.h" 5 | 6 | hvmm_status_t basic_tests_run(uint32_t tests) 7 | { 8 | hvmm_status_t result = HVMM_STATUS_UNKNOWN_ERROR; 9 | /* Entry point for sequence of test code */ 10 | if (tests & TESTS_ENABLE_MALLOC) 11 | result = hvmm_tests_malloc(); 12 | 13 | if (tests & TESTS_ENABLE_GIC_TIMER) 14 | result = hvmm_tests_gic_timer(); 15 | 16 | if (tests & TESTS_ENABLE_VGIC) 17 | result = hvmm_tests_vgic(); 18 | 19 | if (tests & TESTS_VDEV) 20 | result = hvmm_tests_vdev(); 21 | 22 | return result; 23 | } 24 | -------------------------------------------------------------------------------- /common/test/tests.h: -------------------------------------------------------------------------------- 1 | #ifndef __TESTS__ 2 | #define __TESTS__ 3 | 4 | #include 5 | 6 | /* Enable/Disable Test Items */ 7 | 8 | /* 9 | * GIC/Timer test disabled due to scheduler test does 10 | * context switching based on timer ticks 11 | */ 12 | #define TESTS_ENABLE_GIC_TIMER 0x01 13 | #define TESTS_ENABLE_GIC_PWM_TIMER 0x02 14 | #define TESTS_ENABLE_MALLOC 0x04 15 | #define TESTS_ENABLE_VGIC 0x08 16 | #define TESTS_VDEV 0x10 17 | #define TESTS_ENABLE_SP804 0x20 18 | 19 | hvmm_status_t basic_tests_run(uint32_t tests); 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /common/test/tests_gic_timer.h: -------------------------------------------------------------------------------- 1 | #ifndef __TESTS_GIC_TIMER_H__ 2 | #define __TESTS_GIC_TIMER_H__ 3 | 4 | #include 5 | 6 | hvmm_status_t hvmm_tests_gic_timer(void); 7 | hvmm_status_t hvmm_tests_vgic(void); 8 | hvmm_status_t hvmm_tests_gic_pwm_timer(void); 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /common/test/tests_malloc.c: -------------------------------------------------------------------------------- 1 | #include "tests_malloc.h" 2 | #include "hvmm_trace.h" 3 | #include "lpae.h" 4 | #include "memory.h" 5 | #include "armv7_p15.h" 6 | 7 | #include 8 | #include 9 | 10 | hvmm_status_t hvmm_tests_malloc(void) 11 | { 12 | HVMM_TRACE_ENTER(); 13 | int *test1; 14 | int *test2; 15 | int *test3; 16 | int *test4; 17 | int *test5; 18 | test1 = (int *)memory_alloc(100); 19 | printh("%s[%d] %x\n", __func__, __LINE__, test1); 20 | test2 = (int *)memory_alloc(1024); 21 | printh("%s[%d] %x\n", __func__, __LINE__, test2); 22 | test3 = (int *)memory_alloc(1025); 23 | printh("%s[%d] %x\n", __func__, __LINE__, test3); 24 | test4 = (int *)memory_alloc(750 * 8); 25 | printh("%s[%d] %x\n", __func__, __LINE__, test4); 26 | test5 = (int *)memory_alloc(218095616 - 8); 27 | printh("%s[%d] %x\n", __func__, __LINE__, test5); 28 | memory_free(test1); 29 | memory_free(test2); 30 | memory_free(test3); 31 | memory_free(test4); 32 | memory_free(test5); 33 | HVMM_TRACE_EXIT(); 34 | return HVMM_STATUS_SUCCESS; 35 | } 36 | -------------------------------------------------------------------------------- /common/test/tests_malloc.h: -------------------------------------------------------------------------------- 1 | #ifndef __TESTS_MMU_H__ 2 | #define __TESTS_MMU_H__ 3 | 4 | #include 5 | 6 | hvmm_status_t hvmm_tests_malloc(void); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /common/test/tests_vdev.c: -------------------------------------------------------------------------------- 1 | #include "tests_vdev.h" 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | hvmm_status_t hvmm_tests_vdev(void) 9 | { 10 | return HVMM_STATUS_UNKNOWN_ERROR; 11 | } 12 | 13 | hvmm_status_t hvmm_tests_vdev_gicd(void) 14 | { 15 | return HVMM_STATUS_UNKNOWN_ERROR; 16 | } 17 | 18 | -------------------------------------------------------------------------------- /common/test/tests_vdev.h: -------------------------------------------------------------------------------- 1 | #ifndef __TESTS_VDEV_H__ 2 | #define __TESTS_VDEV_H__ 3 | #include 4 | 5 | hvmm_status_t hvmm_tests_vdev(void); 6 | hvmm_status_t hvmm_tests_vdev_gicd(void); 7 | #endif 8 | -------------------------------------------------------------------------------- /hypervisor/hardware/arm32ve/include/guest_hw.h: -------------------------------------------------------------------------------- 1 | #ifndef _GUEST_HW_H__ 2 | #define _GUEST_HW_H__ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #define ARCH_REGS_NUM_GPR 13 12 | 13 | /* co-processor registers: cp15, cp2 */ 14 | struct regs_cop { 15 | uint32_t vbar; 16 | uint32_t ttbr0; 17 | uint32_t ttbr1; 18 | uint32_t ttbcr; 19 | uint32_t sctlr; 20 | }; 21 | 22 | /* banked registers */ 23 | struct regs_banked { 24 | uint32_t sp_usr; 25 | uint32_t spsr_svc; 26 | uint32_t sp_svc; 27 | uint32_t lr_svc; 28 | uint32_t spsr_abt; 29 | uint32_t sp_abt; 30 | uint32_t lr_abt; 31 | uint32_t spsr_und; 32 | uint32_t sp_und; 33 | uint32_t lr_und; 34 | uint32_t spsr_irq; 35 | uint32_t sp_irq; 36 | uint32_t lr_irq; 37 | 38 | uint32_t spsr_fiq; 39 | /* Cortex-A15 processor does not support sp_fiq */ 40 | /* uint32_t sp_fiq; */ 41 | uint32_t lr_fiq; 42 | uint32_t r8_fiq; 43 | uint32_t r9_fiq; 44 | uint32_t r10_fiq; 45 | uint32_t r11_fiq; 46 | uint32_t r12_fiq; 47 | }; 48 | 49 | /* Defines the architecture specific registers */ 50 | struct arch_regs { 51 | uint32_t cpsr; /* CPSR */ 52 | uint32_t pc; /* Program Counter */ 53 | uint32_t lr; 54 | uint32_t gpr[ARCH_REGS_NUM_GPR]; /* R0 - R12 */ 55 | } __attribute((packed)); 56 | 57 | /* Defines the architecture specific information, except general regsiters */ 58 | struct arch_context { 59 | struct regs_cop regs_cop; 60 | struct regs_banked regs_banked; 61 | }; 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /hypervisor/hardware/arm32ve/libhw/gic.h: -------------------------------------------------------------------------------- 1 | #ifndef __GIC_H__ 2 | #define __GIC_H__ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #define GIC_NUM_MAX_IRQS 1024 10 | #define gic_cpumask_current() (1u << smp_processor_id()) 11 | #define GIC_INT_PRIORITY_DEFAULT 0xa0 12 | 13 | enum gic_int_polarity { 14 | GIC_INT_POLARITY_LEVEL = 0, 15 | GIC_INT_POLARITY_EDGE = 1 16 | }; 17 | 18 | enum gic_sgi { 19 | GIC_SGI_SLOT_CHECK = 1, 20 | }; 21 | 22 | void gic_interrupt(int fiq, void *regs); 23 | hvmm_status_t gic_enable_irq(uint32_t irq); 24 | hvmm_status_t gic_disable_irq(uint32_t irq); 25 | /** 26 | * @brief Initializes GIC. 27 | *
28 |  * Initialization sequence
29 |  * 1. Determine GIC's base address and set it.
30 |  * 2. Initialize and Enable GIC Distributor.
31 |  * 3. Initialize and Enable GIC CPU Interface for this CPU.
32 |  * 
33 | * @return If initialization success then return success, 34 | * otherwise return "unknown error". 35 | */ 36 | hvmm_status_t gic_init(void); 37 | hvmm_status_t gic_deactivate_irq(uint32_t irq); 38 | hvmm_status_t gic_completion_irq(uint32_t irq); 39 | /** 40 | * @brief Returns Virtual interface control register(GICH)'s base address. 41 | * @return Base address of GICH 42 | */ 43 | volatile uint32_t *gic_vgic_baseaddr(void); 44 | 45 | /** 46 | * @brief Configures for a given IRQ. 47 | * @param irq Interrupt number. 48 | * @param polarity level-sensitive or edge-triggered. 49 | * @param cpumask Targets processor mask for the interrupt. 50 | * @param priority Priority level for each interrupt. 51 | * @return If interrupt number is vaild then return success, 52 | * otherwise return "unsupported feature". 53 | */ 54 | hvmm_status_t gic_configure_irq(uint32_t irq, 55 | enum gic_int_polarity polarity, uint8_t cpumask, 56 | uint8_t priority); 57 | 58 | uint32_t gic_get_irq_number(void); 59 | 60 | /** 61 | * @brief Send SGI to target core. 62 | * @param target Target core id 63 | * @param sgi SGI number 64 | * @return if sgi < 16, return "bad access", else return success. 65 | */ 66 | hvmm_status_t gic_set_sgi(const uint32_t target, uint32_t sgi); 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /hypervisor/hardware/arm32ve/vdev/vdev_hvc_ping.c: -------------------------------------------------------------------------------- 1 | #include 2 | #define DEBUG 3 | #include 4 | #include 5 | 6 | static int32_t vdev_hvc_ping_write(struct arch_vdev_trigger_info *info, 7 | struct arch_regs *regs) 8 | { 9 | printh("[hyp] _hyp_hvc_service:ping\n\r"); 10 | return 0; 11 | } 12 | 13 | static int32_t vdev_hvc_ping_check(struct arch_vdev_trigger_info *info, 14 | struct arch_regs *regs) 15 | { 16 | if ((info->iss & 0xFFFF) == 0xFFFE) 17 | return 0; 18 | 19 | return VDEV_NOT_FOUND; 20 | } 21 | 22 | static hvmm_status_t vdev_hvc_ping_reset(void) 23 | { 24 | return HVMM_STATUS_SUCCESS; 25 | } 26 | 27 | struct vdev_ops _vdev_hvc_ping_ops = { 28 | .init = vdev_hvc_ping_reset, 29 | .check = vdev_hvc_ping_check, 30 | .write = vdev_hvc_ping_write, 31 | }; 32 | 33 | struct vdev_module _vdev_hvc_ping_module = { 34 | .name = "K-Hypervisor vDevice HVC Ping Module", 35 | .author = "Kookmin Univ.", 36 | .ops = &_vdev_hvc_ping_ops, 37 | }; 38 | 39 | hvmm_status_t vdev_hvc_ping_init() 40 | { 41 | hvmm_status_t result = HVMM_STATUS_BUSY; 42 | 43 | result = vdev_register(VDEV_LEVEL_MIDDLE, &_vdev_hvc_ping_module); 44 | if (result == HVMM_STATUS_SUCCESS) 45 | printh("vdev registered:'%s'\n", _vdev_hvc_ping_module.name); 46 | else { 47 | printh("%s: Unable to register vdev:'%s' code=%x\n", 48 | __func__, _vdev_hvc_ping_module.name, result); 49 | } 50 | 51 | return result; 52 | } 53 | vdev_module_middle_init(vdev_hvc_ping_init); 54 | -------------------------------------------------------------------------------- /hypervisor/hardware/arm32ve/vdev/vdev_hvc_stay.c: -------------------------------------------------------------------------------- 1 | #include 2 | #define DEBUG 3 | #include 4 | #include 5 | 6 | static int32_t vdev_hvc_stay_write(struct arch_vdev_trigger_info *info, 7 | struct arch_regs *regs) 8 | { 9 | printh("[hyp] _hyp_hvc_service:stay\n\r"); 10 | return 0; 11 | } 12 | 13 | static int32_t vdev_hvc_stay_check(struct arch_vdev_trigger_info *info, 14 | struct arch_regs *regs) 15 | { 16 | if ((info->iss & 0xFFFF) == 0xFFFF) 17 | return 0; 18 | 19 | return VDEV_NOT_FOUND; 20 | } 21 | 22 | static hvmm_status_t vdev_hvc_stay_reset_values(void) 23 | { 24 | return HVMM_STATUS_SUCCESS; 25 | } 26 | 27 | struct vdev_ops _vdev_hvc_stay_ops = { 28 | .init = vdev_hvc_stay_reset_values, 29 | .check = vdev_hvc_stay_check, 30 | .write = vdev_hvc_stay_write, 31 | }; 32 | 33 | struct vdev_module _vdev_hvc_stay_module = { 34 | .name = "K-Hypervisor vDevice HVC Stay Module", 35 | .author = "Kookmin Univ.", 36 | .ops = &_vdev_hvc_stay_ops, 37 | }; 38 | 39 | hvmm_status_t vdev_hvc_stay_init() 40 | { 41 | hvmm_status_t result = HVMM_STATUS_BUSY; 42 | 43 | 44 | result = vdev_register(VDEV_LEVEL_MIDDLE, &_vdev_hvc_stay_module); 45 | if (result == HVMM_STATUS_SUCCESS) 46 | printh("vdev registered:'%s'\n", _vdev_hvc_stay_module.name); 47 | else { 48 | printh("%s: Unable to register vdev:'%s' code=%x\n", 49 | __func__, _vdev_hvc_stay_module.name, result); 50 | } 51 | 52 | return result; 53 | } 54 | vdev_module_middle_init(vdev_hvc_stay_init); 55 | -------------------------------------------------------------------------------- /hypervisor/hardware/arm32ve/vdev/vdev_hvc_yield.c: -------------------------------------------------------------------------------- 1 | #include 2 | #define DEBUG 3 | #include 4 | 5 | static int32_t vdev_hvc_yield_write(struct arch_vdev_trigger_info *info, 6 | struct arch_regs *regs) 7 | { 8 | printh("[hyp] _hyp_hvc_service:yield\n\r"); 9 | guest_switchto(sched_policy_determ_next(), 0); 10 | return 0; 11 | } 12 | 13 | static int32_t vdev_hvc_yield_check(struct arch_vdev_trigger_info *info, 14 | struct arch_regs *regs) 15 | { 16 | if ((info->iss & 0xFFFF) == 0xFFFD) 17 | return 0; 18 | 19 | return VDEV_NOT_FOUND; 20 | } 21 | 22 | static hvmm_status_t vdev_hvc_yield_reset_values(void) 23 | { 24 | return HVMM_STATUS_SUCCESS; 25 | } 26 | 27 | struct vdev_ops _vdev_hvc_yield_ops = { 28 | .init = vdev_hvc_yield_reset_values, 29 | .check = vdev_hvc_yield_check, 30 | .write = vdev_hvc_yield_write, 31 | }; 32 | 33 | struct vdev_module _vdev_hvc_yield_module = { 34 | .name = "K-Hypervisor vDevice HVC Yield Module", 35 | .author = "Kookmin Univ.", 36 | .ops = &_vdev_hvc_yield_ops, 37 | }; 38 | 39 | hvmm_status_t vdev_hvc_yield_init() 40 | { 41 | hvmm_status_t result = HVMM_STATUS_BUSY; 42 | 43 | result = vdev_register(VDEV_LEVEL_MIDDLE, &_vdev_hvc_yield_module); 44 | if (result == HVMM_STATUS_SUCCESS) 45 | printh("vdev registered:'%s'\n", _vdev_hvc_yield_module.name); 46 | else { 47 | printh("%s: Unable to register vdev:'%s' code=%x\n", 48 | __func__, _vdev_hvc_yield_module.name, result); 49 | } 50 | 51 | return result; 52 | } 53 | vdev_module_middle_init(vdev_hvc_yield_init); 54 | -------------------------------------------------------------------------------- /hypervisor/hardware/pc/README.md: -------------------------------------------------------------------------------- 1 | hal : PC for debugging purpose. 2 | ======= 3 | ARMv7 Virtualization Extension based Hypervisor 4 | 5 | Implementation On-going ... 6 | -------------------------------------------------------------------------------- /hypervisor/include/memory.h: -------------------------------------------------------------------------------- 1 | #ifndef __MM_H__ 2 | #define __MM_H__ 3 | 4 | #include 5 | #include "arch_types.h" 6 | 7 | /** 8 | * @brief Enum values of the stage2 memory attribute. 9 | * 10 | * \ref Memory_attribute "Memory attribute configuration" 11 | */ 12 | enum memattr { 13 | MEMATTR_SO = 0x0, /* Strongly Ordered */ 14 | MEMATTR_DM = 0x1, /* Device memory */ 15 | MEMATTR_NORMAL_ONC = 0x4, /* Outer Non-cacheable */ 16 | MEMATTR_NORMAL_OWT = 0x8, 17 | MEMATTR_NORMAL_OWB = 0xC, 18 | MEMATTR_NORMAL_INC = 0x1, 19 | MEMATTR_NORMAL_IWT = 0x2, 20 | MEMATTR_NORMAL_IWB = 0x3, 21 | }; 22 | 23 | /** 24 | * @brief Memory map descriptor. 25 | * 26 | * Memory map information descriptor. 27 | * - label Name of the descriptor. 28 | * - va Intermediate physical address(IPA). 29 | * - pa Physical address. 30 | * - size Size of this memory area. 31 | * - attr Memory attribute value. 32 | */ 33 | struct memmap_desc { 34 | char *label; 35 | uint64_t va; 36 | uint64_t pa; 37 | uint32_t size; 38 | enum memattr attr; 39 | }; 40 | 41 | struct memory_ops { 42 | /** Initalize Memory state */ 43 | hvmm_status_t (*init)(struct memmap_desc **, struct memmap_desc **); 44 | 45 | /** Allocate heap memory */ 46 | void * (*alloc)(unsigned long size); 47 | 48 | /** Free heap memory */ 49 | void (*free)(void *ap); 50 | 51 | /** Save guest memory structure */ 52 | hvmm_status_t (*save)(void); 53 | 54 | /** Restore guest memory structure */ 55 | hvmm_status_t (*restore)(vcpuid_t); 56 | 57 | /** Dump state of the memory */ 58 | hvmm_status_t (*dump)(void); 59 | }; 60 | 61 | struct memory_module { 62 | /** tag must be initialized to HAL_TAG */ 63 | uint32_t tag; 64 | 65 | /** 66 | * Version of the module-specific device API. This value is used by 67 | * the derived-module user to manage different device implementations. 68 | * The user who uses this module is responsible for checking 69 | * the module_api_version and device version fields to ensure that 70 | * the user is capable of communicating with the specific module 71 | * implementation. 72 | * 73 | */ 74 | uint32_t version; 75 | 76 | /** Identifier of module */ 77 | const char *id; 78 | 79 | /** Name of this module */ 80 | const char *name; 81 | 82 | /** Author/owner/implementor of the module */ 83 | const char *author; 84 | 85 | /** Memory Operation */ 86 | struct memory_ops *ops; 87 | }; 88 | 89 | extern struct memory_module _memory_module; 90 | extern uint32_t _guest_bin_start; 91 | extern uint32_t _guest2_bin_start; 92 | extern uint32_t _guest_secondary_bin_start; 93 | 94 | void memory_free(void *ap); 95 | void *memory_alloc(unsigned long size); 96 | hvmm_status_t memory_save(void); 97 | hvmm_status_t memory_restore(vcpuid_t vmid); 98 | hvmm_status_t memory_init(struct memmap_desc **guest0, 99 | struct memmap_desc **guest1); 100 | 101 | #endif 102 | -------------------------------------------------------------------------------- /hypervisor/include/timer.h: -------------------------------------------------------------------------------- 1 | #ifndef __TIMER_H__ 2 | #define __TIMER_H__ 3 | 4 | #include "hvmm_types.h" 5 | #include "arch_types.h" 6 | 7 | 8 | #define GUEST_TIMER 0 9 | #define HOST_TIMER 1 10 | 11 | typedef void(*timer_callback_t)(void *pdata); 12 | 13 | struct timer_val { 14 | uint32_t interval_us; 15 | timer_callback_t callback; 16 | }; 17 | 18 | struct timer_ops { 19 | /** The init function should only be used in the entire system */ 20 | hvmm_status_t (*init)(void); 21 | 22 | /** Enable the timer interrupt */ 23 | hvmm_status_t (*enable)(void); 24 | 25 | /** Disable the timer interrupt */ 26 | hvmm_status_t (*disable)(void); 27 | 28 | /** Set timer duration */ 29 | hvmm_status_t (*set_interval)(uint64_t); 30 | 31 | /** Dump state of the timer */ 32 | hvmm_status_t (*dump)(void); 33 | 34 | }; 35 | 36 | struct timer_module { 37 | /** tag must be initialized to HAL_TAG */ 38 | uint32_t tag; 39 | 40 | /** 41 | * Version of the module-specific device API. This value is used by 42 | * the derived-module user to manage different device implementations. 43 | * The user who uses this module is responsible for checking 44 | * the module_api_version and device version fields to ensure that 45 | * the user is capable of communicating with the specific module 46 | * implementation. 47 | * 48 | */ 49 | uint32_t version; 50 | 51 | /** Identifier of module */ 52 | const char *id; 53 | 54 | /** Name of this module */ 55 | const char *name; 56 | 57 | /** Author/owner/implementor of the module */ 58 | const char *author; 59 | 60 | /** Timer Operation */ 61 | struct timer_ops *ops; 62 | 63 | }; 64 | 65 | extern struct timer_module _timer_module; 66 | /* 67 | * Calling this function is required only once in the entire system 68 | * prior to calls to other functions of Timer module. 69 | */ 70 | hvmm_status_t timer_init(uint32_t irq); 71 | hvmm_status_t timer_set(struct timer_val *timer, uint32_t host); 72 | 73 | 74 | void set_timer_cnt(void); 75 | uint64_t get_timer_savecnt(void); 76 | uint64_t get_timer_curcnt(void); 77 | uint64_t get_timer_cnt(void); 78 | uint32_t get_timer_interval_us(uint64_t after, uint64_t before); 79 | #endif 80 | -------------------------------------------------------------------------------- /hypervisor/memory.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | static struct memory_ops *_memory_ops; 8 | 9 | /** 10 | * @brief Hyp mode general-purpose storage allocator. 11 | * 12 | * Obtains the storage from hyp mode heap memory. 13 | * - First, search free block list. 14 | * - Second, if free block list has no list or not enough size of list, 15 | * Obtains storage from heap memory. 16 | * - Third, there are list has enough size, return list's pointer. 17 | * 18 | * @param size Size of space 19 | * @return Allocated space 20 | */ 21 | void *memory_alloc(unsigned long size) 22 | { 23 | /* memory_hw_alloc */ 24 | if (_memory_ops->alloc) 25 | return _memory_ops->alloc(size); 26 | 27 | return 0; 28 | } 29 | 30 | /** 31 | * @brief Free allocated memory. 32 | * 33 | * Freed the header of the allocated block. 34 | * 35 | * @param addr The address of target block. 36 | * @return void 37 | */ 38 | void memory_free(void *ap) 39 | { 40 | /* memory_hw_free */ 41 | if (_memory_ops->free) 42 | _memory_ops->free(ap); 43 | } 44 | 45 | hvmm_status_t memory_save(void) 46 | { 47 | hvmm_status_t ret = HVMM_STATUS_UNKNOWN_ERROR; 48 | 49 | /* memory_hw_save */ 50 | if (_memory_ops->save) 51 | ret = _memory_ops->save(); 52 | 53 | return ret; 54 | } 55 | 56 | hvmm_status_t memory_restore(vcpuid_t vmid) 57 | { 58 | hvmm_status_t ret = HVMM_STATUS_UNKNOWN_ERROR; 59 | 60 | /* memory_hw_restore */ 61 | if (_memory_ops->restore) 62 | ret = _memory_ops->restore(vmid); 63 | 64 | return ret; 65 | } 66 | 67 | hvmm_status_t memory_init(struct memmap_desc **guest0, 68 | struct memmap_desc **guest1) 69 | { 70 | hvmm_status_t ret = HVMM_STATUS_UNKNOWN_ERROR; 71 | _memory_ops = _memory_module.ops; 72 | 73 | /* memory_hw_init */ 74 | if (_memory_ops->init) { 75 | ret = _memory_ops->init(guest0, guest1); 76 | if (ret) 77 | printh("host initial failed:'%s'\n", _memory_module.name); 78 | } 79 | 80 | return ret; 81 | } 82 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_arndale/build/bmguest_bmguest.sh: -------------------------------------------------------------------------------- 1 | #for bmguest + bmguest 2 | 3 | export TARGET_PRODUCT="cortex_a15x2_arndale" 4 | export GUEST_COUNT=2 5 | 6 | export HYPERVISOR_BIN="hvc-man-switch.bin" 7 | export HYPERVISOR_BUILD_SCRIPT="make clean && \ 8 | make CROSS_COMPILE=arm-linux-gnueabihf-" 9 | export HYPERVISOR_CLEAN_SCRIPT="make clean" 10 | 11 | export UBOOT_DIR="u-boot-native" 12 | export UBOOT="u-boot.bin" 13 | export UBOOT_BUILD_SCRIPT="make arndale5250 CROSS_COMPILE=arm-none-eabi-" 14 | export UBOOT_CLEAN_SCRIPT="make clean" 15 | 16 | export BMGUEST_BIN="bmguest.bin" 17 | export GUEST0_DIR="guestos/guestloader" 18 | export GUEST0_BIN="guestloader.bin" 19 | export GUEST0_BUILD_SCRIPT="cd ../bmguest/ && \ 20 | make clean && \ 21 | make GUEST_NUMBER=0 && \ 22 | cp $BMGUEST_BIN ../../guestimages/ && \ 23 | nm bmguest.axf -n > System.map && \ 24 | cp System.map ../../guestimages/ && \ 25 | cd ../../$GUEST0_DIR && \ 26 | make clean && \ 27 | make GUEST_NUMBER=0 " 28 | export GUEST0_CLEAN_SCRIPT="make clean" 29 | 30 | export GUEST1_DIR="guestos/guestloader" 31 | export GUEST1_BIN="guestloader.bin" 32 | export GUEST1_BUILD_SCRIPT="cd ../bmguest/ && \ 33 | make clean && \ 34 | make GUEST_NUMBER=1 && \ 35 | cp $BMGUEST_BIN ../../guestimages/ && \ 36 | cd ../../$GUEST1_DIR && \ 37 | make clean && \ 38 | make GUEST_NUMBER=1 MONITOR=y" 39 | export GUEST1_CLEAN_SCRIPT="make clean" 40 | 41 | export GUEST_IMAGE_DIR="guestimages" 42 | export CI_BUILD_DIR="bmguest_bmguest" 43 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_arndale/build/linaro_bmguest.sh: -------------------------------------------------------------------------------- 1 | #for bmguest + linux 2 | 3 | export TARGET_PRODUCT="cortex_a15x2_arndale" 4 | 5 | export GUEST_COUNT=2 6 | 7 | export HYPERVISOR_BIN="hvc-man-switch.bin" 8 | export HYPERVISOR_BUILD_SCRIPT="make clean && \ 9 | make" 10 | export HYPERVISOR_CLEAN_SCRIPT="make clean" 11 | 12 | export UBOOT_DIR="u-boot-native" 13 | export UBOOT="u-boot.bin" 14 | export UBOOT_BUILD_SCRIPT="make arndale5250 CROSS_COMPILE=arm-none-eabi-" 15 | export UBOOT_CLEAN_SCRIPT="make clean" 16 | 17 | export ZIMAGE_BIN="zImage" 18 | export BMGUEST_BIN="bmguest.bin" 19 | export GUEST0_DIR="guestos/guestloader" 20 | export GUEST0_BIN="guestloader.bin" 21 | export GUEST0_BUILD_SCRIPT="cd ../android-linaro && \ 22 | sh build-linaro-kernel.sh && \ 23 | cd ../linaro && \ 24 | cp arch/arm/boot/zImage ../../guestimages/ && \ 25 | cd ../../$GUEST0_DIR && \ 26 | make clean && \ 27 | make LINUX=y" 28 | export GUEST0_CLEAN_SCRIPT="make clean" 29 | 30 | export GUEST1_DIR="guestos/guestloader" 31 | export GUEST1_BIN="guestloader.bin" 32 | export GUEST1_BUILD_SCRIPT="cd ../bmguest/ && \ 33 | make clean && \ 34 | make GUEST_NUMBER=1 && \ 35 | cp $BMGUEST_BIN ../../guestimages/ && \ 36 | cd ../../$GUEST1_DIR && \ 37 | make clean && \ 38 | make GUEST_NUMBER=1" 39 | export GUEST1_CLEAN_SCRIPT="make clean" 40 | 41 | export GUEST_IMAGE_DIR="guestimages" 42 | export CI_BUILD_DIR="bmguest_linux" 43 | 44 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_arndale/build/linaro_ucos-ii.sh: -------------------------------------------------------------------------------- 1 | #for bmguest + linux 2 | 3 | export TARGET_PRODUCT="cortex_a15x2_arndale" 4 | 5 | export GUEST_COUNT=2 6 | 7 | export HYPERVISOR_BIN="hvc-man-switch.bin" 8 | export HYPERVISOR_BUILD_SCRIPT="make clean && \ 9 | make" 10 | export HYPERVISOR_CLEAN_SCRIPT="make clean" 11 | 12 | export UBOOT_DIR="u-boot-native" 13 | export UBOOT="u-boot.bin" 14 | export UBOOT_BUILD_SCRIPT="make arndale5250 CROSS_COMPILE=arm-none-eabi-" 15 | export UBOOT_CLEAN_SCRIPT="make clean" 16 | 17 | export ZIMAGE_BIN="zImage" 18 | export RTOS_BIN="rtos.bin" 19 | export GUEST0_DIR="guestos/guestloader" 20 | export GUEST0_BIN="guestloader.bin" 21 | export GUEST0_BUILD_SCRIPT="cd ../android-linaro && \ 22 | sh build-linaro-kernel.sh && \ 23 | cd ../linaro && \ 24 | cp arch/arm/boot/zImage ../../guestimages/ && \ 25 | cd ../../$GUEST0_DIR && \ 26 | make clean && \ 27 | make LINUX=y" 28 | export GUEST0_CLEAN_SCRIPT="make clean" 29 | 30 | export GUEST1_DIR="guestos/guestloader" 31 | export GUEST1_BIN="guestloader.bin" 32 | export GUEST1_BUILD_SCRIPT="cd ../ucos-ii/ && \ 33 | make clean && \ 34 | make CROSS_COMPILE=arm-none-eabi- && \ 35 | cp $RTOS_BIN ../../guestimages/ && \ 36 | cd ../../$GUEST1_DIR && \ 37 | make clean && \ 38 | make GUEST_NUMBER=1 RTOS=y" 39 | 40 | export GUEST1_CLEAN_SCRIPT="make clean" 41 | 42 | export GUEST_IMAGE_DIR="guestimages" 43 | export CI_BUILD_DIR="bmguest_linux" 44 | 45 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_arndale/build/linux_bmguest.sh: -------------------------------------------------------------------------------- 1 | #for bmguest + linux 2 | 3 | export TARGET_PRODUCT="cortex_a15x2_arndale" 4 | 5 | export GUEST_COUNT=2 6 | 7 | export HYPERVISOR_BIN="hvc-man-switch.bin" 8 | export HYPERVISOR_BUILD_SCRIPT="make clean && \ 9 | make" 10 | export HYPERVISOR_CLEAN_SCRIPT="make clean" 11 | 12 | export UBOOT_DIR="u-boot-native" 13 | export UBOOT="u-boot.bin" 14 | export UBOOT_BUILD_SCRIPT="make arndale5250 CROSS_COMPILE=arm-none-eabi-" 15 | export UBOOT_CLEAN_SCRIPT="make clean" 16 | 17 | export ZIMAGE_BIN="zImage" 18 | export BMGUEST_BIN="bmguest.bin" 19 | export GUEST0_DIR="guestos/guestloader" 20 | export GUEST0_BIN="guestloader.bin" 21 | #make CROSS_COMPILE=arm-linux-gnueabihf- ARCH=arm -j8 22 | #cp arch/arm/boot/zImage ../../guestimages/ && \ 23 | #cp System.map ../../guestimages/ &&\ 24 | export GUEST0_BUILD_SCRIPT="cd ../linux && \ 25 | make CROSS_COMPILE=arm-linux-gnueabihf- ARCH=arm -j8 26 | cp arch/arm/boot/zImage ../../guestimages/ && \ 27 | cp System.map ../../guestimages/ &&\ 28 | cd ../../$GUEST0_DIR && \ 29 | make clean && \ 30 | make LINUX=y" 31 | export GUEST0_CLEAN_SCRIPT="make clean" 32 | 33 | export GUEST1_DIR="guestos/guestloader" 34 | export GUEST1_BIN="guestloader.bin" 35 | export GUEST1_BUILD_SCRIPT="cd ../bmguest/ && \ 36 | make clean && \ 37 | make GUEST_NUMBER=1 && \ 38 | cp $BMGUEST_BIN ../../guestimages/ && \ 39 | cd ../../$GUEST1_DIR && \ 40 | make clean && \ 41 | make GUEST_NUMBER=1 MONITOR=y" 42 | export GUEST1_CLEAN_SCRIPT="make clean" 43 | 44 | export GUEST_IMAGE_DIR="guestimages" 45 | export CI_BUILD_DIR="bmguest_linux" 46 | 47 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_arndale/build/linux_ucos-ii.sh: -------------------------------------------------------------------------------- 1 | #for rtos + linux 2 | 3 | export TARGET_PRODUCT="cortex_a15x2_arndale" 4 | 5 | export GUEST_COUNT=2 6 | 7 | export HYPERVISOR_BIN="hvc-man-switch.bin" 8 | export HYPERVISOR_BUILD_SCRIPT="make clean && \ 9 | make LINUX=y RTOS=y CROSS_COMPILE=arm-linux-gnueabihf-" 10 | export HYPERVISOR_CLEAN_SCRIPT="make clean" 11 | 12 | export UBOOT_DIR="u-boot-native" 13 | export UBOOT="u-boot.bin" 14 | export UBOOT_BUILD_SCRIPT="make arndale5250 CROSS_COMPILE=arm-none-eabi-" 15 | export UBOOT_CLEAN_SCRIPT="make clean" 16 | 17 | export ZIMAGE_BIN="zImage" 18 | export RTOS_BIN="rtos.bin" 19 | export GUEST0_DIR="guestos/guestloader" 20 | export GUEST0_BIN="guestloader.bin" 21 | export GUEST0_BUILD_SCRIPT="cd ../linux && \ 22 | make ARCH=arm arndale_minimal_linux_defconfig && \ 23 | make CROSS_COMPILE=arm-linux-gnueabihf- ARCH=arm -j8 && \ 24 | cp arch/arm/boot/zImage ../../guestimages/ && \ 25 | cd ../../$GUEST0_DIR && \ 26 | make clean && \ 27 | make LINUX=y" 28 | export GUEST0_CLEAN_SCRIPT="make clean" 29 | 30 | export GUEST1_DIR="guestos/guestloader" 31 | export GUEST1_BIN="guestloader.bin" 32 | export GUEST1_BUILD_SCRIPT="cd ../ucos-ii/ && \ 33 | make clean && \ 34 | make CROSS_COMPILE=arm-none-eabi- && \ 35 | cp $RTOS_BIN ../../guestimages/ && \ 36 | cd ../../$GUEST1_DIR && \ 37 | make clean && \ 38 | make GUEST_NUMBER=1" 39 | 40 | export GUEST1_CLEAN_SCRIPT="make clean" 41 | 42 | export GUEST_IMAGE_DIR="guestimages" 43 | export CI_BUILD_DIR="bmguest_linux" 44 | 45 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_arndale/config-default.mk: -------------------------------------------------------------------------------- 1 | # Configuration file included in Makefile 2 | # 3 | # Copyright (C) 2011 Columbia University. All rights reserved. 4 | # Christoffer Dall 5 | # Use of this source code is governed by a BSD-style license that can be 6 | # found in the LICENSE.txt file. 7 | # 8 | # This is a sample configuration file. To make changes, copy this file to 9 | # config.mk and modify that file. 10 | # 11 | # For all systems you can override USE_INITRD and KCMD from the command-line. 12 | # 13 | 14 | ########################################################################### 15 | # Main options 16 | # 17 | CROSS_COMPILE ?= arm-linux-gnueabihf- 18 | ARCH ?= arm 19 | 20 | SYSTEM ?= arndale 21 | 22 | #CPPFLAGS += -D_SMP_ 23 | #CPPFLAGS += -D_MON_ 24 | #CPPFLAGS += -D_GDB_ 25 | CPPFLAGS += -mcpu=cortex-a15 -marm 26 | CPPFLAGS += -g 27 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_arndale/drivers/mct/mct.c: -------------------------------------------------------------------------------- 1 | #include "mct_priv.h" 2 | #include 3 | #define likely(x) __builtin_expect(!!(x), 1) 4 | static void *exynos5_sys_timer; 5 | static inline uint32_t exynos5_mct_read(uint32_t offset) 6 | { 7 | return vmm_readl((void *) EXYNOS5_MCT_BASE + offset); 8 | } 9 | static void exynos5_mct_write(uint32_t value, uint32_t offset) 10 | { 11 | uint32_t stat_addr; 12 | uint32_t mask; 13 | uint32_t i; 14 | exynos5_sys_timer = (void *)EXYNOS5_MCT_BASE; 15 | vmm_writel(value, exynos5_sys_timer + offset); 16 | if (likely(offset >= EXYNOS5_MCT_L_BASE(0))) { 17 | uint32_t base = offset & EXYNOS5_MCT_L_MASK; 18 | switch (offset & ~EXYNOS5_MCT_L_MASK) { 19 | case (uint32_t) MCT_L_TCON_OFFSET: 20 | stat_addr = base + MCT_L_WSTAT_OFFSET; 21 | mask = 1 << 3; 22 | break; 23 | case (uint32_t) MCT_L_ICNTB_OFFSET: 24 | stat_addr = base + MCT_L_WSTAT_OFFSET; 25 | mask = 1 << 1; /* L_ICNTB write status */ 26 | break; 27 | case (uint32_t) MCT_L_TCNTB_OFFSET: 28 | stat_addr = base + MCT_L_WSTAT_OFFSET; 29 | mask = 1 << 0; /* L_TCNTB write status */ 30 | break; 31 | default: 32 | return; 33 | } 34 | } else { 35 | switch (offset) { 36 | case (uint32_t) EXYNOS5_MCT_G_TCON: 37 | stat_addr = EXYNOS5_MCT_G_WSTAT; 38 | mask = 1 << 16; /* G_TCON write status */ 39 | break; 40 | case (uint32_t) EXYNOS5_MCT_G_COMP0_L: 41 | stat_addr = EXYNOS5_MCT_G_WSTAT; 42 | mask = 1 << 0; /* G_COMP0_L write status */ 43 | break; 44 | case (uint32_t) EXYNOS5_MCT_G_COMP0_U: 45 | stat_addr = EXYNOS5_MCT_G_WSTAT; 46 | mask = 1 << 1; /* G_COMP0_U write status */ 47 | break; 48 | case (uint32_t) EXYNOS5_MCT_G_COMP0_ADD_INCR: 49 | stat_addr = EXYNOS5_MCT_G_WSTAT; 50 | mask = 1 << 2; /* G_COMP0_ADD_INCR w status */ 51 | break; 52 | case (uint32_t) EXYNOS5_MCT_G_CNT_L: 53 | stat_addr = EXYNOS5_MCT_G_CNT_WSTAT; 54 | mask = 1 << 0; /* G_CNT_L write status */ 55 | break; 56 | case (uint32_t) EXYNOS5_MCT_G_CNT_U: 57 | stat_addr = EXYNOS5_MCT_G_CNT_WSTAT; 58 | mask = 1 << 1; /* G_CNT_U write status */ 59 | break; 60 | default: 61 | return; 62 | } 63 | } 64 | /* Wait maximum 1 ms until written values are applied */ 65 | for (i = 0; i < 0x1000; i++) { 66 | /* So we do this loop up to 1000 times */ 67 | if (exynos5_mct_read(stat_addr) & mask) { 68 | vmm_writel(mask, exynos5_sys_timer + stat_addr); 69 | return; 70 | } 71 | } 72 | } 73 | 74 | void mct_init(void) 75 | { 76 | uint32_t reg; 77 | exynos5_mct_write(0, EXYNOS5_MCT_G_CNT_L); 78 | exynos5_mct_write(0, EXYNOS5_MCT_G_CNT_U); 79 | reg = exynos5_mct_read(EXYNOS5_MCT_G_TCON); 80 | reg |= MCT_G_TCON_START; 81 | exynos5_mct_write(reg, EXYNOS5_MCT_G_TCON); 82 | } 83 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_arndale/drivers/mct/mct_priv.h: -------------------------------------------------------------------------------- 1 | #ifndef __MCT_PRIV_H__ 2 | #define __MCT_PRIV_H__ 3 | 4 | #define EXYNOS5_MCT_BASE 0x101C0000 5 | #define EXYNOS5_MCTREG(x) (x) 6 | #define EXYNOS5_MCT_L_MASK (0xffffff00) 7 | #define MCT_L_TCON_OFFSET (0x20) 8 | #define MCT_L_WSTAT_OFFSET (0x40) 9 | #define MCT_L_ICNTB_OFFSET (0x08) 10 | #define EXYNOS5_MCT_G_TCON EXYNOS5_MCTREG(0x240) 11 | #define EXYNOS5_MCT_G_WSTAT EXYNOS5_MCTREG(0x24C) 12 | #define EXYNOS5_MCT_G_COMP0_L EXYNOS5_MCTREG(0x200) 13 | #define EXYNOS5_MCT_G_COMP0_U EXYNOS5_MCTREG(0x204) 14 | #define EXYNOS5_MCT_G_COMP0_ADD_INCR EXYNOS5_MCTREG(0x208) 15 | #define EXYNOS5_MCT_G_CNT_L EXYNOS5_MCTREG(0x100) 16 | #define EXYNOS5_MCT_G_CNT_U EXYNOS5_MCTREG(0x104) 17 | #define MCT_L_TCNTB_OFFSET (0x00) 18 | #define EXYNOS5_MCT_G_CNT_WSTAT EXYNOS5_MCTREG(0x110) 19 | #define MCT_G_TCON_START (1 << 8) 20 | #define _EXYNOS5_MCT_L_BASE EXYNOS5_MCTREG(0x300) 21 | #define EXYNOS5_MCT_L_BASE(x) (_EXYNOS5_MCT_L_BASE + (0x100 + x)) 22 | 23 | void mct_init(void); 24 | #endif 25 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_arndale/drivers/pwm/pwm.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "pwm_priv.h" 3 | #include "gic.h" 4 | #include "hvmm_trace.h" 5 | #include 6 | #include 7 | uint32_t tcntb1; 8 | static pwm_timer_callback_t _callback; 9 | 10 | 11 | hvmm_status_t pwm_timer_enable_int() 12 | { 13 | uint32_t tcon; 14 | uint32_t tcstat; 15 | HVMM_TRACE_ENTER(); 16 | tcon = vmm_readl(TCON); 17 | tcstat = vmm_readl(CSTAT); 18 | /* auto reload set & timer start */ 19 | tcon |= (TCON_T1RELOAD); 20 | tcon |= (TCON_T1START); 21 | vmm_writel(tcon, TCON); 22 | /* interrupt enable */ 23 | tcstat |= 1 << 1; 24 | vmm_writel(tcstat, CSTAT); 25 | HVMM_TRACE_EXIT(); 26 | return HVMM_STATUS_SUCCESS; 27 | } 28 | hvmm_status_t pwm_timer_disable_int() 29 | { 30 | uint32_t tcstat; 31 | uint32_t tcon; 32 | /* Stop pwm timer1 */ 33 | tcon = vmm_readl(TCON); 34 | tcon &= ~(1 << 8); 35 | vmm_writel(tcon, TCON); 36 | /* Disable Pwm timer1 Interrupt */ 37 | tcstat = vmm_readl(CSTAT); 38 | tcstat &= ~(1 << 1); 39 | vmm_writel(tcstat, CSTAT); 40 | return HVMM_STATUS_SUCCESS; 41 | } 42 | hvmm_status_t pwm_timer_set_interval(uint32_t interval) 43 | { 44 | tcntb1 = 16500; 45 | return HVMM_STATUS_SUCCESS; 46 | } 47 | static void _pwm_timer_irq_handler(int irq, void *regs, void *pdata) 48 | { 49 | _callback(regs); 50 | } 51 | hvmm_status_t pwm_timer_enable_irq() 52 | { 53 | hvmm_status_t result = HVMM_STATUS_UNSUPPORTED_FEATURE; 54 | /* handler */ 55 | interrupt_request(69, &_pwm_timer_irq_handler); 56 | /* configure and enable interrupt */ 57 | interrupt_host_configure(69); 58 | result = HVMM_STATUS_SUCCESS; 59 | return result; 60 | } 61 | hvmm_status_t pwm_timer_set_callback(pwm_timer_callback_t callback) 62 | { 63 | _callback = callback; 64 | return HVMM_STATUS_SUCCESS; 65 | } 66 | 67 | void pwm_timer_init() 68 | { 69 | uint32_t tcfg0; 70 | uint32_t tcfg1; 71 | uint32_t tcon; 72 | pwm_timer_set_interval(0); 73 | pwm_timer_enable_irq(); 74 | tcfg0 = vmm_readl(TCFG0); 75 | tcfg1 = vmm_readl(TCFG1); 76 | tcon = vmm_readl(TCON); 77 | /* prescaler */ 78 | tcfg0 &= ~(0xff); 79 | tcfg0 |= 250 - 1; 80 | vmm_writel(tcfg0, TCFG0); 81 | /* mux */ 82 | tcfg1 &= ~(0xf << 4); 83 | tcfg1 |= (0x3 << 4); 84 | vmm_writel(tcfg1, TCFG1); 85 | /* count buffer resister */ 86 | vmm_writel(tcntb1, TCNTB(1)); 87 | /* count buffer resister load */ 88 | tcon |= TCON_T1MANUALUPD; 89 | vmm_writel(tcon, TCON); 90 | tcon &= ~(TCON_T1MANUALUPD); 91 | vmm_writel(tcon, TCON); 92 | } 93 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_arndale/drivers/pwm/pwm_priv.h: -------------------------------------------------------------------------------- 1 | #ifndef __PWM_PRIV_H__ 2 | #define __PWM_PRIV_H__ 3 | 4 | #define PWMBASE (void *) 0x12DD0000 5 | #define PWM_TIMERREG(x) (PWMBASE + (x)) 6 | #define TCFG0 PWM_TIMERREG(0x00) 7 | #define TCFG1 PWM_TIMERREG(0x04) 8 | #define TCON PWM_TIMERREG(0x08) 9 | #define PWM_TIMERREG2(tmr, reg) PWM_TIMERREG((reg)+0x0c+((tmr)*0x0c)) 10 | #define CSTAT PWM_TIMERREG(0x44) 11 | #define TCNTB(tmr) PWM_TIMERREG2(tmr, 0x00) 12 | #define TCMPB(tmr) PWM_TIMERREG2(tmr, 0x04) 13 | #define TCNTO(tmr) PWM_TIMERREG2(tmr, (((tmr) == 4) ? 0x04 : 0x08)) 14 | #define TCON_T4RELOAD (1<<22) 15 | #define TCON_T4MANUALUPD (1<<21) 16 | #define TCON_T4START (1<<20) 17 | #define TCON_T0RELOAD (1<<3) 18 | #define TCON_T0MANUALUPD (1<<1) 19 | #define TCON_T0START (1<<0) 20 | #define TCON_T2RELOAD (1<<15) 21 | #define TCON_T2MANUALUPD (1<<13) 22 | #define TCON_T2START (1<<12) 23 | #define TCON_T1MANUALUPD (1<<9) 24 | #define TCON_T1START (1<<8) 25 | #define TCON_T1RELOAD (1<<11) 26 | 27 | #endif 28 | 29 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_arndale/drivers/uart/exynos-uart.h: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2009 Samsung Electronics 3 | * Minkyu Kang 4 | * Heungjun Kim 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License as 8 | * published by the Free Software Foundation; either version 2 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 19 | * MA 02111-1307 USA 20 | * 21 | */ 22 | 23 | #ifndef __ASM_ARCH_UART_H_ 24 | #define __ASM_ARCH_UART_H_ 25 | 26 | #ifndef __ASSEMBLY__ 27 | /* baudrate rest value */ 28 | union br_rest { 29 | unsigned short slot; /* udivslot */ 30 | unsigned char value; /* ufracval */ 31 | }; 32 | 33 | struct s5p_uart { 34 | unsigned int ulcon; 35 | unsigned int ucon; 36 | unsigned int ufcon; 37 | unsigned int umcon; 38 | unsigned int utrstat; 39 | unsigned int uerstat; 40 | unsigned int ufstat; 41 | unsigned int umstat; 42 | unsigned char utxh; 43 | unsigned char res1[3]; 44 | unsigned char urxh; 45 | unsigned char res2[3]; 46 | unsigned int ubrdiv; 47 | union br_rest rest; 48 | unsigned char res3[0xffd0]; 49 | }; 50 | 51 | static inline int s5p_uart_divslot(void) 52 | { 53 | return 0; 54 | } 55 | 56 | #endif /* __ASSEMBLY__ */ 57 | 58 | #endif 59 | 60 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_arndale/drivers/uart/uart_print.c: -------------------------------------------------------------------------------- 1 | #include "arch_types.h" 2 | #include "exynos-uart.h" 3 | #include 4 | #include 5 | 6 | #ifdef CFG_EXYNOS5250 7 | #ifdef CFG_BOARD_ARNDALE 8 | #define UART2_BASE 0x12c20000 9 | //#define UART2_BASE 0x12c10000 10 | #else 11 | #error "Configuration for board is not specified!" 12 | #endif 13 | 14 | /* Exynos 5250 UART register macros */ 15 | #define UTXH 0x20 16 | #define UFSTAT 0x18 17 | #define UART_BASE (UART0 + UTXH) 18 | 19 | #define TX_FIFO_FULL_MASK (1 << 24) 20 | 21 | static int serial_err_check(int op) 22 | { 23 | struct s5p_uart *const uart = (struct s5p_uart *) UART2_BASE; 24 | unsigned int mask; 25 | if (op) 26 | mask = 0x8; 27 | else 28 | mask = 0xf; 29 | return readl(&uart->uerstat) & mask; 30 | } 31 | 32 | void uart_putc(const char c) 33 | { 34 | struct s5p_uart *const uart = (struct s5p_uart *) UART2_BASE; 35 | while ((readl(&uart->ufstat) & TX_FIFO_FULL_MASK)) { 36 | if (serial_err_check(1)) 37 | return; 38 | } 39 | writeb(c, &uart->utxh); 40 | if (c == '\n') 41 | uart_putc('\r'); 42 | } 43 | void uart_print(const char *str) 44 | { 45 | while (*str) 46 | uart_putc(*str++); 47 | } 48 | 49 | void uart_print_hex32(uint32_t v) 50 | { 51 | unsigned int mask8 = 0xF; 52 | unsigned int c; 53 | int i; 54 | uart_print("0x"); 55 | for (i = 7; i >= 0; i--) { 56 | c = ((v >> (i * 4)) & mask8); 57 | if (c < 10) 58 | c += '0'; 59 | else 60 | c += 'A' - 10; 61 | uart_putc((char) c); 62 | } 63 | } 64 | 65 | void uart_print_hex64(uint64_t v) 66 | { 67 | uart_print_hex32(v >> 32); 68 | uart_print_hex32((uint32_t)(v & 0xFFFFFFFF)); 69 | } 70 | 71 | #endif 72 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_arndale/flash_bmguest.sh: -------------------------------------------------------------------------------- 1 | sudo dd if=hvc-man-switch.bin of=/dev/sdb bs=512 seek=1105 2 | sudo dd if=guestimages/guest0.bin of=/dev/sdb bs=512 seek=1205 3 | sudo dd if=guestimages/guest1.bin of=/dev/sdb bs=512 seek=17589 4 | sudo dd if=guestimages/bmguest.bin of=/dev/sdb bs=512 seek=17789 5 | sudo dd if=guestimages/bmguest.bin of=/dev/sdb bs=512 seek=34173 6 | sudo dd if=guestimages/System.map of=/dev/sdb bs=512 seek=34373 7 | sudo sync 8 | sudo umount /dev/sdb* 9 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_arndale/guestimages/zImage: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kesl/khypervisor/722d32a42e08eba144dc2fa1a528c1369055204c/platform-device/cortex_a15x2_arndale/guestimages/zImage -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_arndale/guestos/android-linaro/README: -------------------------------------------------------------------------------- 1 | ***************************************** 2 | mijong kim 3 | e-mail : mijong3000@gmail.com 4 | kookmin.univ 5 | ***************************************** 6 | 7 | How to start linaro-android & bmguest 8 | also you can check this url (https://github.com/kesl/khypervisor/tree/v1/platform-device/cortex_a15x2_arndale) 9 | how to build others(linux + bmguest , bmguest +bmguest ...) 10 | this shell script and file is based on that url. 11 | 12 | 0. get linaro-kernel 13 | - clone linaro-kernel source 14 | 15 | $ sh get_linaro_kernel.sh 16 | 17 | 1. only build linaro kernel 18 | - if you want to build only linaro kernel zImage 19 | just start shellscript 20 | 21 | $ sh build-linaro-kernel.sh 22 | 23 | 24 | 2. build all ( linaro kernel + bmguest + hypervisor ) 25 | - if you want to build all file. do this process 26 | 27 | a) in this directory "~/khypervisor/platform-device/cortex_a15x2_arndale/build" 28 | 29 | $ sh linaro_bmguest.sh 30 | 31 | b) in this directory "~/khypervisor" 32 | 33 | $ make 34 | 35 | 36 | 3. upload sdcard all builded file (linaro kernel + bmguest +hypervisor + android) 37 | - if you build all file then upload sdcard 38 | 39 | a) we will use linaro tool so install linaro tool 40 | (url : https://releases.linaro.org/13.05/android/arndale) 41 | 42 | $ sudo add-apt-repository ppa:linaro-maintainers/tools 43 | $ sudo apt-get update 44 | $ sudo apt-get install linaro-image-tools 45 | 46 | 47 | b) get android file (boot.tar.bz2, system.tar.bz2, userdata.tar.bz2) 48 | 49 | start shell script "get-android.sh" 50 | 51 | $ sh get-android.sh 52 | 53 | 54 | c) you install linaro tool then start "upload-sdcard.sh" 55 | 56 | $ sh upload-sdcard.sh 57 | 58 | d) in boot 59 | - input 60 | ZIMAGE: ARNDALE # mmc read 0xb0000000 451 64;mmc read 0x40000000 4B5 1f4a;mmc read 0x80000000 23ff 14;mmc read 0x46400000 2413 1bbc;mmc read 80100000 3fcf A; go 0xb000004c 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_arndale/guestos/android-linaro/board.dtb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kesl/khypervisor/722d32a42e08eba144dc2fa1a528c1369055204c/platform-device/cortex_a15x2_arndale/guestos/android-linaro/board.dtb -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_arndale/guestos/android-linaro/build-linaro-kernel.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | cp .config ../linaro 3 | cp initrd.cpio ../linaro 4 | cd ../linaro/ 5 | make ARCH=arm menuconfig 6 | make -j4 ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- zImage modules 7 | cd ../android-linaro 8 | cat board.dtb >> ../linaro/arch/arm/boot/zImage 9 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_arndale/guestos/android-linaro/get-android.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | wget https://releases.linaro.org/13.12/android/arndale/boot.tar.bz2 4 | wget https://releases.linaro.org/13.12/android/arndale/system.tar.bz2 5 | wget https://releases.linaro.org/13.12/android/arndale/userdata.tar.bz2 6 | 7 | wget --no-check-certificate 'https://docs.google.com/uc?export=download&id=0B8VxwJmrTtCBWE9Del9nOEdCOEk' -O AngryBirds_1.3.2_rio.apk 8 | 9 | wget --no-check-certificate 'https://docs.google.com/uc?export=download&id=0B8VxwJmrTtCBSGhKQTBkUWUxQzg' -O com.antutu.ABenchMark-2.9.1-free-a3f3-www.apkhere.com.apk 10 | 11 | wget --no-check-certificate 'https://docs.google.com/uc?export=download&id=0B8VxwJmrTtCBeEdLTkp1NnJJdFE' -O Geekbench_3_v3.1.4.apk 12 | 13 | tar -xvf userdata.tar.bz2 14 | 15 | mv AngryBirds_1.3.2_rio.apk com.antutu.ABenchMark-2.9.1-free-a3f3-www.apkhere.com.apk Geekbench_3_v3.1.4.apk ./data/app 16 | 17 | tar -cjvf userdata.tar.bz2 data 18 | 19 | 20 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_arndale/guestos/android-linaro/get-builded-bootfile.sh: -------------------------------------------------------------------------------- 1 | wget http://keslproject.iptime.org/mediawiki/images/4/4d/Arndale-bl1.bin 2 | wget http://keslproject.iptime.org/mediawiki/images/a/ae/Smdk5250-spl.bin 3 | wget http://keslproject.iptime.org/mediawiki/images/7/71/U-boot.bin 4 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_arndale/guestos/android-linaro/get_linaro_kernel.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | rm -rf linaro 3 | rm -rf ../linaro 4 | 5 | set -e 6 | 7 | EXACT=1 8 | DIR=../linaro 9 | 10 | CPUS=`grep -c processor /proc/cpuinfo` 11 | 12 | usage() 13 | { 14 | echo 'Usage: $0 -c .config[ -t -d directory ]' 15 | echo -e " -c .config file The kernel config file from the build. Download from:\n http://snapshots.linaro.org/android/~linaro-android/arndale-linaro-14.06-release/1//kernel_config\n from a browser with cookies enabled." 16 | echo " -t Reproduce the from the tip of the branch rather than doing" 17 | echo " an exact replica build" 18 | echo " -d The directory to download code and build from" 19 | echo " Default: ${DIR}" 20 | exit 1 21 | } 22 | 23 | while getopts "c:d:ht" optn; do 24 | case $optn in 25 | d ) DIR=$OPTARG;; 26 | t ) EXACT=0;; 27 | c ) CFG=$OPTARG;; 28 | h ) usage; exit 1;; 29 | esac 30 | done 31 | 32 | # download the kernel 33 | if [ -d ${DIR} ] ; then 34 | echo "Directory ${DIR} exists. If the kernel code exists in this directory you may continue without cloning the git repository for the kernel. Are you sure you want to do this? (y/n) " 35 | read CONTINUE 36 | [ ${CONTINUE} == y ] || exit 1 37 | else 38 | git clone git://git.linaro.org/landing-teams/working/samsung/kernel $DIR 39 | fi 40 | 41 | cd $DIR 42 | git checkout 5a93c058f6bd377fc5edad3e07b1f4d9f18f0c32 43 | 44 | 45 | 46 | 47 | # download the kernel config 48 | #curl -q http://snapshots.linaro.org/android/~linaro-android/arndale-linaro-14.06-release/1//kernel_config> linaro_kernel_config 49 | 50 | # build the code 51 | #CROSS_COMPILE=`which arm-linux-gnueabi-gcc |sed -e 's,gcc,,'` 52 | #[ -d out ] || mkdir out 53 | #[ -f out/.config ] || cp linaro_kernel_config out/.config 54 | #if [[ `grep 'CONFIG_ARCH_MULTIPLATFORM=y' out/.config` ]]; then 55 | # KERNEL_IMAGE=zImage 56 | #else 57 | # KERNEL_IMAGE=uImage 58 | #fi 59 | #make -j${CPUS} O=out ARCH=arm CROSS_COMPILE=$CROSS_COMPILE $KERNEL_IMAGE modules 60 | #mkdir out/modules_for_android 61 | #make O=out ARCH=arm modules_install INSTALL_MOD_PATH=modules_for_android 62 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_arndale/guestos/android-linaro/initrd.cpio: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kesl/khypervisor/722d32a42e08eba144dc2fa1a528c1369055204c/platform-device/cortex_a15x2_arndale/guestos/android-linaro/initrd.cpio -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_arndale/guestos/android-linaro/input: -------------------------------------------------------------------------------- 1 | d 2 | 1 3 | d 4 | 2 5 | wq 6 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_arndale/guestos/android-linaro/upload-sdcard.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "input you are sdcard name:" 4 | read sdcardname 5 | echo "you are sdcard is $sdcardname" 6 | 7 | 8 | sudo linaro-android-media-create --mmc /dev/$sdcardname --dev arndale --boot boot.tar.bz2 --system system.tar.bz2 --userdata userdata.tar.bz2 9 | 10 | sudo fdisk /dev/$sdcardname < input 11 | 12 | #sudo dd if=../../arndale-bl1.bin of=/dev/$sdcardname bs=512 seek=1 13 | #sudo dd if=../../u-boot-native/spl/smdk5250-spl.bin of=/dev/$sdcardname bs=512 seek=17 14 | #sudo dd if=../../u-boot-native/u-boot.bin of=/dev/$sdcardname bs=512 seek=49 15 | sudo dd if=./Arndale-bl1.bin of=/dev/$sdcardname bs=512 seek=1 16 | sudo dd if=./Smdk5250-spl.bin of=/dev/$sdcardname bs=512 seek=17 17 | sudo dd if=./U-boot.bin of=/dev/$sdcardname bs=512 seek=49 18 | 19 | sudo dd if=../../hvc-man-switch.bin of=/dev/$sdcardname bs=512 seek=1105 20 | sudo dd if=../../guestimages/guest0.bin of=/dev/$sdcardname bs=512 seek=1205 21 | sudo dd if=../../guestimages/guest1.bin of=/dev/$sdcardname bs=512 seek=9215 22 | sudo dd if=../../guestimages/zImage of=/dev/$sdcardname bs=512 seek=9235 23 | sudo dd if=../../guestimages/bmguest.bin of=/dev/$sdcardname bs=512 seek=16335 24 | sudo sync 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_arndale/guestos/bmguest/.gitignore: -------------------------------------------------------------------------------- 1 | filesystem.cpio.gz 2 | linux-system.axf 3 | uImage 4 | model.lds 5 | config.mk 6 | *.o 7 | *.swp 8 | tags 9 | modelsemi.lds 10 | bmguest.bin 11 | *.axf 12 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_arndale/guestos/bmguest/README.md: -------------------------------------------------------------------------------- 1 | How to build a baremetal guest 2 | ============================== 3 | Makefile usage 4 | -------------- 5 |
 6 |   Usage: $ GUESTTYPE= make clean all
 7 |   Example:
 8 |   - Building a Hyp Monitor guest: $ GUESTTYPE=GUEST_HYPMON make clean all
 9 |   - Building a Secure Monitor guest: $ GUESTTYPE=GUEST_SECMON make clean all
10 | 
11 | 12 | 1. Building a Hyp monitor guest 13 | ------------------------------ 14 | - The program (bmguest.bin) runs in Non-secure Supervisor mode as a guest of the Hyp monitor 15 | - Physical Entry point: IPA:0x00000000 16 | - Hyp call (hvc instruction) to request the Hyp monitor to switch the context manually 17 |
18 |  $ make
19 |  or
20 |  $ GUESTTYPE=GUEST_HYPMON make
21 | arm-unknown-linux-gnueabi-gcc -DSMP -mcpu=cortex-a15 -DVEXPRESS -g -D__MONITOR_CALL_HVC__ -DLDS_PHYS_OFFSET='0x00000000' -DLDS_GUEST_OFFSET='0x00000000' -DLDS_GUEST_STACK='0x0F000000' -DNUM_ITERATIONS=3 -DGUEST_LABEL='"[guest0] "' -DLDS_GUEST_HYPMON=1 -DKCMD='"console=ttyAMA0 mem=512M mem=512M@0x880000000 earlyprintk root=/dev/nfs nfsroot=192.168.0.32:/srv/nfsroot,tcp rw ip=dhcp nfsrootdebug"' -c -o guest.o guest.S
22 | ...
23 | arm-unknown-linux-gnueabi-ld -o bmguest.axf guest.o c_start.o string.o uart_print.o --script=model.lds
24 | arm-unknown-linux-gnueabi-objcopy -O binary -S bmguest.axf bmguest.bin
25 | =================================================================
26 |   BUILT GUEST TYPE:GUEST_HYPMON 
27 |   GUESTCONFIGS FLAGS:-D__MONITOR_CALL_HVC__ -DLDS_PHYS_OFFSET='0x00000000' -DLDS_GUEST_OFFSET='0x00000000' -DLDS_GUEST_STACK='0x0F000000' -DNUM_ITERATIONS=3 -DGUEST_LABEL='[guest0] ' -DLDS_GUEST_HYPMON=1 
28 | =================================================================
29 |   Entry point physical address:
30 | 00000000 A __hypmon_guest_start
31 | 
32 | 33 | 2. Building a Secure monitor guest 34 | ------------------------------- 35 | - The program (bmguest.bin) runs in Non-secure Supervisor mode along side of the Monitor runs in Secure mode 36 | - Physical Entry point: 0xE0000000 37 | - Secure Monitor Call (smc instruction) to request the Secure Monitor to hand over the execution control to the Secure World 38 |
39 |  $ GUESTTYPE=GUEST_SECMON make
40 | arm-unknown-linux-gnueabi-gcc -DSMP -mcpu=cortex-a15 -DVEXPRESS -g -DLDS_PHYS_OFFSET='0xE0000000' -DLDS_GUEST_OFFSET='0xE0000000' -DLDS_GUEST_STACK='0xEF000000' -DNUM_ITERATIONS=3 -DGUEST_LABEL='"[guest0] "' -DLDS_GUEST_SECMON=1 -DKCMD='"console=ttyAMA0 mem=512M mem=512M@0x880000000 earlyprintk root=/dev/nfs nfsroot=192.168.0.32:/srv/nfsroot,tcp rw ip=dhcp nfsrootdebug"' -c -o guest.o guest.S
41 | ...
42 | =================================================================
43 |   BUILT GUEST TYPE:GUEST_SECMON 
44 |   GUESTCONFIGS FLAGS:-DLDS_PHYS_OFFSET='0xE0000000' -DLDS_GUEST_OFFSET='0xE0000000' -DLDS_GUEST_STACK='0xEF000000' -DNUM_ITERATIONS=3 -DGUEST_LABEL='[guest0] ' -DLDS_GUEST_SECMON=1 
45 | =================================================================
46 |   Entry point physical address:
47 | e0000000 A __secmon_guest_start
48 | 
49 | 
50 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_arndale/guestos/bmguest/boot.S: -------------------------------------------------------------------------------- 1 | /* 2 | * boot.S - Secure/Non-Secure Switching Monitor 3 | * 4 | * Copyright (C) 2013 KESL. All rights reserved. 5 | * 6 | */ 7 | .syntax unified 8 | .arch_extension sec 9 | .arch_extension virt 10 | .text 11 | 12 | @ Guest start code 13 | .global guest_start 14 | guest_start: 15 | 16 | b common_guest_entry 17 | .type guest_start, % function 18 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_arndale/guestos/bmguest/config-default.mk: -------------------------------------------------------------------------------- 1 | # Configuration file included in Makefile 2 | # 3 | # Copyright (C) 2011 Columbia University. All rights reserved. 4 | # Christoffer Dall 5 | # Use of this source code is governed by a BSD-style license that can be 6 | # found in the LICENSE.txt file. 7 | # 8 | # This is a sample configuration file. To make changes, copy this file to 9 | # config.mk and modify that file. 10 | # 11 | # For all systems you can override USE_INITRD and KCMD from the command-line. 12 | # 13 | 14 | ########################################################################### 15 | # Main options 16 | # 17 | CROSS_COMPILE ?= arm-linux-gnueabihf- 18 | ARCH ?= arm 19 | CPPFLAGS += -DSMP 20 | CPPFLAGS += -mcpu=cortex-a15 -marm 21 | CPPFLAGS += -DVEXPRESS -g -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_arndale/guestos/bmguest/drivers/exynos-uart.h: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2009 Samsung Electronics 3 | * Minkyu Kang 4 | * Heungjun Kim 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License as 8 | * published by the Free Software Foundation; either version 2 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 19 | * MA 02111-1307 USA 20 | * 21 | */ 22 | 23 | #ifndef __ASM_ARCH_UART_H_ 24 | #define __ASM_ARCH_UART_H_ 25 | 26 | #ifndef __ASSEMBLY__ 27 | /* baudrate rest value */ 28 | union br_rest { 29 | unsigned short slot; /* udivslot */ 30 | unsigned char value; /* ufracval */ 31 | }; 32 | 33 | struct s5p_uart { 34 | unsigned int ulcon; 35 | unsigned int ucon; 36 | unsigned int ufcon; 37 | unsigned int umcon; 38 | unsigned int utrstat; 39 | unsigned int uerstat; 40 | unsigned int ufstat; 41 | unsigned int umstat; 42 | unsigned char utxh; 43 | unsigned char res1[3]; 44 | unsigned char urxh; 45 | unsigned char res2[3]; 46 | unsigned int ubrdiv; 47 | union br_rest rest; 48 | unsigned char res3[0xffd0]; 49 | }; 50 | 51 | static inline int s5p_uart_divslot(void) 52 | { 53 | return 0; 54 | } 55 | 56 | #endif /* __ASSEMBLY__ */ 57 | 58 | #endif 59 | 60 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_arndale/guestos/bmguest/drivers/io-exynos.h: -------------------------------------------------------------------------------- 1 | #ifndef __IO_EXYNOS_H__ 2 | #define __IO_EXYNOS_H_ 3 | /* 4 | * For write data on physical address. 5 | */ 6 | #include "arch_types.h" 7 | #include "asm-arm_inline.h" 8 | #define __raw_write32(a, v) (*(volatile uint32_t *)(a) = (v)) 9 | #define __raw_read32(a) (*(volatile uint32_t *)(a)) 10 | #define __iowmb() dsb() 11 | #define __iormb() dsb() 12 | #define arch_out_le32(a, v) {__iowmb(); __raw_write32(a, v); } 13 | #define arch_in_le32(a) ({uint32_t v = __raw_read32(a); __iormb(); v; }) 14 | static inline uint32_t vmm_readl(volatile void *addr) 15 | { 16 | return arch_in_le32(addr); 17 | } 18 | static inline void vmm_writel(uint32_t data, volatile void *addr) 19 | { 20 | arch_out_le32(addr, data); 21 | } 22 | #endif 23 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_arndale/guestos/bmguest/drivers/pwm_timer.h: -------------------------------------------------------------------------------- 1 | #ifndef __TESTS_PWM_TIMER_H__ 2 | #define __TESTS_PWM_TIMER_H__ 3 | 4 | #include 5 | 6 | /* For Guest OS */ 7 | #define PWMBASE (void *)0x3FD10000 8 | #define PWM_TIMERREG(x) (PWMBASE + (x)) 9 | #define TCFG0 PWM_TIMERREG(0x00) 10 | #define TCFG1 PWM_TIMERREG(0x04) 11 | #define TCON PWM_TIMERREG(0x08) 12 | #define PWM_TIMERREG2(tmr, reg) PWM_TIMERREG((reg) + 0x0c + ((tmr) * 0x0c)) 13 | #define CSTAT PWM_TIMERREG(0x44) 14 | #define TCNTB(tmr) PWM_TIMERREG2(tmr, 0x00) 15 | #define TCMPB(tmr) PWM_TIMERREG2(tmr, 0x04) 16 | #define TCNTO(tmr) PWM_TIMERREG2(tmr, (((tmr) == 4) ? 0x04 : 0x08)) 17 | #define TCON_T4RELOAD (1<<22) 18 | #define TCON_T4MANUALUPD (1<<21) 19 | #define TCON_T4START (1<<20) 20 | #define TCON_T0RELOAD (1<<3) 21 | #define TCON_T0MANUALUPD (1<<1) 22 | #define TCON_T0START (1<<0) 23 | #define TCON_T2RELOAD (1<<15) 24 | #define TCON_T2MANUALUPD (1<<13) 25 | #define TCON_T2START (1<<12) 26 | #define TCON_T1MANUALUPD (1<<9) 27 | #define TCON_T1START (1<<8) 28 | #define TCON_T1RELOAD (1<<11) 29 | 30 | typedef void (*pwm_timer_callback_t)(void *pdata); 31 | 32 | /* Initialize pwm timer 1 */ 33 | void pwm_timer_init(); 34 | /* enable the timer. */ 35 | hvmm_status_t pwm_timer_enable_int(); 36 | /* Disable the timer. */ 37 | hvmm_status_t pwm_timer_disable_int(); 38 | /* 39 | * Sets time interval. Converts from microseconds 40 | * to count and sets time interval. 41 | */ 42 | hvmm_status_t pwm_timer_set_interval(uint32_t tval); 43 | /* Enables timer irq. */ 44 | hvmm_status_t pwm_timer_enable_irq(); 45 | /* Adds callback funtion. Called when occur timer interrupt */ 46 | hvmm_status_t pwm_timer_set_callback(pwm_timer_callback_t callback); 47 | hvmm_status_t hvmm_tests_pwm_timer(void); 48 | void interrupt_pwmtimer(int irq, void *pregs, void *pdata); 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_arndale/guestos/bmguest/drivers/uart.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "exynos-uart.h" 3 | /* UART Base Address determined by Hypervisor's Stage 2 Translation Table */ 4 | #define UART0 0x12C20000 5 | static char _dummy_byte; 6 | 7 | /* Exynos 5250 UART register macros */ 8 | #define UTXH 0x20 9 | #define UFSTAT 0x18 10 | #define UART_BASE (UART0 + UTXH) 11 | 12 | #define TX_FIFO_FULL_MASK (1 << 24) 13 | #define readl(a) (*(volatile unsigned int *)(a)) 14 | #define writeb(v, a) (*(volatile unsigned char *)(a) = (v)) 15 | 16 | static int serial_err_check(int op) 17 | { 18 | struct s5p_uart *const uart = (struct s5p_uart *) UART0; 19 | unsigned int mask; 20 | if (op) 21 | mask = 0x8; 22 | else 23 | mask = 0xf; 24 | 25 | return readl(&uart->uerstat) & mask; 26 | } 27 | 28 | void uart_putc(const char c) 29 | { 30 | struct s5p_uart *const uart = (struct s5p_uart *) UART0; 31 | while ((readl(&uart->ufstat) & TX_FIFO_FULL_MASK)) 32 | if (serial_err_check(1)) 33 | return; 34 | 35 | writeb(c, &uart->utxh); 36 | if (c == '\n') 37 | uart_putc('\r'); 38 | } 39 | void uart_print(const char *str) 40 | { 41 | while (*str) 42 | uart_putc(*str++); 43 | } 44 | 45 | void uart_print_hex32(uint32_t v) 46 | { 47 | unsigned int mask8 = 0xF; 48 | unsigned int c; 49 | int i; 50 | uart_print("0x"); 51 | for (i = 7; i >= 0; i--) { 52 | c = ((v >> (i * 4)) & mask8); 53 | if (c < 10) 54 | c += '0'; 55 | else 56 | c += 'A' - 10; 57 | uart_putc((char) c); 58 | } 59 | } 60 | 61 | void uart_print_hex64(uint64_t v) 62 | { 63 | uart_print_hex32(v >> 32); 64 | uart_print_hex32((uint32_t)(v & 0xFFFFFFFF)); 65 | } 66 | 67 | void uart_init(void) 68 | { 69 | /* TODO: 70 | * Figure out how to initialize the UART. 71 | * Currently, intialized by Hypervisor for FastModels RTSM_VE, 72 | * as a workaround 73 | */ 74 | /* ibrd 0x24 */ 75 | /* UART_BASE[9] = 0x10; */ 76 | /* UART_BASE[12] = 0xc300; */ 77 | } 78 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_arndale/guestos/bmguest/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | /* #define TESTS_ENABLE_PWM_TIMER */ 9 | 10 | int main() 11 | { 12 | uart_print(GUEST_LABEL); 13 | uart_print("=== Starting platform main n\r"); 14 | #ifdef TESTS_ENABLE_PWM_TIMER 15 | hvmm_tests_pwm_timer(); 16 | #endif 17 | while (1) 18 | ; 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_arndale/guestos/bmguest/model.lds.S: -------------------------------------------------------------------------------- 1 | /* 2 | * model.lds.S - simple linker script for stand-alone Linux booting 3 | * 4 | * Copyright (C) 2011 ARM Limited. All rights reserved. 5 | * 6 | * Use of this source code is governed by a BSD-style license that can be 7 | * found in the LICENSE.txt file. 8 | */ 9 | 10 | OUTPUT_FORMAT("elf32-littlearm") 11 | OUTPUT_ARCH(arm) 12 | TARGET(binary) 13 | 14 | PHYS_OFFSET = 0x40000000; 15 | 16 | /* NS.SVC mode code space 17 | * LDS_GUEST_OFFSET ~ LDS_GUEST_STACK + 0x01000000 18 | * - simon 19 | */ 20 | GUEST_OFFSET = 0x40000000; 21 | GUEST_STACK = 0x4F000000; 22 | 23 | SECTIONS { 24 | . = PHYS_OFFSET; 25 | 26 | /* Guest image between Kernel and Mon */ 27 | . = GUEST_OFFSET; 28 | #if (LDS_GUEST_SECMON==1) 29 | __secmon_guest_start = .; 30 | #elif (LDS_GUEST_HYPMON==1) 31 | __hypmon_guest_start = .; 32 | #else 33 | __monitor_type_unknown_guest_start = .; 34 | #endif 35 | 36 | /* Put most of the actual boot loader code up in high memory 37 | * where it won't get overwritten by kernel, initrd or atags. 38 | */ 39 | .text : 40 | { 41 | *(.text) 42 | } 43 | . = ALIGN(4); 44 | .rodata : 45 | { 46 | *(.rodata) 47 | } 48 | . = ALIGN(4); 49 | .data : 50 | { 51 | *(.data) 52 | } 53 | . = ALIGN(4); 54 | begin_bss = .; 55 | .bss : 56 | { 57 | *(.bss) 58 | } 59 | end_bss = .; 60 | _end = .; 61 | . = GUEST_STACK; 62 | guest_stacktop_svc = .; 63 | . = GUEST_STACK + 0x00400000; 64 | guest_stacklimit_svc = .; 65 | guest_stacktop_irq = .; 66 | . = GUEST_STACK + 0x00800000; 67 | guest_stacklimit_irq = .; 68 | guest_stacktop = .; 69 | . = GUEST_STACK + 0x01000000; 70 | guest_stacklimit = .; 71 | } 72 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_arndale/guestos/guestloader/Makefile: -------------------------------------------------------------------------------- 1 | # Usage: make 2 | # Example: 3 | # $ make ; build for bmguest 4 | # $ make LINUX=y ; build for linux guest 5 | # $ make RTOS=y ; build for rtos guest 6 | 7 | # Include config file 8 | include config-default.mk 9 | COMMON_SOURCE_DIR=../../../../common 10 | COMMON_LOADER_DIR=$(COMMON_SOURCE_DIR)/guest/loader 11 | OBJS += boot.o main.o drivers/serial_s5p.o drivers/uart.o drivers/timer.o drivers/gpio.o\ 12 | $(COMMON_SOURCE_DIR)/log/print.o \ 13 | $(COMMON_SOURCE_DIR)/log/sscanf.o \ 14 | $(COMMON_SOURCE_DIR)/log/format.o \ 15 | $(COMMON_SOURCE_DIR)/log/string.o \ 16 | $(COMMON_SOURCE_DIR)/guest/core/exception.o \ 17 | $(COMMON_SOURCE_DIR)/guest/core/gic.o \ 18 | $(COMMON_SOURCE_DIR)/guest/test/test_vtimer.o \ 19 | $(COMMON_LOADER_DIR)/linuxloader.o \ 20 | $(COMMON_LOADER_DIR)/guestloader_common.o \ 21 | $(COMMON_LOADER_DIR)/cli.o \ 22 | $(COMMON_LOADER_DIR)/monitor/monitor_cli.o \ 23 | $(COMMON_LOADER_DIR)/monitor/gdb_stub.o \ 24 | $(COMMON_LOADER_DIR)/monitor/guest_monitor.o 25 | GUESTLOADERIMG = guestloader.axf 26 | GUESTLOADERBIN = guestloader.bin 27 | LD_SCRIPT = model.lds.S 28 | INCLUDES = -I. -I$(COMMON_SOURCE_DIR) -I$(COMMON_SOURCE_DIR)/include \ 29 | -I$(COMMON_LOADER_DIR) -I$(COMMON_SOURCE_DIR)/guest \ 30 | -I$(COMMON_SOURCE_DIR)/guest/core -I../../ \ 31 | -I$(COMMON_LOADER_DIR)/monitor \ 32 | -I drivers 33 | 34 | CPPFLAGS += $(INCLUDES) 35 | CC = $(CROSS_COMPILE)gcc 36 | LD = $(CROSS_COMPILE)ld 37 | OBJCOPY = $(CROSS_COMPILE)objcopy 38 | ifeq ($(LINUX), y) 39 | GUESTLOADERCONFIGS = -DLINUX_GUEST 40 | endif 41 | ifeq ($(MONITOR), y) 42 | GUESTLOADERCONFIGS += -DMONITOR_GUEST 43 | endif 44 | GUESTLOADERCONFIGS += -DGUEST_NUMBER=$(GUEST_NUMBER) 45 | GUESTLOADERCONFIGS += -DGUEST_PATH=$(GUESTBIN) -DARNDALE 46 | all: $(GUESTLOADERBIN) 47 | clean distclean: 48 | rm -f $(GUESTLOADERIMG) $(GUESTLOADERBIN) \ 49 | model.lds $(OBJS) 50 | $(GUESTLOADERIMG): $(OBJS) model.lds 51 | $(LD) -o $@ $(OBJS) --script=model.lds 52 | $(GUESTLOADERBIN): $(GUESTLOADERIMG) 53 | $(OBJCOPY) -O binary -S $< $@ 54 | $(GUESTBIN): 55 | @echo "ERROS: Copy $@ from guestos/target_guest/ after building it" 56 | boot.o: boot.S 57 | $(CC) $(CPPFLAGS) $(GUESTLOADERCONFIGS) -DKCMD='$(KCMD)' -c -o $@ $< 58 | %.o: %.c 59 | $(CC) $(CPPFLAGS) $(GUESTLOADERCONFIGS) -O2 -ffreestanding -I. -c -o $@ $< 60 | model.lds: $(LD_SCRIPT) Makefile $(GUESTBIN) 61 | $(CC) $(CPPFLAGS) $(GUESTLOADERCONFIGS) -E -P -C -o $@ $< 62 | force: ; 63 | Makefile: ; 64 | .PHONY: all clean distclean config-default.mk 65 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_arndale/guestos/guestloader/README.md: -------------------------------------------------------------------------------- 1 | # How to test guestloader 2 | 3 | ##Linux guest + bmguest
4 | Download linux using gitmodule command. 5 |
 6 | cd {khypervisor_root_dir}
 7 | source platform-device/cortex_a15x2_arndale/build/linux_bmguest.sh
 8 | make
 9 | 
10 | 11 | ##Linux guest + RTOS guest
12 | Download linux using gitmodule command. 13 |
14 | cd {khypervisor_root_dir}
15 | source platform-device/cortex_a15x2_rtsm/build/linux_ucos-ii.sh
16 | make
17 | 
18 | 19 | ##bmguest + bmguest 20 |
21 | cd {khypervisor_root_dir}
22 | source platform-device/cortex_a15x2_rtsm/build/bmguest_bmguest.sh
23 | make
24 | 
25 | 26 | ##How to Flash a K-hypervisor to arndale board 27 | Please refer khypervisor/platform-device/cortex_a15x2_arndale/README.md 28 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_arndale/guestos/guestloader/boot.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 KESL. All rights reserved. 3 | */ 4 | .text 5 | @ Guest loader start code 6 | .global guestloader_start 7 | guestloader_start: 8 | /* Stack pointer initialization */ 9 | @ sp for irq 10 | msr cpsr_c, #0xd2 11 | ldr sp, = guestloader_stacklimit_irq 12 | 13 | @ sp for svc 14 | msr cpsr_c, #0xd3 15 | ldr sp, =guestloader_stacklimit_svc 16 | 17 | @ exception vector 18 | ldr r0, = guestloader_vector 19 | mcr p15, 0, r0, c12, c0, 0 @ VBAR 20 | 21 | /* Initilaize bss section */ 22 | ldr r2, =begin_bss 23 | ldr r3, =end_bss 24 | mov r0, #0 25 | 1: str r0, [r2], #4 @ clear bss 26 | cmp r2, r3 27 | blo 1b 28 | 29 | /* Initilaize shared memory */ 30 | ldr r2, =shared_memory_start 31 | ldr r3, =shared_memory_end 32 | mov r0, #0 33 | 2: str r0, [r2], #4 34 | cmp r2, r3 35 | blo 2b 36 | 37 | #ifdef _SMP_ 38 | @Check CPU ID 39 | mrc p15, 0, r0, c0, c0, 5 @MPIDR (ARMv7 only) 40 | bfc r0, #24, #8 @ CPU Number, taking multicluster into account 41 | cmp r0, #0 42 | beq 2f 43 | 44 | @ Secondary CPUs (for SMP booting in Linux Guest) 45 | cmp r0, #1 46 | bne 2f @ Will delete after Vcpu currectly work 47 | 48 | ldr r1, =guestloader_stacktop_svc - 0x100 /* not exactly complete */ 49 | adr r2, 1f 50 | ldmia r2, {r3 - r7} 51 | stmia r1, {r3 - r7} 52 | ldr r0, =0x1c010030 53 | mov pc, r1 54 | 55 | 1: 56 | wfe 57 | ldr r1, [r0] 58 | cmp r1, #0 59 | beq 1b 60 | mov pc, r1 61 | 62 | 2: 63 | #endif 64 | 65 | mov r0, r10 @ For Boot status 66 | @ Call the C entrypoint 67 | b main 68 | 69 | .type guestloader_start, %function 70 | 71 | .align 5 72 | guestloader_vector: 73 | .word 0 /* reset */ 74 | .word 0 /* undefined instruction */ 75 | .word 0 /* svc */ 76 | .word 0 /* pabort */ 77 | .word 0 /* dabort */ 78 | .word 0 /* unused */ 79 | b except_irq /* irq*/ 80 | .word 0 /* fiq*/ 81 | 82 | except_irq: 83 | @ Push registers 84 | push {r0 - r12} 85 | mrs r0, spsr /* CPSR */ 86 | push {r0, lr} 87 | 88 | mov r0, sp 89 | bl _except_irq 90 | 91 | @ Pop registers 92 | pop {r0, lr} /* CPSR, LR */ 93 | msr spsr, r0 94 | pop {r0 - r12} 95 | 96 | @ movs pc, lr 97 | subs pc, lr, #4 98 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_arndale/guestos/guestloader/config-default.mk: -------------------------------------------------------------------------------- 1 | include ../../config-default.mk 2 | 3 | # 4 | # Main options 5 | # 6 | CROSS_COMPILE = arm-linux-gnueabihf- 7 | ARCH = arm 8 | CPPFLAGS += -mcpu=cortex-a15 -marm -g 9 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_arndale/guestos/guestloader/drivers/serial_s5p.c: -------------------------------------------------------------------------------- 1 | #include "serial_s5p.h" 2 | #include 3 | 4 | #define TX_FIFO_FULL_MASK (1 << 24) 5 | #define RX_FIFO_COUNT_MASK 0xff 6 | #define RX_FIFO_FULL_MASK (1 << 8) 7 | 8 | static uint32_t uart_base_in; 9 | static uint32_t uart_base_out; 10 | 11 | int check_uart_mode(void) 12 | { 13 | if (uart_base_out == UART_BASE) 14 | return MODE_LOADER; 15 | else 16 | return MODE_GDB; 17 | } 18 | 19 | int set_uart_mode(int mode) 20 | { 21 | if(mode == MODE_LOADER) { 22 | uart_base_in = UART_BASE; 23 | uart_base_out = UART_BASE; 24 | } else if (mode == MODE_GDB) { 25 | uart_base_in = UART_GDB_BASE; 26 | uart_base_out = UART_GDB_LOG_BASE; 27 | } 28 | } 29 | 30 | static int serial_err_check(int op, int io) 31 | { 32 | struct s5p_uart *uart; 33 | unsigned int mask; 34 | if(io == 0) 35 | uart = (struct s5p_uart *) uart_base_in; 36 | else 37 | uart = (struct s5p_uart *) uart_base_out; 38 | 39 | if (op) 40 | mask = 0x8; 41 | else 42 | mask = 0xf; 43 | return readl(&uart->uerstat) & mask; 44 | } 45 | 46 | int serial_tst_fifo(void) 47 | { 48 | struct s5p_uart *const uart = (struct s5p_uart *) uart_base_in; 49 | 50 | /* There is not a data in the FIFO */ 51 | while (!(readl(&uart->ufstat) & (RX_FIFO_COUNT_MASK | 52 | RX_FIFO_FULL_MASK))) { 53 | return 0; 54 | } 55 | /* There is a data in the FIFO */ 56 | return 1; 57 | } 58 | 59 | int serial_getc(void) 60 | { 61 | struct s5p_uart *const uart = (struct s5p_uart *) uart_base_in; 62 | 63 | /* wait for character to arrive */ 64 | while (!(readl(&uart->ufstat) & (RX_FIFO_COUNT_MASK | 65 | RX_FIFO_FULL_MASK))) { 66 | if (serial_err_check(0, 0)) 67 | return 0; 68 | } 69 | return (int)(readb(&uart->urxh) & 0xff); 70 | } 71 | 72 | void serial_putc(const char c) 73 | { 74 | struct s5p_uart *const uart = (struct s5p_uart *) uart_base_out; 75 | while ((readl(&uart->ufstat) & TX_FIFO_FULL_MASK)) { 76 | if (serial_err_check(1, 1)) 77 | return; 78 | } 79 | writeb(c, &uart->utxh); 80 | } 81 | #define UART_BAUD 115200 82 | #define CONFIG_SYS_CLK_FREQ 24000000 83 | void serial_setbrg_dev(uint32_t base) 84 | { 85 | struct s5p_uart *const uart = (struct s5p_uart *)base; 86 | uint32_t uclk = CONFIG_SYS_CLK_FREQ; 87 | uint32_t baudrate = UART_BAUD; 88 | uint32_t val; 89 | 90 | val = uclk / baudrate; 91 | 92 | writel(val / 16 - 1, &uart->ubrdiv); 93 | 94 | writeb(val % 16, 95 | &uart->rest.value); 96 | 97 | } 98 | void serial_init(void) 99 | { 100 | struct s5p_uart *const uart = (struct s5p_uart *)UART_BASE; 101 | /* enable FIFOs */ 102 | writel(0x1, &uart->ufcon); 103 | writel(0, &uart->umcon); 104 | /* 8N1 */ 105 | writel(0x3, &uart->ulcon); 106 | /* No interrupts, no DMA, pure polling */ 107 | writel(0x245, &uart->ucon); 108 | uart_base_in = UART_BASE; 109 | uart_base_out = UART_BASE; 110 | } 111 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_arndale/guestos/guestloader/drivers/serial_s5p.h: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2009 Samsung Electronics 3 | * Minkyu Kang 4 | * Heungjun Kim 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License as 8 | * published by the Free Software Foundation; either version 2 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 19 | * MA 02111-1307 USA 20 | * 21 | */ 22 | #ifndef __ASM_ARCH_UART_H_ 23 | #define __ASM_ARCH_UART_H_ 24 | 25 | #include "arch_types.h" 26 | 27 | /* baudrate rest value */ 28 | union br_rest { 29 | unsigned short slot; /* udivslot */ 30 | unsigned char value; /* ufracval */ 31 | }; 32 | 33 | struct s5p_uart { 34 | unsigned int ulcon; 35 | unsigned int ucon; 36 | unsigned int ufcon; 37 | unsigned int umcon; 38 | unsigned int utrstat; 39 | unsigned int uerstat; 40 | unsigned int ufstat; 41 | unsigned int umstat; 42 | unsigned char utxh; 43 | unsigned char res1[3]; 44 | unsigned char urxh; 45 | unsigned char res2[3]; 46 | unsigned int ubrdiv; 47 | union br_rest rest; 48 | unsigned char res3[0xffd0]; 49 | }; 50 | 51 | /* Exynos 5250 UART register macros */ 52 | #define UTXH 0x20 53 | #define UFSTAT 0x18 54 | /* UART Base Address determined by Hypervisor's Stage 2 Translation Table */ 55 | 56 | #ifdef _MON_ 57 | 58 | #ifdef MONITOR_GUEST 59 | #define UART_BASE 0x12C20000 60 | #else 61 | #define UART_BASE 0x12C10000 62 | #endif 63 | 64 | #else 65 | #define UART_BASE 0x12C20000 66 | #endif 67 | 68 | #define UART_GDB_LOG_BASE 0x12C10000 69 | #define UART_GDB_BASE 0x12C20000 70 | 71 | #define MODE_GDB 1 72 | #define MODE_LOADER 0 73 | 74 | int serial_tst_fifo(void); 75 | int serial_getc(void); 76 | void serial_putc(const char c); 77 | void serial_setbrg_dev(uint32_t base); 78 | void serial_init(void); 79 | int set_uart_mode(int mode); 80 | int check_uart_mode(void); 81 | #endif 82 | 83 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_arndale/guestos/guestloader/drivers/timer.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include "timer.h" 6 | 7 | #define BOOT_COUNT 5 8 | #define SHED_TICK 1000 9 | #define BOOT_COUNT_RATIO (SHED_TICK/BOOT_COUNT) 10 | #define VTIMER_IRQ 30 11 | 12 | int bootcount = BOOT_COUNT * BOOT_COUNT_RATIO; 13 | /** 14 | * * @brief Handler of timer interrupt. 15 | * */ 16 | void timer_handler(int irq, void *pregs, void *pdata) 17 | { 18 | if (0 == (bootcount % BOOT_COUNT_RATIO)) { 19 | uart_print("Hit any key to stop autoboot : "); 20 | uart_print_hex32(bootcount / BOOT_COUNT_RATIO); 21 | uart_print("\n"); 22 | } 23 | if (bootcount == 0) 24 | guestloader_flag_autoboot(1); 25 | bootcount--; 26 | } 27 | 28 | void timer_init(void) 29 | { 30 | /* Registers vtimer hander */ 31 | gic_set_irq_handler(VTIMER_IRQ, timer_handler, 0); 32 | /* Enables receiving virtual timer interrupt */ 33 | timer_enable(); 34 | } 35 | 36 | void timer_disable(void) 37 | { 38 | /* Disables receiving virtual timer interrupt. */ 39 | vtimer_mask(1); 40 | } 41 | 42 | void timer_enable(void) 43 | { 44 | /* Enables receiving virtual timer interrupt. */ 45 | vtimer_mask(0); 46 | } 47 | 48 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_arndale/guestos/guestloader/drivers/timer.h: -------------------------------------------------------------------------------- 1 | #ifndef __TIMER_H__ 2 | #define __TIMER_H__ 3 | 4 | /** 5 | * * @brief Registers timer handler and enables timer interrupt. 6 | * */ 7 | void timer_init(void); 8 | /** 9 | * * @brief Disables receiving virtual timer interrupt. 10 | * */ 11 | void timer_disable(void); 12 | /** 13 | * * @brief Enables receiving virtual timer interrupt. 14 | * */ 15 | void timer_enable(void); 16 | #endif 17 | 18 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_arndale/guestos/guestloader/drivers/uart.c: -------------------------------------------------------------------------------- 1 | #include "serial_s5p.h" 2 | #include 3 | #include 4 | 5 | void uart_putc(const char c) 6 | { 7 | if (c == '\n') 8 | serial_putc('\r'); 9 | serial_putc(c); 10 | } 11 | 12 | int uart_tst_fifo(void) 13 | { 14 | if (!serial_tst_fifo()) 15 | return 0; 16 | else 17 | return 1; 18 | } 19 | 20 | void uart_print(const char *str) 21 | { 22 | int i = 0; 23 | while (*str) { 24 | if(check_uart_mode() == MODE_GDB){ 25 | i++; 26 | if(i > 80) { 27 | i = 0; 28 | uart_putc('\n'); 29 | } 30 | } 31 | uart_putc(*str++); 32 | } 33 | 34 | } 35 | 36 | void uart_print_hex32(uint32_t v) 37 | { 38 | unsigned int mask8 = 0xF; 39 | unsigned int c; 40 | int i; 41 | uart_print("0x"); 42 | for (i = 7; i >= 0; i--) { 43 | c = ((v >> (i * 4)) & mask8); 44 | if (c < 10) 45 | c += '0'; 46 | else 47 | c += 'A' - 10; 48 | uart_putc((char)c); 49 | } 50 | } 51 | 52 | void uart_print_hex64(uint64_t v) 53 | { 54 | uart_print_hex32(v >> 32); 55 | uart_print_hex32((uint32_t)(v & 0xFFFFFFFF)); 56 | } 57 | 58 | #define NULL '\0' 59 | char uart_getc(void) 60 | { 61 | char ch = serial_getc(); 62 | if (ch == '\r'){ 63 | ch = '\n'; 64 | } 65 | if(check_uart_mode() != MODE_GDB) 66 | uart_putc(ch); 67 | return ch; 68 | } 69 | 70 | void uart_gets(char *str, int max_column) 71 | { 72 | char *retval; 73 | char ch; 74 | retval = str; 75 | ch = uart_getc(); 76 | while (ch != '\n' && max_column > 0) { 77 | *retval = ch; 78 | retval++; 79 | max_column--; 80 | if (max_column == 0) 81 | break; 82 | ch = uart_getc(); 83 | } 84 | *retval = NULL; 85 | } 86 | void uart_init(void) 87 | { 88 | serial_init(); 89 | init_print(); 90 | } 91 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_arndale/guestos/guestloader/guestloader.h: -------------------------------------------------------------------------------- 1 | #ifndef __GUESTLOADER_H__ 2 | #define __GUESTLOADER_H__ 3 | #include "memmap.cfg" 4 | #define MACHINE_TYPE 4274 5 | #define GUEST_START_ADDR LDS_LOADER_PHYS_START 6 | #define ZIMAGE_PHYS_ADDR LDS_GUEST_START 7 | #endif 8 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_arndale/guestos/guestloader/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include "drivers/timer.h" 7 | #include 8 | #define DEBUG 9 | #include 10 | #include 11 | #include 12 | #include "drivers/gpio.h" 13 | 14 | #define MAX_CMD_STR_SIZE 256 15 | #define PROMPT "kboot# " 16 | #define BOOTCMD "boot" 17 | 18 | volatile int autoboot; 19 | 20 | static void guestloader_init(void) 21 | { 22 | /* Initializes serial */ 23 | uart_init(); 24 | /* Initializes GIC */ 25 | gic_init(); 26 | #ifdef _MON_ 27 | monitoring_init(); 28 | #endif 29 | /* Ready to accept irqs with GIC. Enable it now */ 30 | irq_enable(); 31 | /* Initializes timer */ 32 | timer_init(); 33 | /* Initializes autoboot flag */ 34 | autoboot = 0; 35 | } 36 | 37 | void guestloader_flag_autoboot(int flag) 38 | { 39 | autoboot = flag; 40 | } 41 | 42 | static void guestloader_autoboot(void) 43 | { 44 | timer_disable(); 45 | cli_exec_cmd(BOOTCMD); 46 | } 47 | 48 | static void guestloader_cliboot(void) 49 | { 50 | char input_cmd[MAX_CMD_STR_SIZE]; 51 | /* Disable timer for guest os */ 52 | timer_disable(); 53 | 54 | while (1) { 55 | uart_print(PROMPT); 56 | uart_gets(input_cmd, MAX_CMD_STR_SIZE); 57 | cli_exec_cmd(input_cmd); 58 | } 59 | } 60 | 61 | void main(int boot_status) 62 | { 63 | /*If Booting status is reboot, run this function. */ 64 | if (boot_status) 65 | reboot(); 66 | /* Initializes guestloder */ 67 | guestloader_init(); 68 | /* Show Hypervisor Banner */ 69 | uart_print(BANNER_STRING); 70 | 71 | #ifdef MONITOR_GUEST 72 | guestloader_cliboot(); 73 | #endif 74 | /* Auto boot or CLI boot */ 75 | while (1) { 76 | /* Auto boot */ 77 | if (autoboot) 78 | guestloader_autoboot(); 79 | /* Use CLI, if press any key */ 80 | else if (uart_tst_fifo()) 81 | guestloader_cliboot(); 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_arndale/guestos/guestloader/memmap.cfg: -------------------------------------------------------------------------------- 1 | #define LDS_STACK 0x4F000000 2 | #ifdef LINUX_GUEST 3 | #define LDS_GUEST_START 0x46400000 4 | #else 5 | #define LDS_GUEST_START 0x40500000 6 | #endif 7 | #define LDS_LOADER_PHYS_START 0x40000000 8 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_arndale/guestos/guestloader/model.lds.S: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | * model.lds.S - simple linker script for stand-alone Linux booting 4 | * 5 | * Copyright (C) 2011 ARM Limited. All rights reserved. 6 | * 7 | * Use of this source code is governed by a BSD-style license that can be 8 | * found in the LICENSE.txt file. 9 | */ 10 | 11 | OUTPUT_FORMAT("elf32-littlearm") 12 | OUTPUT_ARCH(arm) 13 | TARGET(binary) 14 | #include "memmap.cfg" 15 | PHYS_STACK = LDS_STACK; 16 | GUEST_START = LDS_GUEST_START; 17 | LOADER_PHYS_START = LDS_LOADER_PHYS_START; 18 | SECTIONS 19 | { 20 | #ifdef LINUX_GUEST 21 | . = GUEST_START; 22 | loader_end = .; 23 | guest_start = .; 24 | guest_end = . + 0x500000; 25 | #else 26 | . = GUEST_START; 27 | loader_end = .; 28 | guest_start = .; 29 | guest_end = . + 0x200000; 30 | #endif 31 | 32 | system_map_start = 0x40D00000; 33 | . = system_map_start; 34 | system_map_end = .; 35 | 36 | shared_memory_start = 0x4EC00000; 37 | . = shared_memory_start; 38 | shared_memory_end = . + 0x400000; 39 | 40 | . = LOADER_PHYS_START; 41 | loader_start = .; 42 | .text : { 43 | *(.text) 44 | } 45 | .= ALIGN(4); 46 | .rodata : { 47 | *(.rodata) 48 | } 49 | .= ALIGN(4); 50 | .data : { 51 | *(.data) 52 | } 53 | .= ALIGN(4); 54 | begin_bss = .; 55 | .bss : { 56 | *(.bss) 57 | } 58 | end_bss = .; 59 | 60 | guestloader_end = .; 61 | 62 | . = PHYS_STACK; 63 | guestloader_stacktop_svc = .; 64 | . = PHYS_STACK + 0x00400000; 65 | guestloader_stacklimit_svc = .; 66 | guestloader_stacktop_irq = .; 67 | . = PHYS_STACK + 0x00800000; 68 | guestloader_stacklimit_irq = .; 69 | 70 | restore_start = 0x70000000; 71 | restore_guest_start = restore_start + 0x00500000; 72 | restore_guest_end = restore_guest_start + (guest_end - guest_start); 73 | restore_end = restore_start + (guestloader_end - loader_start); 74 | 75 | } 76 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_arndale/guestos/ucos-ii/Makefile: -------------------------------------------------------------------------------- 1 | .EXPORT_ALL_VARIABLES: 2 | 3 | DIRS = arch/arm drivers init lib 4 | TOPDIR := $(shell if [ "$$PWD" != "" ]; then echo $$PWD; else pwd; fi) 5 | 6 | CC = $(CROSS_COMPILE)gcc 7 | AS = $(CROSS_COMPILE)as 8 | LD = $(CROSS_COMPILE)ld 9 | AS = $(CROSS_COMPILE)as 10 | AR = $(CROSS_COMPILE)ar 11 | OBJCOPY = $(CROSS_COMPILE)objcopy 12 | OBJDUMP = $(CROSS_COMPILE)objdump 13 | NM = nm 14 | 15 | INCLUDES = -I. -I$(TOPDIR)/include 16 | 17 | CFLAGS = $(INCLUDES) -g -nostdinc -Wall -fno-builtin -fomit-frame-pointer -fPIC -fno-stack-protector 18 | LDFLAGS = -static -nostdlib -nostartfiles -nodefaultlibs 19 | OCFLAGS = -O binary -R .note -R .comment -S 20 | ELF32_LDFLAGS = -Wl,-T,ld-script 21 | BIN_FILE = rtos 22 | #CPPFLAGS += -march=armv7-a -marm 23 | CFLAGS += -mcpu=cortex-a15 -marm 24 | #CPPFLAGS += -DTHUMB2_KERNEL 25 | 26 | OBJ_FILES = arch/arm/arm.o drivers/drivers.o init/init.o 27 | LIBS = lib/lib.a kernel/kernel.a 28 | 29 | all: 30 | for i in $(DIRS) ; do make -C $$i || exit $? ; done 31 | $(CC) $(LDFLAGS) -o $(BIN_FILE).elf $(ELF32_LDFLAGS) $(OBJ_FILES) $(LIBS) -lgcc 32 | $(OBJCOPY) $(OCFLAGS) $(BIN_FILE).elf $(BIN_FILE).bin 33 | $(NM) $(BIN_FILE).elf |sort > $(BIN_FILE).map 34 | $(OBJDUMP) -D $(BIN_FILE).elf > $(BIN_FILE).dis 35 | 36 | force: 37 | 38 | clean: 39 | for i in $(DIRS) ; do make -C $$i clean; done 40 | rm -f $(BIN_FILE).elf 41 | rm -f $(BIN_FILE).map 42 | rm -f $(BIN_FILE).dis 43 | rm -f $(BIN_FILE).bin 44 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_arndale/guestos/ucos-ii/README.md: -------------------------------------------------------------------------------- 1 | How To Build 2 | 3 | - make CROSS_COMPILE=/arm-none-eabi- 4 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_arndale/guestos/ucos-ii/arch/Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_arndale/guestos/ucos-ii/arch/arm/Makefile: -------------------------------------------------------------------------------- 1 | OBJECTS = entry.o setup.o os_cpu_a.o os_cpu_c.o irq.o timer.o 2 | 3 | INCLUDES=../../include 4 | 5 | all : arm.o 6 | 7 | arm.o: $(MAKEFILE) $(OBJECTS) 8 | $(LD) -r -o arm.o $(OBJECTS) 9 | sync 10 | 11 | setup.o: $(MAKEFILE) setup.S 12 | $(CC) $(CFLAGS) -c setup.S 13 | 14 | entry.o: $(MAKEFILE) entry.S 15 | $(CC) $(CFLAGS) -c entry.S 16 | 17 | os_cpu_a.o: $(MAKEFILE) os_cpu_a.S 18 | $(CC) $(CFLAGS) -c os_cpu_a.S 19 | 20 | os_cpu_c.o: os_cpu_c.c 21 | $(CC) $(CFLAGS) -I$(INCLUDES) -c os_cpu_c.c 22 | 23 | irq.o: irq.c 24 | $(CC) $(CFLAGS) -I$(INCLUDES) -c irq.c 25 | 26 | timer.o: timer.c 27 | $(CC) $(CFLAGS) -I$(INCLUDES) -c timer.c 28 | 29 | clean: 30 | rm -f *.o 31 | 32 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_arndale/guestos/ucos-ii/arch/arm/entry.S: -------------------------------------------------------------------------------- 1 | 2 | .extern do_IRQ 3 | 4 | .text 5 | .global start_ram 6 | start_ram: 7 | b guest_entry 8 | .type start_ram, %function 9 | guest_entry: 10 | cpsid i 11 | /* Initialize bss section */ 12 | ldr r2, =begin_bss 13 | ldr r3, =end_bss 14 | mov r0, #0 15 | 1: str r0, [r2], #4 @ clear bss 16 | cmp r2, r3 17 | blo 1b 18 | 19 | @ sp for guest svc mode 20 | ldr sp, =guest_stacklimit_svc 21 | 22 | @ sp_irq 23 | msr cpsr_c, #0xd2 24 | ldr sp, =guest_stacklimit_irq 25 | 26 | @ sp for guest (system/user) 27 | msr cpsr_c, #0xdf 28 | ldr sp, =guest_stacklimit 29 | 30 | @ exception vector 31 | ldr r0, =nonsecure_vector 32 | mcr p15, 0, r0, c12, c0, 0 @ VBAR 33 | 34 | b start_up 35 | 36 | .align 5 37 | nonsecure_vector: 38 | .word 0 /* reset */ 39 | b arm_undef_exception 40 | b arm_swi_exception 41 | b arm_prefetch_abort_exception 42 | b arm_data_abort_exception 43 | nop 44 | b arm_irq_exception 45 | b arm_fiq_exception 46 | 47 | arm_undef_exception: 48 | movs pc, lr 49 | 50 | arm_swi_exception: 51 | ldmfd sp!, {r0} 52 | stmfd sp!, {r0, lr} 53 | mrs r0, SPSR 54 | stmfd sp!, {r0} 55 | ldr r0, [lr, #-4] 56 | bic r0, r0, #0xff000000 57 | cmp r0, #0x00 58 | bne return_swi_handler 59 | return_swi_handler: 60 | ldmfd sp!, {r0} 61 | msr SPSR_cxsf, r0 62 | ldmfd sp!, {r0,lr} 63 | movs pc, lr 64 | 65 | arm_prefetch_abort_exception: 66 | b arm_prefetch_abort_exception 67 | 68 | arm_data_abort_exception: 69 | b arm_data_abort_exception 70 | 71 | arm_fiq_exception: 72 | subs pc, lr, #4 73 | 74 | arm_irq_exception: 75 | mrs r8, spsr 76 | stmfd sp!, {r0-r3} 77 | mov r2, sp 78 | add sp, sp,#16 79 | sub r3,lr,#4 80 | mov r1, r8 81 | orr r1, r1, #0x80 82 | msr SPSR, r1 83 | ldr r0,=irq_svc_handler 84 | movs pc,r0 85 | 86 | irq_svc_handler: 87 | stmfd sp!,{r3} 88 | stmfd sp!,{r4-r12,lr} 89 | mov r4,r2 90 | ldmfd r4!,{r0-r3} 91 | stmfd sp!,{r0-r3} 92 | mrs r5,CPSR 93 | bic r5, r5, #0x80 // I bit clear 94 | stmfd sp!,{r5} 95 | ldr r0,=OSIntNesting 96 | ldrb r1,[r0] 97 | add r1,r1,#1 98 | strb r1,[r0] 99 | 100 | mov r0, sp 101 | bl do_IRQ 102 | bl OSIntExit 103 | ldmfd sp!,{r0} 104 | msr SPSR,r0 105 | ldmfd sp!,{r0 - r12, lr , pc}^ 106 | 107 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_arndale/guestos/ucos-ii/arch/arm/os_cpu_a.S: -------------------------------------------------------------------------------- 1 | .extern OSTCBCur 2 | .extern OSTaskSwHook 3 | .extern OSTCBHighRdy 4 | .extern OSPrioCur 5 | .extern OSPrioHighRdy 6 | 7 | #define NOINT 0xc0 8 | 9 | .globl OSIntCtxSw 10 | 11 | .globl OSCtxSw 12 | OSCtxSw: 13 | stmfd sp!,{lr} // push resume address 14 | stmfd sp!,{r0 - r12, lr} // push rest context 15 | mrs r0,SPSR 16 | bic r0, r0, #0x80 // F bit Clear 17 | 18 | stmfd sp!,{r0} // push CPSR 19 | 20 | ldr r0,=OSTCBCur // r0 <= &OSTCBCur 21 | ldr r0,[r0] // r0 <= OSTCBCur 22 | str sp,[r0] // OSTCBCur->OSTCBStkPtr = sp 23 | 24 | bl OSTaskSwHook // Call user defined task switch hook 25 | 26 | ldr r0,=OSTCBCur // r0 <= &OSTCBCur 27 | ldr r1,=OSTCBHighRdy // r1 <= &OSTCBHighRdy 28 | 29 | ldr r2,[r1] // r2 <= OSTCBHighRdy 30 | str r2,[r0] // OSTCBCur = OSTCBHighRdy 31 | 32 | ldr r0,=OSPrioCur // r0 <= &OSPrioCur 33 | ldr r1,=OSPrioHighRdy // r1 <= &OSPrioHighRdy 34 | 35 | ldrb r3,[r1] // r3 <= OSPrioHighRdy 36 | strb r3,[r0] // OSPrioCur = OSPrioHighRdy 37 | 38 | ldr sp,[r2] // sp <= OSTCBHighRdy->OSTCBStkPtr 39 | ldmfd sp!,{r0} // restore SP... 40 | 41 | msr SPSR,r0 42 | ldmfd sp!,{r0 - r12, lr,pc} // Load task's context & SPSR-> CPSR & Run task 43 | 44 | 45 | OSIntCtxSw: 46 | add sp,sp,#16 47 | ldr r0,=OSTCBCur 48 | ldr r0,[r0] 49 | str sp,[r0] 50 | ldr r0,=OSTCBCur 51 | ldr r1,=OSTCBHighRdy 52 | ldr r2,[r1] 53 | str r2,[r0] 54 | ldr r0,=OSPrioCur 55 | ldr r1,=OSPrioHighRdy 56 | ldrb r3,[r1] 57 | strb r3,[r0] 58 | ldr sp,[r2] 59 | ldmfd sp!,{r0} 60 | msr spsr,r0 61 | ldmfd sp!,{r0 - r12,lr,pc}^ 62 | 63 | .extern OSTaskSwHook 64 | .extern OSRunning 65 | .extern OSTCBHighRdy 66 | .extern OSStartHighRdy 67 | .globl OSStartHighRdy 68 | 69 | OSStartHighRdy: 70 | ldr r0,=OSRunning /* Indicate that multitasking has started */ 71 | mov r1,#1 72 | strb r1,[r0] 73 | ldr r0,=OSTCBHighRdy /* r0 <= &OSTCBHighRdy */ 74 | ldr r0,[r0] /* r0 <= OSTCBHighRdy */ 75 | ldr sp,[r0] /* sp <= OSTCBHighRdy->OSTCBStkPtr */ 76 | ldmfd sp!,{r0} /* restore SP... */ 77 | msr CPSR,r0 78 | ldmfd sp!,{r0 - r12, lr , pc} /* Load task's context & Run task */ 79 | 80 | .global OSCPUSaveSR 81 | OSCPUSaveSR: 82 | mrs r0,CPSR 83 | orr r1,r0,#0x80 84 | msr CPSR_c,r1 85 | bx lr 86 | 87 | 88 | .global OSCPURestoreSR 89 | OSCPURestoreSR: 90 | msr CPSR_c,r0 91 | bx lr 92 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_arndale/guestos/ucos-ii/arch/arm/setup.S: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define C15_C0_M 0x0001 4 | #define C15_C0_A 0x0002 5 | #define C15_C0_C 0x0004 6 | #define C15_C0_W 0x0008 7 | #define C15_C0_B 0x0080 8 | #define C15_C0_S 0x0100 9 | #define C15_C0_R 0x0200 10 | #define C15_C0_Z 0x0800 11 | #define C15_C0_I 0x1000 12 | #define C15_C0_V 0x2000 13 | 14 | #define ARM_MODE_MASK 0x1F 15 | #define ARM_MODE_SVC 0x13 16 | #define ARM_MODE_UND 0x1B 17 | #define ARM_MODE_ABT 0x17 18 | #define ARM_MODE_IRQ 0x12 19 | #define ARM_MODE_FIQ 0x11 20 | #define ARM_MODE_USR 0x10 21 | #define ARM_MODE_SYS 0x1F 22 | #define ARM_NOIRQ_SVC 0xD3 23 | #define ARM_NOIRQ_UND 0xDB 24 | #define ARM_NOIRQ_ABT 0xD7 25 | #define ARM_NOIRQ_IRQ 0xD2 26 | #define ARM_NOIRQ_FIQ 0xD1 27 | #define ARM_NOIRQ_USR 0xD0 28 | #define ARM_NOIRQ_SYS 0xDF 29 | 30 | #define ARM_IRQ_BIT 0x080 31 | #define ARM_FIQ_BIT 0x040 32 | #define ARM_A_BIT 0x100 33 | 34 | .globl start_up 35 | .extern main 36 | 37 | start_up: 38 | bl main 39 | 40 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_arndale/guestos/ucos-ii/arch/arm/timer.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | static void do_timer_interrupt() 9 | { 10 | OSTimeTick(); 11 | } 12 | 13 | void init_time(void) 14 | { 15 | request_irq(30, do_timer_interrupt, 0, "timer", NULL); 16 | } 17 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_arndale/guestos/ucos-ii/drivers/Makefile: -------------------------------------------------------------------------------- 1 | OBJECTS = serial.o gpio.o 2 | MAKEFILE= Makefile 3 | INCLUDES=../include 4 | 5 | all: drivers.o 6 | 7 | drivers.o : $(OBJECTS) 8 | $(LD) -r -o drivers.o $(OBJECTS) 9 | sync 10 | 11 | serial.o : serial.c 12 | $(CC) $(CFLAGS) -I$(INCLUDES) -c serial.c 13 | 14 | gpio.o : gpio.c 15 | $(CC) $(CFLAGS) -I$(INCLUDES) -c gpio.c 16 | 17 | clean: 18 | rm -f *.o 19 | 20 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_arndale/guestos/ucos-ii/drivers/serial.c: -------------------------------------------------------------------------------- 1 | #include "includes.h" 2 | 3 | /* UART Base Address determined by Hypervisor's Stage 2 Translation Table */ 4 | #define UART0 0x12C20000 5 | 6 | /* baudrate rest value */ 7 | union br_rest { 8 | unsigned short slot; /* udivslot */ 9 | unsigned char value; /* ufracval */ 10 | }; 11 | 12 | struct s5p_uart { 13 | unsigned int ulcon; 14 | unsigned int ucon; 15 | unsigned int ufcon; 16 | unsigned int umcon; 17 | unsigned int utrstat; 18 | unsigned int uerstat; 19 | unsigned int ufstat; 20 | unsigned int umstat; 21 | unsigned char utxh; 22 | unsigned char res1[3]; 23 | unsigned char urxh; 24 | unsigned char res2[3]; 25 | unsigned int ubrdiv; 26 | union br_rest rest; 27 | unsigned char res3[0xffd0]; 28 | }; 29 | 30 | /* Exynos 5250 UART register macros */ 31 | #define UTXH 0x20 32 | #define UFSTAT 0x18 33 | #define UART_BASE (UART0 + UTXH) 34 | 35 | #define RX_FIFO_COUNT_MASK 0xff 36 | #define RX_FIFO_FULL_MASK (1 << 8) 37 | #define TX_FIFO_FULL_MASK (1 << 24) 38 | 39 | #define readl(a) (*(volatile unsigned int *)(a)) 40 | #define readb(a) (*(volatile unsigned char *)(a)) 41 | #define writeb(v, a) (*(volatile unsigned char *)(a) = (v)) 42 | 43 | 44 | static int serial_err_check(int op) 45 | { 46 | struct s5p_uart *const uart = (struct s5p_uart *) UART0; 47 | unsigned int mask; 48 | 49 | if(op) 50 | mask = 0x8; 51 | else 52 | mask = 0xf; 53 | 54 | return readl(&uart->uerstat) & mask; 55 | 56 | } 57 | 58 | static inline int s5p_uart_divslot(void) 59 | { 60 | return 0; 61 | } 62 | 63 | 64 | void uart_tx_char(char c) 65 | { 66 | struct s5p_uart *const uart = (struct s5p_uart *) UART0; 67 | 68 | 69 | while((readl(&uart->ufstat) & TX_FIFO_FULL_MASK)) { 70 | if (serial_err_check(1)) 71 | return; 72 | } 73 | 74 | writeb(c, &uart->utxh); 75 | } 76 | 77 | void uart_out_char_check_CR(const char c) 78 | { 79 | uart_tx_char(c); 80 | if (c == '\n') 81 | uart_tx_char('\r'); 82 | } 83 | 84 | int uart_out_str(char *str, int size) 85 | { 86 | int lp; 87 | 88 | for (lp = 0; lp < size; lp++) 89 | uart_tx_char(str[lp]); 90 | 91 | return lp; 92 | } 93 | 94 | int uart_out_str_check_CR(char *str, int size) 95 | { 96 | int lp; 97 | 98 | for (lp = 0; lp < size; lp++) 99 | uart_out_char_check_CR(str[lp]); 100 | 101 | return lp; 102 | } 103 | 104 | 105 | int serial_getc_dev(void) 106 | { 107 | struct s5p_uart * const uart = (struct s5p_uart *) UART0; 108 | 109 | /* wait for character to arrive */ 110 | while (!(readl(&uart->ufstat) & (RX_FIFO_COUNT_MASK | RX_FIFO_FULL_MASK))) { 111 | if (serial_err_check(0)) 112 | return 0; 113 | } 114 | 115 | return (int) (readb(&uart->urxh) & 0xff); 116 | } 117 | 118 | char uart_rx_char() 119 | { 120 | return 0; 121 | } 122 | 123 | void uart_init() 124 | { 125 | return; 126 | } 127 | 128 | 129 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_arndale/guestos/ucos-ii/include/asm-arm/arch_types.h: -------------------------------------------------------------------------------- 1 | #ifndef __ARCH_TYPES_H__ 2 | #define __ARCH_TYPES_H__ 3 | 4 | typedef unsigned int uint32_t; 5 | typedef unsigned short uint16_t; 6 | typedef unsigned long long uint64_t; 7 | typedef unsigned char uint8_t; 8 | #endif 9 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_arndale/guestos/ucos-ii/include/asm-arm/asm-arm_inline.h: -------------------------------------------------------------------------------- 1 | #ifndef __ASM_ARM_INLINE__ 2 | #define __ASM_ARM_INLINE__ 3 | 4 | #define sev() __asm__ __volatile__ ("sev" : : : "memory") 5 | #define wfe() __asm__ __volatile__ ("wfe" : : : "memory") 6 | #define wfi() __asm__ __volatile__ ("wfi" : : : "memory") 7 | 8 | #define isb() __asm__ __volatile__ ("isb" : : : "memory") 9 | #define dsb() __asm__ __volatile__ ("dsb" : : : "memory") 10 | #define dmb() __asm__ __volatile__ ("dmb" : : : "memory") 11 | 12 | #define irq_enable() asm volatile("cpsie i" : : : "memory") 13 | #define asm_clz(x) ({ uint32_t rval; asm volatile(\ 14 | " clz %0, %1\n\t" \ 15 | : "=r" (rval) : "r" (x) : ); rval; }) 16 | 17 | 18 | #define irq_disable() asm volatile ("cpsid i" : : : "memory") 19 | 20 | #define irq_disabled() ({ unsigned long tf; \ 21 | asm volatile (" mrs %0, cpsr\n\t" \ 22 | : "=r" (tf) \ 23 | : \ 24 | : "memory", "cc"); \ 25 | (tf & CPSR_IRQ_DISABLED) ? TRUE : FALSE; \ 26 | }) 27 | 28 | 29 | #define irq_save(flags) do { \ 30 | asm volatile ( \ 31 | "mrs %0, cpsr\n\t" \ 32 | "cpsid i\n\t" \ 33 | : "=r" ((flags)) : : "memory", "cc"); \ 34 | } while (0) 35 | 36 | 37 | #define irq_restore(flags) do { \ 38 | asm volatile (" msr cpsr_c, %0" \ 39 | : : "r" ((flags)) : "memory", "cc"); \ 40 | } while (0) 41 | 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_arndale/guestos/ucos-ii/include/asm-arm/board.h: -------------------------------------------------------------------------------- 1 | #ifndef _BOARD_H_ 2 | #define _BOARD_H_ 3 | 4 | #define SMI_RAM_BASE 0x80000000 5 | #define RAM_BASE 0x80000000 6 | #define RAM_SIZE SIZE_64M 7 | 8 | #define SMI_RAM_SIZE 0x04000000 9 | #define FIQSTACKEND SMI_RAM_BASE+SMI_RAM_SIZE-4 10 | #define SVCSTACKEND FIQSTACKEND-0x00020000 11 | #define IRQSTACKEND SVCSTACKEND-0x00020000 12 | #define USERSTACKEND IRQSTACKEND-0x00020000 13 | 14 | #endif /* _BOARD_H_ */ 15 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_arndale/guestos/ucos-ii/include/asm-arm/irq.h: -------------------------------------------------------------------------------- 1 | #ifndef _INTERRUPT_H_ 2 | #define _INTERRUPT_H_ 3 | 4 | #include 5 | 6 | struct irqaction { 7 | void (*handler)(); 8 | unsigned long flags; 9 | const char *name; 10 | struct irqaction *next; 11 | int irq; 12 | void *dev_id; 13 | }; 14 | 15 | struct irq_desc { 16 | struct irqaction *action; /* IRQ action list */ 17 | unsigned int status; /* IRQ status */ 18 | unsigned int depth; /* nested irq disables */ 19 | }; 20 | 21 | extern struct irq_desc irq_desc[34]; 22 | 23 | extern void unhand(); 24 | void init_IRQ(); 25 | int request_irq(unsigned int irq, void (*handler)(void), 26 | unsigned long irqflags, const char *devname, void *dev_id); 27 | void free_irq(unsigned int irq, void *dev_id); 28 | 29 | 30 | #endif /* _INTERRUPT_H_ */ 31 | 32 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_arndale/guestos/ucos-ii/include/asm-arm/irqs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * linux/include/asm-arm/arch-s3c6410/irqs.h 3 | * 4 | * Copyright (C) 1999 ARM Limited 5 | * Copyright (C) 2000 Deep Blue Solutions Ltd. 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | */ 21 | 22 | #ifndef __ARM_IRQS_H__ 23 | #define __ARM_IRQS_H__ 24 | 25 | 26 | #endif 27 | 28 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_arndale/guestos/ucos-ii/include/asm-arm/ptrace.h: -------------------------------------------------------------------------------- 1 | #ifndef __ASM_ARM_PTRACE_H 2 | #define __ASM_ARM_PTRACE_H 3 | 4 | #define PTRACE_GETREGS 12 5 | #define PTRACE_SETREGS 13 6 | #define PTRACE_GETFPREGS 14 7 | #define PTRACE_SETFPREGS 15 8 | 9 | #define PTRACE_GETWMMXREGS 18 10 | #define PTRACE_SETWMMXREGS 19 11 | 12 | #define PTRACE_OLDSETOPTIONS 21 13 | 14 | #define PTRACE_GET_THREAD_AREA 22 15 | /* 16 | * PSR bits 17 | */ 18 | #define USR26_MODE 0x00000000 19 | #define FIQ26_MODE 0x00000001 20 | #define IRQ26_MODE 0x00000002 21 | #define SVC26_MODE 0x00000003 22 | #define USR_MODE 0x00000010 23 | #define FIQ_MODE 0x00000011 24 | #define IRQ_MODE 0x00000012 25 | #define SVC_MODE 0x00000013 26 | #define ABT_MODE 0x00000017 27 | #define UND_MODE 0x0000001b 28 | #define SYSTEM_MODE 0x0000001f 29 | #define MODE32_BIT 0x00000010 30 | #define MODE_MASK 0x0000001f 31 | #define PSR_T_BIT 0x00000020 32 | #define PSR_F_BIT 0x00000040 33 | #define PSR_I_BIT 0x00000080 34 | #define PSR_J_BIT 0x01000000 35 | #define PSR_Q_BIT 0x08000000 36 | #define PSR_V_BIT 0x10000000 37 | #define PSR_C_BIT 0x20000000 38 | #define PSR_Z_BIT 0x40000000 39 | #define PSR_N_BIT 0x80000000 40 | #define PCMASK 0 41 | 42 | /* 43 | * Groups of PSR bits 44 | */ 45 | #define PSR_f 0xff000000 /* Flags */ 46 | #define PSR_s 0x00ff0000 /* Status */ 47 | #define PSR_x 0x0000ff00 /* Extension */ 48 | #define PSR_c 0x000000ff /* Control */ 49 | 50 | 51 | /* this struct defines the way the registers are stored on the 52 | stack during a system call. */ 53 | 54 | struct pt_regs { 55 | long cpsr; 56 | long r0; 57 | long r1; 58 | long r2; 59 | long r3; 60 | long r4; 61 | long r5; 62 | long r6; 63 | long r7; 64 | long r8; 65 | long r9; 66 | long r10; 67 | long r11; 68 | long r12; 69 | long lr; 70 | long pc; 71 | }; 72 | 73 | 74 | #endif 75 | 76 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_arndale/guestos/ucos-ii/include/asm-arm/pwm_priv.h: -------------------------------------------------------------------------------- 1 | #ifndef __PWM_PRIV_H__ 2 | #define __PWM_PRIV_H__ 3 | 4 | #define PWMBASE (void*)0x12DD0000 5 | #define PWM_TIMERREG(x) (PWMBASE + (x)) 6 | #define TCFG0 PWM_TIMERREG(0x00) 7 | #define TCFG1 PWM_TIMERREG(0x04) 8 | #define TCON PWM_TIMERREG(0x08) 9 | #define PWM_TIMERREG2(tmr,reg) PWM_TIMERREG((reg)+0x0c+((tmr)*0x0c)) 10 | #define CSTAT PWM_TIMERREG(0x44) 11 | #define TCNTB(tmr) PWM_TIMERREG2(tmr, 0x00) 12 | #define TCMPB(tmr) PWM_TIMERREG2(tmr, 0x04) 13 | #define TCNTO(tmr) PWM_TIMERREG2(tmr, (((tmr) == 4) ? 0x04 : 0x08)) 14 | #define TCON_T4RELOAD (1<<22) 15 | #define TCON_T4MANUALUPD (1<<21) 16 | #define TCON_T4START (1<<20) 17 | #define TCON_T0RELOAD (1<<3) 18 | #define TCON_T0MANUALUPD (1<<1) 19 | #define TCON_T0START (1<<0) 20 | #define TCON_T2RELOAD (1<<15) 21 | #define TCON_T2MANUALUPD (1<<13) 22 | #define TCON_T2START (1<<12) 23 | #define TCON_T1MANUALUPD (1<<9) 24 | #define TCON_T1START (1<<8) 25 | #define TCON_T1RELOAD (1<<11) 26 | 27 | #endif 28 | 29 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_arndale/guestos/ucos-ii/include/asm-arm/timer.h: -------------------------------------------------------------------------------- 1 | #ifndef _TIMER_H 2 | #define _TIMER_H 3 | 4 | void init_time(void); 5 | 6 | #endif /* _TIMER_H */ 7 | 8 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_arndale/guestos/ucos-ii/include/includes.h: -------------------------------------------------------------------------------- 1 | /* 2 | ********************************************************************************************************* 3 | * uC/OS-II 4 | * The Real-Time Kernel 5 | * 6 | * (c) Copyright 1992-1999, Jean J. Labrosse, Weston, FL 7 | * All Rights Reserved 8 | * 9 | * MASTER INCLUDE FILE 10 | ********************************************************************************************************* 11 | */ 12 | 13 | #ifndef _INCLUDES_H_ 14 | #define _INCLUDES_H_ 15 | 16 | #include "ucos_ii.h" 17 | #include "asm-arm/os_cpu.h" 18 | #include "asm-arm/io-exynos.h" 19 | #include "os_cfg.h" 20 | 21 | #endif /* INCLUDES_H_ */ 22 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_arndale/guestos/ucos-ii/include/stdarg.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __STDARG_H 3 | #define __STDARG_H 4 | 5 | 6 | typedef char *va_list; 7 | # define va_start(ap, p) (ap = (char *) (&(p)+1)) 8 | # define va_arg(ap, type) ((type *) (ap += sizeof(type)))[-1] 9 | # define va_end(ap) 10 | 11 | #endif /* __STDARG_H */ 12 | 13 | #if __FIRST_ARG_IN_AX__ 14 | #error First arg is in a register, stdarg.h cannot take its address 15 | #endif 16 | 17 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_arndale/guestos/ucos-ii/include/string.h: -------------------------------------------------------------------------------- 1 | #ifndef _STRING_HEADER_ 2 | #define _STRING_HEADER_ 3 | 4 | #include 5 | 6 | extern char * ___strtok; 7 | extern char * strpbrk(const char *,const char *); 8 | extern char * strtok(char *,const char *); 9 | extern char * strsep(char **,const char *); 10 | extern __kernel_size_t strspn(const char *,const char *); 11 | extern char * strcpy(char *,const char *); 12 | extern char * strncpy(char *,const char *, __kernel_size_t); 13 | extern char * strcat(char *, const char *); 14 | extern char * strncat(char *, const char *, __kernel_size_t); 15 | extern int strcmp(const char *,const char *); 16 | extern int strncmp(const char *,const char *,__kernel_size_t); 17 | extern int strnicmp(const char *, const char *, __kernel_size_t); 18 | extern char * strchr(const char *,int); 19 | extern char * strrchr(const char *,int); 20 | extern char * strstr(const char *,const char *); 21 | extern __kernel_size_t strlen(const char *); 22 | extern __kernel_size_t strnlen(const char *,__kernel_size_t); 23 | extern void * memset(void *,int,__kernel_size_t); 24 | extern void * memcpy(void *,const void *,__kernel_size_t); 25 | extern void * memmove(void *,const void *,__kernel_size_t); 26 | extern void * memscan(void *,int,__kernel_size_t); 27 | extern int memcmp(const void *,const void *,__kernel_size_t); 28 | extern void * memchr(const void *,int,__kernel_size_t); 29 | extern unsigned long strtoul(const char *p, char **out_p, int base); 30 | extern char* itoa(int value, char *string, int radix); 31 | 32 | extern void UpperStr( char *Str ); 33 | extern void LowerStr( char *Str ); 34 | 35 | #endif // _STRING_HEADER_ 36 | 37 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_arndale/guestos/ucos-ii/include/types.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _TYPES_H_4782374832742374327423 3 | #define _TYPES_H_4782374832742374327423 4 | 5 | typedef unsigned long ulong; 6 | typedef unsigned short ushort; 7 | typedef unsigned char uchar; 8 | typedef unsigned int uint; 9 | 10 | #ifndef __cplusplus 11 | typedef int bool; 12 | #define true 1 13 | #define false 0 14 | #endif 15 | 16 | typedef enum { 17 | VAR_LONG=32, 18 | VAR_SHORT=16, 19 | VAR_CHAR=8 20 | } VAR_TYPE; 21 | 22 | #ifndef NULL 23 | #define NULL (void *)0 24 | #endif 25 | 26 | #endif 27 | 28 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_arndale/guestos/ucos-ii/init/Makefile: -------------------------------------------------------------------------------- 1 | INCLUDES = ../include 2 | OBJECTS = main.o 3 | MAKEFILE=Makefile 4 | 5 | all: init.o 6 | 7 | init.o : $(MAKEFILE) $(OBJECTS) 8 | $(LD) -r -o init.o $(OBJECTS) 9 | sync 10 | 11 | 12 | main.o: main.c 13 | $(CC) $(CFLAGS) -I$(INCLUDES) -c main.c 14 | 15 | clean: 16 | rm -f *.o 17 | 18 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_arndale/guestos/ucos-ii/kernel/Makefile: -------------------------------------------------------------------------------- 1 | INCLUDES = ../include 2 | OBJECTS = ucos_ii.o 3 | #CFLAGS = -c -Wall-fno-builtin 4 | #-fno-omit-frame-pointer 5 | 6 | all: kernel.a 7 | 8 | kernel.a : $(OBJECTS) 9 | $(AR) rcs kernel.a $(OBJECTS) 10 | sync 11 | 12 | 13 | ucos_ii.o: $(INCLUDES)/ucos_ii.h \ 14 | os_dbg.c os_core.c os_flag.c os_mbox.c \ 15 | os_mutex.c os_q.c os_sem.c os_task.c \ 16 | os_time.c os_mem.c 17 | $(CC) $(CFLAGS) -I$(INCLUDES) -c ucos_ii.c 18 | 19 | clean: 20 | rm -f *.o 21 | rm -f *.a 22 | 23 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_arndale/guestos/ucos-ii/kernel/README.md: -------------------------------------------------------------------------------- 1 | You can get the code from http://www.micrium.com. 2 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_arndale/guestos/ucos-ii/kernel/kernel.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kesl/khypervisor/722d32a42e08eba144dc2fa1a528c1369055204c/platform-device/cortex_a15x2_arndale/guestos/ucos-ii/kernel/kernel.a -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_arndale/guestos/ucos-ii/ld-script: -------------------------------------------------------------------------------- 1 | OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm") 2 | OUTPUT_ARCH(arm) 3 | ENTRY(start_ram) 4 | PHYS_OFFSET = 0x40000000; 5 | GUEST_OFFSET = 0x40000000; 6 | GUEST_STACK = 0x4F000000; 7 | SECTIONS 8 | { 9 | . = ALIGN(4); 10 | . = 0x40000000; 11 | .text : 12 | { 13 | arch/arm/arm.o(.text) 14 | *(.text) 15 | } 16 | 17 | .= ALIGN(4); 18 | .rodata : { 19 | *(.rodata) 20 | } 21 | .= ALIGN(4); 22 | .data : { 23 | *(.data) 24 | } 25 | .= ALIGN(4); 26 | begin_bss = .; 27 | .bss : { 28 | *(.bss) 29 | } 30 | end_bss = .; 31 | _end = .; 32 | 33 | . = GUEST_STACK; 34 | guest_stacktop_svc = .; 35 | . = GUEST_STACK + 0x00400000; 36 | guest_stacklimit_svc = .; 37 | guest_stacktop_irq = .; 38 | . = GUEST_STACK + 0x00800000; 39 | guest_stacklimit_irq = .; 40 | guest_stacktop = .; 41 | . = GUEST_STACK + 0x01000000; 42 | guest_stacklimit = .; 43 | } 44 | 45 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_arndale/guestos/ucos-ii/lib/Makefile: -------------------------------------------------------------------------------- 1 | INCLUDES = ../include 2 | OBJECTS =vsprintf.o string.o printf.o 3 | MAKEFILE=Makefile 4 | 5 | 6 | all: lib.a 7 | 8 | #lib.o : $(MAKEFILE) $(OBJECTS) 9 | $(LD) -r -o lib.o $(OBJECTS) 10 | sync 11 | 12 | lib.a : $(MAKEFILE) $(OBJECTS) 13 | $(AR) rcs lib.a $(OBJECTS) 14 | sync 15 | 16 | 17 | vsprintf.o : vsprintf.c 18 | $(CC) $(CFLAGS) -I$(INCLUDES) -c vsprintf.c 19 | 20 | string.o : string.c 21 | $(CC) $(CFLAGS) -I$(INCLUDES) -c string.c 22 | 23 | printf.o : printf.c 24 | $(CC) $(CFLAGS) -I$(INCLUDES) -c printf.c 25 | 26 | clean: 27 | rm -f *.o 28 | rm -f *.a 29 | 30 | 31 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_arndale/guestos/ucos-ii/lib/printf.c: -------------------------------------------------------------------------------- 1 | #include "stdio.h" 2 | #include "includes.h" 3 | 4 | #define HIS_MAX 8 5 | 6 | char HisBuff[HIS_MAX][32] = { { 0, }, }; 7 | int HisCount = 0; 8 | int HisIndex = 0; 9 | 10 | void uart_out_char_check_CR(const char c); 11 | int uart_out_str_check_CR(char *str, int size); 12 | void uart_tx_char(char c); 13 | 14 | int putc(char c) 15 | { 16 | uart_out_char_check_CR( c ); 17 | return 1; 18 | } 19 | 20 | int putx(char c) 21 | { 22 | uart_tx_char(c); 23 | return 1; 24 | } 25 | 26 | int printf(const char *fmt, ...) 27 | { 28 | char buffer[1024]; 29 | va_list ap; 30 | int len; 31 | 32 | va_start(ap, fmt); 33 | len = vsprintf(buffer, fmt, ap); 34 | va_end(ap); 35 | 36 | uart_out_str_check_CR(buffer, len); 37 | 38 | return len; 39 | } 40 | 41 | extern char uart_rx_char(); 42 | int getc(void) 43 | { 44 | return uart_rx_char(); 45 | } 46 | 47 | int gets(char *s) 48 | { 49 | int cnt = 0; 50 | char c; 51 | 52 | while ((c = getc()) != CR) { 53 | if (c != BS) { 54 | cnt++; 55 | *s++ = c; 56 | printf("%c", c); 57 | } else { 58 | if (cnt > 0) { 59 | cnt--; 60 | *s-- = ' '; 61 | printf("\b \b"); 62 | } 63 | 64 | } 65 | } 66 | *s = 0; 67 | 68 | return (cnt); 69 | } 70 | 71 | int serial_gets(char *buf, int size) 72 | { 73 | int i; 74 | for (i = 0; i < size; i++) 75 | buf[i] = getc(); 76 | 77 | return 0; 78 | } 79 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_arndale/include/mct.h: -------------------------------------------------------------------------------- 1 | #ifndef __MCT_H__ 2 | #define __MCT_H__ 3 | /* 4 | * To operate Generic timer's system counter register 5 | * on Arndale board, call mct_init function. 6 | */ 7 | 8 | void mct_init(void); 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_arndale/include/pwm.h: -------------------------------------------------------------------------------- 1 | #ifndef __PWM_H__ 2 | #define __PWM_H__ 3 | #include "arch_types.h" 4 | #include "hvmm_types.h" 5 | typedef void (*pwm_timer_callback_t)(void *pdata); 6 | 7 | /* Initialize pwm timer 1 */ 8 | void pwm_timer_init(); 9 | /* enable the timer. */ 10 | hvmm_status_t pwm_timer_enable_int(); 11 | /* Disable the timer. */ 12 | hvmm_status_t pwm_timer_disable_int(); 13 | /* 14 | * Sets time interval. Converts from microseconds 15 | * to count and sets time interval. 16 | */ 17 | hvmm_status_t pwm_timer_set_interval(uint32_t tval); 18 | /* Enables timer irq. */ 19 | hvmm_status_t pwm_timer_enable_irq(); 20 | /* Adds callback funtion. Called when occur timer interrupt */ 21 | hvmm_status_t pwm_timer_set_callback(pwm_timer_callback_t callback); 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_arndale/model.lds.S: -------------------------------------------------------------------------------- 1 | /* 2 | * model.lds.S - simple linker script for stand-alone Linux booting 3 | * 4 | * Copyright (C) 2011 ARM Limited. All rights reserved. 5 | * 6 | * Use of this source code is governed by a BSD-style license that can be 7 | * found in the LICENSE.txt file. 8 | */ 9 | 10 | OUTPUT_FORMAT("elf32-littlearm") 11 | OUTPUT_ARCH(arm) 12 | TARGET(binary) 13 | ENTRY(start) 14 | 15 | #include "k-hypervisor-config.h" 16 | 17 | MON_STACK = CFG_MEMMAP_MON_OFFSET + MON_SIZE; 18 | SEC_STACKTOP = MON_STACK + MON_STACK_SIZE; 19 | /* NS.SVC mode code space */ 20 | GUEST0_STACK = CFG_MEMMAP_GUEST0_OFFSET + GUEST_SIZE_MAX; 21 | GUEST1_STACK = CFG_MEMMAP_GUEST1_OFFSET + GUEST_SIZE_MAX; 22 | #ifdef _SMP_ 23 | GUEST2_STACK = CFG_MEMMAP_GUEST2_OFFSET + GUEST_SIZE_MAX; 24 | GUEST3_STACK = CFG_MEMMAP_GUEST3_OFFSET + GUEST_SIZE_MAX; 25 | #endif 26 | 27 | SECTIONS { 28 | . = CFG_MEMMAP_PHYS_START; 29 | . = CFG_MEMMAP_PHYS_START + 0x8000 - 0x40; 30 | . = CFG_MEMMAP_PHYS_START + 0x00d00000; 31 | 32 | fs_start = .; 33 | fs_end = .; 34 | 35 | /* Guest 0 */ 36 | . = CFG_MEMMAP_GUEST0_OFFSET; 37 | _guest0_bin_start = .; 38 | _guest0_bin_end = .; 39 | 40 | . = GUEST0_STACK; 41 | guest0_stacktop = .; 42 | . = GUEST0_STACK + 0x01000000; 43 | guest0_stacklimit = .; 44 | 45 | /* Guest 1 */ 46 | . = CFG_MEMMAP_GUEST1_OFFSET; 47 | _guest1_bin_start = .; 48 | _guest1_bin_end = .; 49 | 50 | . = GUEST1_STACK; 51 | guest1_stacktop = .; 52 | . = GUEST1_STACK + 0x01000000; 53 | guest1_stacklimit = .; 54 | 55 | #ifdef _SMP_ 56 | /* Guest 2 */ 57 | . = CFG_MEMMAP_GUEST2_OFFSET; 58 | _guest2_bin_start = .; 59 | _guest2_bin_end = .; 60 | 61 | . = GUEST2_STACK; 62 | guest2_stacktop = .; 63 | . = GUEST2_STACK + 0x01000000; 64 | guest2_stacklimit = .; 65 | 66 | /* Guest 3 */ 67 | . = CFG_MEMMAP_GUEST3_OFFSET; 68 | _guest3_bin_start = .; 69 | _guest3_bin_end = .; 70 | 71 | . = GUEST3_STACK; 72 | guest3_stacktop = .; 73 | . = GUEST3_STACK + 0x01000000; 74 | guest3_stacklimit = .; 75 | #endif 76 | . = CFG_MEMMAP_MON_OFFSET; 77 | /* Put most of the actual boot loader code up in high memory 78 | * where it won't get overwritten by kernel, initrd or atags. 79 | */ 80 | .text : { 81 | *(.text); 82 | __vdev_module_high_start = .; 83 | *(.vdev_module0.init); 84 | __vdev_module_high_end = .; 85 | *(.vdev_module1.init); 86 | __vdev_module_middle_end = .; 87 | *(.vdev_module2.init); 88 | __vdev_module_low_end = .; 89 | } 90 | . = ALIGN(4); 91 | .rodata : { 92 | *(.rodata) 93 | } 94 | . = ALIGN(4); 95 | .data : { 96 | *(.data) 97 | } 98 | . = ALIGN(4); 99 | begin_bss = .; 100 | .bss : { 101 | *(.bss) 102 | } 103 | end_bss = .; 104 | 105 | . = MON_STACK; 106 | mon_stacktop = .; 107 | . = MON_STACK + MON_STACK_SIZE; 108 | mon_stacklimit = .; 109 | 110 | . = SEC_STACKTOP; 111 | sec_stacktop = .; 112 | . = SEC_STACKTOP + SEC_STACK_SIZE; 113 | sec_stacklimit = .; 114 | } 115 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_arndale/patch/linaro-android-ttysac1-formortor-diff.config: -------------------------------------------------------------------------------- 1 | 322c322 2 | < CONFIG_DEBUG_S3C_UART=1 3 | --- 4 | > CONFIG_DEBUG_S3C_UART=2 5 | 472c472 6 | < CONFIG_CMDLINE="console=tty0 console=ttySAC1,115200n8 androidboot.hardware=exynos5250-arndale rootwait ro rootdelay=3 init=/init androidboot.console=ttySAC1 fbdev=/dev/graphics/fb2 root=dev/ram0 rw mem=1024M mac=02:8e:2c:9b:f3:b8 coherent_pool=1M" 7 | --- 8 | > CONFIG_CMDLINE="console=tty0 console=ttySAC2,115200n8 androidboot.hardware=exynos5250-arndale rootwait ro rootdelay=3 init=/init androidboot.console=ttySAC2 fbdev=/dev/graphics/fb2 root=dev/ram0 rw mem=1024M mac=02:8e:2c:9b:f3:b8 coherent_pool=1M" 9 | 2165,2166c2165,2166 10 | < CONFIG_DEBUG_S3C_UART1=y 11 | < # CONFIG_DEBUG_S3C_UART2 is not set 12 | --- 13 | > # CONFIG_DEBUG_S3C_UART1 is not set 14 | > CONFIG_DEBUG_S3C_UART2=y 15 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_arndale/patch/u-boot-bootz.patch: -------------------------------------------------------------------------------- 1 | diff --git a/include/configs/arndale5250.h b/include/configs/arndale5250.h 2 | index 2daa3a6..8efb8a4 100644 3 | --- a/include/configs/arndale5250.h 4 | +++ b/include/configs/arndale5250.h 5 | @@ -100,6 +100,7 @@ 6 | /* Command definition*/ 7 | #include 8 | 9 | +#define CONFIG_CMD_BOOTZ 10 | #define CONFIG_CMD_PING 11 | #define CONFIG_CMD_ELF 12 | #define CONFIG_CMD_MMC 13 | @@ -137,11 +138,16 @@ 14 | /* secondary SMP pens */ 15 | #define CONFIG_SPL_SMP_PEN (CONFIG_SPL_TEXT_BASE + CONFIG_SPL_MAX_SIZE - 8) 16 | 17 | -#define CONFIG_BOOTCOMMAND "mmc read 40007000 451 2000; bootm 40007000" 18 | +#ifdef CONFIG_CMD_BOOTZ 19 | +#define CONFIG_BOOTCOMMAND "mmc read 80008000 C51 2000; bootz 80008000" 20 | +#define CONFIG_SYS_PROMPT "ZIMAGE: ARNDALE # " 21 | +#else 22 | +#define CONFIG_BOOTCOMMAND "mmc read 40008000 C51 2000; bootm 40008000" 23 | +#define CONFIG_SYS_PROMPT "UIMAGE: ARNDALE # " 24 | +#endif 25 | /* Miscellaneous configurable options */ 26 | #define CONFIG_SYS_LONGHELP /* undef to save memory */ 27 | #define CONFIG_SYS_HUSH_PARSER /* use "hush" command parser */ 28 | -#define CONFIG_SYS_PROMPT "ARNDALE5250 # " 29 | #define CONFIG_SYS_CBSIZE 256 /* Console I/O Buffer Size */ 30 | #define CONFIG_SYS_PBSIZE 384 /* Print Buffer Size */ 31 | #define CONFIG_SYS_MAXARGS 16 /* max number of command args */ 32 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_arndale/patch/u-boot_arndale.patch: -------------------------------------------------------------------------------- 1 | diff --git a/include/configs/arndale5250.h b/include/configs/arndale5250.h 2 | index 2daa3a6..2dc6595 100644 3 | --- a/include/configs/arndale5250.h 4 | +++ b/include/configs/arndale5250.h 5 | @@ -137,7 +137,7 @@ 6 | /* secondary SMP pens */ 7 | #define CONFIG_SPL_SMP_PEN (CONFIG_SPL_TEXT_BASE + CONFIG_SPL_MAX_SIZE - 8) 8 | 9 | -#define CONFIG_BOOTCOMMAND "mmc read 40007000 451 2000; bootm 40007000" 10 | +#define CONFIG_BOOTCOMMAND "mmc read 0xa0000000 451 800; mmc read 0x60000000 851 400; mmc read 0x90000000 851 400; go 0xa000004c" 11 | /* Miscellaneous configurable options */ 12 | #define CONFIG_SYS_LONGHELP /* undef to save memory */ 13 | #define CONFIG_SYS_HUSH_PARSER /* use "hush" command parser */ 14 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_rtsm/build/android_bmguest.sh: -------------------------------------------------------------------------------- 1 | #for bmguest + android linux 2 | 3 | export TARGET_PRODUCT="cortex_a15x2_rtsm" 4 | 5 | export GUEST_COUNT=2 6 | 7 | export HYPERVISOR_BIN="hvc-man-switch.axf" 8 | export HYPERVISOR_BUILD_SCRIPT="make clean && \ 9 | make" 10 | export HYPERVISOR_CLEAN_SCRIPT="make clean" 11 | 12 | export UBOOT_DIR="" 13 | export UBOOT="" 14 | export UBOOT_BUILD_SCRIPT="" 15 | export UBOOT_CLEAN_SCRIPT="" 16 | 17 | export ZIMAGE_BIN="zImage" 18 | export BMGUEST_BIN="bmguest.bin" 19 | export GUEST0_DIR="guestos/guestloader" 20 | export GUEST0_BIN="guestloader.bin" 21 | export GUEST0_BUILD_SCRIPT="cd ../android_boot/ && \ 22 | ./linaro_kernel_build_cmds.sh && \ 23 | cd linaro-kernel && \ 24 | cp out/arch/arm/boot/zImage ../../../guestimages/ && \ 25 | cat ../../../patch/rtsm_ve-cortex_a15x1.dtb >> ../../../guestimages/zImage && \ 26 | cd ../../../$GUEST0_DIR && \ 27 | make clean && \ 28 | make LINUX=y ANDROID=y" 29 | export GUEST0_CLEAN_SCRIPT="make clean" 30 | export GUEST1_DIR="guestos/guestloader" 31 | export GUEST1_BIN="guestloader.bin" 32 | export GUEST1_BUILD_SCRIPT="cd ../bmguest/ && \ 33 | make clean && \ 34 | make GUEST_NUMBER=1 && \ 35 | cp $BMGUEST_BIN ../../guestimages/ && \ 36 | cd ../../$GUEST1_DIR && \ 37 | make clean && \ 38 | make" 39 | export GUEST1_CLEAN_SCRIPT="make clean" 40 | 41 | export GUEST_IMAGE_DIR="guestimages" 42 | export CI_BUILD_DIR="bmguest_linux" 43 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_rtsm/build/bmguest_bmguest.sh: -------------------------------------------------------------------------------- 1 | #for bmguest + bmguest 2 | 3 | export TARGET_PRODUCT="cortex_a15x2_rtsm" 4 | 5 | export GUEST_COUNT=2 6 | 7 | export HYPERVISOR_BIN="hvc-man-switch.axf" 8 | export HYPERVISOR_BUILD_SCRIPT="make clean && \ 9 | make" 10 | export HYPERVISOR_CLEAN_SCRIPT="make clean" 11 | 12 | export UBOOT_DIR="" 13 | export UBOOT="" 14 | export UBOOT_BUILD_SCRIPT="" 15 | export UBOOT_CLEAN_SCRIPT="" 16 | 17 | export BMGUEST_BIN="bmguest.bin" 18 | export GUEST0_DIR="guestos/guestloader" 19 | export GUEST0_BIN="guestloader.bin" 20 | export GUEST0_BUILD_SCRIPT="cd ../bmguest/ && \ 21 | make clean && \ 22 | make GUEST_NUMBER=0 && \ 23 | cp $BMGUEST_BIN ../../guestimages/ && \ 24 | cd ../../$GUEST0_DIR && \ 25 | make clean && \ 26 | make GUEST_NUMBER=0" 27 | export GUEST0_CLEAN_SCRIPT="make clean" 28 | 29 | export GUEST1_DIR="guestos/guestloader" 30 | export GUEST1_BIN="guestloader.bin" 31 | export GUEST1_BUILD_SCRIPT="cd ../bmguest/ && \ 32 | make clean && \ 33 | make GUEST_NUMBER=1 && \ 34 | cp $BMGUEST_BIN ../../guestimages/ && \ 35 | cd ../../$GUEST1_DIR && \ 36 | make clean && \ 37 | make GUEST_NUMBER=1" 38 | export GUEST1_CLEAN_SCRIPT="make clean" 39 | 40 | export GUEST_IMAGE_DIR="guestimages" 41 | export CI_BUILD_DIR="bmguest_bmguest" 42 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_rtsm/build/bmguest_bmguest_bmguest_bmguest.sh: -------------------------------------------------------------------------------- 1 | #for bmguest + bmguest 2 | 3 | export TARGET_PRODUCT="cortex_a15x2_rtsm" 4 | 5 | export GUEST_COUNT=4 6 | 7 | export HYPERVISOR_BIN="hvc-man-switch.axf" 8 | export HYPERVISOR_BUILD_SCRIPT="make clean && \ 9 | make" 10 | export HYPERVISOR_CLEAN_SCRIPT="make clean" 11 | 12 | export UBOOT_DIR="" 13 | export UBOOT="" 14 | export UBOOT_BUILD_SCRIPT="" 15 | export UBOOT_CLEAN_SCRIPT="" 16 | 17 | export BMGUEST_BIN="bmguest.bin" 18 | export GUEST0_DIR="guestos/guestloader" 19 | export GUEST0_BIN="guestloader.bin" 20 | export GUEST0_BUILD_SCRIPT="cd ../bmguest/ && \ 21 | make clean && \ 22 | make GUEST_NUMBER=0 && \ 23 | cp $BMGUEST_BIN ../../guestimages/ && \ 24 | cd ../../$GUEST0_DIR && \ 25 | make clean && \ 26 | make GUEST_NUMBER=0" 27 | export GUEST0_CLEAN_SCRIPT="make clean" 28 | 29 | export GUEST1_DIR="guestos/guestloader" 30 | export GUEST1_BIN="guestloader.bin" 31 | export GUEST1_BUILD_SCRIPT="cd ../bmguest/ && \ 32 | make clean && \ 33 | make GUEST_NUMBER=1 && \ 34 | cp $BMGUEST_BIN ../../guestimages/ && \ 35 | cd ../../$GUEST1_DIR && \ 36 | make clean && \ 37 | make GUEST_NUMBER=1" 38 | export GUEST1_CLEAN_SCRIPT="make clean" 39 | 40 | export GUEST2_DIR="guestos/guestloader" 41 | export GUEST2_BIN="guestloader.bin" 42 | export GUEST2_BUILD_SCRIPT="cd ../bmguest/ && \ 43 | make clean && \ 44 | make GUEST_NUMBER=2 45 | cp $BMGUEST_BIN ../../guestimages/ && \ 46 | cd ../../$GUEST2_DIR && \ 47 | make clean && \ 48 | make GUEST_NUMBER=2" 49 | export GUEST2_CLEAN_SCRIPT="make clean" 50 | 51 | export GUEST3_DIR="guestos/guestloader" 52 | export GUEST3_BIN="guestloader.bin" 53 | export GUEST3_BUILD_SCRIPT="cd ../bmguest/ && \ 54 | make clean && \ 55 | make GUEST_NUMBER=3 56 | cp $BMGUEST_BIN ../../guestimages/ && \ 57 | cd ../../$GUEST3_DIR && \ 58 | make clean && \ 59 | make GUEST_NUMBER=3" 60 | export GUEST3_CLEAN_SCRIPT="make clean" 61 | 62 | export GUEST_IMAGE_DIR="guestimages" 63 | export CI_BUILD_DIR="bmguest_bmguest" 64 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_rtsm/build/linux_bmguest.sh: -------------------------------------------------------------------------------- 1 | #for bmguest + linux 2 | 3 | export TARGET_PRODUCT="cortex_a15x2_rtsm" 4 | 5 | export GUEST_COUNT=2 6 | 7 | export HYPERVISOR_BIN="hvc-man-switch.axf" 8 | export HYPERVISOR_BUILD_SCRIPT="make clean && \ 9 | make" 10 | export HYPERVISOR_CLEAN_SCRIPT="make clean" 11 | 12 | export UBOOT_DIR="" 13 | export UBOOT="" 14 | export UBOOT_BUILD_SCRIPT="" 15 | export UBOOT_CLEAN_SCRIPT="" 16 | 17 | export ZIMAGE_BIN="zImage" 18 | export BMGUEST_BIN="bmguest.bin" 19 | export GUEST0_DIR="guestos/guestloader" 20 | export GUEST0_BIN="guestloader.bin" 21 | export GUEST0_BUILD_SCRIPT="cd ../linux && \ 22 | make ARCH=arm vexpress_minhw_defconfig && \ 23 | cp -a ../../patch/host-a15.dtb . && \ 24 | make CROSS_COMPILE=arm-none-linux-gnueabi- ARCH=arm -j8 && \ 25 | cp System.map ../../guestimages/ && \ 26 | cat host-a15.dtb >> arch/arm/boot/zImage && \ 27 | cp arch/arm/boot/zImage ../../guestimages/ && \ 28 | cd ../../$GUEST0_DIR && \ 29 | make clean && \ 30 | make LINUX=y" 31 | export GUEST0_CLEAN_SCRIPT="make clean" 32 | 33 | export GUEST1_DIR="guestos/guestloader" 34 | export GUEST1_BIN="guestloader.bin" 35 | export GUEST1_BUILD_SCRIPT="cd ../bmguest/ && \ 36 | make clean && \ 37 | make GUEST_NUMBER=1 && \ 38 | cp $BMGUEST_BIN ../../guestimages/ && \ 39 | cd ../../$GUEST1_DIR && \ 40 | make clean && \ 41 | make" 42 | export GUEST1_CLEAN_SCRIPT="make clean" 43 | 44 | export GUEST_IMAGE_DIR="guestimages" 45 | export CI_BUILD_DIR="bmguest_linux" 46 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_rtsm/build/linux_bmguest_bmguest.sh: -------------------------------------------------------------------------------- 1 | #for bmguest + linux 2 | 3 | export TARGET_PRODUCT="cortex_a15x2_rtsm" 4 | 5 | export GUEST_COUNT=3 6 | 7 | export HYPERVISOR_BIN="hvc-man-switch.axf" 8 | export HYPERVISOR_BUILD_SCRIPT="make clean && \ 9 | make" 10 | export HYPERVISOR_CLEAN_SCRIPT="make clean" 11 | 12 | export UBOOT_DIR="" 13 | export UBOOT="" 14 | export UBOOT_BUILD_SCRIPT="" 15 | export UBOOT_CLEAN_SCRIPT="" 16 | 17 | export ZIMAGE_BIN="zImage" 18 | export BMGUEST_BIN="bmguest.bin" 19 | export GUEST0_DIR="guestos/guestloader" 20 | export GUEST0_BIN="guestloader.bin" 21 | export GUEST0_BUILD_SCRIPT="cd ../linux && \ 22 | make ARCH=arm vexpress_minhw_defconfig && \ 23 | cp -a ../../patch/fs.cpio . && \ 24 | cp -a ../../patch/host-a15.dtb . && \ 25 | make CROSS_COMPILE=arm-linux-gnueabihf- ARCH=arm -j8 && \ 26 | cat host-a15.dtb >> arch/arm/boot/zImage && \ 27 | cp arch/arm/boot/zImage ../../guestimages/ && \ 28 | cd ../../$GUEST0_DIR && \ 29 | make clean && \ 30 | make LINUX=y" 31 | export GUEST0_CLEAN_SCRIPT="make clean" 32 | 33 | export GUEST1_DIR="guestos/guestloader" 34 | export GUEST1_BIN="guestloader.bin" 35 | export GUEST1_BUILD_SCRIPT="cd ../bmguest/ && \ 36 | make clean && \ 37 | make GUEST_NUMBER=1 && \ 38 | cp $BMGUEST_BIN ../../guestimages/ && \ 39 | cd ../../$GUEST1_DIR && \ 40 | make clean && \ 41 | make" 42 | export GUEST1_CLEAN_SCRIPT="make clean" 43 | 44 | export GUEST2_DIR="guestos/bmguest" 45 | export GUEST2_BIN="bmguest.bin" 46 | export GUEST2_BUILD_SCRIPT="make clean && \ 47 | make GUEST_NUMBER=2 " 48 | export GUEST2_CLEAN_SCRIPT="make clean" 49 | 50 | export GUEST_IMAGE_DIR="guestimages" 51 | export CI_BUILD_DIR="bmguest_linux" 52 | 53 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_rtsm/build/linux_bmguest_bmguest_bmguest.sh: -------------------------------------------------------------------------------- 1 | #for bmguest + linux 2 | 3 | export TARGET_PRODUCT="cortex_a15x2_rtsm" 4 | 5 | export GUEST_COUNT=4 6 | 7 | export HYPERVISOR_BIN="hvc-man-switch.axf" 8 | export HYPERVISOR_BUILD_SCRIPT="make clean && \ 9 | make" 10 | export HYPERVISOR_CLEAN_SCRIPT="make clean" 11 | 12 | export UBOOT_DIR="" 13 | export UBOOT="" 14 | export UBOOT_BUILD_SCRIPT="" 15 | export UBOOT_CLEAN_SCRIPT="" 16 | 17 | export ZIMAGE_BIN="zImage" 18 | export BMGUEST_BIN="bmguest.bin" 19 | export GUEST0_DIR="guestos/guestloader" 20 | export GUEST0_BIN="guestloader.bin" 21 | export GUEST0_BUILD_SCRIPT="cd ../linux && \ 22 | make ARCH=arm vexpress_minhw_defconfig && \ 23 | cp -a ../../patch/fs.cpio . && \ 24 | cp -a ../../patch/host-a15.dtb . && \ 25 | make CROSS_COMPILE=arm-linux-gnueabihf- ARCH=arm -j8 && \ 26 | cat host-a15.dtb >> arch/arm/boot/zImage && \ 27 | cp arch/arm/boot/zImage ../../guestimages/ && \ 28 | cd ../../$GUEST0_DIR && \ 29 | make clean && \ 30 | make LINUX=y GUEST_NUMBER=0" 31 | export GUEST0_CLEAN_SCRIPT="make clean" 32 | 33 | export GUEST1_DIR="guestos/guestloader" 34 | export GUEST1_BIN="guestloader.bin" 35 | export GUEST1_BUILD_SCRIPT="cd ../bmguest/ && \ 36 | make clean && \ 37 | make GUEST_NUMBER=1 && \ 38 | cp $BMGUEST_BIN ../../guestimages/ && \ 39 | cd ../../$GUEST1_DIR && \ 40 | make clean && \ 41 | make GUEST_NUMBER=1" 42 | export GUEST1_CLEAN_SCRIPT="make clean" 43 | 44 | export GUEST2_DIR="guestos/guestloader" 45 | export GUEST2_BIN="guestloader.bin" 46 | export GUEST2_BUILD_SCRIPT="cd ../bmguest/ && \ 47 | make clean && \ 48 | make GUEST_NUMBER=2 49 | cp $BMGUEST_BIN ../../guestimages/ && \ 50 | cd ../../$GUEST2_DIR && \ 51 | make clean && \ 52 | make GUEST_NUMBER=2" 53 | export GUEST2_CLEAN_SCRIPT="make clean" 54 | 55 | export GUEST3_DIR="guestos/guestloader" 56 | export GUEST3_BIN="guestloader.bin" 57 | export GUEST3_BUILD_SCRIPT="cd ../bmguest/ && \ 58 | make clean && \ 59 | make GUEST_NUMBER=3 60 | cp $BMGUEST_BIN ../../guestimages/ && \ 61 | cd ../../$GUEST3_DIR && \ 62 | make clean && \ 63 | make GUEST_NUMBER=3" 64 | export GUEST3_CLEAN_SCRIPT="make clean" 65 | 66 | export GUEST_IMAGE_DIR="guestimages" 67 | export CI_BUILD_DIR="bmguest_linux" 68 | 69 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_rtsm/config-default.mk: -------------------------------------------------------------------------------- 1 | # Configuration file included in Makefile 2 | # 3 | # Copyright (C) 2011 Columbia University. All rights reserved. 4 | # Christoffer Dall 5 | # Use of this source code is governed by a BSD-style license that can be 6 | # found in the LICENSE.txt file. 7 | # 8 | # This is a sample configuration file. To make changes, copy this file to 9 | # config.mk and modify that file. 10 | # 11 | # For all systems you can override USE_INITRD and KCMD from the command-line. 12 | # 13 | 14 | ########################################################################### 15 | # Main options 16 | # 17 | CROSS_COMPILE ?= arm-linux-gnueabihf- 18 | ARCH ?= arm 19 | 20 | SYSTEM ?= vexpress 21 | 22 | #CPPFLAGS += -DSMP 23 | #CPPFLAGS += -D_MON_ 24 | CPPFLAGS += -mcpu=cortex-a15 -marm 25 | CPPFLAGS += -g 26 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_rtsm/drivers/uart/uart_print.c: -------------------------------------------------------------------------------- 1 | #include "arch_types.h" 2 | #include 3 | 4 | 5 | #ifdef CFG_GENERIC_CA15 6 | #ifdef CFG_BOARD_RTSM_VE_CA15 7 | #define UART0_BASE 0x1C090000 8 | #else 9 | #error "Configuration for board is not specified!"\ 10 | " GENERIC_CA15 but board is unknown." 11 | #endif 12 | 13 | 14 | void uart_print(const char *str) 15 | { 16 | volatile char *pUART = (char *) UART0_BASE; 17 | while (*str) 18 | *pUART = *str++; 19 | } 20 | 21 | void uart_putc(const char c) 22 | { 23 | /* Wait until there is space in the FIFO */ 24 | while (*((uint32_t *)(UART0_BASE + 0x18)) & 0x20) 25 | ; 26 | /* Send the character */ 27 | volatile char *pUART = (char *) UART0_BASE; 28 | *pUART = c; 29 | } 30 | 31 | void uart_print_hex32(uint32_t v) 32 | { 33 | unsigned int mask8 = 0xF; 34 | unsigned int c; 35 | int i; 36 | uart_print("0x"); 37 | for (i = 7; i >= 0; i--) { 38 | c = ((v >> (i * 4)) & mask8); 39 | if (c < 10) 40 | c += '0'; 41 | else 42 | c += 'A' - 10; 43 | uart_putc((char) c); 44 | } 45 | } 46 | 47 | void uart_print_hex64(uint64_t v) 48 | { 49 | uart_print_hex32(v >> 32); 50 | uart_print_hex32((uint32_t)(v & 0xFFFFFFFF)); 51 | } 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_rtsm/guestimages/zImage: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kesl/khypervisor/722d32a42e08eba144dc2fa1a528c1369055204c/platform-device/cortex_a15x2_rtsm/guestimages/zImage -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_rtsm/guestos/android_boot/linaro_kernel_build_cmds.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | EXACT=1 6 | DIR=linaro-kernel 7 | 8 | CPUS=`grep -c processor /proc/cpuinfo` 9 | 10 | usage() 11 | { 12 | echo 'Usage: $0 -c .config[ -t -d directory ]' 13 | echo -e " -c .config file The kernel config file from the build. Download from:\n http://snapshots.linaro.org/android/~linaro-android/vexpress-linaro-4.2.2-13.08-release/1//kernel_config\n from a browser with cookies enabled." 14 | echo " -t Reproduce the from the tip of the branch rather than doing" 15 | echo " an exact replica build" 16 | echo " -d The directory to download code and build from" 17 | echo " Default: ${DIR}" 18 | exit 1 19 | } 20 | 21 | while getopts "c:d:ht" optn; do 22 | case $optn in 23 | d ) DIR=$OPTARG;; 24 | t ) EXACT=0;; 25 | c ) CFG=$OPTARG;; 26 | h ) usage; exit 1;; 27 | esac 28 | done 29 | 30 | # download the kernel 31 | if [ -d ${DIR} ] ; then 32 | echo "Directory ${DIR} exists. If the kernel code exists in this directory you may continue without cloning the git repository for the kernel. Are you sure you want to do this? (y/n) " 33 | read CONTINUE 34 | [ ${CONTINUE} == y ] || exit 1 35 | else 36 | git clone git://git.linaro.org/kernel/linux-linaro-tracking $DIR 37 | fi 38 | 39 | cd $DIR 40 | git checkout 8abe04ab20f5e2b7bc76b5e69860facc3a743760 41 | 42 | # download the kernel config 43 | cp ../../../patch/vexpress_android ./linaro_kernel_config 44 | 45 | # build the code 46 | CROSS_COMPILE=`which arm-linux-gnueabi-gcc |sed -e 's,gcc,,'` 47 | [ -d out ] || mkdir out 48 | [ -f out/.config ] || cp linaro_kernel_config out/.config 49 | if [[ `grep 'CONFIG_ARCH_MULTIPLATFORM=y' out/.config` ]]; then 50 | KERNEL_IMAGE=zImage 51 | else 52 | KERNEL_IMAGE=uImage 53 | fi 54 | make -j${CPUS} O=out ARCH=arm CROSS_COMPILE=$CROSS_COMPILE $KERNEL_IMAGE modules 55 | #mkdir out/modules_for_android 56 | make O=out ARCH=arm modules_install INSTALL_MOD_PATH=modules_for_android 57 | 58 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_rtsm/guestos/android_boot/uInitrd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kesl/khypervisor/722d32a42e08eba144dc2fa1a528c1369055204c/platform-device/cortex_a15x2_rtsm/guestos/android_boot/uInitrd -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_rtsm/guestos/bmguest/.gitignore: -------------------------------------------------------------------------------- 1 | filesystem.cpio.gz 2 | linux-system.axf 3 | uImage 4 | model.lds 5 | config.mk 6 | *.o 7 | *.swp 8 | tags 9 | modelsemi.lds 10 | bmguest.bin 11 | *.axf 12 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_rtsm/guestos/bmguest/README.md: -------------------------------------------------------------------------------- 1 | How to build a baremetal guest 2 | ============================== 3 | Makefile usage 4 | -------------- 5 |
 6 |   Usage: $ GUESTTYPE= make clean all
 7 |   Example:
 8 |   - Building a Hyp Monitor guest: $ GUESTTYPE=GUEST_HYPMON make clean all
 9 |   - Building a Secure Monitor guest: $ GUESTTYPE=GUEST_SECMON make clean all
10 | 
11 | 12 | 1. Building a Hyp monitor guest 13 | ------------------------------ 14 | - The program (bmguest.bin) runs in Non-secure Supervisor mode as a guest of the Hyp monitor 15 | - Physical Entry point: IPA:0x00000000 16 | - Hyp call (hvc instruction) to request the Hyp monitor to switch the context manually 17 |
18 |  $ make
19 |  or
20 |  $ GUESTTYPE=GUEST_HYPMON make
21 | arm-unknown-linux-gnueabi-gcc -DSMP -mcpu=cortex-a15 -DVEXPRESS -g -D__MONITOR_CALL_HVC__ -DLDS_PHYS_OFFSET='0x00000000' -DLDS_GUEST_OFFSET='0x00000000' -DLDS_GUEST_STACK='0x0F000000' -DNUM_ITERATIONS=3 -DGUEST_LABEL='"[guest0] "' -DLDS_GUEST_HYPMON=1 -DKCMD='"console=ttyAMA0 mem=512M mem=512M@0x880000000 earlyprintk root=/dev/nfs nfsroot=192.168.0.32:/srv/nfsroot,tcp rw ip=dhcp nfsrootdebug"' -c -o guest.o guest.S
22 | ...
23 | arm-unknown-linux-gnueabi-ld -o bmguest.axf guest.o c_start.o string.o uart_print.o --script=model.lds
24 | arm-unknown-linux-gnueabi-objcopy -O binary -S bmguest.axf bmguest.bin
25 | =================================================================
26 |   BUILT GUEST TYPE:GUEST_HYPMON 
27 |   GUESTCONFIGS FLAGS:-D__MONITOR_CALL_HVC__ -DLDS_PHYS_OFFSET='0x00000000' -DLDS_GUEST_OFFSET='0x00000000' -DLDS_GUEST_STACK='0x0F000000' -DNUM_ITERATIONS=3 -DGUEST_LABEL='[guest0] ' -DLDS_GUEST_HYPMON=1 
28 | =================================================================
29 |   Entry point physical address:
30 | 00000000 A __hypmon_guest_start
31 | 
32 | 33 | 2. Building a Secure monitor guest 34 | ------------------------------- 35 | - The program (bmguest.bin) runs in Non-secure Supervisor mode along side of the Monitor runs in Secure mode 36 | - Physical Entry point: 0xE0000000 37 | - Secure Monitor Call (smc instruction) to request the Secure Monitor to hand over the execution control to the Secure World 38 |
39 |  $ GUESTTYPE=GUEST_SECMON make
40 | arm-unknown-linux-gnueabi-gcc -DSMP -mcpu=cortex-a15 -DVEXPRESS -g -DLDS_PHYS_OFFSET='0xE0000000' -DLDS_GUEST_OFFSET='0xE0000000' -DLDS_GUEST_STACK='0xEF000000' -DNUM_ITERATIONS=3 -DGUEST_LABEL='"[guest0] "' -DLDS_GUEST_SECMON=1 -DKCMD='"console=ttyAMA0 mem=512M mem=512M@0x880000000 earlyprintk root=/dev/nfs nfsroot=192.168.0.32:/srv/nfsroot,tcp rw ip=dhcp nfsrootdebug"' -c -o guest.o guest.S
41 | ...
42 | =================================================================
43 |   BUILT GUEST TYPE:GUEST_SECMON 
44 |   GUESTCONFIGS FLAGS:-DLDS_PHYS_OFFSET='0xE0000000' -DLDS_GUEST_OFFSET='0xE0000000' -DLDS_GUEST_STACK='0xEF000000' -DNUM_ITERATIONS=3 -DGUEST_LABEL='[guest0] ' -DLDS_GUEST_SECMON=1 
45 | =================================================================
46 |   Entry point physical address:
47 | e0000000 A __secmon_guest_start
48 | 
49 | 
50 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_rtsm/guestos/bmguest/boot.S: -------------------------------------------------------------------------------- 1 | /* 2 | * boot.S - Secure/Non-Secure Switching Monitor 3 | * 4 | * Copyright (C) 2013 KESL. All rights reserved. 5 | * 6 | */ 7 | .syntax unified 8 | .arch_extension sec 9 | .arch_extension virt 10 | .text 11 | 12 | @ Guest start code 13 | .global guest_start 14 | guest_start: 15 | 16 | b common_guest_entry 17 | .type guest_start, % function 18 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_rtsm/guestos/bmguest/config-default.mk: -------------------------------------------------------------------------------- 1 | # Configuration file included in Makefile 2 | # 3 | # Copyright (C) 2011 Columbia University. All rights reserved. 4 | # Christoffer Dall 5 | # Use of this source code is governed by a BSD-style license that can be 6 | # found in the LICENSE.txt file. 7 | # 8 | # This is a sample configuration file. To make changes, copy this file to 9 | # config.mk and modify that file. 10 | # 11 | # For all systems you can override USE_INITRD and KCMD from the command-line. 12 | # 13 | 14 | ########################################################################### 15 | # Main options 16 | # 17 | CROSS_COMPILE ?= arm-linux-gnueabihf- 18 | ARCH ?= arm 19 | 20 | SYSTEM ?= vexpress 21 | 22 | CPPFLAGS += -DSMP 23 | CPPFLAGS += -mcpu=cortex-a15 -marm 24 | CPPFLAGS += -DVEXPRESS -g 25 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_rtsm/guestos/bmguest/drivers/sp804_timer.h: -------------------------------------------------------------------------------- 1 | #ifndef __SP804_H_ 2 | #define __SP804_H_ 3 | #include "arch_types.h" 4 | 5 | uint32_t sp804_secondary_base(uint32_t sp804_base); 6 | void sp804_irq_clear(uint32_t sp804_base); 7 | void sp804_start(uint32_t sp804_base); 8 | void sp804_load(uint32_t loadval, uint32_t sp804_base); 9 | uint32_t sp804_read(uint32_t sp804_base); 10 | void sp804_stop(uint32_t sp804_base); 11 | void sp804_init_periodic(uint32_t sp804_base, uint32_t load_value); 12 | void sp804_init_oneshot(uint32_t sp804_base); 13 | void sp804_init(uint32_t sp804_base, uint32_t load_value); 14 | hvmm_status_t hvmm_tests_sp804_timer(void); 15 | 16 | #endif 17 | 18 | 19 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_rtsm/guestos/bmguest/drivers/uart.c: -------------------------------------------------------------------------------- 1 | /* UART Base Address determined by Hypervisor's Stage 2 Translation Table */ 2 | 3 | #define UART_BASE ((volatile unsigned int *) 0x1C090000) 4 | 5 | static char _dummy_byte; 6 | 7 | void uart_init(void) 8 | { 9 | /* TODO: 10 | Figure out how to initialize the UART. 11 | Currently, intialized by Hypervisor for FastModels 12 | RTSM_VE, as a workaround 13 | */ 14 | /* ibrd 0x24 */ 15 | /* UART_BASE[9] = 0x10; */ 16 | /* UART_BASE[12] = 0xc300; */ 17 | } 18 | 19 | void uart_print(char *str) 20 | { 21 | char *pUART = (char *) UART_BASE; 22 | while (*str) 23 | *pUART = *str++; 24 | } 25 | 26 | void uart_putc(char c) 27 | { 28 | volatile char *pUART = (char *) UART_BASE; 29 | *pUART = c; 30 | } 31 | 32 | void uart_print_hex32(unsigned int v) 33 | { 34 | unsigned int mask8 = 0xF; 35 | unsigned int c; 36 | int i; 37 | uart_print("0x"); 38 | for (i = 7; i >= 0; i--) { 39 | c = ((v >> (i * 4)) & mask8); 40 | if (c < 10) 41 | c += '0'; 42 | else 43 | c += 'A' - 10; 44 | uart_putc((char) c); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_rtsm/guestos/bmguest/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | /* 9 | #define TESTS_ENABLE_SP804_TIMER 10 | */ 11 | /* 12 | #define TESTS_TRAP_WFI 13 | #define TESTS_TRAP_SMC 14 | #define TESTS_TRAP_SCTLR 15 | #define TESTS_TRAP_DDCISW 16 | #define TESTS_TRAP_ACTLR 17 | */ 18 | 19 | int main() 20 | { 21 | int val; 22 | uart_print(GUEST_LABEL); 23 | uart_print("\n\r=== Starting platform main\n\r"); 24 | #ifdef TESTS_ENABLE_SP804_TIMER 25 | /* Test the SP804 timer */ 26 | hvmm_tests_sp804_timer(); 27 | #endif 28 | #ifdef TESTS_TRAP_WFI 29 | WFI(); 30 | #endif 31 | #ifdef TESTS_TRAP_SMC 32 | SVC(); 33 | /* SMC(); */ 34 | #endif 35 | #ifdef TESTS_TRAP_SCTLR 36 | READ_SCTLR(val); 37 | WRITE_SCTLR(val); 38 | #endif 39 | #ifdef TESTS_TRAP_DDCISW 40 | WRITE_DCCISW(val); 41 | #endif 42 | #ifdef TESTS_TRAP_ACTLR 43 | READ_ACTLR(val); 44 | WRITE_ACTLR(val); 45 | #endif 46 | 47 | while (1) 48 | ; 49 | return 0; 50 | } 51 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_rtsm/guestos/bmguest/model.lds.S: -------------------------------------------------------------------------------- 1 | /* 2 | * model.lds.S - simple linker script for stand-alone Linux booting 3 | * 4 | * Copyright (C) 2011 ARM Limited. All rights reserved. 5 | * 6 | * Use of this source code is governed by a BSD-style license that can be 7 | * found in the LICENSE.txt file. 8 | */ 9 | 10 | OUTPUT_FORMAT("elf32-littlearm") 11 | OUTPUT_ARCH(arm) 12 | TARGET(binary) 13 | 14 | #ifdef LDS_PHYS_OFFSET 15 | PHYS_OFFSET = LDS_PHYS_OFFSET; 16 | #else 17 | PHYS_OFFSET = 0x80000000; 18 | #endif 19 | 20 | /* NS.SVC mode code space 21 | * LDS_GUEST_OFFSET ~ LDS_GUEST_STACK + 0x01000000 22 | * - simon 23 | */ 24 | #ifdef LDS_GUEST_OFFSET 25 | GUEST_OFFSET = LDS_GUEST_OFFSET; 26 | #else 27 | GUEST_OFFSET = 0x80000000; 28 | #endif 29 | 30 | #ifdef LDS_GUEST_STACK 31 | GUEST_STACK = LDS_GUEST_STACK; 32 | #else 33 | GUEST_STACK = 0x8F000000; 34 | #endif 35 | 36 | SECTIONS { 37 | . = PHYS_OFFSET; 38 | 39 | /* Guest image between Kernel and Mon */ 40 | . = GUEST_OFFSET; 41 | #if (LDS_GUEST_SECMON==1) 42 | __secmon_guest_start = .; 43 | #elif (LDS_GUEST_HYPMON==1) 44 | __hypmon_guest_start = .; 45 | #else 46 | __monitor_type_unknown_guest_start = .; 47 | #endif 48 | 49 | /* Put most of the actual boot loader code up in high memory 50 | * where it won't get overwritten by kernel, initrd or atags. 51 | */ 52 | .text : 53 | { 54 | *(.text) 55 | } 56 | . = ALIGN(4); 57 | .rodata : 58 | { 59 | *(.rodata) 60 | } 61 | . = ALIGN(4); 62 | .data : 63 | { 64 | *(.data) 65 | } 66 | . = ALIGN(4); 67 | begin_bss = .; 68 | .bss : 69 | { 70 | *(.bss) 71 | } 72 | end_bss = .; 73 | 74 | . = GUEST_STACK; 75 | guest_stacktop_svc = .; 76 | . = GUEST_STACK + 0x00400000; 77 | guest_stacklimit_svc = .; 78 | guest_stacktop_irq = .; 79 | . = GUEST_STACK + 0x00800000; 80 | guest_stacklimit_irq = .; 81 | guest_stacktop = .; 82 | . = GUEST_STACK + 0x01000000; 83 | guest_stacklimit = .; 84 | } 85 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_rtsm/guestos/bmguest/trap.h: -------------------------------------------------------------------------------- 1 | #ifndef _TRAP_H_ 2 | #define _TRAP_H_ 3 | 4 | #define MRC(reg, cp, opc1, crn, crm, opc2) \ 5 | __asm__ __volatile__ ( \ 6 | " mrc " #cp "," #opc1 ", %0," #crn "," #crm "," #opc2 "\n" \ 7 | : "=r" (reg)) 8 | 9 | #define MCR(reg, cp, opc1, crn, crm, opc2) \ 10 | __asm__ __volatile__ ( \ 11 | " mcr " #cp "," #opc1 ", %0," #crn "," #crm "," #opc2 "\n" \ 12 | : : "r" (reg)) 13 | 14 | #define MRC15(reg, op1, crn, crm, op2) MRC(reg, p15, op1, crn, crm, op2) 15 | #define MCR15(reg, op1, crn, crm, op2) MCR(reg, p15, op1, crn, crm, op2) 16 | 17 | /* TESTS_HCR.TGE */ 18 | #define SMC() __asm__ __volatile__ ("smc #0") 19 | 20 | /* TESTS_HCR.TVM */ 21 | #define WRITE_SCTLR(reg) MCR(reg, p15, 0, c1, c0, 0) 22 | #define READ_SCTLR(reg) MRC(reg, p15, 0, c1, c0, 0) 23 | 24 | /* TESTS_HCR.TPU */ 25 | #define WRITE_DCCISW(reg) MCR(reg, p15, 0, c7, c14, 2) 26 | /* #define READ_DCCISW(reg) MRC(reg, p15, 0, c7, c14, 2) /* WRITE ONLY */ 27 | 28 | /* TESTS_HCR.TAC */ 29 | #define WRITE_ACTLR(reg) MCR(reg, p15, 0, c1, c0, 1) 30 | #define READ_ACTLR(reg) MRC(reg, p15, 0, c1, c0, 1) 31 | 32 | /* TESTS_HCR.TWE */ 33 | #define WFE() __asm__ __volatile__ ("wfe" : : : "memory") 34 | /* TESTS_HCR.TW1 */ 35 | #define WFI() __asm__ __volatile__ ("wfi" : : : "memory") 36 | /* TESTS_HCR.TSC */ 37 | #define SMC() __asm__ __volatile__ ("smc #0") 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_rtsm/guestos/guestloader/Makefile: -------------------------------------------------------------------------------- 1 | # Usage: make 2 | # Example: 3 | # $ make ; build for bmguest 4 | # $ make LINUX=y ; build for linux guest 5 | 6 | # Include config file 7 | include config-default.mk 8 | COMMON_SOURCE_DIR=../../../../common 9 | COMMON_LOADER_DIR=$(COMMON_SOURCE_DIR)/guest/loader 10 | OBJS += boot.o main.o drivers/uart.o drivers/pl011.o drivers/timer.o\ 11 | $(COMMON_SOURCE_DIR)/log/print.o \ 12 | $(COMMON_SOURCE_DIR)/log/format.o \ 13 | $(COMMON_SOURCE_DIR)/log/string.o \ 14 | $(COMMON_SOURCE_DIR)/guest/core/exception.o \ 15 | $(COMMON_SOURCE_DIR)/guest/core/gic.o \ 16 | $(COMMON_SOURCE_DIR)/guest/test/test_vtimer.o \ 17 | $(COMMON_LOADER_DIR)/linuxloader.o \ 18 | $(COMMON_LOADER_DIR)/guestloader_common.o \ 19 | $(COMMON_LOADER_DIR)/cli.o \ 20 | $(COMMON_LOADER_DIR)/monitor/monitor_cli.o \ 21 | $(COMMON_LOADER_DIR)/monitor/guest_monitor.o 22 | GUESTLOADERIMG = guestloader.axf 23 | GUESTLOADERBIN = guestloader.bin 24 | LD_SCRIPT = model.lds.S 25 | INCLUDES = -I. -I$(COMMON_SOURCE_DIR) -I$(COMMON_SOURCE_DIR)/include \ 26 | -I$(COMMON_LOADER_DIR) -I$(COMMON_SOURCE_DIR)/guest \ 27 | -I$(COMMON_SOURCE_DIR)/guest/core -I../../ \ 28 | -I$(COMMON_LOADER_DIR)/monitor 29 | 30 | CPPFLAGS += $(INCLUDES) 31 | CC = $(CROSS_COMPILE)gcc 32 | LD = $(CROSS_COMPILE)ld 33 | OBJCOPY = $(CROSS_COMPILE)objcopy 34 | GUESTLOADERCONFIGS = -DBM_GUEST 35 | ifeq ($(LINUX), y) 36 | GUESTLOADERCONFIGS = -DLINUX_GUEST 37 | GUESTBIN = ../../guestimages/zImage 38 | else 39 | GUESTBIN = ../../guestimages/bmguest.bin 40 | endif 41 | ifeq ($(MONITOR), y) 42 | GUESTLOADERCONFIGS += -DMONITOR_GUEST 43 | endif 44 | GUESTLOADERCONFIGS += -DGUEST_PATH=$(GUESTBIN) 45 | ifeq ($(ANDROID), y) 46 | GUESTLOADERCONFIGS += -DINITRD_PATH=../android_boot/uInitrd -DUSE_ANDROID_INITRD 47 | endif 48 | #GUEST_NUMBER = "GUEST0" 49 | GUESTLOADERCONFIGS += -DGUEST_NUMBER=$(GUEST_NUMBER) 50 | all: $(GUESTLOADERBIN) 51 | clean distclean: 52 | rm -f $(GUESTLOADERIMG) $(GUESTLOADERBIN) \ 53 | model.lds $(OBJS) 54 | $(GUESTLOADERIMG): $(OBJS) model.lds 55 | $(LD) -o $@ $(OBJS) --script=model.lds 56 | $(GUESTLOADERBIN): $(GUESTLOADERIMG) 57 | $(OBJCOPY) -O binary -S $< $@ 58 | ifeq ($(LINUX), y) 59 | $(GUESTBIN): 60 | @echo "ERROS: Copy $@ from guestos/linux/arch/arm/boot/ after building it" 61 | else 62 | $(GUESTBIN): 63 | @echo "ERROS: Copy $@ from guestos/bmguest/ after building it" 64 | endif 65 | boot.o: boot.S 66 | $(CC) $(CPPFLAGS) $(GUESTLOADERCONFIGS) -DKCMD='$(KCMD)' -c -o $@ $< 67 | %.o: %.c 68 | $(CC) $(CPPFLAGS) $(GUESTLOADERCONFIGS) -O2 -ffreestanding -I. -c -o $@ $< 69 | model.lds: $(LD_SCRIPT) Makefile $(GUESTBIN) 70 | $(CC) $(CPPFLAGS) $(GUESTLOADERCONFIGS) -E -P -C -o $@ $< 71 | force: ; 72 | Makefile: ; 73 | .PHONY: all clean distclean config-default.mk 74 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_rtsm/guestos/guestloader/README.md: -------------------------------------------------------------------------------- 1 | # How to test guestloader 2 | 3 | ##Linux guest + bmguest
4 | Download linux using gitmodule command. 5 |
 6 | cd {khypervisor_root_dir}
 7 | source platform-device/cortex_a15x2_rtsm/build/linux_bmguest.sh
 8 | make
 9 | cd platform-device/cortex_a15x2_rtsm
10 | RTSM_VE_Cortex-A15x1-A7x1 -a coretile.cluster0.cpu0=hvc-man-switch.axf
11 | 
12 | 13 | ##bmguest + bmguest 14 |
15 | cd {khypervisor_root_dir}
16 | source platform-device/cortex_a15x2_rtsm/build/bmguest_bmguest.sh
17 | make
18 | cd platform-device/cortex_a15x2_rtsm
19 | RTSM_VE_Cortex-A15x1-A7x1 -a coretile.cluster0.cpu0=hvc-man-switch.axf
20 | 
21 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_rtsm/guestos/guestloader/boot.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 KESL. All rights reserved. 3 | */ 4 | .text 5 | @ Guest loader start code 6 | .global guestloader_start 7 | guestloader_start: 8 | /* Stack pointer initialization */ 9 | @ sp for irq 10 | msr cpsr_c, #0xd2 11 | ldr sp, = guestloader_stacklimit_irq 12 | 13 | @ sp for svc 14 | msr cpsr_c, #0xd3 15 | ldr sp, =guestloader_stacklimit_svc 16 | 17 | @ exception vector 18 | ldr r0, = guestloader_vector 19 | mcr p15, 0, r0, c12, c0, 0 @ VBAR 20 | 21 | #ifdef _SMP_ 22 | @Check CPU ID 23 | mrc p15, 0, r0, c0, c0, 5 @MPIDR (ARMv7 only) 24 | bfc r0, #24, #8 @ CPU Number, taking multicluster into account 25 | cmp r0, #0 26 | beq 2f 27 | 28 | @ Secondary CPUs (for SMP booting in Linux Guest) 29 | cmp r0, #1 30 | bne 2f @ Will delete after Vcpu currectly work 31 | 32 | ldr r1, =guestloader_stacktop_svc - 0x100 /* not exactly complete */ 33 | adr r2, 1f 34 | ldmia r2, {r3 - r7} 35 | stmia r1, {r3 - r7} 36 | ldr r0, =0x1c010030 37 | mov pc, r1 38 | 39 | 1: 40 | wfe 41 | ldr r1, [r0] 42 | cmp r1, #0 43 | beq 1b 44 | mov pc, r1 45 | 46 | 2: 47 | #endif 48 | 49 | mov r0, r10 50 | 51 | @ Call the C entrypoint 52 | b main 53 | .type guestloader_start, %function 54 | 55 | .align 5 56 | guestloader_vector: 57 | .word 0 /* reset */ 58 | .word 0 /* undefined instruction */ 59 | .word 0 /* svc */ 60 | .word 0 /* pabort */ 61 | .word 0 /* dabort */ 62 | .word 0 /* unused */ 63 | b except_irq /* irq*/ 64 | .word 0 /* fiq*/ 65 | 66 | except_irq: 67 | @ Push registers 68 | push {r0 - r12} 69 | mrs r0, spsr /* CPSR */ 70 | push {r0, lr} 71 | 72 | mov r0, sp 73 | bl _except_irq 74 | 75 | @ Pop registers 76 | pop {r0, lr} /* CPSR, LR */ 77 | msr spsr, r0 78 | pop {r0 - r12} 79 | 80 | @ movs pc, lr 81 | subs pc, lr, #4 82 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_rtsm/guestos/guestloader/config-default.mk: -------------------------------------------------------------------------------- 1 | include ../../config-default.mk 2 | 3 | # 4 | # Main options 5 | # 6 | CPPFLAGS += -mcpu=cortex-a15 -marm -g 7 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_rtsm/guestos/guestloader/drivers/pl011.c: -------------------------------------------------------------------------------- 1 | #include "pl011.h" 2 | #include "asm_io.h" 3 | 4 | void pl011_putc(const char c) 5 | { 6 | /* Wait until there is space in the FIFO */ 7 | while (*((uint32_t *)(PL011_BASE + 0x18)) & 0x20) 8 | ; 9 | /* Send the character */ 10 | writel(c, (uint32_t *) PL011_BASE + PL011_UARTDR); 11 | } 12 | 13 | int pl011_tst_fifo(uint32_t base) 14 | { 15 | /* There is not a data in the FIFO */ 16 | if (readl((void *)(base + PL011_UARTFR)) & PL011_UARTFR_RXFE) 17 | return 0; 18 | else 19 | /* There is a data in the FIFO */ 20 | return 1; 21 | } 22 | 23 | char pl011_getc(uint32_t base) 24 | { 25 | char data; 26 | /* Wait until there is data in the FIFO */ 27 | while (readl((void *)(base + PL011_UARTFR)) & PL011_UARTFR_RXFE) 28 | ; 29 | data = *((uint32_t *)(base + PL011_UARTDR)); 30 | /* Check for an error flag */ 31 | if (data & 0xFFFFFF00) { 32 | /* Clear the error */ 33 | writel(0xFFFFFFFF, (uint32_t *) PL011_BASE + PL011_UARTECR); 34 | return -1; 35 | } 36 | return data; 37 | } 38 | 39 | void pl011_init(uint32_t base, uint32_t baudrate, uint32_t input_clock) 40 | { 41 | unsigned int divider; 42 | unsigned int temp; 43 | unsigned int remainder; 44 | unsigned int fraction; 45 | 46 | /* First, disable everything */ 47 | writel(0x0, (void *)(base + PL011_UARTCR)); 48 | 49 | /* 50 | * Set baud rate 51 | * 52 | * IBRD = UART_CLK / (16 * BAUD_RATE) 53 | * FBRD = RND((64 * MOD(UART_CLK,(16 * BAUD_RATE))) 54 | * / (16 * BAUD_RATE)) 55 | */ 56 | temp = 16 * baudrate; 57 | divider = input_clock / temp; 58 | remainder = input_clock % temp; 59 | temp = (8 * remainder) / baudrate; 60 | fraction = (temp >> 1) + (temp & 1); 61 | 62 | writel(divider, (void *)(base + PL011_UARTIBRD)); 63 | writel(fraction, (void *)(base + PL011_UARTFBRD)); 64 | 65 | /* Set the UART to be 8 bits, 1 stop bit, 66 | * no parity, fifo enabled 67 | */ 68 | writel((PL011_UARTLCR_H_WLEN_8 | PL011_UARTLCR_H_FEN), 69 | (void *)(base + PL011_UARTLCR_H)); 70 | 71 | /* Finally, enable the UART */ 72 | writel((PL011_UARTCR_UARTEN | PL011_UARTCR_TXE | PL011_UARTCR_RXE), 73 | (void *)(base + PL011_UARTCR)); 74 | } 75 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_rtsm/guestos/guestloader/drivers/timer.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include "timer.h" 6 | 7 | #define BOOT_COUNT 5 8 | #define SHED_TICK 1000 9 | #define BOOT_COUNT_RATIO (SHED_TICK/BOOT_COUNT) 10 | #define VTIMER_IRQ 30 11 | 12 | int bootcount = BOOT_COUNT * BOOT_COUNT_RATIO; 13 | /** 14 | * @brief Handler of timer interrupt. 15 | */ 16 | void timer_handler(int irq, void *pregs, void *pdata) 17 | { 18 | if (0 == (bootcount % BOOT_COUNT_RATIO)) { 19 | uart_print("Hit any key to stop autoboot : "); 20 | uart_print_dec(bootcount / BOOT_COUNT_RATIO); 21 | uart_print("\n"); 22 | } 23 | if (bootcount == 0) 24 | guestloader_flag_autoboot(1); 25 | bootcount--; 26 | } 27 | 28 | void timer_init(void) 29 | { 30 | /* Registers vtimer hander */ 31 | gic_set_irq_handler(VTIMER_IRQ, timer_handler, 0); 32 | /* Enables receiving virtual timer interrupt */ 33 | timer_enable(); 34 | } 35 | 36 | void timer_disable(void) 37 | { 38 | /* Disables receiving virtual timer interrupt. */ 39 | vtimer_mask(1); 40 | } 41 | 42 | void timer_enable(void) 43 | { 44 | /* Enables receiving virtual timer interrupt. */ 45 | vtimer_mask(0); 46 | } 47 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_rtsm/guestos/guestloader/drivers/timer.h: -------------------------------------------------------------------------------- 1 | #ifndef __TIMER_H__ 2 | #define __TIMER_H__ 3 | 4 | /** 5 | * @brief Registers timer handler and enables timer interrupt. 6 | */ 7 | void timer_init(void); 8 | /** 9 | * @brief Disables receiving virtual timer interrupt. 10 | */ 11 | void timer_disable(void); 12 | /** 13 | * @brief Enables receiving virtual timer interrupt. 14 | */ 15 | void timer_enable(void); 16 | #endif 17 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_rtsm/guestos/guestloader/drivers/uart.c: -------------------------------------------------------------------------------- 1 | #include "arch_types.h" 2 | #include 3 | #include "pl011.h" 4 | #include 5 | 6 | #define UART_BASE PL011_BASE 7 | #define UART_INCLK 24000000 8 | #define UART_BAUD 115200 9 | #define NULL '\0' 10 | 11 | void uart_putc(const char c) 12 | { 13 | if (c == '\n') 14 | pl011_putc('\r'); 15 | pl011_putc(c); 16 | } 17 | 18 | void uart_print(const char *str) 19 | { 20 | while (*str) { 21 | uart_putc(*str); 22 | str++; 23 | } 24 | volatile char *pUART = (char *) UART_BASE; 25 | while (*str) 26 | *pUART = *str++; 27 | } 28 | 29 | #define UART_PRINT_BUF 12 30 | void uart_print_dec(uint32_t v) 31 | { 32 | char print_buf[UART_PRINT_BUF]; 33 | char *s; 34 | int i; 35 | s = print_buf + UART_PRINT_BUF - 1; 36 | *s = NULL; 37 | if (v == 0UL) 38 | *--s = '0'; 39 | else { 40 | for (; v != 0UL;) { 41 | *--s = ((v % 10) + '0'); 42 | v /= 10; 43 | } 44 | } 45 | uart_print(s); 46 | } 47 | 48 | void uart_print_hex32(uint32_t v) 49 | { 50 | unsigned int mask8 = 0xF; 51 | unsigned int c; 52 | int i; 53 | uart_print("0x"); 54 | for (i = 7; i >= 0; i--) { 55 | c = ((v >> (i * 4)) & mask8); 56 | if (c < 10) 57 | c += '0'; 58 | else 59 | c += 'A' - 10; 60 | uart_putc((char) c); 61 | } 62 | } 63 | 64 | void uart_print_hex64(uint64_t v) 65 | { 66 | uart_print_hex32(v >> 32); 67 | uart_print_hex32((uint32_t)(v & 0xFFFFFFFF)); 68 | } 69 | 70 | int uart_tst_fifo(void) 71 | { 72 | if (!pl011_tst_fifo(UART_BASE)) 73 | return 0; 74 | else 75 | return 1; 76 | } 77 | 78 | char uart_getc() 79 | { 80 | char ch = pl011_getc(UART_BASE); 81 | if (ch == '\r') 82 | ch = '\n'; 83 | uart_putc(ch); 84 | return ch; 85 | } 86 | 87 | void uart_gets(char *str, int max_column) 88 | { 89 | char *retval; 90 | char ch; 91 | retval = str; 92 | ch = uart_getc(); 93 | while (ch != '\n' && max_column > 0) { 94 | *retval = ch; 95 | retval++; 96 | max_column--; 97 | if (max_column == 0) 98 | break; 99 | ch = uart_getc(); 100 | } 101 | *retval = NULL; 102 | } 103 | 104 | void uart_init(void) 105 | { 106 | pl011_init(UART_BASE, UART_BAUD, UART_INCLK); 107 | init_print(); 108 | } 109 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_rtsm/guestos/guestloader/guestloader.h: -------------------------------------------------------------------------------- 1 | #ifndef __GUESTLOADER_H__ 2 | #define __GUESTLOADER_H__ 3 | #include "memmap.cfg" 4 | #define MACHINE_TYPE 2272 5 | #define GUEST_START_ADDR LDS_LOADER_PHYS_START 6 | #define ZIMAGE_PHYS_ADDR LDS_GUEST_START 7 | /** @brief Flag for autoboot 8 | * @param flag If flag is '0', it is auto boot, otherwise CLI boot 9 | */ 10 | void guestloader_flag_autoboot(int flag); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_rtsm/guestos/guestloader/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include "drivers/timer.h" 7 | #include 8 | #define DEBUG 9 | #include 10 | #include 11 | 12 | #define MAX_CMD_STR_SIZE 256 13 | #define PROMPT "kboot# " 14 | #define BOOTCMD "boot" 15 | 16 | volatile int autoboot; 17 | 18 | static void guestloader_init(void) 19 | { 20 | /* Initializes serial */ 21 | uart_init(); 22 | /* Initializes GIC */ 23 | gic_init(); 24 | /* Initializes monitoring */ 25 | monitoring_init(); 26 | /* Ready to accept irqs with GIC. Enable it now */ 27 | irq_enable(); 28 | /* Initializes timer */ 29 | timer_init(); 30 | /* Initializes autoboot flag */ 31 | autoboot = 0; 32 | } 33 | 34 | void guestloader_flag_autoboot(int flag) 35 | { 36 | autoboot = flag; 37 | } 38 | 39 | static void guestloader_autoboot(void) 40 | { 41 | /* Disable timer for guest os */ 42 | timer_disable(); 43 | cli_exec_cmd(BOOTCMD); 44 | } 45 | 46 | static void guestloader_cliboot(void) 47 | { 48 | char input_cmd[MAX_CMD_STR_SIZE]; 49 | /* Disable timer for guest os */ 50 | timer_disable(); 51 | while (1) { 52 | uart_print(PROMPT); 53 | uart_gets(input_cmd, MAX_CMD_STR_SIZE); 54 | cli_exec_cmd(input_cmd); 55 | } 56 | } 57 | 58 | void main(int boot_status) 59 | { 60 | /*If Booting status is reboot, run this function. */ 61 | uart_print("guest bootloader\n"); 62 | if(boot_status){ 63 | reboot(); 64 | } 65 | /* Initializes guestloder */ 66 | guestloader_init(); 67 | /* Show Hypervisor Banner */ 68 | uart_print(BANNER_STRING); 69 | /* Auto boot or CLI boot */ 70 | while (1) { 71 | /* Auto boot */ 72 | if (autoboot) 73 | guestloader_autoboot(); 74 | /* Use CLI, if press any key */ 75 | else if (uart_tst_fifo()) 76 | guestloader_cliboot(); 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_rtsm/guestos/guestloader/memmap.cfg: -------------------------------------------------------------------------------- 1 | #define LDS_STACK 0x8F000000 2 | #define LDS_GUEST_START 0x80500000 3 | #define LDS_LOADER_PHYS_START 0x80000000 4 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_rtsm/guestos/guestloader/model.lds.S: -------------------------------------------------------------------------------- 1 | /* 2 | * model.lds.S - simple linker script for stand-alone Linux booting 3 | * 4 | * Copyright (C) 2011 ARM Limited. All rights reserved. 5 | * 6 | * Use of this source code is governed by a BSD-style license that can be 7 | * found in the LICENSE.txt file. 8 | */ 9 | 10 | OUTPUT_FORMAT("elf32-littlearm") 11 | OUTPUT_ARCH(arm) 12 | TARGET(binary) 13 | #include "memmap.cfg" 14 | INPUT(GUEST_PATH) 15 | 16 | #ifdef USE_ANDROID_INITRD 17 | INPUT(INITRD_PATH) 18 | #endif 19 | #ifdef _MON_ 20 | INPUT(../../guestimages/System.map) 21 | #endif 22 | 23 | PHYS_STACK = LDS_STACK; 24 | GUEST_START = LDS_GUEST_START; 25 | LOADER_PHYS_START = LDS_LOADER_PHYS_START; 26 | 27 | SECTIONS 28 | { 29 | . = GUEST_START; 30 | loader_end = .; 31 | guest_start = .; 32 | .guest : {GUEST_PATH} 33 | .= ALIGN(4); 34 | guest_end = .; 35 | 36 | #ifdef USE_ANDROID_INITRD 37 | . = 0x80D00000; 38 | initrd_start = .; 39 | .androidrfs : { INITRD_PATH } 40 | initrd_end = .; 41 | #endif 42 | 43 | #ifdef _MON_ 44 | system_map_start = 0x82000000; 45 | . = system_map_start; 46 | .systemmap : {../../guestimages/System.map} 47 | system_map_end = .; 48 | #endif 49 | 50 | . = LOADER_PHYS_START; 51 | loader_start = .; 52 | .text : { 53 | *(.text) 54 | } 55 | .= ALIGN(4); 56 | .rodata : { 57 | *(.rodata) 58 | } 59 | .= ALIGN(4); 60 | .data : { 61 | *(.data) 62 | } 63 | .= ALIGN(4); 64 | begin_bss = .; 65 | .bss : { 66 | *(.bss) 67 | } 68 | end_bss = .; 69 | 70 | . = ALIGN(4); 71 | 72 | shared_memory_start = 0x8EC00000; 73 | . = shared_memory_start; 74 | shared_memory_end = . + 0x400000; 75 | 76 | guestloader_end = .; 77 | 78 | . = PHYS_STACK; 79 | guestloader_stacktop_svc = .; 80 | . = PHYS_STACK + 0x00400000; 81 | guestloader_stacklimit_svc = .; 82 | guestloader_stacktop_irq = .; 83 | . = PHYS_STACK + 0x00800000; 84 | guestloader_stacklimit_irq = .; 85 | 86 | restore_start = 0xB0000000; 87 | restore_guest_start = restore_start + 0x00500000; 88 | restore_guest_end = restore_guest_start + (guest_end - guest_start); 89 | restore_end = restore_start + (guestloader_end - loader_start); 90 | } 91 | -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_rtsm/patch/fs.cpio: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kesl/khypervisor/722d32a42e08eba144dc2fa1a528c1369055204c/platform-device/cortex_a15x2_rtsm/patch/fs.cpio -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_rtsm/patch/host-a15.dtb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kesl/khypervisor/722d32a42e08eba144dc2fa1a528c1369055204c/platform-device/cortex_a15x2_rtsm/patch/host-a15.dtb -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_rtsm/patch/host-a15x1.dtb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kesl/khypervisor/722d32a42e08eba144dc2fa1a528c1369055204c/platform-device/cortex_a15x2_rtsm/patch/host-a15x1.dtb -------------------------------------------------------------------------------- /platform-device/cortex_a15x2_rtsm/patch/rtsm_ve-cortex_a15x1.dtb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kesl/khypervisor/722d32a42e08eba144dc2fa1a528c1369055204c/platform-device/cortex_a15x2_rtsm/patch/rtsm_ve-cortex_a15x1.dtb -------------------------------------------------------------------------------- /platform-device/pc/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile 2 | # 3 | # Usage: make 4 | # Example: 5 | # $ make # build for pc version of khypervisor 6 | 7 | # Include config file (prefer config.mk fall back to config-default.mk) 8 | ifneq ($(wildcard config.mk),) 9 | include config.mk 10 | else 11 | include config-default.mk 12 | endif 13 | 14 | .SUFFIXES: .c .o 15 | 16 | PROJECT_ROOT_DIR=../.. 17 | HYPERVISOR_SOURCE_DIR=$(PROJECT_ROOT_DIR)/hypervisor 18 | COMMON_SOURCE_DIR=$(PROJECT_ROOT_DIR)/common 19 | 20 | OBJS = main.o \ 21 | timer.o 22 | 23 | SRCS = main.c \ 24 | timer.c 25 | 26 | INCLUDES = -I $(PROJECT_ROOT_DIR) 27 | 28 | INCLUDES += -I $(COMMON_SOURCE_DIR) \ 29 | -I $(COMMON_SOURCE_DIR)/include 30 | 31 | INCLUDES += -I $(HYPERVISOR_SOURCE_DIR) \ 32 | -I $(HYPERVISOR_SOURCE_DIR)/include \ 33 | -I $(HYPERVISOR_SOURCE_DIR)/hal/arm32ve/include 34 | 35 | CPPFLAGS += $(CONFIG_FLAGS) $(INCLUDES) 36 | 37 | CC = $(CROSS_COMPILE)gcc 38 | LD = $(CROSS_COMPILE)ld 39 | NM = $(CROSS_COMPILE)nm 40 | 41 | TARGET = pc 42 | 43 | all: $(TARGET) 44 | 45 | $(TARGET): $(OBJS) 46 | $(CC) $(CPPFLAGS) -Wall -O0 -o $@ $(OBJS) 47 | 48 | clean: 49 | rm -rf $(OBJS) $(TARGET) 50 | 51 | .PHONY: all clean config.mk config-default.mk 52 | -------------------------------------------------------------------------------- /platform-device/pc/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kesl/khypervisor/722d32a42e08eba144dc2fa1a528c1369055204c/platform-device/pc/README.md -------------------------------------------------------------------------------- /platform-device/pc/config-default.mk: -------------------------------------------------------------------------------- 1 | # Configuration file included in Makefile 2 | # 3 | # Copyright (C) 2011 Columbia University. All rights reserved. 4 | # Christoffer Dall 5 | # Use of this source code is governed by a BSD-style license that can be 6 | # found in the LICENSE.txt file. 7 | # 8 | # This is a sample configuration file. To make changes, copy this file to 9 | # config.mk and modify that file. 10 | # 11 | # For all systems you can override USE_INITRD and KCMD from the command-line. 12 | # 13 | 14 | ########################################################################### 15 | # Main options 16 | # 17 | CROSS_COMPILE ?= 18 | ARCH ?= x86_64 19 | 20 | CPPFLAGS += -g 21 | -------------------------------------------------------------------------------- /platform-device/pc/k-hypervisor-config.h: -------------------------------------------------------------------------------- 1 | #ifndef KHYPERVISOR_CONFIG_H 2 | #define KHYPERVISOR_CONFIG_H 3 | 4 | #endif /* KHYPERVISOR_CONFIG_H */ 5 | -------------------------------------------------------------------------------- /platform-device/pc/main.c: -------------------------------------------------------------------------------- 1 | #include "timer.h" 2 | 3 | int main(void) 4 | { 5 | start_timer(); 6 | 7 | while (1) 8 | ; 9 | return 0; 10 | } 11 | -------------------------------------------------------------------------------- /platform-device/pc/timer.c: -------------------------------------------------------------------------------- 1 | #include "timer.h" 2 | 3 | void start_timer() 4 | { 5 | } 6 | -------------------------------------------------------------------------------- /platform-device/pc/timer.h: -------------------------------------------------------------------------------- 1 | #ifndef __PC_TIMER_H__ 2 | #define __PC_TIMER_H__ 3 | 4 | #include 5 | 6 | void start_timer(void); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /scripts/apply_patch.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | export APPLY_ROOT=$PWD 3 | 4 | cd $APPLY_ROOT/platform-device/cortex_a15x2_rtsm/guestos/linux 5 | git reset --hard 6 | git clean -xdf 7 | git branch -D temp 8 | git checkout 7d1f9aeff1ee4a20b1aeb377dd0f579fe9647619 -b temp 9 | git branch -D 3.8 10 | git checkout 7d1f9aeff1ee4a20b1aeb377dd0f579fe9647619 -b 3.8 11 | git apply ../../patch/linux-fastmodels-config-add-minimal-linux-config.patch 12 | 13 | cd $APPLY_ROOT/platform-device/cortex_a15x2_arndale/guestos/linux 14 | echo $APPLY_ROOT/platform-device/cortex_a15x2_arndale/guestos/linux 15 | 16 | cd $APPLY_ROOT/platform-device/cortex_a15x2_arndale/u-boot-native 17 | git reset --hard 18 | git clean -xdf 19 | 20 | cd $APPLY_ROOT/platform-device/cortex_a15x2_arndale/guestos/linux 21 | git reset --hard 22 | git clean -xdf 23 | git branch -D temp 24 | git checkout origin/exynos-jb -b temp 25 | git branch -D exynos-jb 26 | git checkout origin/exynos-jb -b exynos-jb 27 | git apply ../../patch/linux-arndale-config-add-minimal-linux-config.patch 28 | -------------------------------------------------------------------------------- /scripts/build_android_vexpress_mmc.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | export APPLY_ROOT=$PWD 3 | 4 | cd $PWD/platform-device/cortex_a15x2_rtsm/guestos/android_boot/ 5 | 6 | wget http://releases.linaro.org/13.08/android/vexpress/boot.tar.bz2 7 | wget http://releases.linaro.org/13.08/android/vexpress/system.tar.bz2 8 | wget http://releases.linaro.org/13.08/android/vexpress/userdata.tar.bz2 9 | linaro-android-media-create --image-file linaro.img --image-size 2000M --dev vexpress --boot boot.tar.bz2 --system system.tar.bz2 --userdata userdata.tar.bz2 10 | -------------------------------------------------------------------------------- /scripts/build_tags.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | find . ! \( \( -type d -path './*/guestos/linux' -o -path './*/u-boot*' -o -path './*/ucos-ii' \) -prune \) -name "*.[chCHS]" -exec etags -a {} \; 3 | find . ! \( \( -type d -path './*/guestos/linux' -o -path './*/u-boot*' -o -path './*/guestos/ucos-ii' \) -prune \) -name "*.[chCHS]" -print >> ./cscope.files 4 | cscope -b -q -k 5 | rm cscope.files 6 | -------------------------------------------------------------------------------- /scripts/ci/README.md: -------------------------------------------------------------------------------- 1 | # Continuous Integration for K-hypervisor 2 | -------------------------------------------------------------------------------- /scripts/ci/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kesl/khypervisor/722d32a42e08eba144dc2fa1a528c1369055204c/scripts/ci/__init__.py -------------------------------------------------------------------------------- /scripts/ci/archive.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import os 3 | import shutil 4 | import tarfile 5 | 6 | CI_DIR = os.path.dirname(os.path.abspath(__file__)) 7 | SCRIPT_DIR = os.path.dirname(CI_DIR) 8 | ROOT_DIR = os.path.dirname(SCRIPT_DIR) 9 | PLATFORM_DIR = os.path.join(ROOT_DIR, 'platform-device') 10 | 11 | IMAGE_DIR_NAME = 'out' 12 | TARGET_NAME = 'k-hypervisor_full_images.tar.gz' 13 | 14 | class ZipFolder(): 15 | def __init__(self, location): 16 | self.location = location 17 | 18 | def makeCompress(self): 19 | try: 20 | if os.path.exists(self.location): 21 | print str(self.location) 22 | compressTar = tarfile.open(TARGET_NAME, "w:gz") 23 | compressTar.add(self.location) 24 | compressTar.close() 25 | print "Compress complete ", self.location 26 | return True 27 | else: 28 | print " (ZipFile)No Such Folder ",self.location 29 | return False 30 | except: 31 | print str(sys.exc_info()) 32 | return False 33 | 34 | def ArchiveImage(): 35 | print '@@ Compress images @@' 36 | product = str(os.getenv('TARGET_PRODUCT')) 37 | 38 | os.chdir(IMAGE_DIR_NAME) 39 | 40 | target = product + "/" + str(os.getenv('CI_BUILD_DIR')) + "/" + TARGET_NAME 41 | 42 | zipFolder = ZipFolder(product) 43 | if zipFolder.makeCompress() == False : 44 | return False 45 | try: 46 | shutil.move(TARGET_NAME, target) 47 | except IOError, e: 48 | print "Unable to copy file. %s" % TARGET_NAME 49 | return False 50 | 51 | print '@@ Compress Done@@' 52 | return True 53 | 54 | if __name__ == '__main__': 55 | ArchiveImage() 56 | 57 | -------------------------------------------------------------------------------- /scripts/ci/extract.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import os 3 | import shutil 4 | import distutils.core 5 | 6 | CI_DIR = os.path.dirname(os.path.abspath(__file__)) 7 | SCRIPT_DIR = os.path.dirname(CI_DIR) 8 | ROOT_DIR = os.path.dirname(SCRIPT_DIR) 9 | PLATFORM_DIR = os.path.join(ROOT_DIR, 'platform-device') 10 | 11 | IMAGE_DIR_NAME = 'out' 12 | 13 | def ExtractImage(): 14 | print '@@ extract images @@' 15 | 16 | product = str(os.getenv('TARGET_PRODUCT')) 17 | 18 | image_dir = ROOT_DIR + "/" + IMAGE_DIR_NAME + "/" + product + "/" 19 | image_dir += str(os.getenv('CI_BUILD_DIR')) 20 | print image_dir 21 | 22 | if not os.path.exists(image_dir): 23 | os.makedirs(image_dir) 24 | 25 | target_dir = PLATFORM_DIR + "/" + product 26 | 27 | # copy hypervisor image 28 | print 'copy hypervisor image' 29 | hypervisor_image = str(os.getenv('HYPERVISOR_BIN')) 30 | try: 31 | shutil.copy2(target_dir + "/" + hypervisor_image, image_dir + "/") 32 | except IOError, e: 33 | print "Unable to copy file. %s" % hypervisor_image 34 | return False 35 | 36 | # copy guest images 37 | print 'copy guest image' 38 | guest_image = str(os.getenv('GUEST_IMAGE_DIR')) 39 | try: 40 | distutils.dir_util.copy_tree(target_dir + "/" + guest_image, 41 | image_dir + "/") 42 | except IOError, e: 43 | print "Unable to copy file. %s" % guest_image 44 | return False 45 | 46 | # copy bootloader images 47 | if (os.getenv('UBOOT_DIR') != "") : 48 | print 'copy bootloader image' 49 | bootloader_image = str(os.getenv('UBOOT_DIR')) 50 | bootloader_image = bootloader_image + "/" + str(os.getenv('UBOOT')) 51 | try: 52 | shutil.copy2(target_dir + "/" + bootloader_image, image_dir + "/") 53 | except IOError, e: 54 | print "Unable to copy file. %s" % bootloader_image 55 | return False 56 | 57 | print '@@ extract done@@' 58 | return True 59 | 60 | if __name__ == '__main__': 61 | ExtractImage() 62 | 63 | -------------------------------------------------------------------------------- /scripts/ci/result_parser.py: -------------------------------------------------------------------------------- 1 | import os 2 | import shutil 3 | import subprocess 4 | import sys 5 | import re 6 | import time 7 | import simulator 8 | 9 | CI_DIR = os.path.dirname(os.path.abspath(__file__)) 10 | SCRIPT_DIR = os.path.dirname(CI_DIR) 11 | ROOT_DIR = os.path.dirname(SCRIPT_DIR) 12 | PLATFORM_DIR = os.path.join(ROOT_DIR, 'platform-device') 13 | 14 | HYPERVISOR_LOG = 'hypervisor' 15 | GUEST_LOG = 'guest' 16 | 17 | class TestLog: 18 | def __init__(self): 19 | self.list = [] 20 | 21 | def PrintTestResult(self, a_class, a_name, a_result): 22 | print str(a_class + " " + a_name + " " + a_result) 23 | 24 | def GetResult(self, a_class, a_func): 25 | result = False 26 | for g in self.list: 27 | if str(g['test_class']) == a_class and \ 28 | str(g['test_func']) == a_func : 29 | self.PrintTestResult(str(g['test_class']), 30 | str(g['test_func']), 31 | str(g['test_result']).strip()) 32 | if (str(g['test_result']).strip() == 'PASS'): 33 | result = True 34 | elif (str(g['test_result']).strip() == 'FAILED'): 35 | result = False 36 | break 37 | 38 | return result 39 | 40 | def AddResult(self, a_result): 41 | self.list.append(a_result) 42 | 43 | class ResultParser: 44 | def __init__(self): 45 | self._re = re.compile(r'[\[K\-HYPERVISOR\]TEST\#](?P[^#]+)[#]' 46 | '(?P[^#]+)[#](?P[^#]+)[#]' 47 | '(?P[^#]+)') 48 | self.guest_log = 'guest' 49 | self.hypervisor_log = 'hypervisor' 50 | self.test_log = TestLog() 51 | 52 | def GetLogResult(self, a_class, a_name): 53 | print "Test " + str(a_class) + " " + str(a_name) 54 | return self.test_log.GetResult(a_class, a_name) 55 | 56 | def SaveLog(self, product, input): 57 | print product 58 | print input 59 | 60 | for line in open(input, 'rt'): 61 | #print line 62 | node = self._re.match(line) 63 | if node is not None: 64 | g = node.groupdict() 65 | test_class = str(g['test_class']) 66 | print test_class 67 | self.test_log.AddResult(g) 68 | 69 | return True 70 | 71 | def ParseLog(self, product): 72 | print '@@ Parse Log @@' 73 | product = str(os.getenv('TARGET_PRODUCT')) 74 | target_dir = PLATFORM_DIR + "/" + product + "/" 75 | 76 | self.SaveLog(product, target_dir + "/" + HYPERVISOR_LOG + ".log") 77 | guest_count = int(os.getenv('GUEST_COUNT')) 78 | print "guest_count" + str(guest_count) 79 | for n in range(0, guest_count): 80 | self.SaveLog(product, target_dir + 81 | GUEST_LOG + str(n) + ".log") 82 | 83 | print '@@ Check done@@' 84 | 85 | if __name__ == '__main__': 86 | product = str(os.getenv('TARGET_PRODUCT')) 87 | result_parser = ResultParser() 88 | 89 | result_parser.ParseLog(product) 90 | result_parser.GetLogResult('INSTALLATION', 'BOOT') 91 | 92 | -------------------------------------------------------------------------------- /scripts/ci/simulator.py: -------------------------------------------------------------------------------- 1 | import os 2 | import shutil 3 | import subprocess 4 | import sys 5 | import re 6 | import time 7 | import signal 8 | 9 | CI_DIR = os.path.dirname(os.path.abspath(__file__)) 10 | SCRIPT_DIR = os.path.dirname(CI_DIR) 11 | ROOT_DIR = os.path.dirname(SCRIPT_DIR) 12 | PLATFORM_DIR = os.path.join(ROOT_DIR, 'platform-device') 13 | 14 | SIMULATOR_OPTION = str(os.getenv('SIMULATOR_OPTION')) 15 | RTSM_LOG = [' -C motherboard.pl011_uart0.out_file=', 16 | ' -C motherboard.pl011_uart1.out_file=', 17 | ' -C motherboard.pl011_uart2.out_file=' 18 | ] 19 | 20 | HYPERVISOR_LOG = 'hypervisor' 21 | GUEST_LOG = 'guest' 22 | 23 | def RunSimulator(duration): 24 | print '@@ Run Simulator @@' 25 | 26 | product = str(os.getenv('TARGET_PRODUCT')) 27 | hypervisor_image = str(os.getenv('HYPERVISOR_BIN')) 28 | target_dir = PLATFORM_DIR + "/" + product + "/" 29 | 30 | os.chdir(target_dir) 31 | sys.stdout.flush() 32 | env = os.environ.copy() 33 | 34 | simul = SIMULATOR_OPTION + PLATFORM_DIR + "/" + product + "/" 35 | simul += hypervisor_image 36 | 37 | log_option = RTSM_LOG[0] + HYPERVISOR_LOG + ".log" 38 | guest_count = int(os.getenv('GUEST_COUNT')) 39 | 40 | print "guest_count : " + str(guest_count) 41 | for n in range(0, guest_count): 42 | if RTSM_LOG[n + 1] == None: 43 | print '@@@ overflow log path is not valid @@@' 44 | return False 45 | log_option += RTSM_LOG[n + 1] + GUEST_LOG + str(n) + ".log" 46 | 47 | simul += log_option 48 | 49 | print simul 50 | 51 | pro = subprocess.Popen( 52 | ['/bin/bash', 53 | '-c', simul], 54 | stdout=subprocess.PIPE, 55 | preexec_fn=os.setsid, 56 | cwd=target_dir, env=env) 57 | 58 | print 'wating for %d sec'% (duration) 59 | time.sleep(duration) 60 | 61 | os.killpg(pro.pid, signal.SIGTERM) 62 | print '@@ Kill Simulator@@' 63 | 64 | return True 65 | 66 | if __name__ == '__main__': 67 | 68 | RunSimulator(int(sys.argv[1])) 69 | -------------------------------------------------------------------------------- /scripts/ci/tests/README.md: -------------------------------------------------------------------------------- 1 | # Continuous Integration for K-hypervisor 2 | -------------------------------------------------------------------------------- /scripts/ci/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kesl/khypervisor/722d32a42e08eba144dc2fa1a528c1369055204c/scripts/ci/tests/__init__.py -------------------------------------------------------------------------------- /scripts/ci/tests/test_code_quality.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | from os.path import join 4 | from nose.tools import ok_, eq_ 5 | 6 | PROJRELROOT = '../' 7 | sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), PROJRELROOT))) 8 | sys.path.append(os.path.abspath('./')) 9 | 10 | import checkpatch 11 | 12 | def test_coding_style(): 13 | print 'Code Quality Check... : Coding Style' 14 | eq_(checkpatch.RunPullRequestPatch(), True) 15 | 16 | def test_clang(): 17 | eq_(True, True) 18 | 19 | -------------------------------------------------------------------------------- /scripts/ci/tests/test_installation.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | from os.path import join 4 | from nose.tools import ok_, eq_ 5 | 6 | PROJRELROOT = '../' 7 | sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), PROJRELROOT))) 8 | sys.path.append(os.path.abspath('./')) 9 | 10 | import result_parser 11 | 12 | the_product = str(os.getenv('TARGET_PRODUCT')) 13 | the_parser = result_parser.ResultParser() 14 | the_parser.ParseLog(the_product) 15 | 16 | def test_flash(): 17 | eq_(True, True) 18 | 19 | def test_boot(): 20 | guest_count = int(os.getenv('GUEST_COUNT')) 21 | print "guest_count" + str(guest_count) 22 | guest_type = os.getenv('CI_BUILD_DIR') 23 | guests = guest_type.split("_") 24 | 25 | for n in range(0, guest_count): 26 | guest_boot = guests[n].upper() + "-BOOT" 27 | print guest_boot 28 | ret = the_parser.GetLogResult('INSTALLATION', guest_boot) 29 | eq_(ret, True) 30 | -------------------------------------------------------------------------------- /scripts/ci/tests/test_integration.py: -------------------------------------------------------------------------------- 1 | from nose.tools import ok_, eq_ 2 | 3 | def test_integration(): 4 | eq_(True, True) 5 | -------------------------------------------------------------------------------- /scripts/ci/tests/test_load.py: -------------------------------------------------------------------------------- 1 | from nose.tools import ok_, eq_ 2 | 3 | def test_load(): 4 | eq_(True, True) 5 | -------------------------------------------------------------------------------- /scripts/ci/tests/test_performance.py: -------------------------------------------------------------------------------- 1 | from nose.tools import ok_, eq_ 2 | 3 | def test_performance(): 4 | eq_(True, True) 5 | -------------------------------------------------------------------------------- /scripts/ci/tests/test_release.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | from os.path import join 4 | from nose.tools import ok_, eq_ 5 | 6 | PROJRELROOT = '../' 7 | sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), PROJRELROOT))) 8 | sys.path.append(os.path.abspath('./')) 9 | 10 | import extract 11 | import archive 12 | import upload 13 | 14 | def test_extract(): 15 | print 'Extract Release Files... ' 16 | eq_(extract.ExtractImage(), True) 17 | 18 | def test_archive(): 19 | print 'Archive Release Files... ' 20 | eq_(archive.ArchiveImage(), True) 21 | 22 | def test_upload(): 23 | print 'Upload Release Files... ' 24 | if (os.getenv('BULID_TYPE') != None): 25 | eq_(upload.Upload(), True) 26 | else: 27 | eq_(True, True) 28 | -------------------------------------------------------------------------------- /scripts/ci/tests/test_smoke.py: -------------------------------------------------------------------------------- 1 | from nose.tools import ok_, eq_ 2 | 3 | def test_smoke(): 4 | eq_(True, True) 5 | -------------------------------------------------------------------------------- /scripts/run_mmc_rtsm.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | RTSM_VE_Cortex-A15x1-A7x1 -C motherboard.smsc_91c111.enabled=1 -C motherboard.hostbridge.userNetworking=1 -C motherboard.mmc.p_mmc_file="platform-device/cortex_a15x2_rtsm/guestos/android_boot/linaro.img" -a coretile.cluster0.cpu0=platform-device/cortex_a15x2_rtsm/hvc-man-switch.axf 3 | -------------------------------------------------------------------------------- /scripts/run_rtsm.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | RTSM_VE_Cortex-A15x1-A7x1 -C motherboard.smsc_91c111.enabled=1 -C motherboard.hostbridge.userNetworking=1 -a coretile.cluster0.cpu0=platform-device/cortex_a15x2_rtsm/hvc-man-switch.axf 3 | -------------------------------------------------------------------------------- /scripts/uboot_rtsm.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | LD_LIBRARY_PATH=/usr/local/RTSM_A15-A7x14_VE/models/Linux64_GCC-4.1/ RTSM_VE_Cortex-A15x1-A7x1 --cadi-server -C motherboard.flashloader0.fname=$PWD/armflash.bin 3 | --------------------------------------------------------------------------------