Skip to content

Commit

Permalink
sw: Fix putchar.c
Browse files Browse the repository at this point in the history
  • Loading branch information
alex96295 committed Oct 10, 2023
1 parent 478edfa commit 2191fce
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions sw/snRuntime/src/platforms/standalone/putchar.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,19 @@ static volatile struct putc_buffer {

// Provide an implementation for putchar.
void snrt_putchar(char character) {
if (@HTIF_SERVER@ == 1){
volatile struct putc_buffer *buf = &putc_buffer[snrt_hartid()];
buf->data[buf->hdr.size++] = character;
if (buf->hdr.size == PUTC_BUFFER_LEN || character == '\n') {
buf->hdr.syscall_mem[0] = 64; // sys_write
buf->hdr.syscall_mem[1] = 1; // file descriptor (1 = stdout)
buf->hdr.syscall_mem[2] = (uintptr_t)&buf->data; // buffer
buf->hdr.syscall_mem[3] = buf->hdr.size; // length
volatile struct putc_buffer *buf = &putc_buffer[snrt_hartid()];
buf->data[buf->hdr.size++] = character;
if (buf->hdr.size == PUTC_BUFFER_LEN || character == '\n') {
buf->hdr.syscall_mem[0] = 64; // sys_write
buf->hdr.syscall_mem[1] = 1; // file descriptor (1 = stdout)
buf->hdr.syscall_mem[2] = (uintptr_t)&buf->data; // buffer
buf->hdr.syscall_mem[3] = buf->hdr.size; // length

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

buf->hdr.size = 0;
}
buf->hdr.size = 0;
}
}

0 comments on commit 2191fce

Please sign in to comment.