├── .gitignore ├── LICENSE ├── README.md ├── arch └── mips │ ├── baikal-t1 │ ├── baikal.ld │ ├── baikal.mk │ ├── boot.S │ ├── gpr_context.c │ ├── include │ │ ├── addr.h │ │ ├── arch.h │ │ ├── baikal-t1.h │ │ ├── boot.h │ │ ├── gpr_context.h │ │ ├── instruction_emulation.h │ │ ├── interrupts.h │ │ ├── launch.h │ │ ├── p5600.h │ │ ├── pic32mz.h │ │ ├── segcfg.h │ │ └── timer.h │ ├── instruction_emulation.c │ ├── interrupts.c │ ├── timer.c │ └── uart_driver.c │ ├── common │ ├── common.mk │ ├── hal.c │ ├── include │ │ ├── hal.h │ │ ├── mips_cp0.h │ │ ├── tlb.h │ │ └── vcpu.h │ ├── tlb.c │ └── vcpu.c │ └── pic32mz │ ├── boot.S │ ├── include │ ├── arch.h │ ├── gpr_context.h │ ├── instruction_emulation.h │ ├── interrupts.h │ ├── pic32mz.h │ └── timer.h │ ├── instruction_emulation.c │ ├── interrupts.c │ ├── pic32mz.ld │ ├── pic32mz.mk │ ├── timer.c │ └── uart_driver.c ├── bare-metal-apps ├── apps │ ├── blink │ │ ├── app.mk │ │ └── blink.c │ ├── button │ │ ├── app.mk │ │ └── button.c │ ├── coremark │ │ ├── app.mk │ │ └── main.c │ ├── dhrystone │ │ ├── app.mk │ │ └── dhrystone.c │ ├── inputUART │ │ ├── app.mk │ │ └── inputUART.c │ ├── int_latency │ │ ├── app.mk │ │ ├── latency-average.c │ │ ├── latency.c │ │ ├── ols-log.csv │ │ └── osl.csv │ ├── int_redirect │ │ ├── app.mk │ │ └── redirection.c │ ├── malloc_sample │ │ ├── app.mk │ │ └── malloc_sample.c │ ├── outputUART │ │ ├── app.mk │ │ └── outputUART.c │ ├── output_signal │ │ ├── app.mk │ │ └── output_signal.c │ ├── ping │ │ ├── app.mk │ │ └── ping.c │ ├── pong │ │ ├── app.mk │ │ └── pong.c │ ├── read-flash │ │ ├── app.mk │ │ └── read-flash.c │ ├── shared-buffer │ │ ├── app.mk │ │ └── shared-buffer.c │ ├── spi │ │ ├── app.mk │ │ └── spi.c │ ├── tcp-listener │ │ ├── app.mk │ │ └── tcp-listener.c │ ├── usb │ │ ├── app.mk │ │ └── usb.c │ ├── webserver │ │ ├── .tcp-listener.c.kate-swp │ │ ├── app.mk │ │ ├── html-sources │ │ │ ├── bg_stripe.png │ │ │ ├── board.js │ │ │ ├── cloud.png │ │ │ ├── favicon.png │ │ │ ├── index.html │ │ │ ├── make-Cfiles.py │ │ │ ├── pic32mz.jpg │ │ │ └── picotcp_style.css │ │ └── webserver.c │ └── wolfssl │ │ ├── .tcp-listener.c.kate-swp │ │ ├── SSL_cert.h │ │ ├── SSL_keys.h │ │ ├── app.mk │ │ ├── cert │ │ ├── cert.pem │ │ ├── make-SSL-include.py │ │ └── privkey.pem │ │ ├── html-sources │ │ ├── bg_stripe.png │ │ ├── board.js │ │ ├── cloud.png │ │ ├── favicon.png │ │ ├── index.html │ │ ├── make-Cfiles.py │ │ ├── pic32mz.jpg │ │ └── picotcp_style.css │ │ ├── web_files.c │ │ ├── web_files.h │ │ ├── wolfssl.mk │ │ ├── wolfssl_app-web-test.c │ │ ├── wolfssl_app.c │ │ └── wolfssl_app_rsa-test.c ├── arch │ └── mips │ │ ├── baikal-t1 │ │ ├── baikal.ld │ │ ├── crt0.s │ │ ├── eth.c │ │ ├── hal.mk │ │ ├── include │ │ │ ├── arch.h │ │ │ ├── eth.h │ │ │ └── platform.h │ │ └── platform.c │ │ └── pic32mz │ │ ├── crt0.s │ │ ├── eth.c │ │ ├── hal.mk │ │ ├── include │ │ ├── arch.h │ │ ├── eth.h │ │ └── platform.h │ │ ├── pic32mz.ld │ │ └── platform.c ├── include │ ├── eth.h │ ├── libc.h │ ├── pic32mz.h │ └── puf.h ├── lib │ ├── include │ │ ├── hypercalls.h │ │ ├── libc.h │ │ ├── malloc.h │ │ ├── network.h │ │ ├── types.h │ │ └── usb.h │ ├── lib.mk │ ├── libc.c │ ├── malloc.c │ └── network.c └── platform │ ├── baikal_t1_board │ ├── Makefile │ ├── include │ │ ├── io.h │ │ └── uart.h │ ├── platform.mk │ └── uart.c │ ├── pic32mz_chipkit_Wifire │ ├── Makefile │ ├── include │ │ ├── io.h │ │ └── uart.h │ ├── platform.mk │ └── uart.c │ ├── pic32mz_curiosity │ ├── Makefile │ ├── include │ │ ├── io.h │ │ └── uart.h │ ├── platform.mk │ └── uart.c │ └── pic32mz_starter_kit │ ├── Makefile │ ├── include │ ├── io.h │ └── uart.h │ ├── platform.mk │ └── uart.c ├── bin ├── Microchip_Curiosity_UART.hex ├── Microchip_Eth_Starter_Kit_UART.hex ├── board-control-noKey.py ├── board-control.py ├── chipKIT-WiFire-EF.hex ├── install-tools-baikal.sh ├── install-tools-pic32mz.sh ├── pic32prog └── test_puf_vm.py ├── doc ├── doxygen │ └── Doxyfile ├── images │ ├── baikal-t1.jpg │ ├── chipkit-wifire-top.jpg │ ├── chipkit-wifire.jpg │ ├── curiosity.jpg │ ├── gdb_bb.jpg │ ├── starter_kit.jpg │ └── wi-fire.jpg └── prpl-security-guidance-2-5-2.pdf ├── drivers ├── drivers.mk ├── include │ ├── pic32mz-ethernet.h │ └── usb.h ├── inter-vm-comm.c ├── performance-counter.c ├── pic32mz-ethernet-shared.c ├── pic32mz-ethernet.c ├── pic32mz-interrupt-latency-test.c ├── pic32mz-interrupt-redirect.c ├── pic32mz-puf-flash.c ├── pic32mz-timer-test.c ├── pic32mz-usb.c ├── t1-baikal-UART-test.c └── virtual-io.c ├── include ├── globals.h ├── guest_interrupts.h └── hypercall_defines.h ├── platform ├── baikal_t1_board │ ├── Makefile │ ├── board │ │ ├── board.c │ │ ├── board.mk │ │ └── uart.c │ ├── cfg │ │ ├── coremark.cfg │ │ ├── dhrystone.cfg │ │ ├── sample-3VMs.cfg │ │ ├── sample-blink.cfg │ │ ├── sample-linux.cfg │ │ └── sample-ping-pong.cfg │ └── include │ │ └── platform.h ├── cfg_reader │ └── genconf.c ├── include │ ├── board.h │ └── uart.h ├── pic32mz_chipkit_Wifire │ ├── Makefile │ ├── board │ │ ├── board.c │ │ ├── board.mk │ │ └── uart.c │ ├── cfg │ │ ├── sample-3VMs.cfg │ │ ├── sample-blink.cfg │ │ ├── sample-ping-pong.cfg │ │ └── sample-redirection.cfg │ ├── debug │ │ ├── dp_busblaster.cfg │ │ ├── gdbinit │ │ ├── wifire.cfg │ │ └── wifire.tcl │ └── include │ │ └── platform.h ├── pic32mz_curiosity │ ├── Makefile │ ├── board │ │ ├── board.c │ │ ├── board.mk │ │ └── uart.c │ ├── cfg │ │ ├── output-signal.cfg │ │ ├── sample-3VMs.cfg │ │ ├── sample-blink.cfg │ │ ├── sample-ping-pong.cfg │ │ └── sample-redirection.cfg │ └── include │ │ ├── platform.h │ │ └── vms.info └── pic32mz_starter_kit │ ├── Makefile │ ├── board │ ├── board.c │ ├── board.mk │ ├── reset.c │ └── uart.c │ ├── cfg │ ├── coremark.cfg │ ├── dhrystone.cfg │ ├── latency.cfg │ ├── sample-3VMs.cfg │ ├── sample-4VMs.cfg │ ├── sample-blink.cfg │ ├── sample-ping-pong.cfg │ ├── sample-read-flash.cfg │ ├── sample-redirection.cfg │ ├── shared-ethernet.cfg │ ├── webserver.cfg │ └── wolfssl.cfg │ └── include │ └── platform.h ├── scripts ├── genhex.sh └── genversion.sh └── sys ├── kernel ├── driver.c ├── exception.c ├── hypercall.c ├── include │ ├── driver.h │ ├── exception.h │ ├── hypercall.h │ ├── scheduler.h │ └── vm.h ├── kernel.mk ├── scheduler.c └── vm.c ├── lib ├── include │ ├── libc.h │ ├── linkedlist.h │ ├── malloc.h │ ├── queue.h │ └── types.h ├── lib.mk ├── libc.c ├── linkedlist.c ├── malloc.c └── queue.c └── sys.mk /.gitignore: -------------------------------------------------------------------------------- 1 | .cproject 2 | .project 3 | 4 | **/*.bin 5 | **/*.cnt 6 | **/*.elf 7 | **/*.lst 8 | **/*.map 9 | **/*.o 10 | **/*.sec 11 | **/*.hex 12 | 13 | include/config.h 14 | 15 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016, prpl Foundation 2 | 3 | Permission to use, copy, modify, and/or distribute this software for any purpose with or without 4 | fee is hereby granted, provided that the above copyright notice and this permission notice appear 5 | in all copies. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 8 | INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 9 | FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 10 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 11 | ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 12 | 13 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## What is the prplHypervisor™? 2 | 3 | The prplHypervisor™ is the industry-first open source hypervisor specifically designed to provide security 4 | through separation for the billions of embedded connected devices that power the Internet of Things. The MIPS 5 | M5150 version of the prplHypervisor™ implements MIPS VZ extensions to provide a lightweight isolation layer for 6 | Microchip Technology’s PIC32MZ microcontrollers. In addition to real-time hardware virtualization, the prplHypervisor™ 7 | provides additional security services including prplPUF™ authentication and prplSecureInterVM™ communications. 8 | 9 | The prplHypervisor™ features minimal attack surface - less than 7,000 lines of code, limited footprint – 30KB flash, 10 | 4K RAM/VM, up to eight isolated domains. Performance tests show negligible overhead for context switching and interVM 11 | communications. prplHypervisor™, prplPUF™, and prplSecureInterVM™ technologies are part of the prplSecurity™ open source 12 | framework and are released under prpl Foundation permissive license – see http://prplfoundation.org/ip-policy. 13 | 14 | 15 | ## How to build? 16 | 17 | Once you have the building environment configured, go to a platform board folder: 18 | 19 | prpl-hypervisor/platform/pic32mz_starter_kit; 20 | prpl-hypervisor/platform/pic32mz_chipkit_Wifire, or; 21 | prpl-hypervisor/platform/pic32mz_curiosity. 22 | 23 | Then, perform: 24 | 25 | make && make load 26 | 27 | 28 | See the complete documentation in https://github.com/prplfoundation/prpl-hypervisor/wiki. 29 | 30 | -------------------------------------------------------------------------------- /arch/mips/baikal-t1/baikal.mk: -------------------------------------------------------------------------------- 1 | # 2 | #Copyright (c) 2016, prpl Foundation 3 | # 4 | #Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | #fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | #in all copies. 7 | # 8 | #THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | #INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | #FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | #LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | #ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | # 14 | #This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | 16 | baikal: 17 | $(CC) $(CFLAGS) $(INC_DIRS) \ 18 | $(TOPDIR)arch/mips/baikal-t1/timer.c \ 19 | $(TOPDIR)arch/mips/baikal-t1/interrupts.c \ 20 | $(TOPDIR)arch/mips/baikal-t1/boot.S \ 21 | $(TOPDIR)arch/mips/baikal-t1/uart_driver.c \ 22 | $(TOPDIR)arch/mips/baikal-t1/gpr_context.c \ 23 | $(TOPDIR)arch/mips/baikal-t1/instruction_emulation.c 24 | -------------------------------------------------------------------------------- /arch/mips/baikal-t1/include/arch.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2016, prpl Foundation 3 | 4 | Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | in all copies. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | 14 | This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | 16 | */ 17 | 18 | #ifndef __ARCH_H 19 | #define __ARCH_H 20 | 21 | #define BARE_METAL_ENTRY_POINT 0x80001000 22 | #define LINUX_ENTRY_POINT 0x80100400 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /arch/mips/baikal-t1/include/baikal-t1.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2016, prpl Foundation 3 | 4 | Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | in all copies. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | 14 | This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | 16 | */ 17 | 18 | /* 19 | * Baikal-T (P5600) core address definitions 20 | * 21 | */ 22 | 23 | #ifndef _BAIKAL_T1_H 24 | #define _BAIKAL_T1_H 25 | 26 | #define UART0_BASE(a) *(volatile unsigned*) (0xBF04A000 + (a<<2)) 27 | #define UART0_RBR UART0_BASE(0) 28 | #define UART0_IER UART0_BASE(1) 29 | #define UART0_IIR UART0_BASE(2) 30 | #define UART0_LCR UART0_BASE(3) 31 | #define UART0_LSR UART0_BASE(5) 32 | #define UART0_MSR UART0_BASE(6) 33 | 34 | #define UART1_BASE(a) *(volatile unsigned*) (0xBF04B000 + (a<<2)) 35 | #define UART1_RBR UART1_BASE(0) 36 | #define UART1_IER UART1_BASE(1) 37 | #define UART1_IIR UART1_BASE(2) 38 | #define UART1_LCR UART1_BASE(3) 39 | #define UART1_LSR UART1_BASE(5) 40 | #define UART1_MSR UART1_BASE(6) 41 | 42 | 43 | typedef union { 44 | struct{ 45 | unsigned exl:1; 46 | unsigned k:1; 47 | unsigned :1; 48 | unsigned u:1; 49 | unsigned ie:1; 50 | unsigned event:10; 51 | unsigned :8; 52 | unsigned ec:2; 53 | unsigned :6; 54 | unsigned m:1; 55 | }; 56 | struct{ 57 | unsigned w:32; 58 | }; 59 | } perf_control_t; 60 | 61 | 62 | #endif /* _BAIKAL_T1_H */ 63 | -------------------------------------------------------------------------------- /arch/mips/baikal-t1/include/boot.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2016, prpl Foundation 3 | 4 | Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | in all copies. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | 14 | This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | 16 | */ 17 | 18 | #define LEAF(symbol) \ 19 | .globl symbol; \ 20 | .align 2; \ 21 | .type symbol,@function; \ 22 | .ent symbol,0; \ 23 | symbol: .frame sp,0,ra 24 | 25 | #define NESTED(symbol, framesize, rpc) \ 26 | .globl symbol; \ 27 | .align 2; \ 28 | .type symbol,@function; \ 29 | .ent symbol,0; \ 30 | symbol: .frame sp, framesize, rpc 31 | 32 | #define END(function) \ 33 | .end function; \ 34 | .size function,.-function 35 | 36 | 37 | -------------------------------------------------------------------------------- /arch/mips/baikal-t1/include/gpr_context.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2016, prpl Foundation 3 | 4 | Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | in all copies. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | 14 | This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | 16 | */ 17 | 18 | /* 19 | * Baikal-T (P5600) core address definitions 20 | * 21 | */ 22 | 23 | #ifndef _GRP_CONTEXT_H 24 | #define _GRP_CONTEXT_H 25 | 26 | #include 27 | 28 | #define GPR_SIZE (34*4) /* 32 GPR + HI and LO */ 29 | 30 | void gpr_context_restore(uint32_t* gpr_p); 31 | void gpr_context_save(uint32_t* gpr_p); 32 | 33 | /** 34 | * These functions can read/write the saved registers from the stack. 35 | * On P5600, the guests share the same GPR set (GPR Shadows are not implemented). Thus, 36 | * the hypercall parameters are read/write from the stack. 37 | */ 38 | void MoveToPreviousGuestGPR(uint32_t reg, uint32_t value); 39 | uint32_t MoveFromPreviousGuestGPR(uint32_t reg); 40 | 41 | 42 | #endif /* _GRP_CONTEXT_H */ 43 | -------------------------------------------------------------------------------- /arch/mips/baikal-t1/include/instruction_emulation.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016, prpl Foundation 3 | * 4 | * Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | * fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | * in all copies. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | * FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | * 14 | * This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | * 16 | */ 17 | 18 | #ifndef _INSTRUCTION_EMULATION 19 | #define _INSTRUCTION_EMULATION 20 | 21 | /* Extract instructions fields */ 22 | #define OPCODE(i) (i >> 26) 23 | #define FUNC(i) (i & 0x3F) 24 | #define RS(i) ((i >> 21) & 0x1f) 25 | #define RT(i) ((i >> 16) & 0x1f) 26 | #define RD(i) ((i >> 11) & 0x1f) 27 | #define SEL(i) (i & 0x7) 28 | #define IMED(i) (i & 0xFFFF) 29 | #define SIMED(i) (IMED(i) & 0x8000 ? 0xFFFF0000 | IMED(i) : IMED(i)) 30 | #define JT(i) ((x & 0x3FFFFFF) << 2) 31 | #define UPPERPC(i) (i & 0xF0000000) 32 | #define CO(i) ((i >> 25) & 0x1) 33 | 34 | uint32_t __instruction_emulation(uint32_t epc); 35 | 36 | #endif -------------------------------------------------------------------------------- /arch/mips/baikal-t1/include/interrupts.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2016, prpl Foundation 3 | 4 | Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | in all copies. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | 14 | This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | */ 16 | 17 | #ifndef __INTERRUPTS_H__ 18 | #define __INTERRUPTS_H__ 19 | 20 | typedef void handler_vector_t(); 21 | 22 | uint32_t register_interrupt(handler_vector_t * handler, uint32_t interrupt_number); 23 | 24 | 25 | #endif 26 | 27 | -------------------------------------------------------------------------------- /arch/mips/baikal-t1/include/launch.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2016, prpl Foundation 3 | 4 | Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | in all copies. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | 14 | This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | 16 | */ 17 | 18 | 19 | #ifndef __LAUCH_H__ 20 | #define __LAUCH_H__ 21 | 22 | #define LOG2CPULAUNCH 5 23 | #define LAUNCH_PC 0 24 | #define LAUNCH_GP 4 25 | #define LAUNCH_SP 8 26 | #define LAUNCH_A0 12 27 | #define LAUNCH_FLAGS 28 28 | 29 | #define LAUNCH_FREADY 1 30 | #define LAUNCH_FGO 2 31 | #define LAUNCH_FGONE 4 32 | 33 | #define CPULAUNCH 0x00000f00 34 | #define NCPULAUNCH 8 35 | 36 | #define LAUNCHPERIOD 10000 37 | 38 | #endif /*__LAUCH_H__ */ 39 | 40 | -------------------------------------------------------------------------------- /arch/mips/baikal-t1/include/timer.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2016, prpl Foundation 3 | 4 | Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | in all copies. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | 14 | This code was written by Sergio Johann at Embedded System Group (GSE) at PUCRS/Brazil. 15 | 16 | */ 17 | 18 | #ifndef _TIMER_H 19 | #define _TIMER_H 20 | 21 | void start_timer(); 22 | 23 | #endif -------------------------------------------------------------------------------- /arch/mips/common/common.mk: -------------------------------------------------------------------------------- 1 | # 2 | #Copyright (c) 2016, prpl Foundation 3 | # 4 | #Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | #fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | #in all copies. 7 | # 8 | #THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | #INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | #FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | #LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | #ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | # 14 | #This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | 16 | common: 17 | $(CC) $(CFLAGS) $(INC_DIRS) \ 18 | $(TOPDIR)arch/mips/common/hal.c \ 19 | $(TOPDIR)arch/mips/common/tlb.c \ 20 | $(TOPDIR)arch/mips/common/vcpu.c 21 | -------------------------------------------------------------------------------- /arch/mips/pic32mz/include/arch.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2016, prpl Foundation 3 | 4 | Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | in all copies. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | 14 | This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | 16 | */ 17 | 18 | #ifndef __ARCH_H 19 | #define __ARCH_H 20 | 21 | #define BARE_METAL_ENTRY_POINT 0x9d001000 22 | #define LINUX_ENTRY_POINT 0x80100400 23 | #define GPR_SIZE 32 24 | 25 | #include 26 | #include 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /arch/mips/pic32mz/include/gpr_context.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2016, prpl Foundation 3 | 4 | Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | in all copies. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | 14 | This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | 16 | */ 17 | 18 | #ifndef _GRP_CONTEXT_H 19 | #define _GRP_CONTEXT_H 20 | 21 | /** 22 | * These macros can read/write registers on the previous GPR Shadow. 23 | * On PIC32MZ, the guests are kept on separated GRP shadows. Thus, 24 | * the hypercall parameters are read from them. 25 | */ 26 | 27 | /* Write to previous gpr shadow */ 28 | #define MoveToPreviousGuestGPR(reg, value) asm volatile ( \ 29 | "wrpgpr $%0, %1" \ 30 | : : "K" (reg), "r" ((uint32_t) (value))) 31 | 32 | /* Read from previous gpr shadow */ 33 | #define MoveFromPreviousGuestGPR(reg) ({ int32_t __value; \ 34 | asm volatile ( \ 35 | "rdpgpr %0, $%1" \ 36 | : "=r" (__value) : "K" (reg)); \ 37 | __value; }) 38 | 39 | #endif /* _GRP_CONTEXT_H */ 40 | -------------------------------------------------------------------------------- /arch/mips/pic32mz/include/instruction_emulation.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016, prpl Foundation 3 | * 4 | * Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | * fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | * in all copies. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | * FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | * 14 | * This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | * 16 | */ 17 | 18 | #ifndef _INSTRUCTION_EMULATION 19 | #define _INSTRUCTION_EMULATION 20 | 21 | uint32_t __instruction_emulation(uint32_t epc); 22 | 23 | #endif -------------------------------------------------------------------------------- /arch/mips/pic32mz/include/interrupts.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2016, prpl Foundation 3 | 4 | Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | in all copies. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | 14 | This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | */ 16 | 17 | #ifndef __INTERRUPTS_H__ 18 | #define __INTERRUPTS_H__ 19 | 20 | typedef void handler_vector_t(); 21 | 22 | uint32_t register_interrupt(handler_vector_t * handler); 23 | uint32_t InterruptHandler(); 24 | 25 | 26 | #endif 27 | 28 | -------------------------------------------------------------------------------- /arch/mips/pic32mz/include/timer.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2016, prpl Foundation 3 | 4 | Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | in all copies. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | 14 | This code was written by Sergio Johann at Embedded System Group (GSE) at PUCRS/Brazil. 15 | 16 | */ 17 | 18 | #ifndef _TIMER_H 19 | #define _TIMER_H 20 | 21 | void start_timer(); 22 | 23 | #endif -------------------------------------------------------------------------------- /arch/mips/pic32mz/instruction_emulation.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016, prpl Foundation 3 | * 4 | * Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | * fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | * in all copies. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | * FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | * 14 | * This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | * 16 | */ 17 | 18 | /** 19 | * @file instruction_emulation.c 20 | * 21 | * @section DESCRIPTION Functions to perform instruction emulation. This should be part of the vcpu.c infrastructure. 22 | * However, not all platforms will require it. For example, the PIC32MZ that only performs bare-metal applications 23 | * does not implement it. 24 | */ 25 | 26 | #include 27 | #include 28 | 29 | 30 | /** 31 | * @brief Instruction emulation entry. 32 | * 33 | * @param 34 | */ 35 | uint32_t __instruction_emulation(uint32_t epc){ 36 | 37 | WARNING("Instruction emulation not implemented."); 38 | 39 | return 0; 40 | } -------------------------------------------------------------------------------- /arch/mips/pic32mz/pic32mz.mk: -------------------------------------------------------------------------------- 1 | # 2 | #Copyright (c) 2016, prpl Foundation 3 | # 4 | #Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | #fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | #in all copies. 7 | # 8 | #THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | #INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | #FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | #LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | #ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | # 14 | #This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | 16 | pic32mz: 17 | $(CC) $(CFLAGS) $(INC_DIRS) \ 18 | $(TOPDIR)arch/mips/pic32mz/timer.c \ 19 | $(TOPDIR)arch/mips/pic32mz/interrupts.c \ 20 | $(TOPDIR)arch/mips/pic32mz/boot.S \ 21 | $(TOPDIR)arch/mips/pic32mz/uart_driver.c \ 22 | $(TOPDIR)arch/mips/pic32mz/instruction_emulation.c 23 | 24 | -------------------------------------------------------------------------------- /bare-metal-apps/apps/blink/app.mk: -------------------------------------------------------------------------------- 1 | #Copyright (c) 2016, prpl Foundation 2 | # 3 | #Permission to use, copy, modify, and/or distribute this software for any purpose with or without 4 | #fee is hereby granted, provided that the above copyright notice and this permission notice appear 5 | #in all copies. 6 | # 7 | #THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 8 | #INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 9 | #FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 10 | #LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 11 | #ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 12 | # 13 | #This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 14 | 15 | 16 | # Define your additional include paths 17 | #INC_DIRS += 18 | 19 | #Aditional C flags 20 | #CFLAGS += 21 | 22 | #Aditional Libraries 23 | #LIBS += 24 | 25 | #default stack size 512 bytes 26 | STACK_SIZE = 512 27 | 28 | #Include your additional mk files here. 29 | 30 | app: 31 | $(CC) $(CFLAGS) $(INC_DIRS) $(TOPDIR)apps/$(APP)/$(APP).c -o $(TOPDIR)apps/$(APP)/$(APP).o 32 | 33 | -------------------------------------------------------------------------------- /bare-metal-apps/apps/blink/blink.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2016, prpl Foundation 3 | 4 | Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | in all copies. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | 14 | This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | 16 | */ 17 | 18 | /* Simple UART and Blink Bare-metal application sample using virtualized IO. */ 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | volatile int32_t t2 = 0; 28 | 29 | void irq_timer(){ 30 | t2++; 31 | NEXT_TIMER(); 32 | } 33 | 34 | 35 | int main() { 36 | 37 | interrupt_register(irq_timer, GUEST_TIMER_INT); 38 | 39 | START_TIMER(); 40 | 41 | NEXT_TIMER(); 42 | 43 | ENABLE_LED1; 44 | 45 | while (1){ 46 | printf("\r\nBlink LED! Total of %d timer ticks.", t2); 47 | 48 | /* Blink Led */ 49 | TOGGLE_LED1; 50 | 51 | /* 1 second delay */ 52 | mdelay(1000); 53 | } 54 | 55 | return 0; 56 | } 57 | 58 | -------------------------------------------------------------------------------- /bare-metal-apps/apps/button/app.mk: -------------------------------------------------------------------------------- 1 | #Copyright (c) 2016, prpl Foundation 2 | # 3 | #Permission to use, copy, modify, and/or distribute this software for any purpose with or without 4 | #fee is hereby granted, provided that the above copyright notice and this permission notice appear 5 | #in all copies. 6 | # 7 | #THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 8 | #INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 9 | #FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 10 | #LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 11 | #ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 12 | # 13 | #This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 14 | 15 | 16 | # Define your additional include paths 17 | #INC_DIRS += 18 | 19 | #Aditional C flags 20 | #CFLAGS += 21 | 22 | #Aditional Libraries 23 | #LIBS += 24 | 25 | #default stack size 512 bytes 26 | STACK_SIZE = 512 27 | 28 | #Include your additional mk files here. 29 | 30 | app: 31 | $(CC) $(CFLAGS) $(INC_DIRS) $(TOPDIR)apps/$(APP)/$(APP).c -o $(TOPDIR)apps/$(APP)/$(APP).o 32 | 33 | -------------------------------------------------------------------------------- /bare-metal-apps/apps/button/button.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2016, prpl Foundation 3 | 4 | Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | in all copies. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | 14 | This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | 16 | */ 17 | 18 | /* Simple switch button usage on Bare-metal application 19 | * 20 | * Reads SW2 button on Microchip Connectivity Starter Kit. 21 | * 22 | * Enable device access on the cfg file. 23 | * device_mapping = [ "PORTH", "UART2", "PORTB"]; 24 | */ 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | 31 | int main() { 32 | 33 | /* Configure pin RB13 for input (SW2) */ 34 | write(TRISBSET, 1 << 13); /* RB13 input */ 35 | write(CNPUBSET, 1 << 13); /* enable pull-up */ 36 | 37 | /* Configure pin RH1 for output (LED 2) */ 38 | write(TRISHCLR, 2); 39 | 40 | while (1){ 41 | 42 | /* Read SW2 status */ 43 | if (!(read(PORTB) & (1 << 13))) { 44 | /* on/off led */ 45 | write(LATHINV, 2); 46 | 47 | } 48 | } 49 | 50 | return 0; 51 | } 52 | 53 | -------------------------------------------------------------------------------- /bare-metal-apps/apps/dhrystone/app.mk: -------------------------------------------------------------------------------- 1 | #Copyright (c) 2016, prpl Foundation 2 | # 3 | #Permission to use, copy, modify, and/or distribute this software for any purpose with or without 4 | #fee is hereby granted, provided that the above copyright notice and this permission notice appear 5 | #in all copies. 6 | # 7 | #THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 8 | #INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 9 | #FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 10 | #LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 11 | #ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 12 | # 13 | #This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 14 | 15 | 16 | # Define your additional include paths 17 | #INC_DIRS += $(TOPDIR)../../benchmark/dhrystone/ 18 | 19 | #Aditional C flags 20 | CFLAGS += -DPIC32MZ -DTIME -DREG=register 21 | 22 | #Aditional Libraries 23 | #LIBS += 24 | 25 | #stack size 2048 bytes 26 | STACK_SIZE = 2048 27 | 28 | #Include your additional mk files here. 29 | repo-conf: 30 | if [ ! -d "$(TOPDIR)../../benchmark" ]; then \ 31 | git clone https://github.com/crmoratelli/prplHypervisor-benckmarks.git $(TOPDIR)../../benchmark; \ 32 | fi 33 | 34 | app: repo-conf 35 | $(CC) $(CFLAGS) $(INC_DIRS) -fno-inline $(TOPDIR)../../benchmark/dhrystone/dhry_1.c -o $(TOPDIR)apps/$(APP)/dhry_1.o 36 | $(CC) $(CFLAGS) $(INC_DIRS) -fno-inline $(TOPDIR)../../benchmark/dhrystone/dhry_2.c -o $(TOPDIR)apps/$(APP)/dhry_2.o 37 | $(CC) $(CFLAGS) $(INC_DIRS) $(TOPDIR)apps/$(APP)/dhrystone.c -o $(TOPDIR)apps/$(APP)/dhrystone.o 38 | 39 | 40 | -------------------------------------------------------------------------------- /bare-metal-apps/apps/inputUART/app.mk: -------------------------------------------------------------------------------- 1 | #Copyright (c) 2016, prpl Foundation 2 | # 3 | #Permission to use, copy, modify, and/or distribute this software for any purpose with or without 4 | #fee is hereby granted, provided that the above copyright notice and this permission notice appear 5 | #in all copies. 6 | # 7 | #THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 8 | #INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 9 | #FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 10 | #LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 11 | #ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 12 | # 13 | #This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 14 | 15 | 16 | # Define your additional include paths 17 | #INC_DIRS += 18 | 19 | #Aditional C flags 20 | #CFLAGS += 21 | 22 | #Aditional Libraries 23 | #LIBS += 24 | 25 | #default stack size 512 bytes 26 | STACK_SIZE = 512 27 | 28 | #Include your additional mk files here. 29 | 30 | app: 31 | $(CC) $(CFLAGS) $(INC_DIRS) $(TOPDIR)apps/$(APP)/$(APP).c -o $(TOPDIR)apps/$(APP)/$(APP).o 32 | 33 | 34 | -------------------------------------------------------------------------------- /bare-metal-apps/apps/inputUART/inputUART.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2016, prpl Foundation 3 | 4 | Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | in all copies. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | 14 | This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | 16 | */ 17 | 18 | /* Simple UART Bare-metal application sample */ 19 | 20 | #include 21 | #include 22 | 23 | 24 | volatile int32_t t2 = 0; 25 | 26 | void irq_timer(){ 27 | t2++; 28 | } 29 | 30 | uint8_t buffer[32]; 31 | 32 | uint32_t getbuffer(uint8_t *buffer, uint32_t size){ 33 | uint8_t a; 34 | uint32_t i; 35 | for(i=0;i 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | volatile uint32_t t2 = 0; 31 | 32 | void irq_pin(){ 33 | uint32_t d; 34 | 35 | d = readio(PORTD); 36 | if(d & (1<<10)){ 37 | writeio(LATFSET, 1 << 4); 38 | }else{ 39 | writeio(LATFCLR, 1 << 4); 40 | } 41 | //writeio(LATFINV, 1 << 4); 42 | t2++; 43 | 44 | //putchar('!'); 45 | 46 | reenable_interrupt(GUEST_USER_DEFINED_INT_1); 47 | } 48 | 49 | 50 | int main() { 51 | uint32_t timer = 0; 52 | 53 | interrupt_register(irq_pin, GUEST_USER_DEFINED_INT_1); 54 | 55 | ENABLE_LED1; 56 | 57 | /* RD0 as output*/ 58 | writeio(TRISFCLR, 1 << 4); 59 | writeio(LATFCLR, 1 << 4); 60 | writeio(CNPUFCLR, 1 << 4); 61 | writeio(CNPDFCLR, 1 << 4); 62 | writeio(ANSELFCLR, 1 << 4); 63 | 64 | /* configure interrupt for PORTD pin RD10*/ 65 | writeio(CNCONDSET, 0x8000); 66 | writeio(CNENDSET, 1 << 10); 67 | 68 | while (1){ 69 | if(wait_time(timer, 1000)) { 70 | printf("t2 %d\n", t2); 71 | 72 | /* Blink Led */ 73 | TOGGLE_LED1; 74 | 75 | timer = mfc0(CP0_COUNT, 0); 76 | 77 | 78 | } 79 | } 80 | 81 | return 0; 82 | } 83 | 84 | -------------------------------------------------------------------------------- /bare-metal-apps/apps/int_redirect/app.mk: -------------------------------------------------------------------------------- 1 | #Copyright (c) 2016, prpl Foundation 2 | # 3 | #Permission to use, copy, modify, and/or distribute this software for any purpose with or without 4 | #fee is hereby granted, provided that the above copyright notice and this permission notice appear 5 | #in all copies. 6 | # 7 | #THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 8 | #INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 9 | #FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 10 | #LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 11 | #ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 12 | # 13 | #This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 14 | 15 | 16 | # Define your additional include paths 17 | #INC_DIRS += 18 | 19 | #Aditional C flags 20 | #CFLAGS += 21 | 22 | #Aditional Libraries 23 | #LIBS += 24 | 25 | #default stack size 512 bytes 26 | STACK_SIZE = 512 27 | 28 | #Include your additional mk files here. 29 | 30 | app: 31 | $(CC) $(CFLAGS) $(INC_DIRS) $(TOPDIR)apps/$(APP)/redirection.c -o $(TOPDIR)apps/$(APP)/redirection.o 32 | 33 | -------------------------------------------------------------------------------- /bare-metal-apps/apps/malloc_sample/app.mk: -------------------------------------------------------------------------------- 1 | #Copyright (c) 2016, prpl Foundation 2 | # 3 | #Permission to use, copy, modify, and/or distribute this software for any purpose with or without 4 | #fee is hereby granted, provided that the above copyright notice and this permission notice appear 5 | #in all copies. 6 | # 7 | #THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 8 | #INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 9 | #FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 10 | #LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 11 | #ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 12 | # 13 | #This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 14 | 15 | 16 | # Define your additional include paths 17 | #INC_DIRS += 18 | 19 | #Aditional C flags 20 | #CFLAGS += 21 | 22 | #Aditional Libraries 23 | #LIBS += 24 | 25 | #default stack size 512 bytes 26 | STACK_SIZE = 512 27 | 28 | #Include your additional mk files here. 29 | 30 | app: 31 | $(CC) $(CFLAGS) $(INC_DIRS) $(TOPDIR)apps/$(APP)/$(APP).c -o $(TOPDIR)apps/$(APP)/$(APP).o 32 | 33 | -------------------------------------------------------------------------------- /bare-metal-apps/apps/malloc_sample/malloc_sample.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2016, prpl Foundation 3 | 4 | Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | in all copies. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | 14 | This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | 16 | */ 17 | 18 | /* Simple malloc tester application sample */ 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | extern _heap_size; 25 | extern _heap_start; 26 | 27 | volatile int32_t t2 = 0; 28 | 29 | void irq_timer(){ 30 | t2++; 31 | } 32 | 33 | int main() { 34 | 35 | uint8_t* buffer; 36 | uint8_t* buffer2; 37 | uint32_t i; 38 | int32_t ret; 39 | printf("Heap size %d bytes at 0x%x.\n", &_heap_size, &_heap_start); 40 | 41 | while (1){ 42 | buffer = (uint8_t*)malloc(2048); 43 | buffer2 = (uint8_t*)malloc(2048); 44 | for(i=0;i<2048;i++) 45 | buffer[i]=i; 46 | memcpy(buffer2, buffer, 2048); 47 | ret = memcmp(buffer, buffer2, 2048); 48 | if(!ret) 49 | printf("\nWorking!"); 50 | else 51 | printf("\nError!"); 52 | free(buffer); 53 | free(buffer2); 54 | } 55 | 56 | return 0; 57 | } 58 | 59 | -------------------------------------------------------------------------------- /bare-metal-apps/apps/outputUART/app.mk: -------------------------------------------------------------------------------- 1 | # Define your additional include paths 2 | #INC_DIRS += 3 | 4 | #Aditional C flags 5 | #CFLAGS += 6 | 7 | #Aditional Libraries 8 | #LIBS += 9 | 10 | #default stack size 512 bytes 11 | STACK_SIZE = 512 12 | 13 | #Include your additional mk files here. 14 | 15 | app: 16 | $(CC) $(CFLAGS) $(INC_DIRS) $(TOPDIR)apps/$(APP)/$(APP).c -o $(TOPDIR)apps/$(APP)/$(APP).o 17 | 18 | -------------------------------------------------------------------------------- /bare-metal-apps/apps/outputUART/outputUART.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2016, prpl Foundation 3 | 4 | Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | in all copies. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | 14 | This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | 16 | */ 17 | 18 | /* Simple UART Bare-metal application sample */ 19 | 20 | #include 21 | #include 22 | 23 | 24 | volatile int32_t t2 = 0; 25 | 26 | void irq_timer(){ 27 | t2++; 28 | } 29 | 30 | 31 | uint8_t buffer[32]; 32 | 33 | void printf_buffer(uint8_t *buffer, uint32_t size){ 34 | uint32_t i; 35 | for(i=0;i0){ 52 | printf("\n\routputUART Guest ID %d - size %d ", guestid, ret); 53 | printf_buffer(buffer, ret); 54 | } 55 | } 56 | 57 | return 0; 58 | } 59 | 60 | -------------------------------------------------------------------------------- /bare-metal-apps/apps/output_signal/app.mk: -------------------------------------------------------------------------------- 1 | #Copyright (c) 2016, prpl Foundation 2 | # 3 | #Permission to use, copy, modify, and/or distribute this software for any purpose with or without 4 | #fee is hereby granted, provided that the above copyright notice and this permission notice appear 5 | #in all copies. 6 | # 7 | #THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 8 | #INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 9 | #FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 10 | #LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 11 | #ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 12 | # 13 | #This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 14 | 15 | 16 | # Define your additional include paths 17 | #INC_DIRS += 18 | 19 | #Aditional C flags 20 | #CFLAGS += 21 | 22 | #Aditional Libraries 23 | #LIBS += 24 | 25 | #default stack size 512 bytes 26 | STACK_SIZE = 512 27 | 28 | #Include your additional mk files here. 29 | 30 | app: 31 | $(CC) $(CFLAGS) $(INC_DIRS) $(TOPDIR)apps/$(APP)/$(APP).c -o $(TOPDIR)apps/$(APP)/$(APP).o 32 | 33 | -------------------------------------------------------------------------------- /bare-metal-apps/apps/output_signal/output_signal.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2016, prpl Foundation 3 | 4 | Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | in all copies. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | 14 | This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | 16 | */ 17 | 18 | /** 19 | * Generates output signal on pin RPD3 (J5 MOSI) on Curiosity board. 20 | * 21 | * Used as an interrupt generator for interrupt latency tests. See 22 | * documentation for more details. 23 | * 24 | * 25 | */ 26 | 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | 35 | int main() { 36 | uint32_t time = mfc0(CP0_COUNT, 0); 37 | uint32_t interval = 0; 38 | 39 | /* Configure PIN RPD3 as output */ 40 | writeio(TRISDCLR, 8); 41 | 42 | srand(0xdeadbeef); 43 | 44 | while (1){ 45 | if(wait_time(time, interval)){ 46 | time = mfc0(CP0_COUNT, 0); 47 | writeio(LATDINV, 8); 48 | interval = random()%50 + 1; 49 | } 50 | 51 | } 52 | return 0; 53 | } 54 | 55 | -------------------------------------------------------------------------------- /bare-metal-apps/apps/ping/app.mk: -------------------------------------------------------------------------------- 1 | # 2 | #Copyright (c) 2016, prpl Foundation 3 | # 4 | #Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | #fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | #in all copies. 7 | # 8 | #THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | #INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | #FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | #LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | #ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | # 14 | #This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | 16 | 17 | # Define your additional include paths 18 | #INC_DIRS += 19 | 20 | #Aditional C flags 21 | #CFLAGS += 22 | 23 | #Aditional Libraries 24 | #LIBS += 25 | 26 | #default stack size 512 bytes 27 | STACK_SIZE = 512 28 | 29 | #Include your additional mk files here. 30 | 31 | app: 32 | $(CC) $(CFLAGS) $(INC_DIRS) $(TOPDIR)apps/$(APP)/$(APP).c -o $(TOPDIR)apps/$(APP)/$(APP).o 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /bare-metal-apps/apps/pong/app.mk: -------------------------------------------------------------------------------- 1 | #Copyright (c) 2016, prpl Foundation 2 | # 3 | #Permission to use, copy, modify, and/or distribute this software for any purpose with or without 4 | #fee is hereby granted, provided that the above copyright notice and this permission notice appear 5 | #in all copies. 6 | # 7 | #THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 8 | #INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 9 | #FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 10 | #LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 11 | #ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 12 | # 13 | #This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 14 | 15 | 16 | # Define your additional include paths 17 | #INC_DIRS += 18 | 19 | #Aditional C flags 20 | #CFLAGS += 21 | 22 | #Aditional Libraries 23 | #LIBS += 24 | 25 | #default stack size 512 bytes 26 | STACK_SIZE = 512 27 | 28 | #Include your additional mk files here. 29 | 30 | app: 31 | $(CC) $(CFLAGS) $(INC_DIRS) $(TOPDIR)apps/$(APP)/$(APP).c -o $(TOPDIR)apps/$(APP)/$(APP).o 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /bare-metal-apps/apps/read-flash/app.mk: -------------------------------------------------------------------------------- 1 | #Copyright (c) 2016, prpl Foundation 2 | # 3 | #Permission to use, copy, modify, and/or distribute this software for any purpose with or without 4 | #fee is hereby granted, provided that the above copyright notice and this permission notice appear 5 | #in all copies. 6 | # 7 | #THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 8 | #INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 9 | #FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 10 | #LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 11 | #ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 12 | # 13 | #This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 14 | 15 | 16 | # Define your additional include paths 17 | #INC_DIRS += 18 | 19 | #Aditional C flags 20 | #CFLAGS += 21 | 22 | #Aditional Libraries 23 | #LIBS += 24 | 25 | #default stack size 512 bytes 26 | STACK_SIZE = 512 27 | 28 | #Include your additional mk files here. 29 | 30 | app: 31 | $(CC) $(CFLAGS) $(INC_DIRS) $(TOPDIR)apps/$(APP)/$(APP).c -o $(TOPDIR)apps/$(APP)/$(APP).o 32 | 33 | -------------------------------------------------------------------------------- /bare-metal-apps/apps/read-flash/read-flash.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2016, prpl Foundation 3 | 4 | Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | in all copies. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | 14 | This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | 16 | */ 17 | 18 | /* Simple read flash sample. */ 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | 28 | uint32_t buffer[256]; 29 | 30 | int main() { 31 | uint32_t i; 32 | 33 | ENABLE_LED1; 34 | 35 | /* Turn on lead 1 */ 36 | TOGGLE_LED1; 37 | 38 | memset(buffer, 0, sizeof(buffer)); 39 | 40 | int32_t ret = read_1k_data_flash(buffer); 41 | 42 | for(i=0;i 21 | #include 22 | 23 | 24 | volatile int32_t t2 = 0; 25 | 26 | void irq_timer(){ 27 | t2++; 28 | } 29 | 30 | char buffer[32] = "abcdefghijklmnopkrstuvxzABCDEFGH"; 31 | 32 | int main() { 33 | 34 | /* get guest id */ 35 | uint32_t guestid = hyp_get_guest_id(); 36 | 37 | printf("Guest ID: %d", guestid); 38 | 39 | /* share buffer with the hypervisor */ 40 | hyp_puf_shared_memory(guestid, buffer); 41 | 42 | /* printf the hypervisor message */ 43 | printf("\nModified guest buffer: %s", buffer); 44 | 45 | /* do nothing */ 46 | while(1); 47 | 48 | return 0; 49 | } 50 | 51 | -------------------------------------------------------------------------------- /bare-metal-apps/apps/spi/app.mk: -------------------------------------------------------------------------------- 1 | #Copyright (c) 2016, prpl Foundation 2 | # 3 | #Permission to use, copy, modify, and/or distribute this software for any purpose with or without 4 | #fee is hereby granted, provided that the above copyright notice and this permission notice appear 5 | #in all copies. 6 | # 7 | #THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 8 | #INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 9 | #FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 10 | #LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 11 | #ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 12 | # 13 | #This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 14 | 15 | 16 | # Define your additional include paths 17 | #INC_DIRS += 18 | 19 | #Aditional C flags 20 | #CFLAGS += 21 | 22 | #Aditional Libraries 23 | #LIBS += 24 | 25 | #default stack size 512 bytes 26 | STACK_SIZE = 512 27 | 28 | #Include your additional mk files here. 29 | 30 | app: 31 | $(CC) $(CFLAGS) $(INC_DIRS) $(TOPDIR)apps/$(APP)/$(APP).c -o $(TOPDIR)apps/$(APP)/$(APP).o 32 | 33 | 34 | -------------------------------------------------------------------------------- /bare-metal-apps/apps/tcp-listener/app.mk: -------------------------------------------------------------------------------- 1 | #Copyright (c) 2016, prpl Foundation 2 | # 3 | #Permission to use, copy, modify, and/or distribute this software for any purpose with or without 4 | #fee is hereby granted, provided that the above copyright notice and this permission notice appear 5 | #in all copies. 6 | # 7 | #THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 8 | #INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 9 | #FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 10 | #LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 11 | #ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 12 | # 13 | #This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 14 | 15 | 16 | # Define your additional include paths 17 | INC_DIRS += -I ../../../../picotcp/build/include/ 18 | 19 | #Aditional C flags 20 | CFLAGS += -DPICOTCP 21 | 22 | #Aditional Libraries 23 | LIBS += ../../../../picotcp/build/lib/libpicotcp.a 24 | 25 | #default stack size 512 bytes 26 | STACK_SIZE = 4096 27 | 28 | #include your additional mk files. 29 | picotcp_clone: 30 | if [ ! -d "$(TOPDIR)../../picotcp" ]; then \ 31 | git clone https://github.com/crmoratelli/picotcp.git $(TOPDIR)../../picotcp; \ 32 | fi 33 | 34 | picotcp_compile: 35 | if [ ! -f "$(TOPDIR)../../picotcp/.compiled" ]; then \ 36 | make -C $(TOPDIR)../../picotcp CROSS_COMPILE=mips-mti-elf- PLATFORM_CFLAGS="-EL -Os -c -Wa,-mvirt -mips32r5 -mtune=m14k -mno-check-zero-division -msoft-float -fshort-double -ffreestanding -nostdlib -fomit-frame-pointer -G 0" \ 37 | DHCP_SERVER=0 DHCP_CLIENT=0 SLAACV4=0 TFTP=0 AODV=0 IPV6=0 NAT=0 PING=1 ICMP4=1 DNS_CLIENT=0 DNS=0 MDNS=0 DNS_SD=0 SNTP_CLIENT=0 PPP=0 MCAST=1 MLD=0 IPFILTER=0 ARCH=pic32 ICMP6=0 PREFIX=./build; \ 38 | touch $(TOPDIR)../../picotcp/.compiled; \ 39 | fi 40 | 41 | app: picotcp_clone picotcp_compile 42 | $(CC) $(CFLAGS) $(INC_DIRS) $(TOPDIR)apps/$(APP)/$(APP).c -o $(TOPDIR)apps/$(APP)/$(APP).o 43 | 44 | -------------------------------------------------------------------------------- /bare-metal-apps/apps/usb/app.mk: -------------------------------------------------------------------------------- 1 | #Copyright (c) 2016, prpl Foundation 2 | # 3 | #Permission to use, copy, modify, and/or distribute this software for any purpose with or without 4 | #fee is hereby granted, provided that the above copyright notice and this permission notice appear 5 | #in all copies. 6 | # 7 | #THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 8 | #INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 9 | #FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 10 | #LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 11 | #ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 12 | # 13 | #This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 14 | 15 | 16 | # Define your additional include paths 17 | #INC_DIRS += 18 | 19 | #Aditional C flags 20 | #CFLAGS += 21 | 22 | #Aditional Libraries 23 | #LIBS += 24 | 25 | #default stack size 512 bytes 26 | STACK_SIZE = 512 27 | 28 | #Include your additional mk files here. 29 | 30 | app: 31 | $(CC) $(CFLAGS) $(INC_DIRS) $(TOPDIR)apps/$(APP)/$(APP).c -o $(TOPDIR)apps/$(APP)/$(APP).o 32 | 33 | 34 | -------------------------------------------------------------------------------- /bare-metal-apps/apps/usb/usb.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2016, prpl Foundation 3 | 4 | Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | in all copies. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | 14 | This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | 16 | */ 17 | 18 | /* Simple USB Bare-metal application that detects and read device's descriptors. */ 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | /* OWI Robotic Arm */ 27 | #define IDPRODUCT 0 28 | #define IDVENDOR 0x1267 29 | 30 | struct descriptor_decoded descriptor; 31 | 32 | int main() { 33 | int32_t ret = 0, old = 0; 34 | uint32_t tm_poll = 0; 35 | 36 | printf("\nPlease connect any USB device."); 37 | 38 | while (1){ 39 | 40 | if(wait_time(tm_poll, 100)){ 41 | ret = usb_polling(); 42 | if (ret != old){ 43 | if(ret){ 44 | usb_device_descriptor((char*)&descriptor, sizeof(struct descriptor_decoded)); 45 | printf("\nDevice connected: idVendor 0x%x idProduct 0x%x", descriptor.idVendor, descriptor.idProduct); 46 | }else{ 47 | printf("\nDevice Disconnected"); 48 | } 49 | old = ret; 50 | } 51 | tm_poll = mfc0(CP0_COUNT, 0); 52 | } 53 | } 54 | 55 | return 0; 56 | } 57 | 58 | -------------------------------------------------------------------------------- /bare-metal-apps/apps/webserver/.tcp-listener.c.kate-swp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prplfoundation/prpl-hypervisor/b780768365628e27e2584f2b8293409accf393fa/bare-metal-apps/apps/webserver/.tcp-listener.c.kate-swp -------------------------------------------------------------------------------- /bare-metal-apps/apps/webserver/html-sources/bg_stripe.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prplfoundation/prpl-hypervisor/b780768365628e27e2584f2b8293409accf393fa/bare-metal-apps/apps/webserver/html-sources/bg_stripe.png -------------------------------------------------------------------------------- /bare-metal-apps/apps/webserver/html-sources/board.js: -------------------------------------------------------------------------------- 1 | var update_speed = 1000; 2 | 3 | function updateBoardInfo() 4 | { 5 | var xmlhttp = new XMLHttpRequest(); 6 | xmlhttp.onreadystatechange = function() 7 | { 8 | if (xmlhttp.readyState == 4 && xmlhttp.status == 200) 9 | { 10 | var info = JSON.parse(xmlhttp.responseText); 11 | document.getElementById("uptime").innerHTML = info.uptime +" seconds"; 12 | document.getElementById("led1_state").style.backgroundColor = (info.l1 == "on") ? "#FF0000" : "#000000"; 13 | document.getElementById("led2_state").style.backgroundColor = (info.l2 == "on") ? "#FFFF00" : "#000000"; 14 | setTimeout(function(){updateBoardInfo();}, update_speed); 15 | } 16 | }; 17 | xmlhttp.open("GET","board_info",true); 18 | xmlhttp.timeout = 3000; 19 | xmlhttp.ontimeout = function() 20 | { 21 | updateBoardInfo(); 22 | } 23 | xmlhttp.onerror = function(e) 24 | { 25 | setTimeout(function(){updateBoardInfo()}, 1000); 26 | } 27 | xmlhttp.send(); 28 | } 29 | 30 | function toggle_led1(){ 31 | var ajaxPost = new XMLHttpRequest; 32 | ajaxPost.open("GET","led1",true); 33 | ajaxPost.send(""); 34 | } 35 | 36 | function toggle_led2(){ 37 | var ajaxPost = new XMLHttpRequest; 38 | ajaxPost.open("GET","led2",true); 39 | ajaxPost.send(""); 40 | } 41 | 42 | function getIp() 43 | { 44 | var xmlhttp = new XMLHttpRequest(); 45 | xmlhttp.onreadystatechange = function() 46 | { 47 | if (xmlhttp.readyState == 4 && xmlhttp.status == 200) 48 | { 49 | document.getElementById("ip").innerHTML = xmlhttp.responseText; 50 | } 51 | } 52 | xmlhttp.open("GET","ip",true); 53 | xmlhttp.send(); 54 | } 55 | 56 | function getMAC() 57 | { 58 | var xmlhttp = new XMLHttpRequest(); 59 | xmlhttp.onreadystatechange = function() 60 | { 61 | if (xmlhttp.readyState == 4 && xmlhttp.status == 200) 62 | { 63 | document.getElementById("mac").innerHTML = xmlhttp.responseText; 64 | } 65 | } 66 | xmlhttp.open("GET","mac",true); 67 | xmlhttp.send(); 68 | } 69 | 70 | -------------------------------------------------------------------------------- /bare-metal-apps/apps/webserver/html-sources/cloud.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prplfoundation/prpl-hypervisor/b780768365628e27e2584f2b8293409accf393fa/bare-metal-apps/apps/webserver/html-sources/cloud.png -------------------------------------------------------------------------------- /bare-metal-apps/apps/webserver/html-sources/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prplfoundation/prpl-hypervisor/b780768365628e27e2584f2b8293409accf393fa/bare-metal-apps/apps/webserver/html-sources/favicon.png -------------------------------------------------------------------------------- /bare-metal-apps/apps/webserver/html-sources/pic32mz.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prplfoundation/prpl-hypervisor/b780768365628e27e2584f2b8293409accf393fa/bare-metal-apps/apps/webserver/html-sources/pic32mz.jpg -------------------------------------------------------------------------------- /bare-metal-apps/apps/wolfssl/.tcp-listener.c.kate-swp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prplfoundation/prpl-hypervisor/b780768365628e27e2584f2b8293409accf393fa/bare-metal-apps/apps/wolfssl/.tcp-listener.c.kate-swp -------------------------------------------------------------------------------- /bare-metal-apps/apps/wolfssl/cert/cert.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIEATCCAumgAwIBAgIJAPR0csBSL4hpMA0GCSqGSIb3DQEBBQUAMIGWMQswCQYD 3 | VQQGEwJCUjETMBEGA1UECAwKUmlvIEdyYW5kZTEVMBMGA1UEBwwMUG9ydG8gQWxl 4 | Z3JlMRAwDgYDVQQKDAdTZWxmT3JnMQswCQYDVQQLDAJTTzEWMBQGA1UEAwwNMTky 5 | LjE2OC4wLjE1MDEkMCIGCSqGSIb3DQEJARYVY3Jtb3JhdGVsbGlAZ21haWwuY29t 6 | MB4XDTE2MTIyMjEzMTkwMVoXDTE3MTIyMjEzMTkwMVowgZYxCzAJBgNVBAYTAkJS 7 | MRMwEQYDVQQIDApSaW8gR3JhbmRlMRUwEwYDVQQHDAxQb3J0byBBbGVncmUxEDAO 8 | BgNVBAoMB1NlbGZPcmcxCzAJBgNVBAsMAlNPMRYwFAYDVQQDDA0xOTIuMTY4LjAu 9 | MTUwMSQwIgYJKoZIhvcNAQkBFhVjcm1vcmF0ZWxsaUBnbWFpbC5jb20wggEiMA0G 10 | CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDCVH2oiDbGBhWp9DcmZ6dktbGiTLHc 11 | kmo08+X7b18T7LJ9LCZxlk23Iyl2VCShuGO4q204DkoRTlbrRGp0hOoyMoDXONHk 12 | nIUMrwrUw7e4lKerFYxwFQ83YKHHZi9Z2dFrqGLohAceFuBX3hkHoGIANMJ4afZn 13 | C1Z5m/2fiLSubUCPzmrDP7N/pylnMFIKLW62zrnQ71YSH87AmY1TFwel0dIBosJs 14 | YG3wTSgBfpNUltTw/6xFGMvneGu2ZMdIeJSGHVcpaRJUCEabbUm4x8yJpyrTEEZS 15 | PWSBmCuXdUv5ht5yhuBmNe56cTi7DAS8LWOvc6Ofa8hVXD7gaYo9XuLbAgMBAAGj 16 | UDBOMB0GA1UdDgQWBBSHm9AqoqThYTjSpCJtmJrK+QV7+zAfBgNVHSMEGDAWgBSH 17 | m9AqoqThYTjSpCJtmJrK+QV7+zAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBQUA 18 | A4IBAQCiqx1RcSPmGDFd2CSPF3CwgaoknLzfBirDCry1ySqNLY1JZu7yLrJk6FK1 19 | +3Oin4w3y+w3MXpudroR5ibxh6wBG8YgXvgos1/F2UNxLl+ed+Xsez+KEaSwyQlb 20 | mKu2uSgipwgAvM37+NWk8TcDLRDE8YYzpNmDFkkBJcqQ/GXyb+UPhZmqkTFXF0t9 21 | WgTqtMaWxiYllndy7xpVKAT+/BU1usfQTYD0S+m1K9ZhoJbvW7iEqQS5I9wILndf 22 | z+ujx9laaAOWJVmW1wteUjQ7i9y4lPdX/FywKOTrveiOUAsiBmrCzT2igjZKrK4T 23 | ltLPYuWYfpBcHAk0SLPkoqE60zN1 24 | -----END CERTIFICATE----- 25 | -------------------------------------------------------------------------------- /bare-metal-apps/apps/wolfssl/cert/privkey.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN PRIVATE KEY----- 2 | MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDCVH2oiDbGBhWp 3 | 9DcmZ6dktbGiTLHckmo08+X7b18T7LJ9LCZxlk23Iyl2VCShuGO4q204DkoRTlbr 4 | RGp0hOoyMoDXONHknIUMrwrUw7e4lKerFYxwFQ83YKHHZi9Z2dFrqGLohAceFuBX 5 | 3hkHoGIANMJ4afZnC1Z5m/2fiLSubUCPzmrDP7N/pylnMFIKLW62zrnQ71YSH87A 6 | mY1TFwel0dIBosJsYG3wTSgBfpNUltTw/6xFGMvneGu2ZMdIeJSGHVcpaRJUCEab 7 | bUm4x8yJpyrTEEZSPWSBmCuXdUv5ht5yhuBmNe56cTi7DAS8LWOvc6Ofa8hVXD7g 8 | aYo9XuLbAgMBAAECggEACHEhMFQShRG4mTR5vNpd5DscZ1+Ljnhx0rERuZWB/NyY 9 | eGWVmfOclqsZXwGSwc+/zULtMLU2NIBBuGC1ezBW+C1HeZIHVDYUdZOZFdsWvRcA 10 | HaeG/Ut86Lvy6zWeMvoKZfHfshgiMwVtY4PLdJBcEYQ5On/n61wLuqazIt4Oc1FK 11 | OQNgEalkLiz5IJly2syurRV7gYJ2Pjs+AQYvWta+ek4aV4c5fJKIb8E+oXAlDx13 12 | OcsoVCPuxbJmVb1B5/8PLm2392NgoA1nI02iqwPyOzeDRAP4v70qRwSuUeYcE12g 13 | lU0FvGmrLrgJ/ndVRozmifVAHf9uyWZalOSTw0PO2QKBgQD06VUAaoPS9EDUeGst 14 | Au3vitvS5ybk3oyuEeXUjUMXq4VzuqsLB3ryp/bMINUMObA6lFFhm2+rUwZiehsy 15 | 9OdenSHETnaRqzx+3FHLyFBA3nF5HH55VIPPftrcfA/7j9/CX9zOqlw2L271D55y 16 | 1H+tCwoXB94D6HhpvlTBfyxafQKBgQDLIOP2WPZWvMBnUIzngFIoPaYO1osMswlZ 17 | qtGKdlSVVbGmJ+UDCNE/uuxPOj3wjpRi28rI+PImRzB7a58f27VAkQz7gvmx5X0s 18 | e4IuqXcp6XT0NLRw2ZXK8huxmzjldL1TBR87Drg3Z2dE+Ra7MDo/yCERSlqIX9bL 19 | wmSSzj3aNwKBgQDr9hsFaZpUlywXCWYJWfcwgZLFohuhCqJz256ZqPhpR8It/D1r 20 | ROu5+wYXKdLaEoKuDdRSvFVctYNDQe4OrFJ2n+G2pvop4tdISrEsK3TW6vpc+40H 21 | DNxqAAiRwZ4Me1PUjFPLceuh8RVwWnoInJ/ecvJnuha3oTTSfKRgQUzUaQKBgCCS 22 | dJuTJmVAPSYT/5Q7unDjedZVRtTRfMVZI+KtGOEdbbA0I3/6EPvEMJJ/x2DkrByy 23 | G/FgIgxLTBXuawTDyWvCFq/aD8ob/5d7cqOi3w3kdrGWJf0WlvOFITW4q0X4E0fV 24 | wW1J7fZMaX3g52k60Yxavhq0rpHBtILV+CSmV7q/AoGBAM/V+SoNgXpwQC7SnmLZ 25 | fD8Tu2TFpT5BAShw3ATcZmmwHPKoUqbbUC3avrhEb7Bc/5gJJdzMU8zWRpBcx6TZ 26 | neVeJWG8EPDs8Qo1jV9bQpjUywYmq/Q9fdGwUyXdlMXwVd1oY84He0yLAuXQRMc7 27 | /Y+RzSzbzZN0O/e7HWcazVjm 28 | -----END PRIVATE KEY----- 29 | -------------------------------------------------------------------------------- /bare-metal-apps/apps/wolfssl/html-sources/bg_stripe.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prplfoundation/prpl-hypervisor/b780768365628e27e2584f2b8293409accf393fa/bare-metal-apps/apps/wolfssl/html-sources/bg_stripe.png -------------------------------------------------------------------------------- /bare-metal-apps/apps/wolfssl/html-sources/board.js: -------------------------------------------------------------------------------- 1 | var update_speed = 1000; 2 | 3 | function updateBoardInfo() 4 | { 5 | var xmlhttp = new XMLHttpRequest(); 6 | xmlhttp.onreadystatechange = function() 7 | { 8 | if (xmlhttp.readyState == 4 && xmlhttp.status == 200) 9 | { 10 | var info = JSON.parse(xmlhttp.responseText); 11 | document.getElementById("uptime").innerHTML = info.uptime +" seconds"; 12 | document.getElementById("led1_state").style.backgroundColor = (info.l1 == "on") ? "#FF0000" : "#000000"; 13 | document.getElementById("led2_state").style.backgroundColor = (info.l2 == "on") ? "#FFFF00" : "#000000"; 14 | setTimeout(function(){updateBoardInfo();}, update_speed); 15 | } 16 | }; 17 | xmlhttp.open("GET","board_info",true); 18 | xmlhttp.timeout = 3000; 19 | xmlhttp.ontimeout = function() 20 | { 21 | updateBoardInfo(); 22 | } 23 | xmlhttp.onerror = function(e) 24 | { 25 | setTimeout(function(){updateBoardInfo()}, 1000); 26 | } 27 | xmlhttp.send(); 28 | } 29 | 30 | function toggle_led1(){ 31 | var ajaxPost = new XMLHttpRequest; 32 | ajaxPost.open("GET","led1",true); 33 | ajaxPost.send(""); 34 | } 35 | 36 | function toggle_led2(){ 37 | var ajaxPost = new XMLHttpRequest; 38 | ajaxPost.open("GET","led2",true); 39 | ajaxPost.send(""); 40 | } 41 | 42 | function getIp() 43 | { 44 | var xmlhttp = new XMLHttpRequest(); 45 | xmlhttp.onreadystatechange = function() 46 | { 47 | if (xmlhttp.readyState == 4 && xmlhttp.status == 200) 48 | { 49 | document.getElementById("ip").innerHTML = xmlhttp.responseText; 50 | } 51 | } 52 | xmlhttp.open("GET","ip",true); 53 | xmlhttp.send(); 54 | } 55 | 56 | function getMAC() 57 | { 58 | var xmlhttp = new XMLHttpRequest(); 59 | xmlhttp.onreadystatechange = function() 60 | { 61 | if (xmlhttp.readyState == 4 && xmlhttp.status == 200) 62 | { 63 | document.getElementById("mac").innerHTML = xmlhttp.responseText; 64 | } 65 | } 66 | xmlhttp.open("GET","mac",true); 67 | xmlhttp.send(); 68 | } 69 | 70 | -------------------------------------------------------------------------------- /bare-metal-apps/apps/wolfssl/html-sources/cloud.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prplfoundation/prpl-hypervisor/b780768365628e27e2584f2b8293409accf393fa/bare-metal-apps/apps/wolfssl/html-sources/cloud.png -------------------------------------------------------------------------------- /bare-metal-apps/apps/wolfssl/html-sources/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prplfoundation/prpl-hypervisor/b780768365628e27e2584f2b8293409accf393fa/bare-metal-apps/apps/wolfssl/html-sources/favicon.png -------------------------------------------------------------------------------- /bare-metal-apps/apps/wolfssl/html-sources/pic32mz.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prplfoundation/prpl-hypervisor/b780768365628e27e2584f2b8293409accf393fa/bare-metal-apps/apps/wolfssl/html-sources/pic32mz.jpg -------------------------------------------------------------------------------- /bare-metal-apps/apps/wolfssl/web_files.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2016, prpl Foundation 3 | 4 | Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | in all copies. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | 14 | This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | 16 | */ 17 | 18 | 19 | // THIS FILE IS AUTOMATICALLY GENERATED. 20 | // MODIFY html-sources/make-Cfiles.py INSTEAD OF THIS. 21 | 22 | #ifndef WEB_FILES_H_ 23 | #define WEB_FILES_H_ 24 | 25 | 26 | 27 | struct web_file { 28 | const char * filename; 29 | const int * filesize; 30 | const char * content; 31 | const int cacheable; 32 | }; 33 | 34 | extern const struct web_file web_files[7]; 35 | extern const int num_web_files; 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /bare-metal-apps/arch/mips/baikal-t1/baikal.ld: -------------------------------------------------------------------------------- 1 | OUTPUT_FORMAT("elf32-tradlittlemips") 2 | ENTRY(_entry) 3 | 4 | MEMORY 5 | { 6 | ram (rw!x) : ORIGIN = 0x80000000, LENGTH = RAM_SIZE /* RAM area. */ 7 | } 8 | 9 | /* define a global symbol _stack */ 10 | 11 | _stack = ORIGIN(ram) + LENGTH(ram); 12 | _stack_size = STACK_SIZE; 13 | 14 | /* now define the output sections */ 15 | 16 | SECTIONS 17 | { 18 | .text : 19 | { 20 | *(.exception) 21 | . = 0x200; 22 | *(.vector0) 23 | . = 0x1000; 24 | *(.e_entry) 25 | _text = .; 26 | *(.text) 27 | *(.text.*) 28 | _etext = .; 29 | . = ALIGN(4); 30 | } > ram 31 | 32 | .MIPS.abiflags : { 33 | *(.MIPS.abiflags) 34 | . = ALIGN(4); 35 | } > ram 36 | 37 | .reginfo : { 38 | *(.reginfo) 39 | . = ALIGN(4); 40 | } > ram 41 | 42 | .rodata : 43 | { 44 | _rodata = .; 45 | *(.rodata) 46 | *(.rodata.*) 47 | _erodata = .; 48 | . = ALIGN(4); 49 | } > ram 50 | 51 | .data : 52 | { 53 | _data = .; 54 | *(.data) 55 | *(.data.*) 56 | _gp = .; 57 | *(.sdata) 58 | *(.sdata.*) 59 | . = ALIGN(16); 60 | } > ram 61 | 62 | _edata = .; 63 | 64 | .bss : 65 | { 66 | _bss_start = .; 67 | *(.bss) 68 | *(.bss.*) 69 | *(.sbss) 70 | *(.sbss.*) 71 | *(.scommon) 72 | . = ALIGN(4); 73 | _bss_end = . ; 74 | 75 | } > ram 76 | 77 | 78 | } 79 | _end = .; 80 | . = ALIGN(4); 81 | _heap_start = . ; 82 | _heap_size = LENGTH(ram) - (_heap_start - ORIGIN(ram)) - 4 - _stack_size; 83 | -------------------------------------------------------------------------------- /bare-metal-apps/arch/mips/baikal-t1/hal.mk: -------------------------------------------------------------------------------- 1 | # 2 | #Copyright (c) 2016, prpl Foundation 3 | # 4 | #Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | #fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | #in all copies. 7 | # 8 | #THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | #INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | #FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | #LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | #ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | # 14 | #This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | 16 | hal: 17 | $(CC) $(CFLAGS) $(INC_DIRS) $(TOPDIR)arch/mips/baikal-t1/eth.c -o $(TOPDIR)apps/$(APP)/eth.o 18 | $(CC) $(CFLAGS) $(INC_DIRS) $(TOPDIR)arch/mips/baikal-t1/platform.c -o $(TOPDIR)apps/$(APP)/platform.o 19 | $(CC) $(CFLAGS) $(INC_DIRS) $(TOPDIR)arch/mips/baikal-t1/crt0.s -o $(TOPDIR)apps/$(APP)/crt.o 20 | 21 | -------------------------------------------------------------------------------- /bare-metal-apps/arch/mips/baikal-t1/include/arch.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2016, prpl Foundation 3 | 4 | Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | in all copies. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | 14 | This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | 16 | */ 17 | 18 | #ifndef __ARCH_H 19 | #define __ARCH_H 20 | 21 | #define MILISECOND ((850000000/2)/1000) 22 | 23 | #include <../../../../../arch/mips/baikal-t1/include/baikal-t1.h> 24 | #include <../../../../../arch/mips/baikal-t1/include/p5600.h> 25 | #include <../../../../../arch/mips/common/include/mips_cp0.h> 26 | 27 | #endif 28 | 29 | -------------------------------------------------------------------------------- /bare-metal-apps/arch/mips/baikal-t1/include/eth.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2016, prpl Foundation 3 | 4 | Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | in all copies. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | 14 | This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | 16 | */ 17 | 18 | #ifndef ETH_H 19 | #define ETH_H 20 | 21 | #ifdef PICOTCP 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | #include "pico_defines.h" 28 | #include "pico_stack.h" 29 | 30 | 31 | 32 | #define ETH_MESSAGE_SZ 1536 33 | #define ETH_MESSAGELIST_SZ 5 34 | 35 | struct eth_message_t{ 36 | uint32_t size; /* size of each message in message_list */ 37 | uint8_t packet[ETH_MESSAGE_SZ]; 38 | }; 39 | 40 | 41 | struct eth_message_list_t{ 42 | uint32_t in; 43 | uint32_t out; 44 | volatile uint32_t num_packets; 45 | struct eth_message_t ringbuf[ETH_MESSAGELIST_SZ]; 46 | }; 47 | 48 | 49 | int eth_send(struct pico_device *dev, void *buf, int len); 50 | int eth_poll(struct pico_device *dev, int loop_score); 51 | int eth_link_state(struct pico_device *dev); 52 | void eth_watchdog(uint32_t *time, uint32_t ms_delay); 53 | 54 | #endif 55 | #endif 56 | 57 | -------------------------------------------------------------------------------- /bare-metal-apps/arch/mips/baikal-t1/include/platform.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2016, prpl Foundation 3 | 4 | Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | in all copies. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | 14 | This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | 16 | */ 17 | 18 | #ifndef _PLATFORM_H 19 | #define _PLATFORM_H 20 | 21 | #include 22 | 23 | #define CPU_TICK_TO_US(ticks) ((ticks)/((CPU_SPEED/2)/100000)) 24 | #define CPU_TICK_TO_MS(ticks) ((ticks)/((CPU_SPEED/2)/1000)) 25 | #define MS_TO_CPU_TICK(ms) (ms*((CPU_SPEED/2)/1000)) 26 | 27 | #define START_TIMER() mtc0(CP0_STATUS, 0, mfc0(CP0_STATUS, 0) | (1 << 15)) 28 | #define NEXT_TIMER() mtc0(CP0_COMPARE, 0, mfc0(CP0_COUNT, 0) + MS_TO_CPU_TICK(1)) 29 | 30 | #define ENABLE_INTERVM_INT() mtc0(CP0_STATUS, 0, mfc0(CP0_STATUS, 0) | ((GUEST_INTERVM_INT << STATUS_IM_SHIFT) << 2)) 31 | 32 | typedef void interrupt_handler_t(); 33 | 34 | uint32_t interrupt_register(interrupt_handler_t *handler, uint32_t interrupt); 35 | void init_proc(); 36 | uint32_t wait_time(uint32_t old_time, uint32_t ms_delay); 37 | 38 | #endif -------------------------------------------------------------------------------- /bare-metal-apps/arch/mips/pic32mz/hal.mk: -------------------------------------------------------------------------------- 1 | hal: 2 | $(CC) $(CFLAGS) $(INC_DIRS) $(TOPDIR)arch/mips/pic32mz/eth.c -o $(TOPDIR)apps/$(APP)/eth.o 3 | $(CC) $(CFLAGS) $(INC_DIRS) $(TOPDIR)arch/mips/pic32mz/platform.c -o $(TOPDIR)apps/$(APP)/platform.o 4 | $(CC) $(CFLAGS) $(INC_DIRS) $(TOPDIR)arch/mips/pic32mz/crt0.s -o $(TOPDIR)apps/$(APP)/crt.o 5 | 6 | -------------------------------------------------------------------------------- /bare-metal-apps/arch/mips/pic32mz/include/arch.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2016, prpl Foundation 3 | 4 | Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | in all copies. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | 14 | This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | 16 | */ 17 | 18 | #ifndef __ARCH_H 19 | #define __ARCH_H 20 | 21 | #define MILISECOND (100000000/ 1000) 22 | 23 | #include <../../../../../arch/mips/pic32mz/include/pic32mz.h> 24 | #include <../../../../../arch/mips/common/include/mips_cp0.h> 25 | 26 | #endif 27 | 28 | -------------------------------------------------------------------------------- /bare-metal-apps/arch/mips/pic32mz/include/eth.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2016, prpl Foundation 3 | 4 | Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | in all copies. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | 14 | This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | 16 | */ 17 | 18 | #ifndef ETH_H 19 | #define ETH_H 20 | 21 | #ifdef PICOTCP 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | #include "pico_defines.h" 28 | #include "pico_stack.h" 29 | 30 | 31 | 32 | #define ETH_MESSAGE_SZ 1536 33 | #define ETH_MESSAGELIST_SZ 5 34 | 35 | struct eth_message_t{ 36 | uint32_t size; /* size of each message in message_list */ 37 | uint8_t packet[ETH_MESSAGE_SZ]; 38 | }; 39 | 40 | 41 | struct eth_message_list_t{ 42 | uint32_t in; 43 | uint32_t out; 44 | volatile uint32_t num_packets; 45 | struct eth_message_t ringbuf[ETH_MESSAGELIST_SZ]; 46 | }; 47 | 48 | 49 | int eth_send(struct pico_device *dev, void *buf, int len); 50 | int eth_poll(struct pico_device *dev, int loop_score); 51 | int eth_link_state(struct pico_device *dev); 52 | void eth_watchdog(uint32_t *time, uint32_t ms_delay); 53 | 54 | #endif 55 | #endif 56 | 57 | -------------------------------------------------------------------------------- /bare-metal-apps/arch/mips/pic32mz/include/platform.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2016, prpl Foundation 3 | 4 | Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | in all copies. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | 14 | This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | 16 | */ 17 | 18 | #ifndef _PLATFORM_H 19 | #define _PLATFORM_H 20 | 21 | #include 22 | 23 | #define CPU_TICK_TO_US(ticks) ((ticks)/((CPU_SPEED/2)/100000)) 24 | #define CPU_TICK_TO_MS(ticks) ((ticks)/((CPU_SPEED/2)/1000)) 25 | 26 | #define START_TIMER() do{}while(0) 27 | #define NEXT_TIMER() do{}while(0) 28 | #define ENABLE_INTERVM_INT() do{}while(0) 29 | 30 | typedef void interrupt_handler_t(); 31 | 32 | uint32_t interrupt_register(interrupt_handler_t *handler, uint32_t interrupt); 33 | void init_proc(); 34 | uint32_t wait_time(uint32_t old_time, uint32_t ms_delay); 35 | 36 | #endif -------------------------------------------------------------------------------- /bare-metal-apps/arch/mips/pic32mz/pic32mz.ld: -------------------------------------------------------------------------------- 1 | OUTPUT_FORMAT("elf32-tradlittlemips") 2 | ENTRY(_entry) 3 | 4 | MEMORY 5 | { 6 | flash (rx) : ORIGIN = 0x9d000000, LENGTH = FLASH_SIZE /* Flash area*/ 7 | ram (rw!x) : ORIGIN = 0x80000000, LENGTH = RAM_SIZE /* RAM area. */ 8 | } 9 | 10 | /* define a global symbol _stack */ 11 | 12 | _stack = ORIGIN(ram) + LENGTH(ram); 13 | _stack_size = STACK_SIZE; 14 | 15 | /* now define the output sections */ 16 | 17 | SECTIONS 18 | { 19 | .text : 20 | { 21 | *(.exception) 22 | . = 0x200; 23 | *(.vector0) 24 | . = 0x1000; 25 | *(.e_entry) 26 | _text = .; 27 | *(.text) 28 | *(.text.*) 29 | _etext = .; 30 | } > flash 31 | 32 | .MIPS.abiflags : { 33 | __MIPS_abiflags_start = .; 34 | *(.MIPS.abiflags) 35 | __MIPS_abiflags_end = .; 36 | } > flash 37 | 38 | .rodata : 39 | { 40 | _rodata = .; 41 | *(.rodata) 42 | *(.rodata.*) 43 | _erodata = .; 44 | } > flash 45 | 46 | .data : AT (ADDR (.rodata) + SIZEOF (.rodata)) 47 | { 48 | _data = .; 49 | *(.data) 50 | *(.data.*) 51 | _gp = .; 52 | *(.sdata) 53 | *(.sdata.*) 54 | . = ALIGN(16); 55 | } > ram 56 | 57 | _edata = .; 58 | 59 | .bss : 60 | { 61 | _bss_start = .; 62 | *(.bss) 63 | *(.bss.*) 64 | *(.sbss) 65 | *(.sbss.*) 66 | *(.scommon) 67 | . = ALIGN(4); 68 | _bss_end = . ; 69 | } > ram 70 | 71 | } 72 | _end = .; 73 | . = ALIGN(4); 74 | _heap_start = . ; 75 | _heap_size = LENGTH(ram) - (_heap_start - ORIGIN(ram)) - 4 - _stack_size; 76 | 77 | 78 | -------------------------------------------------------------------------------- /bare-metal-apps/include/eth.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2016, prpl Foundation 3 | 4 | Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | in all copies. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | 14 | This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | 16 | */ 17 | 18 | #ifndef ETH_H 19 | #define ETH_H 20 | 21 | #ifdef PICOTCP 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | #include "pico_defines.h" 28 | #include "pico_stack.h" 29 | 30 | 31 | 32 | /* Ethernet Send/Receive */ 33 | 34 | int32_t hyper_eth_send(void *buf, int len); 35 | int32_t hyper_eth_poll(void *buf, int len); 36 | int32_t eth_link_state(struct pico_device *dev); 37 | void eth_get_mac(uint8_t *mac); 38 | 39 | 40 | #define ETH_MESSAGE_SZ 1536 41 | #define ETH_MESSAGELIST_SZ 5 42 | 43 | struct eth_message_t{ 44 | uint32_t size; /* size of each message in message_list */ 45 | uint8_t packet[ETH_MESSAGE_SZ]; 46 | }; 47 | 48 | 49 | struct eth_message_list_t{ 50 | uint32_t in; 51 | uint32_t out; 52 | volatile uint32_t num_packets; 53 | struct eth_message_t ringbuf[ETH_MESSAGELIST_SZ]; 54 | }; 55 | 56 | 57 | int eth_send(struct pico_device *dev, void *buf, int len); 58 | int eth_poll(struct pico_device *dev, int loop_score); 59 | 60 | #endif 61 | #endif 62 | 63 | -------------------------------------------------------------------------------- /bare-metal-apps/lib/include/malloc.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2016, prpl Foundation 3 | 4 | Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | in all copies. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | 14 | This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | 16 | */ 17 | 18 | #ifndef _MALLOC_H_ 19 | #define _MALLOC_H_ 20 | 21 | #include 22 | 23 | #define NULL ((void *)0) 24 | 25 | #define align4(x) ((((x) + 3) >> 2) << 2) 26 | 27 | typedef uint32_t size_t; 28 | 29 | struct mem_block { 30 | struct mem_block *next; /* pointer to the next block */ 31 | size_t size; /* aligned block size. the LSB is used to define if the block is used */ 32 | }; 33 | 34 | void free(void *ptr); 35 | void *malloc(uint32_t size); 36 | void *calloc(uint32_t qty, uint32_t type_size); 37 | void *realloc(void *ptr, uint32_t size); 38 | void init_mem(); 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /bare-metal-apps/lib/include/network.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2016, prpl Foundation 3 | 4 | Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | in all copies. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | 14 | This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | 16 | */ 17 | 18 | #ifndef NETWORK_H 19 | #define NETWORK_H 20 | 21 | #include 22 | #include 23 | 24 | 25 | #define MESSAGELIST_SZ 5 26 | #define MESSAGE_SZ 255 27 | 28 | 29 | /** Return values for inter-vm communication hypercalls */ 30 | #define MESSAGE_VCPU_NOT_FOUND -1 31 | #define MESSAGE_FULL -2 32 | #define MESSAGE_TOO_BIG -3 33 | #define MESSAGE_EMPTY -4 34 | #define MESSAGE_VCPU_NOT_INIT -5 35 | 36 | 37 | 38 | /** Struct for message exchange 39 | It is a circular buffer. Message_list is a char matrix statically allocated. 40 | */ 41 | struct message_t{ 42 | uint32_t source_id; 43 | uint32_t size; /* size of each message in message_list */ 44 | uint8_t message[MESSAGE_SZ]; 45 | }; 46 | 47 | 48 | struct message_list_t{ 49 | uint32_t in; 50 | uint32_t out; 51 | volatile uint32_t num_messages; 52 | struct message_t messages[MESSAGELIST_SZ]; 53 | }; 54 | 55 | 56 | void init_network(); 57 | int32_t ReceiveMessage(uint32_t *source, void* message, uint32_t bufsz, uint32_t block); 58 | int32_t SendMessage(uint32_t target_id, void* message, uint32_t size); 59 | void network_int_handler(); 60 | void print_net_error(int32_t error); 61 | 62 | #endif 63 | 64 | -------------------------------------------------------------------------------- /bare-metal-apps/lib/include/types.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2016, prpl Foundation 3 | 4 | Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | in all copies. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | 14 | This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | 16 | */ 17 | 18 | #ifndef _TYPES_H_ 19 | #define _TYPES_H_ 20 | 21 | typedef __INT8_TYPE__ int8_t; 22 | typedef __INT16_TYPE__ int16_t; 23 | typedef __INT32_TYPE__ int32_t; 24 | typedef __INT64_TYPE__ int64_t; 25 | typedef __UINT8_TYPE__ uint8_t; 26 | typedef __UINT16_TYPE__ uint16_t; 27 | typedef __UINT32_TYPE__ uint32_t; 28 | typedef __UINT64_TYPE__ uint64_t; 29 | 30 | typedef uint32_t size_t; 31 | 32 | #endif /*_TYPES_H_*/ 33 | 34 | -------------------------------------------------------------------------------- /bare-metal-apps/lib/include/usb.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2016, prpl Foundation 3 | 4 | Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | in all copies. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | 14 | This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | 16 | */ 17 | 18 | #ifndef USB_LIB_H 19 | #define USB_LIB_H 20 | 21 | #include 22 | #include 23 | 24 | struct descriptor_decoded{ 25 | uint8_t bLength; 26 | uint8_t bDescriptorType; 27 | uint16_t bcdUSB; 28 | uint8_t bDeviceClass; 29 | uint8_t bDeviceSubClass; 30 | uint8_t bDeviceProtocol; 31 | uint8_t bMaxPacketSize; 32 | uint16_t idVendor; 33 | uint16_t idProduct; 34 | uint16_t bcdDevice; 35 | uint8_t iManufacturer; 36 | uint8_t iProduct; 37 | uint8_t iSerialNumber; 38 | uint8_t bNumConfigurations; 39 | }; 40 | 41 | #endif 42 | 43 | -------------------------------------------------------------------------------- /bare-metal-apps/lib/lib.mk: -------------------------------------------------------------------------------- 1 | 2 | lib: 3 | $(CC) $(CFLAGS) $(INC_DIRS) $(TOPDIR)lib/libc.c -o $(TOPDIR)apps/$(APP)/libc.o 4 | $(CC) $(CFLAGS) $(INC_DIRS) $(TOPDIR)lib/malloc.c -o $(TOPDIR)apps/$(APP)/malloc.o 5 | $(CC) $(CFLAGS) $(INC_DIRS) $(TOPDIR)lib/network.c -o $(TOPDIR)apps/$(APP)/network.o 6 | 7 | 8 | -------------------------------------------------------------------------------- /bare-metal-apps/platform/baikal_t1_board/include/io.h: -------------------------------------------------------------------------------- 1 | /* 2 | C o*pyright (c) 2016, prpl Foundation 3 | 4 | Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | in all copies. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | 14 | This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | 16 | */ 17 | 18 | #ifndef _IO_H 19 | #define _IO_H 20 | 21 | #include 22 | 23 | #define ENABLE_LED1 do{}while(0) 24 | #define ENABLE_LED2 do{}while(0) 25 | #define ENABLE_LED3 do{}while(0) 26 | 27 | #define TOGGLE_LED1 do{}while(0) 28 | #define TOGGLE_LED2 do{}while(0) 29 | #define TOGGLE_LED3 do{}while(0) 30 | 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /bare-metal-apps/platform/baikal_t1_board/include/uart.h: -------------------------------------------------------------------------------- 1 | /* 2 | C o*pyright (c) 2016, prpl Foundation 3 | 4 | Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | in all copies. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | 14 | This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | 16 | */ 17 | 18 | #ifndef _UART_H 19 | #define _UART_H 20 | 21 | #include 22 | #include 23 | 24 | int32_t serial_select(uint32_t serial_number); 25 | void putchar(int32_t value); 26 | int32_t kbhit(void); 27 | uint32_t getchar(void); 28 | 29 | #define UART2 2 30 | #define UART6 6 31 | 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /bare-metal-apps/platform/baikal_t1_board/platform.mk: -------------------------------------------------------------------------------- 1 | # 2 | #Copyright (c) 2016, prpl Foundation 3 | # 4 | #Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | #fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | #in all copies. 7 | # 8 | #THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | #INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | #FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | #LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | #ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | # 14 | #This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | 16 | platform: 17 | $(CC) $(CFLAGS) $(INC_DIRS) uart.c -o $(TOPDIR)apps/$(APP)/uart.o 18 | 19 | 20 | -------------------------------------------------------------------------------- /bare-metal-apps/platform/baikal_t1_board/uart.c: -------------------------------------------------------------------------------- 1 | /* 2 | C o*pyright (c) 2016, prpl Foundation 3 | 4 | Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | in all copies. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | 14 | This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | static uint32_t serial_port = UART2; 23 | 24 | int32_t serial_select(uint32_t serial_number){ 25 | return -1; 26 | } 27 | 28 | 29 | void putchar(int32_t value){ 30 | while( !(UART0_LSR&0x40) ); 31 | UART0_RBR = value; 32 | } 33 | 34 | int32_t kbhit(void){ 35 | return 0; 36 | } 37 | 38 | uint32_t getchar(void){ 39 | return 0; 40 | } 41 | 42 | 43 | -------------------------------------------------------------------------------- /bare-metal-apps/platform/pic32mz_chipkit_Wifire/include/io.h: -------------------------------------------------------------------------------- 1 | /* 2 | C o*pyright (c) 2016, prpl Foundation 3 | 4 | Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | in all copies. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | 14 | This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | 16 | */ 17 | 18 | #ifndef _IO_H 19 | #define _IO_H 20 | 21 | #include 22 | 23 | #define ENABLE_LED1 writeio(TRISGCLR, 1 << 6) 24 | #define ENABLE_LED2 writeio(TRISDCLR, 1 << 4) 25 | #define ENABLE_LED3 writeio(TRISBCLR, 1 << 11) 26 | #define ENABLE_LED4 write(TRISGCLR, 1 << 15) 27 | 28 | #define TOGGLE_LED1 writeio(LATGINV, 1 << 6) 29 | #define TOGGLE_LED2 writeio(LATDINV, 1 << 4) 30 | #define TOGGLE_LED2 writeio(LATBINV, 1 << 11) 31 | #define TOGGLE_LED2 writeio(LATGINV, 1 << 15) 32 | 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /bare-metal-apps/platform/pic32mz_chipkit_Wifire/include/uart.h: -------------------------------------------------------------------------------- 1 | /* 2 | C o*pyright (c) 2016, prpl Foundation 3 | 4 | Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | in all copies. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | 14 | This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | 16 | */ 17 | 18 | #ifndef _UART_H 19 | #define _UART_H 20 | 21 | #include 22 | #include 23 | 24 | int32_t serial_select(uint32_t serial_number); 25 | void putchar(int32_t value); 26 | int32_t kbhit(void); 27 | uint32_t getchar(void); 28 | 29 | #define UART4 4 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /bare-metal-apps/platform/pic32mz_chipkit_Wifire/platform.mk: -------------------------------------------------------------------------------- 1 | # 2 | #Copyright (c) 2016, prpl Foundation 3 | # 4 | #Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | #fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | #in all copies. 7 | # 8 | #THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | #INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | #FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | #LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | #ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | # 14 | #This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | 16 | platform: 17 | $(CC) $(CFLAGS) $(INC_DIRS) uart.c -o $(TOPDIR)apps/$(APP)/uart.o 18 | 19 | 20 | -------------------------------------------------------------------------------- /bare-metal-apps/platform/pic32mz_chipkit_Wifire/uart.c: -------------------------------------------------------------------------------- 1 | /* 2 | C o*pyright (c) 2016, prpl Foundation 3 | 4 | Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | in all copies. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | 14 | This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | static uint32_t serial_port = UART4; 23 | 24 | int32_t serial_select(uint32_t serial_number){ 25 | /* Only UART4 suported. */ 26 | switch (serial_number){ 27 | case UART4: serial_port = UART4; 28 | return UART4; 29 | default: 30 | return -1; 31 | } 32 | } 33 | 34 | 35 | void putchar(int32_t value){ 36 | #ifdef VIRTUALIZED_IO 37 | while(readio(U4STA) & USTA_UTXBF); 38 | writeio(U4TXREG, value); 39 | #else 40 | while(U4STA & USTA_UTXBF); 41 | U4TXREG = value; 42 | #endif 43 | } 44 | 45 | int32_t kbhit(void){ 46 | #ifdef VIRTUALIZED_IO 47 | return (readio(U4STA) & USTA_URXDA); 48 | #else 49 | return (U4STA & USTA_URXDA); 50 | #endif 51 | } 52 | 53 | uint32_t getchar(void){ 54 | while(!kbhit()); 55 | #ifdef VIRTUALIZED_IO 56 | return (uint32_t)readio(U2RXREG); 57 | #else 58 | return (uint32_t)U2RXREG; 59 | #endif 60 | } 61 | -------------------------------------------------------------------------------- /bare-metal-apps/platform/pic32mz_curiosity/include/io.h: -------------------------------------------------------------------------------- 1 | /* 2 | C o*pyright (c) 2016, prpl Foundation 3 | 4 | Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | in all copies. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | 14 | This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | 16 | */ 17 | 18 | #ifndef _IO_H 19 | #define _IO_H 20 | 21 | #include 22 | 23 | #define ENABLE_LED1 writeio(TRISECLR, 8) 24 | #define ENABLE_LED2 writeio(TRISECLR, 0x10); 25 | #define ENABLE_LED3 writeio(TRISECLR, 0x20) 26 | #define ENABLE_LED4_BLUE writeio(TRISBCLR, 0x1) 27 | #define ENABLE_LED4_GREEN writeio(TRISBCLR, 0x2) 28 | #define ENABLE_LED4_YELLOW writeio(TRISBCLR, 0x10) 29 | 30 | #define TOGGLE_LED1 writeio(LATEINV, 8) 31 | #define TOGGLE_LED2 writeio(LATEINV, 0x10) 32 | #define TOGGLE_LED3 writeio(LATEINV, 0x20) 33 | #define TOGGLE_LED4_BLUE writeio(LATBINV, 0x1) 34 | #define TOGGLE_LED4_GREEN writeio(LATBINV, 0x2) 35 | #define TOGGLE_LED4_YELLOW writeio(LATBINV, 0x10) 36 | 37 | 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /bare-metal-apps/platform/pic32mz_curiosity/include/uart.h: -------------------------------------------------------------------------------- 1 | /* 2 | C o*pyright (c) 2016, prpl Foundation 3 | 4 | Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | in all copies. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | 14 | This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | 16 | */ 17 | 18 | #ifndef _UART_H 19 | #define _UART_H 20 | 21 | #include 22 | #include 23 | 24 | int32_t serial_select(uint32_t serial_number); 25 | void putchar(int32_t value); 26 | int32_t kbhit(void); 27 | uint32_t getchar(void); 28 | 29 | #define UART1 1 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /bare-metal-apps/platform/pic32mz_curiosity/platform.mk: -------------------------------------------------------------------------------- 1 | # 2 | #Copyright (c) 2016, prpl Foundation 3 | # 4 | #Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | #fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | #in all copies. 7 | # 8 | #THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | #INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | #FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | #LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | #ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | # 14 | #This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | 16 | platform: 17 | $(CC) $(CFLAGS) $(INC_DIRS) uart.c -o $(TOPDIR)apps/$(APP)/uart.o 18 | 19 | 20 | -------------------------------------------------------------------------------- /bare-metal-apps/platform/pic32mz_curiosity/uart.c: -------------------------------------------------------------------------------- 1 | /* 2 | C o*pyright (c) 2016, prpl Foundation 3 | 4 | Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | in all copies. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | 14 | This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | static uint32_t serial_port = UART1; 23 | 24 | int32_t serial_select(uint32_t serial_number){ 25 | /* select serial 2 or 4 as output */ 26 | switch (serial_number){ 27 | case UART1: serial_port = UART1; 28 | return UART1; 29 | default: 30 | return -1; 31 | } 32 | } 33 | 34 | 35 | /*void putchar(int32_t value){ 36 | if (serial_port == UART1){ 37 | while(U1STA & USTA_UTXBF); 38 | U1TXREG = value; 39 | } 40 | }*/ 41 | 42 | int32_t kbhit(void){ 43 | if (serial_port == UART1){ 44 | return (U1STA & USTA_URXDA); 45 | } 46 | return 0; 47 | } 48 | 49 | uint32_t getchar(void){ 50 | while(!kbhit()); 51 | if (serial_port == UART1){ 52 | return (uint32_t)U1RXREG; 53 | } 54 | return 0; 55 | } 56 | -------------------------------------------------------------------------------- /bare-metal-apps/platform/pic32mz_starter_kit/include/io.h: -------------------------------------------------------------------------------- 1 | /* 2 | C o*pyright (c) 2016, prpl Foundation 3 | 4 | Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | in all copies. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | 14 | This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | 16 | */ 17 | 18 | #ifndef _IO_H 19 | #define _IO_H 20 | 21 | #include 22 | 23 | #define ENABLE_LED1 writeio(TRISHCLR, 1) 24 | #define ENABLE_LED2 writeio(TRISHCLR, 2); 25 | #define ENABLE_LED3 writeio(TRISHCLR, 4) 26 | 27 | #define TOGGLE_LED1 writeio(LATHINV, 1) 28 | #define TOGGLE_LED2 writeio(LATHINV, 2) 29 | #define TOGGLE_LED3 writeio(LATHINV, 4) 30 | 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /bare-metal-apps/platform/pic32mz_starter_kit/include/uart.h: -------------------------------------------------------------------------------- 1 | /* 2 | C o*pyright (c) 2016, prpl Foundation 3 | 4 | Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | in all copies. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | 14 | This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | 16 | */ 17 | 18 | #ifndef _UART_H 19 | #define _UART_H 20 | 21 | #include 22 | #include 23 | 24 | int32_t serial_select(uint32_t serial_number); 25 | void putchar(int32_t value); 26 | int32_t kbhit(void); 27 | uint32_t getchar(void); 28 | 29 | #define UART2 2 30 | #define UART6 6 31 | 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /bare-metal-apps/platform/pic32mz_starter_kit/platform.mk: -------------------------------------------------------------------------------- 1 | # 2 | #Copyright (c) 2016, prpl Foundation 3 | # 4 | #Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | #fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | #in all copies. 7 | # 8 | #THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | #INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | #FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | #LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | #ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | # 14 | #This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | 16 | platform: 17 | $(CC) $(CFLAGS) $(INC_DIRS) uart.c -o $(TOPDIR)apps/$(APP)/uart.o 18 | 19 | 20 | -------------------------------------------------------------------------------- /bare-metal-apps/platform/pic32mz_starter_kit/uart.c: -------------------------------------------------------------------------------- 1 | /* 2 | C o*pyright (c) 2016, prpl Foundation 3 | 4 | Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | in all copies. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | 14 | This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | static uint32_t serial_port = UART2; 23 | 24 | int32_t serial_select(uint32_t serial_number){ 25 | /* select serial 2 or 4 as output */ 26 | switch (serial_number){ 27 | case UART2: serial_port = UART2; 28 | return UART2; 29 | case UART6: serial_port = UART6; 30 | return UART6; 31 | default: 32 | return -1; 33 | } 34 | } 35 | 36 | 37 | void putchar(int32_t value){ 38 | if (serial_port == UART2){ 39 | while(U2STA & USTA_UTXBF); 40 | U2TXREG = value; 41 | }else if (serial_port == UART6){ 42 | while(U6STA & USTA_UTXBF); 43 | U6TXREG = value; 44 | } 45 | } 46 | 47 | int32_t kbhit(void){ 48 | if (serial_port == UART2){ 49 | return (U2STA & USTA_URXDA); 50 | }else if (serial_port == UART6){ 51 | return (U6STA & USTA_URXDA); 52 | } 53 | return 0; 54 | } 55 | 56 | uint32_t getchar(void){ 57 | while(!kbhit()); 58 | if (serial_port == UART2){ 59 | return (uint32_t)U2RXREG; 60 | }else if (serial_port == UART6){ 61 | return (uint32_t)U6RXREG; 62 | } 63 | return 0; 64 | } 65 | -------------------------------------------------------------------------------- /bin/board-control-noKey.py: -------------------------------------------------------------------------------- 1 | import serial 2 | from time import sleep 3 | import base64 4 | import sys 5 | 6 | def readSerial(): 7 | while True: 8 | response = ser.readline(); 9 | return response 10 | 11 | 12 | # main 13 | ser = serial.Serial(port='/dev/ttyACM0', baudrate=115200, timeout=3) 14 | ser.isOpen() 15 | 16 | 17 | # Fake keyCode 18 | binary_keyCode = base64.b16decode('0203030203030010200102000100000000000000000000') 19 | 20 | while(1): 21 | print "ARM Commands: " 22 | print "1 - Start" 23 | print "2 - Stop" 24 | 25 | c = '0' 26 | while c!='1' and c!='2': 27 | c = raw_input('Input:') 28 | 29 | print 'Sending the arm command...' 30 | 31 | for i in range(0, len(binary_keyCode)): 32 | ser.write(binary_keyCode[i]) 33 | ser.flush() 34 | 35 | ser.write(c.encode()) 36 | ser.write('\n'.encode()) 37 | ser.flush() 38 | 39 | print 'Board response: %s' % readSerial() 40 | 41 | -------------------------------------------------------------------------------- /bin/board-control.py: -------------------------------------------------------------------------------- 1 | import serial 2 | from time import sleep 3 | import base64 4 | import sys 5 | 6 | def readSerial(): 7 | while True: 8 | response = ser.readline(); 9 | return response 10 | 11 | 12 | # main 13 | ser = serial.Serial(port='/dev/ttyACM0', baudrate=115200, timeout=3) 14 | ser.isOpen() 15 | 16 | # Wait UART Listener VM to be done. 17 | while(1): 18 | message = readSerial() 19 | if 'Listener' in message: 20 | break 21 | 22 | #Requires the keycode to the Litener VM 23 | ser.write('\n'.encode()) 24 | ser.flush() 25 | 26 | 27 | #Receive the keyCode 28 | while(1): 29 | message = readSerial() 30 | if 'keyCode' in message: 31 | hex_keyCode = message[9:-1] 32 | break 33 | 34 | print "KeyCode: ", hex_keyCode 35 | 36 | binary_keyCode = base64.b16decode(hex_keyCode.upper()) 37 | 38 | while(1): 39 | print "ARM Commands: " 40 | print "1 - Start" 41 | print "2 - Stop" 42 | 43 | c = '0' 44 | while c!='1' and c!='2': 45 | c = raw_input('Input:') 46 | 47 | print 'Sending the arm command...' 48 | 49 | for i in range(0, len(binary_keyCode)): 50 | ser.write(binary_keyCode[i]) 51 | ser.flush() 52 | 53 | ser.write(c.encode()) 54 | ser.write('\n'.encode()) 55 | ser.flush() 56 | 57 | print 'Board response: %s' % readSerial() 58 | 59 | -------------------------------------------------------------------------------- /bin/pic32prog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prplfoundation/prpl-hypervisor/b780768365628e27e2584f2b8293409accf393fa/bin/pic32prog -------------------------------------------------------------------------------- /bin/test_puf_vm.py: -------------------------------------------------------------------------------- 1 | import serial 2 | from time import sleep 3 | import base64 4 | import sys 5 | 6 | def readSerial(): 7 | while True: 8 | response = ser.readline(); 9 | return response 10 | 11 | 12 | # main 13 | ser = serial.Serial(port='/dev/ttyACM0', baudrate=115200, timeout=1) 14 | ser.isOpen() 15 | 16 | while(1): 17 | message = readSerial() 18 | # print message 19 | 20 | if 'keyCode' in message: 21 | hex_keyCode = message[9:-1] 22 | 23 | # print hex_keyCode 24 | break 25 | 26 | binary_keyCode = base64.b16decode(hex_keyCode.upper()) 27 | 28 | temp = list(binary_keyCode) 29 | temp[0] = '1' 30 | temp[1] = '2' 31 | temp[2] = '3' 32 | binary_keyCode_manipulated = "".join(temp) 33 | 34 | print 'Sending the wrong keyCode to the board (%d bytes)' % len(binary_keyCode_manipulated) 35 | 36 | for i in range(0, len(binary_keyCode_manipulated)): 37 | ser.write(binary_keyCode_manipulated[i]) 38 | ser.flush() 39 | 40 | ser.write('\n'.encode()) 41 | ser.flush() 42 | 43 | print 'Board response: %s' % readSerial() 44 | 45 | sleep(2) 46 | 47 | print 'Sending the correct keyCode to the board (%d bytes)' % len(binary_keyCode) 48 | 49 | for i in range(0, len(binary_keyCode)): 50 | ser.write(binary_keyCode[i]) 51 | ser.flush() 52 | 53 | ser.write('\n'.encode()) 54 | ser.flush() 55 | 56 | print 'Board response: %s' % readSerial() 57 | 58 | -------------------------------------------------------------------------------- /doc/images/baikal-t1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prplfoundation/prpl-hypervisor/b780768365628e27e2584f2b8293409accf393fa/doc/images/baikal-t1.jpg -------------------------------------------------------------------------------- /doc/images/chipkit-wifire-top.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prplfoundation/prpl-hypervisor/b780768365628e27e2584f2b8293409accf393fa/doc/images/chipkit-wifire-top.jpg -------------------------------------------------------------------------------- /doc/images/chipkit-wifire.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prplfoundation/prpl-hypervisor/b780768365628e27e2584f2b8293409accf393fa/doc/images/chipkit-wifire.jpg -------------------------------------------------------------------------------- /doc/images/curiosity.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prplfoundation/prpl-hypervisor/b780768365628e27e2584f2b8293409accf393fa/doc/images/curiosity.jpg -------------------------------------------------------------------------------- /doc/images/gdb_bb.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prplfoundation/prpl-hypervisor/b780768365628e27e2584f2b8293409accf393fa/doc/images/gdb_bb.jpg -------------------------------------------------------------------------------- /doc/images/starter_kit.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prplfoundation/prpl-hypervisor/b780768365628e27e2584f2b8293409accf393fa/doc/images/starter_kit.jpg -------------------------------------------------------------------------------- /doc/images/wi-fire.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prplfoundation/prpl-hypervisor/b780768365628e27e2584f2b8293409accf393fa/doc/images/wi-fire.jpg -------------------------------------------------------------------------------- /doc/prpl-security-guidance-2-5-2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prplfoundation/prpl-hypervisor/b780768365628e27e2584f2b8293409accf393fa/doc/prpl-security-guidance-2-5-2.pdf -------------------------------------------------------------------------------- /drivers/t1-baikal-UART-test.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2016, prpl Foundation 3 | 4 | Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | in all copies. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | 14 | This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | 16 | */ 17 | 18 | /** 19 | * @file t1-baikal-UART-test.c 20 | * 21 | * @section DESCRIPTION 22 | * 23 | * Simple test to the interrupt subsystem using UART interrupts. 24 | * 25 | * 26 | */ 27 | 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | 39 | 40 | void interrupt_handler(){ 41 | char a; 42 | 43 | while( (UART0_LSR & 0x1) ){ 44 | a = UART0_RBR; 45 | UART0_RBR = a; 46 | } 47 | } 48 | 49 | /** 50 | * @brief Driver init call. 51 | * Register the interrupt handler and enable UART interrupts. 52 | */ 53 | void uart_init(){ 54 | uint32_t temp; 55 | 56 | if( register_interrupt(interrupt_handler, 3) == 0){ 57 | INFO("UART Baikal-T1 driver registration ERROR."); 58 | return 0; 59 | } 60 | 61 | /*Clean input FIFO */ 62 | while( (UART0_LSR & 0x1) ){ 63 | UART0_RBR; 64 | } 65 | 66 | UART0_IER = 0x1; 67 | 68 | temp = mfc0(CP0_STATUS, 0); 69 | temp |= (STATUS_IM3 << STATUS_IM_SHIFT); 70 | mtc0(CP0_STATUS, 0, temp); 71 | 72 | GIC_SH_MAP_CORE(48) = 1; 73 | GIC_SH_MAP_PIN(48) = 0x80000001; 74 | GIC_SH_POL_HIGH(48); 75 | GIC_SH_SMASK(48); 76 | 77 | INFO("UART Baikal-T1 driver test."); 78 | } 79 | 80 | driver_init(uart_init); 81 | 82 | -------------------------------------------------------------------------------- /include/globals.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2016, prpl Foundation 3 | 4 | Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | in all copies. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | 14 | This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | 16 | */ 17 | 18 | #ifndef __GLOBALS_H 19 | #define __GLOBALS_H 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | #define CRITICAL(X,...) printf("\nCRITICAL: "X, ##__VA_ARGS__); wait_for_reset(); 27 | 28 | #ifdef WARNINGS 29 | #define WARNING(X,...) printf("\nWARNING: "X, ##__VA_ARGS__); 30 | #else 31 | #define WARNING(A,...) do{}while(0); 32 | #endif 33 | 34 | #ifdef ERRORS 35 | #define ERROR(X,...) printf("\nERROR: "X, ##__VA_ARGS__); 36 | #else 37 | #define ERROR(X,...) do{}while(0); 38 | #endif 39 | 40 | #ifdef INFOS 41 | #define INFO(X,...) printf("\n"X, ##__VA_ARGS__); 42 | #else 43 | #define INFO(X,...) do{}while(0); 44 | #endif 45 | 46 | extern struct scheduler_info_t scheduler_info; 47 | 48 | #define is_vcpu_executing (((vcpu_t*)scheduler_info.vcpu_executing) ? ((vcpu_t*)scheduler_info.vcpu_executing) : NULL) 49 | #define vcpu_in_execution ((vcpu_t*)scheduler_info.vcpu_executing) 50 | #define vm_in_execution ((vm_t*)vcpu_in_execution->vm) 51 | 52 | #define MICROSECOND (MILISECOND/1000) 53 | 54 | /* Hypervisor tick interval in microseconds */ 55 | #define SYSTEM_TICK_US 1000 56 | 57 | 58 | 59 | 60 | #endif -------------------------------------------------------------------------------- /include/guest_interrupts.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2016, prpl Foundation 3 | 4 | Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | in all copies. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | 14 | This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | 16 | */ 17 | 18 | /** 19 | * @file guest_interrupts.c 20 | * 21 | * @section DESCRIPTION 22 | * 23 | * Interrupt values for bare-metal applications. 24 | */ 25 | 26 | #ifndef __GUEST_INTERRUPTS_H 27 | #define __GUEST_INTERRUPTS_H 28 | 29 | #ifndef BAIKAL_T1 30 | 31 | #define GUEST_TIMER_INT 1 32 | #define GUEST_INTERVM_INT 2 33 | #define GUEST_USB_INT 4 34 | #define GUEST_ETH_INT 8 35 | #define GUEST_USER_DEFINED_INT_1 0x10 36 | #define GUEST_USER_DEFINED_INT_2 0x20 37 | 38 | #else 39 | 40 | #define GUEST_TIMER_INT 0x20 41 | #define GUEST_INTERVM_INT 2 42 | 43 | #endif 44 | 45 | #endif 46 | 47 | -------------------------------------------------------------------------------- /platform/baikal_t1_board/board/board.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016, prpl Foundation 3 | * 4 | * Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | * fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | * in all copies. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | * FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | * 14 | * This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | * 16 | */ 17 | 18 | /** 19 | * @file platform.c 20 | * 21 | * @section DESCRIPTION 22 | * 23 | * Specific platform initialization. 24 | */ 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | /** 31 | * @brief Called on early hypervisor initialization and responsable for basic the 32 | * platform configuration. 33 | */ 34 | void early_platform_init(){ 35 | 36 | 37 | } 38 | 39 | 40 | void wait_for_reset(){ 41 | while(1){} 42 | } 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /platform/baikal_t1_board/board/board.mk: -------------------------------------------------------------------------------- 1 | # 2 | #Copyright (c) 2016, prpl Foundation 3 | # 4 | #Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | #fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | #in all copies. 7 | # 8 | #THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | #INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | #FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | #LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | #ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | # 14 | #This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | 16 | platform: 17 | $(CC) $(CFLAGS) $(INC_DIRS) \ 18 | board/uart.c \ 19 | board/board.c -------------------------------------------------------------------------------- /platform/baikal_t1_board/board/uart.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016, prpl Foundation 3 | * 4 | * Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | * fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | * in all copies. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | * FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | * 14 | * This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | * 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | /** 24 | * @file uart.c 25 | * 26 | * @section DESCRIPTION 27 | * 28 | * UART initialization and low level UART functions. 29 | * 30 | */ 31 | 32 | /** 33 | * @brief Configures UART2 as stdout and UART6 as alternative. 34 | * @param baudrate_u2 UART2 baudrate. 35 | * @param baudrate_u6 UART6 baudrate. 36 | * @param sysclk System clock. 37 | */ 38 | void init_uart(uint32_t baudrate_u2, uint32_t baudrate_u6, uint32_t sysclk){ 39 | 40 | } 41 | 42 | 43 | /** 44 | * @brief Write char to UART2. 45 | * @param c Character to be writed. 46 | */ 47 | void putchar(uint8_t c){ 48 | while( !(UART0_LSR&0x40) ); 49 | UART0_RBR = c; 50 | } 51 | 52 | 53 | /** 54 | * @brief Block and wait for a character. 55 | * @return Read character. 56 | */ 57 | uint32_t getchar(void){ 58 | 59 | } 60 | 61 | -------------------------------------------------------------------------------- /platform/baikal_t1_board/cfg/sample-3VMs.cfg: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016, prpl Foundation 3 | * 4 | * Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | * fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | * in all copies. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | * FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | * 14 | * This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | * 16 | */ 17 | 18 | /* 19 | * This is a configuration sample for the blink led sample (1 VM). 20 | * 21 | * To compile this example, modify the variable CFG_FILE on the 22 | * Makefile to point to this file. 23 | * 24 | */ 25 | 26 | /* General system configuration */ 27 | system = { 28 | debug = [ "WARNINGS", "INFOS", "ERRORS"]; 29 | uart_speed = 115200; 30 | scheduler_quantum_ms = 10; 31 | guest_quantum_ms = 1; 32 | }; 33 | 34 | 35 | /* Virtual Machines Configuration */ 36 | virtual_machines = ( 37 | { 38 | app_name = "ping"; 39 | os_type = "BARE_METAL"; 40 | priority = 100; 41 | RAM_size_bytes = "MEM_SIZE_32KB"; 42 | }, 43 | { 44 | app_name = "pong"; 45 | os_type = "BARE_METAL"; 46 | priority = 100; 47 | RAM_size_bytes = "MEM_SIZE_32KB"; 48 | }, 49 | { 50 | app_name = "blink"; 51 | os_type = "BARE_METAL"; 52 | priority = 20; 53 | RAM_size_bytes = "MEM_SIZE_32KB"; 54 | } 55 | ); 56 | 57 | -------------------------------------------------------------------------------- /platform/baikal_t1_board/cfg/sample-blink.cfg: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016, prpl Foundation 3 | * 4 | * Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | * fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | * in all copies. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | * FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | * 14 | * This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | * 16 | */ 17 | 18 | /* 19 | * This is a configuration sample for the blink led sample (1 VM) using virtualized IO. 20 | * 21 | * To compile this example, modify the variable CFG_FILE on the 22 | * Makefile to point to this file. 23 | * 24 | */ 25 | 26 | 27 | /* General system configuration */ 28 | system = { 29 | debug = [ "WARNINGS", "INFOS", "ERRORS"]; 30 | uart_speed = 115200; 31 | scheduler_quantum_ms = 10; 32 | guest_quantum_ms = 1; 33 | }; 34 | 35 | 36 | /* Virtual Machines Configuration */ 37 | virtual_machines = ( 38 | { 39 | app_name = "blink"; 40 | os_type = "BARE_METAL"; 41 | priority = 100; 42 | RAM_size_bytes = "MEM_SIZE_64KB"; 43 | } 44 | ); 45 | 46 | -------------------------------------------------------------------------------- /platform/baikal_t1_board/cfg/sample-linux.cfg: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016, prpl Foundation 3 | * 4 | * Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | * fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | * in all copies. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | * FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | * 14 | * This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | * 16 | */ 17 | 18 | /* 19 | * This is a configuration sample for the blink led sample (1 VM) using virtualized IO. 20 | * 21 | * To compile this example, modify the variable CFG_FILE on the 22 | * Makefile to point to this file. 23 | * 24 | */ 25 | 26 | 27 | /* General system configuration */ 28 | system = { 29 | debug = [ "WARNINGS", "INFOS", "ERRORS"]; 30 | uart_speed = 115200; 31 | scheduler_quantum_ms = 10; 32 | guest_quantum_ms = 1; 33 | }; 34 | 35 | 36 | /* Virtual Machines Configuration */ 37 | virtual_machines = ( 38 | { 39 | app_name = "linux"; 40 | os_type = "LINUX"; 41 | priority = 100; 42 | RAM_size_bytes = "MEM_SIZE_32MB"; 43 | memory_maps = ( 44 | /* UART 0 */ 45 | { 46 | base_addr = 0xBF04A000; 47 | page_size = "MEM_SIZE_4KB"; 48 | }, 49 | /* GIC */ 50 | { 51 | base_addr = 0xBBDC0000; 52 | page_size = "MEM_SIZE_128KB"; 53 | }, 54 | /* PMU */ 55 | { 56 | base_addr = 0xBF04D000; 57 | page_size = "MEM_SIZE_8KB"; 58 | } 59 | ); 60 | } 61 | ); 62 | 63 | -------------------------------------------------------------------------------- /platform/baikal_t1_board/cfg/sample-ping-pong.cfg: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016, prpl Foundation 3 | * 4 | * Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | * fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | * in all copies. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | * FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | * 14 | * This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | * 16 | */ 17 | 18 | /* 19 | * This is a configuration sample for the blink led sample (2 VMs). 20 | * 21 | * Ping and Pong VMs perform interVM communication measuring the 22 | * latency delay. 23 | * 24 | * To compile this example, modify the variable CFG_FILE on the 25 | * Makefile to point to this file. 26 | * 27 | */ 28 | 29 | 30 | /* General system configuration */ 31 | system = { 32 | debug = [ "WARNINGS", "INFOS", "ERRORS"]; 33 | uart_speed = 115200; 34 | scheduler_quantum_ms = 5; 35 | guest_quantum_ms = 1; 36 | }; 37 | 38 | 39 | /* Virtual Machines Configuration */ 40 | virtual_machines = ( 41 | { 42 | app_name = "ping"; 43 | os_type = "BARE_METAL"; 44 | priority = 100; 45 | RAM_size_bytes = "MEM_SIZE_32KB"; 46 | }, 47 | { 48 | app_name = "pong"; 49 | os_type = "BARE_METAL"; 50 | priority = 100; 51 | RAM_size_bytes = "MEM_SIZE_32KB"; 52 | } 53 | ); 54 | 55 | -------------------------------------------------------------------------------- /platform/baikal_t1_board/include/platform.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016, prpl Foundation 3 | * 4 | * Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | * fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | * in all copies. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | * FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | * 14 | * This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | * 16 | */ 17 | 18 | 19 | #ifndef _PLATFORM_H 20 | #define _PLATFORM_H 21 | 22 | #include 23 | 24 | #endif -------------------------------------------------------------------------------- /platform/include/board.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016, prpl Foundation 3 | * 4 | * Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | * fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | * in all copies. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | * FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | * 14 | * This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | * 16 | */ 17 | 18 | #ifndef _BOARD_H 19 | #define _BOARD_H 20 | 21 | void early_platform_init(); 22 | void wait_for_reset(); 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /platform/include/uart.h: -------------------------------------------------------------------------------- 1 | #ifndef _UART_H 2 | #define _UART_H 3 | 4 | #include 5 | 6 | void init_uart(uint32_t baudrate_u2, uint32_t baudrate_u6, uint32_t sysclk); 7 | void putchar(uint8_t c); 8 | uint32_t getchar(void); 9 | 10 | #endif -------------------------------------------------------------------------------- /platform/pic32mz_chipkit_Wifire/board/board.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016, prpl Foundation 3 | * 4 | * Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | * fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | * in all copies. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | * FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | * 14 | * This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | * 16 | */ 17 | 18 | /** 19 | * @file platform.c 20 | * 21 | * @section DESCRIPTION 22 | * 23 | * Specific platform initialization. 24 | */ 25 | 26 | #include 27 | #include 28 | 29 | /** 30 | * @brief Called on early hypervisor initialization and responsable for basic the 31 | * platform configuration. 32 | */ 33 | void early_platform_init(){ 34 | init_uart(115200, 9600, CPU_FREQ); 35 | 36 | #if 0 37 | /* SPI1 pin map */ 38 | ANSELBCLR = 0x0008; /* pin B3 used as output for CS */ 39 | TRISBCLR = 0x0008; 40 | TRISDCLR = 0x0002; /* pin D1 used as output for SCLK */ 41 | TRISFCLR = 0x0020; /* pin F5 used as output for MOSI */ 42 | TRISFSET = 0x0010; /* pin F4 used as input for MISO */ 43 | LATFSET = 0x0010; 44 | 45 | SDI1R = 2; /* pin F4 as SPI1 data input */ 46 | RPF5R = 5; /* pin F5 as SPI1 data output */ 47 | 48 | /* SPI config settings */ 49 | SPI1BRG = 4; /* Set clock divider to selected_clock/10: selected_clk/(2*(4+1)) */ 50 | SPI1CON = 0x8120; /* enable SPI / master mode / data transition from high to low clk */ 51 | #endif 52 | } 53 | 54 | void wait_for_reset(){ 55 | while(1); 56 | } 57 | -------------------------------------------------------------------------------- /platform/pic32mz_chipkit_Wifire/board/board.mk: -------------------------------------------------------------------------------- 1 | # 2 | #Copyright (c) 2016, prpl Foundation 3 | # 4 | #Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | #fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | #in all copies. 7 | # 8 | #THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | #INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | #FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | #LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | #ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | # 14 | #This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | 16 | platform: 17 | $(CC) $(CFLAGS) $(INC_DIRS) \ 18 | board/uart.c \ 19 | board/board.c -------------------------------------------------------------------------------- /platform/pic32mz_chipkit_Wifire/board/uart.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "pic32mz.h" 4 | 5 | 6 | void init_uart(uint32_t baudrate_u4, uint32_t baudrate_u1, uint32_t sysclk){ 7 | U4BRG = BRG_BAUD (CPU_SPEED / 2, baudrate_u4); 8 | U4STA = 0; 9 | U4MODE = UMODE_PDSEL_8NPAR | /* 8-bit data, no parity */ 10 | UMODE_ON; /* UART Enable */ 11 | U4STASET = USTA_URXEN | USTA_UTXEN; /* RX / TX Enable */ 12 | 13 | /*TODO: configure UART1 */ 14 | 15 | } 16 | 17 | 18 | 19 | void putchar(char c){ 20 | while(U4STA&USTA_UTXBF); 21 | U4TXREG = c; 22 | } 23 | 24 | 25 | int32_t kbhit(void){ 26 | return (U4STA & USTA_URXDA); 27 | } 28 | 29 | uint32_t getchar(void){ 30 | while(!kbhit()); 31 | return (uint32_t)U4RXREG; 32 | } 33 | 34 | -------------------------------------------------------------------------------- /platform/pic32mz_chipkit_Wifire/cfg/sample-3VMs.cfg: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016, prpl Foundation 3 | * 4 | * Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | * fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | * in all copies. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | * FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | * 14 | * This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | * 16 | */ 17 | 18 | /* 19 | * This is a configuration sample for the blink led sample (1 VM). 20 | * 21 | * To compile this example, modify the variable CFG_FILE on the 22 | * Makefile to point to this file. 23 | * 24 | */ 25 | 26 | /* General system configuration */ 27 | system = { 28 | debug = [ "WARNINGS", "INFOS", "ERRORS"]; 29 | uart_speed = 115200; 30 | scheduler_quantum_ms = 10; 31 | guest_quantum_ms = 1; 32 | }; 33 | 34 | 35 | /* Virtual Machines Configuration */ 36 | virtual_machines = ( 37 | { 38 | app_name = "ping"; 39 | os_type = "BARE_METAL"; 40 | priority = 100; 41 | RAM_size_bytes = "MEM_SIZE_32KB"; 42 | flash_size_bytes = "MEM_SIZE_32KB"; 43 | device_mapping = [ "UART4" ]; 44 | }, 45 | { 46 | app_name = "pong"; 47 | os_type = "BARE_METAL"; 48 | priority = 100; 49 | RAM_size_bytes = "MEM_SIZE_32KB"; 50 | flash_size_bytes = "MEM_SIZE_32KB"; 51 | device_mapping = [ "UART4" ]; 52 | }, 53 | { 54 | app_name = "blink"; 55 | os_type = "BARE_METAL"; 56 | priority = 100; 57 | RAM_size_bytes = "MEM_SIZE_32KB"; 58 | flash_size_bytes = "MEM_SIZE_32KB"; 59 | device_mapping = [ "UART4", "PORTG", "PORTD", "PORTB" ]; 60 | 61 | } 62 | ); 63 | 64 | -------------------------------------------------------------------------------- /platform/pic32mz_chipkit_Wifire/cfg/sample-blink.cfg: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016, prpl Foundation 3 | * 4 | * Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | * fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | * in all copies. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | * FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | * 14 | * This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | * 16 | */ 17 | 18 | /* 19 | * This is a configuration sample for the blink led sample (1 VM) using virtualized IO. 20 | * 21 | * To compile this example, modify the variable CFG_FILE on the 22 | * Makefile to point to this file. 23 | * 24 | */ 25 | 26 | 27 | /* General system configuration */ 28 | system = { 29 | debug = [ "WARNINGS", "INFOS", "ERRORS"]; 30 | uart_speed = 115200; 31 | scheduler_quantum_ms = 10; 32 | guest_quantum_ms = 1; 33 | }; 34 | 35 | 36 | /* Virtual Machines Configuration */ 37 | virtual_machines = ( 38 | { 39 | app_name = "blink"; 40 | os_type = "BARE_METAL"; 41 | priority = 100; 42 | RAM_size_bytes = "MEM_SIZE_32KB"; 43 | flash_size_bytes = "MEM_SIZE_32KB"; 44 | device_mapping = [ "UART4", "PORTG", "PORTD", "PORTB"]; 45 | } 46 | ); 47 | 48 | -------------------------------------------------------------------------------- /platform/pic32mz_chipkit_Wifire/cfg/sample-ping-pong.cfg: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016, prpl Foundation 3 | * 4 | * Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | * fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | * in all copies. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | * FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | * 14 | * This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | * 16 | */ 17 | 18 | /* 19 | * This is a configuration sample for the blink led sample (2 VMs). 20 | * 21 | * Ping and Pong VMs perform interVM communication. 22 | * 23 | * To compile this example, modify the variable CFG_FILE on the 24 | * Makefile to point to this file. 25 | * 26 | */ 27 | 28 | 29 | /* General system configuration */ 30 | system = { 31 | debug = [ "WARNINGS", "INFOS", "ERRORS"]; 32 | uart_speed = 115200; 33 | scheduler_quantum_ms = 10; 34 | guest_quantum_ms = 1; 35 | }; 36 | 37 | 38 | /* Virtual Machines Configuration */ 39 | virtual_machines = ( 40 | { 41 | app_name = "ping"; 42 | os_type = "BARE_METAL"; 43 | priority = 100; 44 | RAM_size_bytes = "MEM_SIZE_32KB"; 45 | flash_size_bytes = "MEM_SIZE_32KB"; 46 | device_mapping = [ "UART4" ]; 47 | }, 48 | { 49 | app_name = "pong"; 50 | os_type = "BARE_METAL"; 51 | priority = 100; 52 | RAM_size_bytes = "MEM_SIZE_32KB"; 53 | flash_size_bytes = "MEM_SIZE_32KB"; 54 | device_mapping = [ "UART4" ]; 55 | } 56 | ); 57 | 58 | -------------------------------------------------------------------------------- /platform/pic32mz_chipkit_Wifire/cfg/sample-redirection.cfg: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016, prpl Foundation 3 | * 4 | * Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | * fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | * in all copies. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | * FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | * 14 | * This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | * 16 | */ 17 | 18 | /* 19 | * This is a configuration sample for int_redirect app using virtualized IO. 20 | * 21 | * To compile this example, modify the variable CFG_FILE on the 22 | * Makefile to point to this file. 23 | * 24 | */ 25 | 26 | 27 | /* General system configuration */ 28 | system = { 29 | debug = [ "WARNINGS", "INFOS", "ERRORS"]; 30 | uart_speed = 115200; 31 | scheduler_quantum_ms = 10; 32 | guest_quantum_ms = 1; 33 | }; 34 | 35 | 36 | /* Virtual Machines Configuration */ 37 | virtual_machines = ( 38 | { 39 | app_name = "int_redirect"; 40 | os_type = "BARE_METAL"; 41 | priority = 100; 42 | RAM_size_bytes = "MEM_SIZE_32KB"; 43 | flash_size_bytes = "MEM_SIZE_32KB"; 44 | device_mapping = [ "UART4", "PORTG", "PORTD", "PORTB"]; 45 | interrupt_redirect = [ "IRQ_U4RX" ]; 46 | } 47 | ); 48 | 49 | -------------------------------------------------------------------------------- /platform/pic32mz_chipkit_Wifire/debug/dp_busblaster.cfg: -------------------------------------------------------------------------------- 1 | # 2 | # Dangerous Prototypes - Bus Blaster 3 | # 4 | # The Bus Blaster has a configurable buffer between the FTDI FT2232H and the 5 | # JTAG header which allows it to emulate various debugger types. It comes 6 | # configured as a JTAGkey device. 7 | # 8 | # http://dangerousprototypes.com/docs/Bus_Blaster 9 | # 10 | 11 | echo "Info : If you need SWD support, flash KT-Link buffer from https://github.com/bharrisau/busblaster 12 | and use dp_busblaster_kt-link.cfg instead" 13 | 14 | interface ftdi 15 | ftdi_device_desc "BUSBLASTERv3c" 16 | ftdi_vid_pid 0x0403 0x07780 17 | 18 | ftdi_layout_init 0x0c08 0x0f1b 19 | ftdi_layout_signal nTRST -data 0x0100 -noe 0x0400 20 | ftdi_layout_signal nSRST -data 0x0200 -noe 0x0800 21 | -------------------------------------------------------------------------------- /platform/pic32mz_chipkit_Wifire/debug/gdbinit: -------------------------------------------------------------------------------- 1 | target remote localhost:3333 2 | set endian little 3 | mem auto 4 | mem 0x80000000 0x80080000 rw 5 | mon mips32 scan_delay 20000000 6 | monitor reset halt -------------------------------------------------------------------------------- /platform/pic32mz_chipkit_Wifire/debug/wifire.tcl: -------------------------------------------------------------------------------- 1 | # ==================================================================================== 2 | echo " reb (Setup for an EJTAGBOOT indicated reset.)" 3 | # ==================================================================================== 4 | proc reb {} { 5 | jtag_reset 0 1;irscan pic32mz.cpu 5;jtag_reset 0 0;irscan pic32mz.cpu 0x0c; 6 | } 7 | 8 | # ==================================================================================== 9 | echo " rnb (Setup for a NORNALBOOT indicated reset.)" 10 | # ==================================================================================== 11 | proc rnb {} { 12 | jtag_reset 0 1; irscan pic32mz.cpu 5;jtag_reset 0 0;irscan pic32mz.cpu 0x0d; 13 | } 14 | -------------------------------------------------------------------------------- /platform/pic32mz_chipkit_Wifire/include/platform.h: -------------------------------------------------------------------------------- 1 | #ifndef _PLATFORM_H 2 | #define _PLATFORM_H 3 | 4 | #include 5 | 6 | #define UARTSTAT U4STA 7 | #define UARTTXREG U4TXREG 8 | #define UART_IRQ_RX IRQ_U4RX 9 | #define UART_IRQ_TX IRQ_U4TX 10 | 11 | 12 | #endif -------------------------------------------------------------------------------- /platform/pic32mz_curiosity/board/board.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016, prpl Foundation 3 | * 4 | * Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | * fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | * in all copies. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | * FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | * 14 | * This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | * 16 | */ 17 | 18 | /** 19 | * @file platform.c 20 | * 21 | * @section DESCRIPTION 22 | * 23 | * Specific platform initialization. 24 | */ 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | /** 31 | * @brief Called on early hypervisor initialization and responsable for basic the 32 | * platform configuration. 33 | */ 34 | void early_platform_init(){ 35 | init_uart(115200, 0, CPU_FREQ); 36 | } 37 | 38 | void wait_for_reset(){ 39 | while(1); 40 | } 41 | 42 | 43 | -------------------------------------------------------------------------------- /platform/pic32mz_curiosity/board/board.mk: -------------------------------------------------------------------------------- 1 | # 2 | #Copyright (c) 2016, prpl Foundation 3 | # 4 | #Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | #fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | #in all copies. 7 | # 8 | #THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | #INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | #FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | #LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | #ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | # 14 | #This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | 16 | platform: 17 | $(CC) $(CFLAGS) $(INC_DIRS) \ 18 | board/uart.c \ 19 | board/board.c -------------------------------------------------------------------------------- /platform/pic32mz_curiosity/board/uart.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | /** 7 | * @file uart.c 8 | * 9 | * @section DESCRIPTION 10 | * 11 | * UART initialization and low level UART functions. 12 | * 13 | */ 14 | 15 | /** 16 | * @brief Configures UART2 as stdout alternative. 17 | * @param baudrate_u2 UART2 baudrate. 18 | * @param baudrate_u6 UART6 baudrate. 19 | * @param sysclk System clock. 20 | */ 21 | void init_uart(uint32_t baudrate_u2, uint32_t baudrate_u6, uint32_t sysclk){ 22 | 23 | U1RXR = 0b0011; /* // RPD10 -> U1RX */ 24 | RPD15R = 0b0001; /* RPD15 -> U1TX */ 25 | 26 | U1STA = 0; 27 | U1BRG = ((int)( ((sysclk/2) / (16*baudrate_u2)) -1)) + 1; 28 | U1MODE = UMODE_PDSEL_8NPAR | /* 8-bit data, no parity */ 29 | UMODE_ON; /* UART Enable */ 30 | U1STASET = USTA_URXEN | USTA_UTXEN; /* RX / TX Enable */ 31 | 32 | baudrate_u6 = 0; /* Only UART1 used for now. */ 33 | } 34 | 35 | 36 | /** 37 | * @brief Write char to UART2. 38 | * @param c Character to be writed. 39 | */ 40 | void putchar(uint8_t c){ 41 | while(U1STA&USTA_UTXBF); 42 | U1TXREG = c; 43 | } 44 | 45 | 46 | /** 47 | * @brief Block and wait for a character. 48 | * @return Read character. 49 | */ 50 | uint32_t getchar(void){ 51 | while(!(U1STA & USTA_URXDA)); 52 | return (uint32_t)U1RXREG; 53 | } 54 | 55 | -------------------------------------------------------------------------------- /platform/pic32mz_curiosity/cfg/output-signal.cfg: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016, prpl Foundation 3 | * 4 | * Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | * fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | * in all copies. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | * FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | * 14 | * This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | * 16 | */ 17 | 18 | /* 19 | * This is a configuration sample for the blink led sample (1 VM) using virtualized IO. 20 | * 21 | * To compile this example, modify the variable CFG_FILE on the 22 | * Makefile to point to this file. 23 | * 24 | */ 25 | 26 | 27 | /* General system configuration */ 28 | system = { 29 | debug = [ "WARNINGS", "INFOS", "ERRORS"]; 30 | uart_speed = 115200; 31 | scheduler_quantum_ms = 10; 32 | guest_quantum_ms = 1; 33 | }; 34 | 35 | 36 | /* Virtual Machines Configuration */ 37 | virtual_machines = ( 38 | { 39 | app_name = "output_signal"; 40 | os_type = "BARE_METAL"; 41 | priority = 100; 42 | RAM_size_bytes = "MEM_SIZE_32KB"; 43 | flash_size_bytes = "MEM_SIZE_32KB"; 44 | device_mapping = [ "PORTE", "UART1", "PORTD"]; 45 | } 46 | ); 47 | 48 | -------------------------------------------------------------------------------- /platform/pic32mz_curiosity/cfg/sample-3VMs.cfg: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016, prpl Foundation 3 | * 4 | * Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | * fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | * in all copies. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | * FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | * 14 | * This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | * 16 | */ 17 | 18 | /* 19 | * This is a configuration sample for the blink led sample (1 VM). 20 | * 21 | * To compile this example, modify the variable CFG_FILE on the 22 | * Makefile to point to this file. 23 | * 24 | */ 25 | 26 | /* General system configuration */ 27 | system = { 28 | debug = [ "WARNINGS", "INFOS", "ERRORS"]; 29 | uart_speed = 115200; 30 | scheduler_quantum_ms = 10; 31 | guest_quantum_ms = 1; 32 | }; 33 | 34 | 35 | /* Virtual Machines Configuration */ 36 | virtual_machines = ( 37 | { 38 | app_name = "ping"; 39 | os_type = "BARE_METAL"; 40 | priority = 100; 41 | RAM_size_bytes = "MEM_SIZE_32KB"; 42 | flash_size_bytes = "MEM_SIZE_32KB"; 43 | device_mapping = [ "UART1"]; 44 | }, 45 | { 46 | app_name = "pong"; 47 | os_type = "BARE_METAL"; 48 | priority = 100; 49 | RAM_size_bytes = "MEM_SIZE_32KB"; 50 | flash_size_bytes = "MEM_SIZE_32KB"; 51 | device_mapping = [ "UART1"]; 52 | }, 53 | { 54 | app_name = "blink"; 55 | os_type = "BARE_METAL"; 56 | priority = 100; 57 | RAM_size_bytes = "MEM_SIZE_32KB"; 58 | flash_size_bytes = "MEM_SIZE_32KB"; 59 | device_mapping = [ "PORTE", "UART1"]; 60 | } 61 | ); 62 | 63 | -------------------------------------------------------------------------------- /platform/pic32mz_curiosity/cfg/sample-blink.cfg: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016, prpl Foundation 3 | * 4 | * Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | * fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | * in all copies. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | * FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | * 14 | * This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | * 16 | */ 17 | 18 | /* 19 | * This is a configuration sample for the blink led sample (1 VM) using virtualized IO. 20 | * 21 | * To compile this example, modify the variable CFG_FILE on the 22 | * Makefile to point to this file. 23 | * 24 | */ 25 | 26 | 27 | /* General system configuration */ 28 | system = { 29 | debug = [ "WARNINGS", "INFOS", "ERRORS"]; 30 | uart_speed = 115200; 31 | scheduler_quantum_ms = 10; 32 | guest_quantum_ms = 1; 33 | }; 34 | 35 | 36 | /* Virtual Machines Configuration */ 37 | virtual_machines = ( 38 | { 39 | app_name = "blink"; 40 | os_type = "BARE_METAL"; 41 | priority = 100; 42 | RAM_size_bytes = "MEM_SIZE_32KB"; 43 | flash_size_bytes = "MEM_SIZE_32KB"; 44 | device_mapping = [ "PORTE", "UART1"]; 45 | } 46 | ); 47 | 48 | -------------------------------------------------------------------------------- /platform/pic32mz_curiosity/cfg/sample-ping-pong.cfg: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016, prpl Foundation 3 | * 4 | * Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | * fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | * in all copies. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | * FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | * 14 | * This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | * 16 | */ 17 | 18 | /* 19 | * This is a configuration sample for the blink led sample (2 VMs). 20 | * 21 | * Ping and Pong VMs perform interVM communication. 22 | * 23 | * To compile this example, modify the variable CFG_FILE on the 24 | * Makefile to point to this file. 25 | * 26 | */ 27 | 28 | 29 | /* General system configuration */ 30 | system = { 31 | debug = [ "WARNINGS", "INFOS", "ERRORS"]; 32 | uart_speed = 115200; 33 | scheduler_quantum_ms = 10; 34 | guest_quantum_ms = 1; 35 | }; 36 | 37 | 38 | /* Virtual Machines Configuration */ 39 | virtual_machines = ( 40 | { 41 | app_name = "ping"; 42 | os_type = "BARE_METAL"; 43 | priority = 100; 44 | RAM_size_bytes = "MEM_SIZE_32KB"; 45 | flash_size_bytes = "MEM_SIZE_32KB"; 46 | device_mapping = [ "UART1" ]; 47 | }, 48 | { 49 | app_name = "pong"; 50 | os_type = "BARE_METAL"; 51 | priority = 100; 52 | RAM_size_bytes = "MEM_SIZE_32KB"; 53 | flash_size_bytes = "MEM_SIZE_32KB"; 54 | device_mapping = [ "UART1" ]; 55 | } 56 | ); 57 | 58 | -------------------------------------------------------------------------------- /platform/pic32mz_curiosity/cfg/sample-redirection.cfg: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016, prpl Foundation 3 | * 4 | * Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | * fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | * in all copies. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | * FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | * 14 | * This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | * 16 | */ 17 | 18 | /* 19 | * This is a configuration sample for int_redirect app using virtualized IO. 20 | * 21 | * To compile this example, modify the variable CFG_FILE on the 22 | * Makefile to point to this file. 23 | * 24 | */ 25 | 26 | 27 | /* General system configuration */ 28 | system = { 29 | debug = [ "WARNINGS", "INFOS", "ERRORS"]; 30 | uart_speed = 115200; 31 | scheduler_quantum_ms = 10; 32 | guest_quantum_ms = 1; 33 | }; 34 | 35 | 36 | /* Virtual Machines Configuration */ 37 | virtual_machines = ( 38 | { 39 | app_name = "int_redirect"; 40 | os_type = "BARE_METAL"; 41 | priority = 100; 42 | RAM_size_bytes = "MEM_SIZE_32KB"; 43 | flash_size_bytes = "MEM_SIZE_32KB"; 44 | device_mapping = [ "PORTE", "UART1"]; 45 | interrupt_redirect = [ "IRQ_U1RX" ]; 46 | } 47 | ); 48 | 49 | -------------------------------------------------------------------------------- /platform/pic32mz_curiosity/include/platform.h: -------------------------------------------------------------------------------- 1 | #ifndef _PLATFORM_H 2 | #define _PLATFORM_H 3 | 4 | #include 5 | 6 | #define UARTSTAT U1STA 7 | #define UARTTXREG U1TXREG 8 | #define UART_IRQ_RX IRQ_U1RX 9 | #define UART_IRQ_TX IRQ_U1TX 10 | 11 | 12 | #endif -------------------------------------------------------------------------------- /platform/pic32mz_curiosity/include/vms.info: -------------------------------------------------------------------------------- 1 | VM name flash_size ram_size address_start 2 | ping 32768 32768 0x9d008000 3 | pong 32768 32768 0x9d010000 4 | blink 32768 32768 0x9d018000 5 | -------------------------------------------------------------------------------- /platform/pic32mz_starter_kit/board/board.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016, prpl Foundation 3 | * 4 | * Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | * fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | * in all copies. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | * FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | * 14 | * This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | * 16 | */ 17 | 18 | /** 19 | * @file platform.c 20 | * 21 | * @section DESCRIPTION 22 | * 23 | * Specific platform initialization. 24 | */ 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | /** 31 | * @brief Called on early hypervisor initialization and responsable for basic the 32 | * platform configuration. 33 | */ 34 | void early_platform_init(){ 35 | init_uart(115200, 9600, CPU_FREQ); 36 | 37 | /* SPI1 pin map */ 38 | ANSELBCLR = 0x0008; /* pin B3 used as output for CS */ 39 | TRISBCLR = 0x0008; 40 | TRISDCLR = 0x0002; /* pin D1 used as output for SCLK */ 41 | TRISFCLR = 0x0020; /* pin F5 used as output for MOSI */ 42 | TRISFSET = 0x0010; /* pin F4 used as input for MISO */ 43 | LATFSET = 0x0010; 44 | 45 | SDI1R = 2; /* pin F4 as SPI1 data input */ 46 | RPF5R = 5; /* pin F5 as SPI1 data output */ 47 | 48 | /* SPI config settings */ 49 | SPI1BRG = 4; /* Set clock divider to selected_clock/10: selected_clk/(2*(4+1)) */ 50 | SPI1CON = 0x8120; /* enable SPI / master mode / data transition from high to low clk */ 51 | } 52 | 53 | 54 | -------------------------------------------------------------------------------- /platform/pic32mz_starter_kit/board/board.mk: -------------------------------------------------------------------------------- 1 | # 2 | #Copyright (c) 2016, prpl Foundation 3 | # 4 | #Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | #fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | #in all copies. 7 | # 8 | #THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | #INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | #FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | #LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | #ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | # 14 | #This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | 16 | platform: 17 | $(CC) $(CFLAGS) $(INC_DIRS) \ 18 | board/reset.c \ 19 | board/uart.c \ 20 | board/board.c -------------------------------------------------------------------------------- /platform/pic32mz_starter_kit/board/uart.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | /** 7 | * @file uart.c 8 | * 9 | * @section DESCRIPTION 10 | * 11 | * UART initialization and low level UART functions. 12 | * 13 | */ 14 | 15 | /** 16 | * @brief Configures UART2 as stdout and UART6 as alternative. 17 | * @param baudrate_u2 UART2 baudrate. 18 | * @param baudrate_u6 UART6 baudrate. 19 | * @param sysclk System clock. 20 | */ 21 | void init_uart(uint32_t baudrate_u2, uint32_t baudrate_u6, uint32_t sysclk){ 22 | 23 | U2RXR = 1; /* RPG6 to UART2 RX */ 24 | RPB14R = 2; /* RPB14R to UART2 TX */ 25 | 26 | U2STA = 0; 27 | U2BRG = ((int)( ((sysclk/2) / (16*baudrate_u2)) -1)) + 1; 28 | U2MODE = UMODE_PDSEL_8NPAR | /* 8-bit data, no parity */ 29 | UMODE_ON; /* UART Enable */ 30 | U2STASET = USTA_URXEN | USTA_UTXEN; /* RX / TX Enable */ 31 | 32 | U6RXR = 3; /* RPD0 to UART6 RX (pin 11) */ 33 | RPF2R = 4; /* RPF2 to UART6 TX (pin 12)*/ 34 | 35 | U6STA = 0; 36 | U6BRG = ((int)( ((sysclk/2) / (16*baudrate_u6)) -1)) + 1; 37 | U6MODE = UMODE_PDSEL_8NPAR | /* 8-bit data, no parity */ 38 | UMODE_ON; /* UART Enable */ 39 | U6STASET = USTA_URXEN | USTA_UTXEN; /* RX / TX Enable */ 40 | } 41 | 42 | 43 | /** 44 | * @brief Write char to UART2. 45 | * @param c Character to be writed. 46 | */ 47 | void putchar(uint8_t c){ 48 | while(U2STA&USTA_UTXBF); 49 | U2TXREG = c; 50 | } 51 | 52 | 53 | /** 54 | * @brief Block and wait for a character. 55 | * @return Read character. 56 | */ 57 | uint32_t getchar(void){ 58 | while(!(U2STA & USTA_URXDA)); 59 | return (uint32_t)U2RXREG; 60 | } 61 | 62 | -------------------------------------------------------------------------------- /platform/pic32mz_starter_kit/cfg/latency.cfg: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016, prpl Foundation 3 | * 4 | * Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | * fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | * in all copies. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | * FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | * 14 | * This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | * 16 | */ 17 | 18 | /* 19 | * This is a configuration sample for int_redirect app using virtualized IO. 20 | * 21 | * To compile this example, modify the variable CFG_FILE on the 22 | * Makefile to point to this file. 23 | * 24 | */ 25 | 26 | 27 | /* General system configuration */ 28 | system = { 29 | debug = [ "WARNINGS", "INFOS", "ERRORS"]; 30 | uart_speed = 115200; 31 | scheduler_quantum_ms = 5; 32 | guest_quantum_ms = 1; 33 | }; 34 | 35 | 36 | /* Virtual Machines Configuration */ 37 | virtual_machines = ( 38 | { 39 | app_name = "int_latency"; 40 | os_type = "BARE_METAL"; 41 | priority = 100; 42 | RAM_size_bytes = "MEM_SIZE_32KB"; 43 | flash_size_bytes = "MEM_SIZE_32KB"; 44 | device_mapping = [ "PORTF", "PORTD", "UART2", "PORTH"]; 45 | interrupt_redirect = [ "IRQ_CND" ]; 46 | } 47 | , 48 | { 49 | app_name = "blink"; 50 | os_type = "BARE_METAL"; 51 | priority = 100; 52 | RAM_size_bytes = "MEM_SIZE_32KB"; 53 | flash_size_bytes = "MEM_SIZE_32KB"; 54 | device_mapping = [ "UART2", "PORTH"]; 55 | } 56 | 57 | ); 58 | 59 | -------------------------------------------------------------------------------- /platform/pic32mz_starter_kit/cfg/sample-3VMs.cfg: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016, prpl Foundation 3 | * 4 | * Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | * fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | * in all copies. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | * FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | * 14 | * This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | * 16 | */ 17 | 18 | /* 19 | * This is a configuration sample for the blink led sample (1 VM). 20 | * 21 | * To compile this example, modify the variable CFG_FILE on the 22 | * Makefile to point to this file. 23 | * 24 | */ 25 | 26 | /* General system configuration */ 27 | system = { 28 | debug = [ "WARNINGS", "INFOS", "ERRORS"]; 29 | uart_speed = 115200; 30 | scheduler_quantum_ms = 10; 31 | guest_quantum_ms = 1; 32 | }; 33 | 34 | 35 | /* Virtual Machines Configuration */ 36 | virtual_machines = ( 37 | { 38 | app_name = "ping"; 39 | os_type = "BARE_METAL"; 40 | priority = 100; 41 | RAM_size_bytes = "MEM_SIZE_32KB"; 42 | flash_size_bytes = "MEM_SIZE_32KB"; 43 | device_mapping = [ "UART2" ]; 44 | }, 45 | { 46 | app_name = "pong"; 47 | os_type = "BARE_METAL"; 48 | priority = 100; 49 | RAM_size_bytes = "MEM_SIZE_32KB"; 50 | flash_size_bytes = "MEM_SIZE_32KB"; 51 | device_mapping = [ "UART2" ]; 52 | }, 53 | { 54 | app_name = "blink"; 55 | os_type = "BARE_METAL"; 56 | priority = 20; 57 | RAM_size_bytes = "MEM_SIZE_32KB"; 58 | flash_size_bytes = "MEM_SIZE_32KB"; 59 | device_mapping = [ "PORTH", "UART2"]; 60 | } 61 | ); 62 | 63 | -------------------------------------------------------------------------------- /platform/pic32mz_starter_kit/cfg/sample-blink.cfg: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016, prpl Foundation 3 | * 4 | * Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | * fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | * in all copies. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | * FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | * 14 | * This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | * 16 | */ 17 | 18 | /* 19 | * This is a configuration sample for the blink led sample (1 VM) using virtualized IO. 20 | * 21 | * To compile this example, modify the variable CFG_FILE on the 22 | * Makefile to point to this file. 23 | * 24 | */ 25 | 26 | 27 | /* General system configuration */ 28 | system = { 29 | debug = [ "WARNINGS", "INFOS", "ERRORS"]; 30 | uart_speed = 115200; 31 | scheduler_quantum_ms = 10; 32 | guest_quantum_ms = 1; 33 | }; 34 | 35 | 36 | /* Virtual Machines Configuration */ 37 | virtual_machines = ( 38 | { 39 | app_name = "blink"; 40 | os_type = "BARE_METAL"; 41 | priority = 100; 42 | RAM_size_bytes = "MEM_SIZE_32KB"; 43 | flash_size_bytes = "MEM_SIZE_32KB"; 44 | device_mapping = [ "PORTH", "UART2"]; 45 | } 46 | ); 47 | 48 | -------------------------------------------------------------------------------- /platform/pic32mz_starter_kit/cfg/sample-ping-pong.cfg: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016, prpl Foundation 3 | * 4 | * Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | * fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | * in all copies. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | * FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | * 14 | * This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | * 16 | */ 17 | 18 | /* 19 | * This is a configuration sample for the blink led sample (2 VMs). 20 | * 21 | * Ping and Pong VMs perform interVM communication measuring the 22 | * latency delay. 23 | * 24 | * To compile this example, modify the variable CFG_FILE on the 25 | * Makefile to point to this file. 26 | * 27 | */ 28 | 29 | 30 | /* General system configuration */ 31 | system = { 32 | debug = [ "WARNINGS", "INFOS", "ERRORS"]; 33 | uart_speed = 115200; 34 | scheduler_quantum_ms = 5; 35 | guest_quantum_ms = 1; 36 | }; 37 | 38 | 39 | /* Virtual Machines Configuration */ 40 | virtual_machines = ( 41 | { 42 | app_name = "ping"; 43 | os_type = "BARE_METAL"; 44 | priority = 100; 45 | RAM_size_bytes = "MEM_SIZE_32KB"; 46 | flash_size_bytes = "MEM_SIZE_32KB"; 47 | device_mapping = [ "UART2" ]; 48 | }, 49 | { 50 | app_name = "pong"; 51 | os_type = "BARE_METAL"; 52 | priority = 100; 53 | RAM_size_bytes = "MEM_SIZE_32KB"; 54 | flash_size_bytes = "MEM_SIZE_32KB"; 55 | device_mapping = [ "UART2" ]; 56 | } 57 | ); 58 | 59 | -------------------------------------------------------------------------------- /platform/pic32mz_starter_kit/cfg/sample-read-flash.cfg: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016, prpl Foundation 3 | * 4 | * Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | * fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | * in all copies. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | * FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | * 14 | * This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | * 16 | */ 17 | 18 | /* 19 | * This is a configuration sample for the read flash sample. 20 | * 21 | * To compile this example, modify the variable CFG_FILE on the 22 | * Makefile to point to this file. 23 | * 24 | */ 25 | 26 | 27 | /* General system configuration */ 28 | system = { 29 | debug = [ "WARNINGS", "INFOS", "ERRORS"]; 30 | uart_speed = 115200; 31 | scheduler_quantum_ms = 10; 32 | guest_quantum_ms = 1; 33 | }; 34 | 35 | 36 | /* Virtual Machines Configuration */ 37 | virtual_machines = ( 38 | { 39 | app_name = "read-flash"; 40 | os_type = "BARE_METAL"; 41 | priority = 100; 42 | RAM_size_bytes = "MEM_SIZE_32KB"; 43 | flash_size_bytes = "MEM_SIZE_32KB"; 44 | device_mapping = [ "PORTH", "UART2"]; 45 | } 46 | ); 47 | 48 | -------------------------------------------------------------------------------- /platform/pic32mz_starter_kit/cfg/sample-redirection.cfg: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016, prpl Foundation 3 | * 4 | * Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | * fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | * in all copies. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | * FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | * 14 | * This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | * 16 | */ 17 | 18 | /* 19 | * This is a configuration sample for int_redirect app using virtualized IO. 20 | * 21 | * To compile this example, modify the variable CFG_FILE on the 22 | * Makefile to point to this file. 23 | * 24 | */ 25 | 26 | 27 | /* General system configuration */ 28 | system = { 29 | debug = [ "WARNINGS", "INFOS", "ERRORS"]; 30 | uart_speed = 115200; 31 | scheduler_quantum_ms = 10; 32 | guest_quantum_ms = 1; 33 | }; 34 | 35 | 36 | /* Virtual Machines Configuration */ 37 | virtual_machines = ( 38 | { 39 | app_name = "int_redirect"; 40 | os_type = "BARE_METAL"; 41 | priority = 100; 42 | RAM_size_bytes = "MEM_SIZE_32KB"; 43 | flash_size_bytes = "MEM_SIZE_32KB"; 44 | device_mapping = [ "PORTH", "UART2"]; 45 | interrupt_redirect = [ "IRQ_U2RX" ]; 46 | } 47 | ); 48 | 49 | -------------------------------------------------------------------------------- /platform/pic32mz_starter_kit/cfg/webserver.cfg: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016, prpl Foundation 3 | * 4 | * Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | * fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | * in all copies. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | * FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | * 14 | * This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | * 16 | */ 17 | 18 | /* 19 | * This is a configuration sample for the blink led sample (1 VM) using virtualized IO. 20 | * 21 | * To compile this example, modify the variable CFG_FILE on the 22 | * Makefile to point to this file. 23 | * 24 | */ 25 | 26 | 27 | /* General system configuration */ 28 | system = { 29 | debug = [ "WARNINGS", "INFOS", "ERRORS"]; 30 | uart_speed = 115200; 31 | scheduler_quantum_ms = 10; 32 | guest_quantum_ms = 1; 33 | }; 34 | 35 | 36 | /* Virtual Machines Configuration */ 37 | virtual_machines = ( 38 | { 39 | app_name = "webserver"; 40 | os_type = "BARE_METAL"; 41 | priority = 100; 42 | RAM_size_bytes = "MEM_SIZE_128KB"; 43 | flash_size_bytes = "MEM_SIZE_128KB"; 44 | device_mapping = [ "PORTH"]; 45 | } 46 | ); 47 | 48 | -------------------------------------------------------------------------------- /platform/pic32mz_starter_kit/cfg/wolfssl.cfg: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016, prpl Foundation 3 | * 4 | * Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | * fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | * in all copies. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | * FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | * 14 | * This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | * 16 | */ 17 | 18 | 19 | /* General system configuration */ 20 | system = { 21 | debug = [ "WARNINGS", "INFOS", "ERRORS"]; 22 | uart_speed = 115200; 23 | scheduler_quantum_ms = 10; 24 | guest_quantum_ms = 1; 25 | }; 26 | 27 | 28 | /* Virtual Machines Configuration */ 29 | virtual_machines = ( 30 | { 31 | app_name = "wolfssl"; 32 | os_type = "BARE_METAL"; 33 | priority = 100; 34 | RAM_size_bytes = "MEM_SIZE_256KB"; 35 | flash_size_bytes = "MEM_SIZE_512KB"; 36 | device_mapping = [ "PORTH"]; 37 | } 38 | ); 39 | 40 | -------------------------------------------------------------------------------- /platform/pic32mz_starter_kit/include/platform.h: -------------------------------------------------------------------------------- 1 | #ifndef _PLATFORM_H 2 | #define _PLATFORM_H 3 | 4 | #include 5 | 6 | #define UARTSTAT U2STA 7 | #define UARTTXREG U2TXREG 8 | #define UART_IRQ_RX IRQ_U2RX 9 | #define UART_IRQ_TX IRQ_U2TX 10 | 11 | 12 | #endif -------------------------------------------------------------------------------- /scripts/genversion.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | version=$(git describe --tags --long | tr "-" " ") 4 | tag=$(echo $version | cut -d' ' -f1) 5 | rev=$(echo $version | cut -d' ' -f2) 6 | hash=$(echo $version | cut -d' ' -f3) 7 | echo \"$tag.$rev \($hash\)\" -------------------------------------------------------------------------------- /sys/kernel/driver.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2016, prpl Foundation 3 | 4 | Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | in all copies. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | 14 | This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | 16 | */ 17 | 18 | /** 19 | * @file driver.c 20 | * 21 | * @section DESCRIPTION 22 | * 23 | * Driver support implementation. Implements the driver_init() call. 24 | * 25 | */ 26 | 27 | 28 | #include 29 | #include 30 | 31 | /* Symbols defined in the linker script indicating the start and the end of the driver's function table. */ 32 | extern uint32_t __drivers_table_init_start; 33 | extern uint32_t __drivers_table_init_end; 34 | 35 | /** 36 | * @brief Walk in the driver's function table calling all initialization functions. 37 | */ 38 | void drivers_initialization(){ 39 | uint32_t i; 40 | for(i=(uint32_t)(&__drivers_table_init_start); i<(int)(&__drivers_table_init_end); i+=sizeof(uint32_t*)){ 41 | ((initcall_t*)*(uint32_t*)i)(); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /sys/kernel/include/driver.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2016, prpl Foundation 3 | 4 | Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | in all copies. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | 14 | This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | 16 | */ 17 | 18 | /** 19 | * @file driver.h 20 | * 21 | * @section DESCRIPTION 22 | * 23 | * Driver definitions. 24 | * The macro driver_init() must be declared for all device drivers indicating its initialization function. The initialization function will be 25 | * called during hypervisor startup. 26 | */ 27 | 28 | #ifndef __DRIVER_H_ 29 | #define __DRIVER_H_ 30 | 31 | #include 32 | 33 | /** 34 | * @brief Allocate a function pointer in a table of device drivers init calls. 35 | * @param fn Init function name. 36 | */ 37 | #define driver_init(fn) static void (*__initcall_t_##fn)() __attribute__ ((section(".__drivers_table_init"))) __attribute__ ((__used__))= fn 38 | 39 | typedef void initcall_t(); 40 | 41 | void drivers_initialization(); 42 | 43 | #endif 44 | 45 | -------------------------------------------------------------------------------- /sys/kernel/include/exception.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2016, prpl Foundation 3 | 4 | Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | in all copies. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | 14 | This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | 16 | */ 17 | 18 | #ifndef _KERNEL_H_ 19 | #define _KERNEL_H_ 20 | 21 | #include 22 | 23 | void general_exception_handler(); 24 | 25 | #endif -------------------------------------------------------------------------------- /sys/kernel/include/hypercall.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2016, prpl Foundation 3 | 4 | Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | in all copies. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | 14 | This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | */ 16 | 17 | #ifndef _HYPERCALL_H 18 | #define _HYPERCALL_H 19 | 20 | #include 21 | #include 22 | 23 | int32_t register_hypercall(hypercall_t* hyper, uint32_t code); 24 | void hypercall_execution(); 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /sys/kernel/include/scheduler.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2016, prpl Foundation 3 | 4 | Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | in all copies. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | 14 | This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | 16 | */ 17 | 18 | #ifndef __SCHEDULER_H 19 | #define __SCHEDULER_H 20 | 21 | #include 22 | #include 23 | 24 | /** 25 | * Keeps the virtual machine and VCPU queues. Additionally, it 26 | * keeps a pointer to the VCPU in execution. 27 | */ 28 | struct scheduler_info_t{ 29 | struct queue_t *vcpu_ready_list; 30 | struct queue_t *virtual_machines_list; 31 | struct vcpu_t *vcpu_executing; 32 | }; 33 | 34 | void fast_interrupt_delivery(struct vcpu_t *target); 35 | void run_scheduler(); 36 | vcpu_t* get_fast_int_vcpu_node(uint32_t fast_int); 37 | vcpu_t* get_vcpu_from_id(uint32_t id); 38 | #endif /* __SCHEDULER_H */ 39 | -------------------------------------------------------------------------------- /sys/kernel/kernel.mk: -------------------------------------------------------------------------------- 1 | # 2 | #Copyright (c) 2016, prpl Foundation 3 | # 4 | #Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | #fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | #in all copies. 7 | # 8 | #THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | #INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | #FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | #LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | #ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | # 14 | #This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | 16 | kernel: 17 | $(CC) $(CFLAGS) $(INC_DIRS) \ 18 | $(TOPDIR)sys/kernel/hypercall.c \ 19 | $(TOPDIR)sys/kernel/exception.c \ 20 | $(TOPDIR)sys/kernel/scheduler.c \ 21 | $(TOPDIR)sys/kernel/vm.c \ 22 | $(TOPDIR)sys/kernel/driver.c 23 | -------------------------------------------------------------------------------- /sys/lib/include/libc.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2016, prpl Foundation 3 | 4 | Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | in all copies. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | 14 | This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | 16 | */ 17 | 18 | #ifndef _LIBC_H_ 19 | #define _LIBC_H_ 20 | 21 | #include 22 | #include 23 | 24 | #define min(a,b) ((a)<(b)?(a):(b)) 25 | #define max(a,b) ((a)>(b)?(a):(b)) 26 | 27 | void *memset(void *dst, int c, unsigned long bytes); 28 | void *memcpy(void *dst, const void *src, unsigned long bytes); 29 | int32_t puts(const char *str); 30 | char *itoa(int i, char *s, int base); 31 | int32_t printf(const char *format, ...); 32 | int32_t sprintf(char *out, const char *format, ...); 33 | int32_t strcmp(const char *s1, const char *s2); 34 | char *strcpy(char *dest, const char *src); 35 | uint32_t strlen(const char *str); 36 | uint32_t hash(unsigned char *str); 37 | 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /sys/lib/include/linkedlist.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2016, prpl Foundation 3 | 4 | Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | in all copies. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | 14 | This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | 16 | */ 17 | 18 | #ifndef __LINKED_LIST_H 19 | #define __LINKED_LIST_H 20 | 21 | #include 22 | 23 | struct list_t { 24 | void *elem; /*!< pointer to list node data */ 25 | struct list_t *next; /*!< pointer to the next list node */ 26 | }; 27 | 28 | int32_t list_append(struct list_t **lst, void *item); 29 | int32_t list_remove_all(struct list_t **lst); 30 | int32_t list_count(struct list_t *lst); 31 | 32 | #endif /* !LINKED_LIST_H */ 33 | -------------------------------------------------------------------------------- /sys/lib/include/malloc.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2016, prpl Foundation 3 | 4 | Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | in all copies. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | 14 | This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | 16 | */ 17 | 18 | #ifndef _MALLOC_H_ 19 | #define _MALLOC_H_ 20 | 21 | #include 22 | 23 | typedef int32_t word_align; 24 | 25 | union header{ /* block header */ 26 | struct{ 27 | union header *ptr; /* mnext block if on free list */ 28 | uint32_t size; /* size of this block */ 29 | } s; 30 | word_align x; /* force block alignment */ 31 | }; 32 | 33 | typedef union header mem_header; 34 | 35 | void HeapInit(void *heap, uint32_t len); 36 | void *malloc(uint32_t size); 37 | void free(void *ptr); 38 | void *calloc(uint32_t qty, uint32_t type_size); 39 | void *realloc(void *ptr, uint32_t size); 40 | uint32_t init_mem(); 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /sys/lib/include/queue.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2016, prpl Foundation 3 | 4 | Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | in all copies. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | 14 | This code was written by Sergio Johann Filho at Embedded System Group (GSE) at PUCRS/Brazil. 15 | 16 | */ 17 | 18 | #ifndef _QUEUE_H 19 | #define _QUEUE_H 20 | 21 | #include 22 | /** 23 | * @brief Queue data structure. 24 | */ 25 | struct queue_t { 26 | int32_t size; /*!< queue size (maximum number of elements) */ 27 | int32_t elem; /*!< number of elements queued */ 28 | int32_t head; /*!< first element of the queue */ 29 | int32_t tail; /*!< last element of the queue */ 30 | void **data; /*!< pointer to an array of pointers to node data */ 31 | }; 32 | 33 | struct queue_t *queue_create(int32_t size); 34 | int32_t queue_destroy(struct queue_t *q); 35 | int32_t queue_count(struct queue_t *q); 36 | int32_t queue_addtail(struct queue_t *q, void *ptr); 37 | void *queue_remhead(struct queue_t *q); 38 | void *queue_remtail(struct queue_t *q); 39 | void *queue_get(struct queue_t *q, int32_t elem); 40 | int32_t queue_set(struct queue_t *q, int32_t elem, void *ptr); 41 | int32_t queue_swap(struct queue_t *q, int32_t elem1, int32_t elem2); 42 | 43 | #endif -------------------------------------------------------------------------------- /sys/lib/include/types.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2016, prpl Foundation 3 | 4 | Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | in all copies. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | 14 | This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | 16 | */ 17 | 18 | #ifndef _TYPES_H_ 19 | #define _TYPES_H_ 20 | 21 | #define NULL ((void*)0) 22 | 23 | typedef __INT8_TYPE__ int8_t; 24 | typedef __INT16_TYPE__ int16_t; 25 | typedef __INT32_TYPE__ int32_t; 26 | typedef __INT64_TYPE__ int64_t; 27 | typedef __UINT8_TYPE__ uint8_t; 28 | typedef __UINT16_TYPE__ uint16_t; 29 | typedef __UINT32_TYPE__ uint32_t; 30 | typedef __UINT64_TYPE__ uint64_t; 31 | 32 | typedef uint32_t size_t; 33 | 34 | #endif /*_TYPES_H_*/ 35 | 36 | -------------------------------------------------------------------------------- /sys/lib/lib.mk: -------------------------------------------------------------------------------- 1 | # 2 | #Copyright (c) 2016, prpl Foundation 3 | # 4 | #Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | #fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | #in all copies. 7 | # 8 | #THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | #INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | #FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | #LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | #ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | # 14 | #This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | 16 | lib: 17 | $(CC) $(CFLAGS) $(INC_DIRS) \ 18 | $(TOPDIR)sys/lib/libc.c \ 19 | $(TOPDIR)sys/lib/linkedlist.c \ 20 | $(TOPDIR)sys/lib/malloc.c \ 21 | $(TOPDIR)sys/lib/queue.c 22 | -------------------------------------------------------------------------------- /sys/sys.mk: -------------------------------------------------------------------------------- 1 | # 2 | #Copyright (c) 2016, prpl Foundation 3 | # 4 | #Permission to use, copy, modify, and/or distribute this software for any purpose with or without 5 | #fee is hereby granted, provided that the above copyright notice and this permission notice appear 6 | #in all copies. 7 | # 8 | #THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 9 | #INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 10 | #FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | #LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 12 | #ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 13 | # 14 | #This code was written by Carlos Moratelli at Embedded System Group (GSE) at PUCRS/Brazil. 15 | 16 | include $(TOPDIR)sys/lib/lib.mk 17 | include $(TOPDIR)sys/kernel/kernel.mk 18 | 19 | --------------------------------------------------------------------------------