Skip to content

Commit c368423

Browse files
committed
sw/saris: Initialize putchar buffer, fix F extension skip
1 parent 030c6f6 commit c368423

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

sw/saris/runtime/crt0.S

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,14 @@ _start:
3030
slli t0, a0, 3
3131
sub sp, sp, t0
3232

33-
# check if the core has the F-extension
34-
csrr t0, misa
35-
andi t0, t0, (1 << 5)
36-
beqz t0, _clr_ireg
33+
.globl _putcb
34+
_init_putcb:
35+
la t0, _putcb
36+
# Initialize ptchar buffer size of each core to 0
37+
slli t1, a0, 10
38+
add t0, t0, t1
39+
sw zero, 0(t0)
40+
sw zero, 4(t0)
3741

3842
_skip_dmcc_work:
3943
# Skip the coming two steps unless we are the DMA core
@@ -78,6 +82,11 @@ _dmcc_work_sync:
7882
# Synchronize cores so data is ready
7983
csrr x0, 0x7C2
8084

85+
# check if the core has the F-extension
86+
csrr t0, misa
87+
andi t0, t0, (1 << 5)
88+
beqz t0, _clr_ireg
89+
8190
# Reset float regs if present
8291
_clr_freg:
8392
fcvt.d.w f0, x0
@@ -158,6 +167,5 @@ _done:
158167
wfi
159168

160169

161-
.globl _putcb
162170
.section .data._putcb
163171
_putcb:

sw/saris/runtime/runtime.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ static inline volatile uint32_t __rt_get_hartid() {
3232
}
3333
// Rudimentary string buffer for putchar calls.
3434
extern uint32_t _putcb;
35-
#define PUTC_BUFFER_LEN (1024 - sizeof(size_t))
35+
#define PUTC_BUFFER_LEN (1024 - sizeof(size_t) - 8*sizeof(uint64_t))
3636

3737
typedef struct {
3838
size_t size;

0 commit comments

Comments
 (0)