mirror of
https://github.com/AmbiML/sparrow-kata-full.git
synced 2025-08-27 09:18:42 +00:00
suicide: Introduce the fault handler test app
Change-Id: I3dc62dd7131d8f77ff81b44cbe06c675c8e52f04 GitOrigin-RevId: d9313e605ba3d1a9462117980ae14f408398437f
This commit is contained in:
parent
ca6153b68c
commit
02e6caec95
21
apps/c/suicide/Makefile
Normal file
21
apps/c/suicide/Makefile
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
SRC_LIBSEL4 ?= $(ROOTDIR)/kata/kernel/libsel4
|
||||||
|
OUT_KATA ?= $(OUT)/kata/riscv32-unknown-elf/release
|
||||||
|
OUT_TMP ?= $(OUT)/tmp/suicide
|
||||||
|
|
||||||
|
INCLUDES += -I$(SRC_LIBSEL4)/arch_include/riscv
|
||||||
|
INCLUDES += -I$(SRC_LIBSEL4)/include
|
||||||
|
INCLUDES += -I$(SRC_LIBSEL4)/mode_include/32
|
||||||
|
INCLUDES += -I$(SRC_LIBSEL4)/sel4_arch_include/riscv32/
|
||||||
|
INCLUDES += -I$(OUT_KATA)/kernel/gen_config
|
||||||
|
INCLUDES += -I$(OUT_KATA)/libsel4/autoconf
|
||||||
|
INCLUDES += -I$(OUT_KATA)/libsel4/gen_config/
|
||||||
|
INCLUDES += -I$(OUT_KATA)/libsel4/include
|
||||||
|
INCLUDES += -I$(OUT_KATA)/libsel4/sel4_arch_include/riscv32
|
||||||
|
|
||||||
|
OPT:=-O0
|
||||||
|
DBG:=-g
|
||||||
|
|
||||||
|
$(OUT_TMP)/suicide.elf: suicide.c
|
||||||
|
mkdir -p $(OUT_TMP)
|
||||||
|
riscv32-unknown-elf-gcc $(DBG) $(OPT) $(INCLUDES) -march=rv32imac -mabi=ilp32 -std=gnu11 -c suicide.c -o $(OUT_TMP)/suicide.o
|
||||||
|
riscv32-unknown-elf-gcc $(DBG) -static -nostdlib $(OUT_TMP)/suicide.o -o $(OUT_TMP)/suicide.elf
|
41
apps/c/suicide/suicide.c
Normal file
41
apps/c/suicide/suicide.c
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2021, Google LLC
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
// This file is a barebones, minimal-dependency test application that simply
|
||||||
|
// derefrences a null pointer to kill itself. It's primary use case is to test
|
||||||
|
// out KataOS' fault handlers.
|
||||||
|
|
||||||
|
#include <kernel/gen_config.h>
|
||||||
|
#include <sel4/arch/syscalls.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
__thread seL4_IPCBuffer *__sel4_ipc_buffer;
|
||||||
|
|
||||||
|
char minisel_tls[4096] __attribute__((__aligned__(4096)));
|
||||||
|
|
||||||
|
__attribute__((naked)) void _start() {
|
||||||
|
asm volatile(
|
||||||
|
".option push \n"
|
||||||
|
".option norelax \n"
|
||||||
|
"la gp, __global_pointer$ \n"
|
||||||
|
"la x4, minisel_tls \n"
|
||||||
|
"addi sp,sp,-16 \n"
|
||||||
|
"sw a0, 12(sp) \n"
|
||||||
|
"sw a1, 8(sp) \n"
|
||||||
|
"sw a2, 4(sp) \n"
|
||||||
|
"sw a3, 0(sp) \n"
|
||||||
|
".option pop \n"
|
||||||
|
"j main \n");
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int a0, int a1, int a2, int a3) {
|
||||||
|
seL4_DebugPutString("Goodbye, cruel world!\n");
|
||||||
|
while (1) {
|
||||||
|
char *p = 0x0;
|
||||||
|
*p = 'g';
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user