-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ff037fa
commit ed13668
Showing
11 changed files
with
110 additions
and
7 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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
#pragma once | ||
|
||
void alt_init(void); | ||
void alt_init(uint64_t freq, uint64_t baud); |
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,40 @@ | ||
/** | ||
* Platform configuration for QEMU virt | ||
*/ | ||
#pragma once | ||
|
||
#define UART_CHESHIRE | ||
#define UART0_BASE_ADDR (0x03002000ull) | ||
|
||
#define MTIME_BASE_ADDR 0x0204bff8ull | ||
#define MTIMECMP_BASE_ADDR 0x02044000ull | ||
|
||
// Min and max usable hart ID. | ||
#define S3K_MIN_HART 0 | ||
#define S3K_MAX_HART 1 | ||
|
||
// Total number of usable harts. | ||
#define S3K_HART_CNT (S3K_MAX_HART - S3K_MIN_HART + 1ul) | ||
|
||
// Number of PMP slots. | ||
#define S3K_PMP_CNT 8 | ||
|
||
// RTC ticks per second | ||
#define S3K_RTC_HZ 1000000ull | ||
|
||
/// Stack size of 1024 KiB | ||
#define S3K_LOG_STACK_SIZE 10 | ||
|
||
#define INIT_CAPS \ | ||
{ \ | ||
[0] = cap_mk_pmp(0x20005fff, MEM_RWX), \ | ||
[1] = cap_mk_memory(0x80020000, 0x80100000, MEM_RWX), \ | ||
[2] = cap_mk_memory(0x03002000, 0x03003000, MEM_RW), \ | ||
[3] = cap_mk_memory(0x0204b000, 0x0204c000, MEM_R), \ | ||
[4] = cap_mk_time(0, 0, S3K_SLOT_CNT), \ | ||
[5] = cap_mk_time(1, 0, S3K_SLOT_CNT), \ | ||
[6] = cap_mk_time(2, 0, S3K_SLOT_CNT), \ | ||
[7] = cap_mk_time(3, 0, S3K_SLOT_CNT), \ | ||
[8] = cap_mk_monitor(0, S3K_PROC_CNT), \ | ||
[9] = cap_mk_channel(0, S3K_CHAN_CNT), \ | ||
} |
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 @@ | ||
export ARCH=rv64imac_zicsr | ||
export ABI=lp64 | ||
export CMODEL=medany | ||
export QEMU_MACHINE=none | ||
export QEMU_SMP=none | ||
export COMMON_INC:=${ROOT}/common/inc | ||
export COMMON_LIB:=${ROOT}/common/build/${PLATFORM} | ||
export STARTFILES:=${ROOT}/common/build/${PLATFORM}/start | ||
PLAT_SRCS=src/drivers/uart/cheshire.c src/drivers/time.c |
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,49 @@ | ||
#include <stdint.h> | ||
|
||
struct uart { | ||
union { | ||
uint32_t rbr; | ||
uint32_t thr; | ||
uint32_t dlab_lsb; | ||
}; | ||
union { | ||
uint32_t interrupt_enable; | ||
uint32_t dlab_msb; | ||
}; | ||
uint32_t interrupt_ident; | ||
uint32_t fifo_control; | ||
uint32_t line_control; | ||
uint32_t modem_control; | ||
uint32_t line_status; | ||
uint32_t modem_status; | ||
}; | ||
|
||
void uart_init(void *base, uint64_t freq, uint64_t baud) | ||
{ | ||
volatile struct uart *uart = base; | ||
uint64_t divisor = freq / (baud << 4); | ||
uint8_t dlo = (uint8_t)(divisor); | ||
uint8_t dhi = (uint8_t)(divisor >> 8); | ||
*((char*)&uart->interrupt_enable) = 0x00; | ||
*((char*)&uart->line_control) = 0x80; | ||
*((char*)&uart->dlab_lsb) = dlo; | ||
*((char*)&uart->dlab_msb) = dhi; | ||
*((char*)&uart->line_control) = 0x03; | ||
*((char*)&uart->fifo_control) = 0xC7; | ||
*((char*)&uart->modem_control) = 0x20; | ||
} | ||
|
||
int uart_putc(void *base, char c) | ||
{ | ||
volatile struct uart *uart = base; | ||
while (!(uart->line_status & 0x20)) | ||
; | ||
uart->thr = (unsigned char)c; | ||
return (unsigned char)c; | ||
} | ||
|
||
int uart_getc(void *base) | ||
{ | ||
return 0; | ||
} | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
#pragma once | ||
|
||
#define PLATFORM_VIRT | ||
#include "plat/config.h" | ||
|
||
// Number of user processes | ||
|