From 071d9cc8ebe555067dd2c73a2ae94d22600b8673 Mon Sep 17 00:00:00 2001 From: Eyck Jentzsch Date: Mon, 14 Apr 2025 17:01:19 +0200 Subject: [PATCH] updates bsp and cleans hello.c --- bare-metal-bsp | 2 +- hello-world/hello.c | 21 ++++++++++++--------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/bare-metal-bsp b/bare-metal-bsp index db3a2d6..e0807b8 160000 --- a/bare-metal-bsp +++ b/bare-metal-bsp @@ -1 +1 @@ -Subproject commit db3a2d68d6c7c73e32d4e2e0aae3a10e7de86576 +Subproject commit e0807b8cddb07c2eb91dfe0b230d3121897b7a96 diff --git a/hello-world/hello.c b/hello-world/hello.c index 399a95e..2d574b8 100644 --- a/hello-world/hello.c +++ b/hello-world/hello.c @@ -15,19 +15,22 @@ int factorial(int i) { } return result; } -extern volatile uint32_t tohost; -extern volatile uint32_t fromhost; -int main() { - volatile int result = factorial(10); - volatile char string[] = "hello world with write in hello"; - volatile uint64_t payload[4] = {64, 0, (uintptr_t)string, - (strlen(string) + 1)}; - tohost = (uint32_t)payload; +void write_tohost(char* string) { + volatile uint64_t payload[4] = {64, 0, (uintptr_t)string, + (strlen(string) + 1)}; + tohost = (uintptr_t)payload; +} + +int main() { + char string[] = "hello world with write in hello"; + + write_tohost(string); write(STDOUT_FILENO, string, sizeof(string)); + int result = factorial(10); printf("Factorial is %d", result); - // printf("End of execution"); + return 0; }