-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sw: Add possibility to get ocd putchar on gvsoc (#126)
Co-authored-by: Germain Haugou <[email protected]>
- Loading branch information
Showing
6 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Copyright 2023 ETH Zurich and University of Bologna. | ||
// Licensed under the Apache License, Version 2.0, see LICENSE for details. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#include <stdint.h> | ||
|
||
/* riscv semihosting standard: | ||
* IN: a0 holds syscall number | ||
* IN: a1 holds pointer to arg struct | ||
* OUT: a0 holds return value (if exists) | ||
*/ | ||
static inline long __ocd_semihost(long n, long _a1) { | ||
register long a0 asm("a0") = n; | ||
register long a1 asm("a1") = _a1; | ||
|
||
// riscv magic values for semihosting | ||
asm volatile( | ||
".option norvc;\t\n" | ||
"slli zero,zero,0x1f\t\n" | ||
"ebreak\t\n" | ||
"srai zero,zero,0x7\t\n" | ||
".option rvc;\t\n" | ||
: "+r"(a0) | ||
: "r"(a1)); | ||
|
||
return a0; | ||
} | ||
|
||
static inline int __ocd_semihost_write(int fd, uint8_t *buffer, int len) { | ||
uint32_t args[3] = {(long)fd, (long)buffer, (long)len}; | ||
__asm__ __volatile__("" : : : "memory"); | ||
return __ocd_semihost(0x05, (long)args); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters