File tree Expand file tree Collapse file tree 5 files changed +266
-0
lines changed
tests/recipes/single-freertos Expand file tree Collapse file tree 5 files changed +266
-0
lines changed Original file line number Diff line number Diff line change 1+ #include <config.h>
2+
3+ VM_IMAGE (freertos_image , XSTR (BAO_WRKDIR_IMGS /freertos .bin ))
4+
5+ struct config config = {
6+
7+ CONFIG_HEADER
8+
9+ .shmemlist_size = 1 ,
10+ .shmemlist = (struct shmem []) {
11+ [0 ] = { .size = 0x00010000 , }
12+ },
13+
14+ .vmlist_size = 1 ,
15+ .vmlist = (struct vm_config []) {
16+ {
17+ .image = {
18+ .base_addr = 0x0 ,
19+ .load_addr = VM_IMAGE_OFFSET (freertos_image ),
20+ .size = VM_IMAGE_SIZE (freertos_image )
21+ },
22+
23+ .entry = 0x0 ,
24+
25+ .platform = {
26+ .cpu_num = 1 ,
27+
28+ .region_num = 1 ,
29+ .regions = (struct vm_mem_region []) {
30+ {
31+ .base = 0x0 ,
32+ .size = 0x8000000
33+ }
34+ },
35+
36+ .ipc_num = 1 ,
37+ .ipcs = (struct ipc []) {
38+ {
39+ .base = 0x70000000 ,
40+ .size = 0x00010000 ,
41+ .shmem_id = 0 ,
42+ .interrupt_num = 1 ,
43+ .interrupts = (irqid_t []) {52 }
44+ }
45+ },
46+
47+ .dev_num = 2 ,
48+ .devs = (struct vm_dev_region []) {
49+ {
50+ /* PL011 */
51+ .pa = 0x9000000 ,
52+ .va = 0xff000000 ,
53+ .size = 0x10000 ,
54+ .interrupt_num = 1 ,
55+ .interrupts = (irqid_t []) {33 }
56+ },
57+ {
58+ .interrupt_num = 1 ,
59+ .interrupts = (irqid_t []) {27 }
60+ }
61+ },
62+
63+ .arch = {
64+ .gic = {
65+ .gicd_addr = 0xf9010000 ,
66+ .gicr_addr = 0xf9020000 ,
67+ }
68+ }
69+ },
70+ },
71+ },
72+ };
Original file line number Diff line number Diff line change 1+ #include <config.h>
2+
3+ VM_IMAGE (baremetal_image , XSTR (BAO_WRKDIR_IMGS /freertos .bin ))
4+
5+ struct config config = {
6+
7+ CONFIG_HEADER
8+
9+ .vmlist_size = 1 ,
10+ .vmlist = (struct vm_config []) {
11+ {
12+ .image = {
13+ .base_addr = 0x80200000 ,
14+ .load_addr = VM_IMAGE_OFFSET (baremetal_image ),
15+ .size = VM_IMAGE_SIZE (baremetal_image )
16+ },
17+
18+ .entry = 0x80200000 ,
19+
20+ .platform = {
21+ .cpu_num = 4 ,
22+
23+ .region_num = 1 ,
24+ .regions = (struct vm_mem_region []) {
25+ {
26+ .base = 0x80200000 ,
27+ .size = 0x4000000
28+ }
29+ },
30+
31+ .dev_num = 1 ,
32+ .devs = (struct vm_dev_region []) {
33+ {
34+ .pa = 0x10000000 ,
35+ .va = 0x10000000 ,
36+ .size = 0x1000 ,
37+ .interrupt_num = 1 ,
38+ .interrupts = (irqid_t []) {10 }
39+ },
40+ },
41+
42+ .arch = {
43+ .irqc = {
44+ .plic = {
45+ .base = 0xc000000 ,
46+ },
47+ },
48+ },
49+ },
50+ },
51+ }
52+ };
Original file line number Diff line number Diff line change 1+ {
2+ pkgs ? import ( fetchTarball {
3+ url = "https://github.com/NixOS/nixpkgs/archive/refs/tags/22.11.tar.gz" ;
4+ sha256 = "sha256:11w3wn2yjhaa5pv20gbfbirvjq6i3m7pqrq2msf0g7cv44vijwgw" ;
5+ } ) { } ,
6+ platform ? " " ,
7+ bao_cfg_repo ? " " ,
8+ bao_cfg ? " " ,
9+ list_tests ? " " ,
10+ list_suites ? " " ,
11+ log_level ? " " ,
12+ GIC_VERSION ? " " ,
13+ IRQC ? " " ,
14+ IPIC ? " " ,
15+ } :
16+
17+ with pkgs ;
18+
19+ let
20+ packages = rec {
21+
22+ setup-cfg = callPackage ../../bao-nix/pkgs/setup-cfg/setup-cfg.nix {
23+ inherit platform ;
24+ inherit GIC_VERSION ;
25+ inherit IRQC ;
26+ inherit IPIC ;
27+ bao-tests = ../../bao-tests ;
28+ tests_srcs = ./src ;
29+ baremetal_patch = ./baremetal.patch ;
30+ } ;
31+
32+ #Build toolchain
33+ toolchain = callPackage ../../bao-nix/pkgs/toolchains/${ setup-cfg . toolchain_name } .nix { } ;
34+
35+ #Build guests
36+ guests = [
37+ ( callPackage ( ../../bao-nix/pkgs/guest/tf/freertos.nix )
38+ {
39+ inherit setup-cfg ;
40+ inherit toolchain ;
41+ guest_name = "freertos" ;
42+ list_tests = "" ;
43+ list_suites = "CPU_BOOT_CHECK IRQ_CHECK" ;
44+ inherit log_level ;
45+ }
46+ )
47+ ] ;
48+
49+ bao_cfg_repo = ./configs ;
50+
51+ #Build Hypervisor
52+ bao = callPackage ../../bao-nix/pkgs/bao/bao.nix
53+ {
54+ inherit setup-cfg ;
55+ inherit toolchain ;
56+ inherit bao_cfg_repo ;
57+ inherit bao_cfg ;
58+ inherit guests ;
59+ #bao_srcs_path = /home/mafs/bao-hypervisor;
60+ } ;
61+
62+ # Build Firmware
63+ firmware = callPackage ../../bao-nix/pkgs/firmware/${ platform } .nix {
64+ inherit toolchain ;
65+ inherit platform ;
66+ inherit setup-cfg ;
67+ } ;
68+ inherit pkgs ;
69+ } ;
70+ in
71+ packages
Original file line number Diff line number Diff line change 1+ #include "testf.h"
2+
3+ BAO_TEST (CPU_BOOT_CHECK ,BOOT )
4+ {
5+ TESTF_PASS ("System booted successfully!\n" );
6+ }
7+
Original file line number Diff line number Diff line change 1+ #include "testf.h"
2+ // #include <plat.h>
3+ // #include <irq.h>
4+ // #include <timer.h>
5+ // #include <uart.h>
6+ // #include <core.h>
7+ #include <core.h>
8+ #include <stdlib.h>
9+ #include <stdio.h>
10+ #include <string.h>
11+ #include <cpu.h>
12+ #include <wfi.h>
13+ #include <spinlock.h>
14+ #include <plat.h>
15+ #include <irq.h>
16+ #include <uart.h>
17+ #include <timer.h>
18+
19+ void test_interrupt_timer_callback ();
20+ void uart_rx_handler ();
21+
22+
23+ volatile bool irq_en_timer = false;
24+ volatile bool irq_en_uart = false;
25+
26+ #define TIMER_INTERVAL (TIME_MS(10))
27+ #define TEST_TIME_WAIT (TIME_MS(100))
28+ #define TEST_TIMEOUT "200"
29+
30+ BAO_TEST (IRQ_CHECK , TIMER )
31+ {
32+ COMMAND_SEND_TIMEOUT (TEST_TIMEOUT );
33+
34+ irq_set_handler (TIMER_IRQ_ID , test_interrupt_timer_callback );
35+ timer_set (TIMER_INTERVAL );
36+ irq_enable (TIMER_IRQ_ID );
37+ irq_set_prio (TIMER_IRQ_ID , IRQ_MAX_PRIO );
38+ while (!irq_en_timer );
39+ EXPECTED_TRUE (irq_en_timer );
40+ }
41+
42+ BAO_TEST (IRQ_CHECK , UART )
43+ {
44+ COMMAND_SEND_TIMEOUT (TEST_TIMEOUT );
45+
46+ uart_enable_rxirq ();
47+ irq_set_handler (UART_IRQ_ID , uart_rx_handler );
48+ irq_set_prio (UART_IRQ_ID , IRQ_MAX_PRIO );
49+ irq_enable (UART_IRQ_ID );
50+ COMMAND_SEND_CHAR ("a" );
51+ while (!irq_en_uart );
52+ EXPECTED_TRUE (irq_en_uart );
53+ }
54+
55+ void test_interrupt_timer_callback ()
56+ {
57+ irq_en_timer = true;
58+ timer_set (TIMER_INTERVAL );
59+ }
60+
61+ void uart_rx_handler (){
62+ uart_clear_rxirq ();
63+ irq_en_uart = true;
64+ }
You can’t perform that action at this time.
0 commit comments