Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sw: Runtime Fixes #166

Merged
merged 3 commits into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sw/snRuntime/base.ld
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ SECTIONS
.cbss :
{
__cbss_start = .;
*(.cbss .cbss.*)
KEEP(*(.cbss .cbss.*))
__cbss_end = .;
} >L3

Expand Down
19 changes: 13 additions & 6 deletions target/snitch_cluster/sw/runtime/rtl/src/putchar.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,21 @@ void _putchar(char character) {
extern uintptr_t volatile tohost, fromhost;

// Rudimentary string buffer for putc calls.
extern uint32_t _edram;
#define PUTC_BUFFER_LEN (1024 - sizeof(size_t))
struct putc_buffer_header {

typedef struct {
size_t size;
uint64_t syscall_mem[8];
};
static volatile struct putc_buffer {
struct putc_buffer_header hdr;
} putc_buffer_header_t;

typedef struct putc_buffer {
putc_buffer_header_t hdr;
char data[PUTC_BUFFER_LEN];
} *const putc_buffer = (void *)&_edram;
} putc_buffer_t;

static volatile putc_buffer_t
putc_buffer[SNRT_CLUSTER_NUM * SNRT_CLUSTER_CORE_NUM]
__attribute__((section(".dram")));

// Provide an implementation for putchar.
void _putchar(char character) {
Expand All @@ -46,10 +51,12 @@ void _putchar(char character) {
buf->hdr.syscall_mem[2] = (uintptr_t)&buf->data; // buffer
buf->hdr.syscall_mem[3] = buf->hdr.size; // length

snrt_mutex_acquire(snrt_mutex());
tohost = (uintptr_t)buf->hdr.syscall_mem;
while (fromhost == 0)
;
fromhost = 0;
snrt_mutex_release(snrt_mutex());

buf->hdr.size = 0;
}
Expand Down
Loading