-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make it possible to use printf during bare-metal execution.
- Loading branch information
Yvan Tortorella
committed
Dec 5, 2023
1 parent
d5eb867
commit 6d0c87f
Showing
7 changed files
with
95 additions
and
4 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,13 @@ | ||
// Copyright 2022 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 "regs/cheshire.h" | ||
#include "dif/clint.h" | ||
#include "dif/uart.h" | ||
#include "util.h" | ||
#include "params.h" | ||
|
||
void cheshire_init_io(); | ||
|
||
void cheshire_close_io(); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// Copyright 2022 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 "cheshire_io.h" | ||
|
||
void soc_init(); | ||
|
||
void soc_close(); |
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,29 @@ | ||
// Copyright 2022 ETH Zurich and University of Bologna. | ||
// Licensed under the Apache License, Version 2.0, see LICENSE for details. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
// Yvan Tortorella <[email protected]> | ||
// | ||
// Library containing IO init/close functions. | ||
|
||
#include "cheshire_io.h" | ||
|
||
void cheshire_init_io() { | ||
// Initialize UART first | ||
uart_open(); | ||
|
||
// Initialize other IOs | ||
// . | ||
// . | ||
// . | ||
}; | ||
|
||
void cheshire_close_io() { | ||
// Close UART first | ||
uart_close(); | ||
|
||
// Close other IOs | ||
// . | ||
// . | ||
// . | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,8 @@ | |
// Nils Wistoff <[email protected]> | ||
// Paul Scheffler <[email protected]> | ||
|
||
#include "regs/cheshire.h" | ||
#include "dif/clint.h" | ||
#include "dif/uart.h" | ||
#include "util.h" | ||
#include "params.h" | ||
|
@@ -64,10 +66,20 @@ void uart_read_str(void *uart_base, void *dst, uint64_t len) { | |
} | ||
|
||
// Default UART provides console | ||
void _putchar(char byte) { | ||
uart_write(&__base_uart, byte); | ||
void uart_open(){ | ||
uint32_t rtc_freq = *reg32(&__base_regs, CHESHIRE_RTC_FREQ_REG_OFFSET); | ||
uint64_t reset_freq = clint_get_core_freq(rtc_freq, 2500); | ||
uart_init(&__base_uart, reset_freq, 115200); | ||
}; | ||
|
||
void _putchar(char character) { | ||
uart_write(&__base_uart, character); | ||
}; | ||
|
||
char _getchar() { | ||
return uart_read(&__base_uart); | ||
}; | ||
|
||
void uart_close() { | ||
uart_write_flush(&__base_uart); | ||
}; |
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,18 @@ | ||
// Copyright 2022 ETH Zurich and University of Bologna. | ||
// Licensed under the Apache License, Version 2.0, see LICENSE for details. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
// Yvan Tortorella <[email protected]> | ||
// | ||
// Library containing general SoC init/close functions. | ||
|
||
#include "init.h" | ||
|
||
void soc_init() { | ||
// IO initialization | ||
cheshire_init_io(); | ||
}; | ||
|
||
void soc_close() { | ||
cheshire_close_io(); | ||
}; |