Adds a way to simulate the programs with spike, to compare PCs and debug
This commit is contained in:
11
bench/crt.S
11
bench/crt.S
@@ -4,13 +4,8 @@
|
||||
|
||||
_start:
|
||||
# réservation d'une (petite) zone de mémoire pour la pile
|
||||
la sp, stack + STACK_SIZE
|
||||
la sp, _stack_start
|
||||
# appel de main, sans espoir de retour !
|
||||
jal main
|
||||
1: j 1b
|
||||
|
||||
.bss
|
||||
.align 4
|
||||
.global stack
|
||||
stack:
|
||||
.skip STACK_SIZE
|
||||
.data
|
||||
.bss
|
||||
|
||||
@@ -1,50 +1,19 @@
|
||||
OUTPUT_ARCH( "riscv" )
|
||||
|
||||
ENTRY (_start)
|
||||
MEMORY
|
||||
{
|
||||
insnmem (rx) : ORIGIN = 0x0000, LENGTH = 8K
|
||||
datamem (wai!x) : ORIGIN = 0x2000, LENGTH = 8K
|
||||
}
|
||||
|
||||
PHDRS
|
||||
{
|
||||
text PT_LOAD;
|
||||
data PT_LOAD;
|
||||
bss PT_LOAD;
|
||||
}
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
PROVIDE(_start = ORIGIN(insnmem));
|
||||
.text : {
|
||||
PROVIDE(_text_start = .);
|
||||
*(.text._start) *(.text .text.*)
|
||||
PROVIDE(_text_end = .);
|
||||
} >insnmem AT>insnmem :text
|
||||
. = 0x10000;
|
||||
.text : { *(.text) }
|
||||
. = ALIGN(8);
|
||||
.data : { *(.data) }
|
||||
.bss : { *(.bss) }
|
||||
. = ALIGN(8);
|
||||
PROVIDE(_memory_start = . );
|
||||
PROVIDE(_memory_end = 0x20000);
|
||||
PROVIDE(_stack_size = 1024); /* 1 KiB */
|
||||
PROVIDE(_stack_start = _memory_end);
|
||||
PROVIDE(_stack_end = _stack_start - _stack_size);
|
||||
|
||||
. = ORIGIN(datamem);
|
||||
.rodata ALIGN(4) : {
|
||||
PROVIDE(_rodata_start = .);
|
||||
*(.rodata .rodata.*)
|
||||
PROVIDE(_rodata_end = .);
|
||||
} >datamem AT>datamem :data
|
||||
|
||||
.data ALIGN(4) : {
|
||||
PROVIDE(_data_start = .);
|
||||
*(.sdata .sdata.*) *(.data .data.*)
|
||||
PROVIDE(_data_end = .);
|
||||
} >datamem AT>datamem :data
|
||||
|
||||
.bss ALIGN(4) : {
|
||||
PROVIDE(_bss_start = .);
|
||||
*(.sbss .sbss.*) *(.bss .bss.*)
|
||||
PROVIDE(_bss_end = .);
|
||||
} >datamem AT>datamem :bss
|
||||
|
||||
PROVIDE(_memory_start = ORIGIN(datamem));
|
||||
PROVIDE(_memory_end = ORIGIN(datamem) + LENGTH(datamem));
|
||||
PROVIDE(_stack_size = 1024); /* 1 KiB */
|
||||
PROVIDE(_stack_start = ORIGIN(datamem) + LENGTH(datamem));
|
||||
PROVIDE(_stack_end = _stack_start - _stack_size);
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ linker = "riscv64-unknown-elf-ld"
|
||||
rustflags = [
|
||||
# "-C", "link-arg=-nostartfiles",
|
||||
"-C", "link-arg=-T../link.ld",
|
||||
"-C", "link-arg=../mem/crt.o",
|
||||
]
|
||||
|
||||
[unstable]
|
||||
|
||||
@@ -46,7 +46,7 @@ impl VGA
|
||||
{
|
||||
let c = if (c as u8 > b'~') || ((c as u8) < b' ')
|
||||
{
|
||||
b'?' - b' '
|
||||
b'/' - b' '
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -79,21 +79,9 @@ impl VGA
|
||||
/// The text must have a length that can fit within a `u16`
|
||||
pub unsafe fn draw_string(x: u16, y: u16, str: &str, color: Color)
|
||||
{
|
||||
//str.chars().enumerate().for_each(|(i, c)| unsafe {
|
||||
//Self::draw_char(x + i as u16 * (FONT_WIDTH as u16), y, c, color)
|
||||
//Self::draw_char(x + (i as u16) << 1, y, c, color)
|
||||
//Self::draw_char(x, y, c, color)
|
||||
//});
|
||||
|
||||
for i in 0..2
|
||||
{
|
||||
Self::draw_char(
|
||||
x + (2 - i) as u16 * (FONT_WIDTH as u16),
|
||||
y,
|
||||
str.as_bytes()[i] as char,
|
||||
color,
|
||||
);
|
||||
}
|
||||
str.bytes().enumerate().for_each(|(i, c)| unsafe {
|
||||
Self::draw_char(x + i as u16 * (FONT_WIDTH as u16), y, c as char, color)
|
||||
});
|
||||
}
|
||||
|
||||
unsafe fn font_plate_index(x: u16, y: u16) -> bool
|
||||
|
||||
@@ -6,15 +6,14 @@ use core::arch::asm;
|
||||
use fpga_lib::{
|
||||
panic_handler,
|
||||
register::X31,
|
||||
vga::{BLUE, GREEN, RED, VGA, WHITE},
|
||||
vga::{BLUE, FONT_WIDTH, GREEN, RED, VGA, WHITE},
|
||||
};
|
||||
|
||||
panic_handler! {}
|
||||
|
||||
#[unsafe(no_mangle)]
|
||||
pub extern "C" fn _start() -> !
|
||||
pub extern "C" fn main() -> !
|
||||
{
|
||||
unsafe { asm!("la sp, _stack_start") }
|
||||
// X31::write_const::<0xdead1ffffffff>();
|
||||
// let test = X31::read() + 10;
|
||||
//unsafe {
|
||||
@@ -27,10 +26,45 @@ pub extern "C" fn _start() -> !
|
||||
// {
|
||||
// VGA::write_pixel_unsafe(i, i, WHITE);
|
||||
// }
|
||||
//unsafe { VGA::draw_char(9, 3, 'S', RED) };
|
||||
unsafe { VGA::draw_string(3, 3, "{Skibidi toilet !!}", GREEN) };
|
||||
//let c = core::hint::black_box('S');
|
||||
let c = core::hint::black_box('S');
|
||||
//unsafe { VGA::draw_char(10, 10, c, RED) };
|
||||
//unsafe { VGA::draw_string(3, 3, "{Skibidi toilet !!}", GREEN) };
|
||||
//}
|
||||
|
||||
// for i in 0..2
|
||||
// {
|
||||
// unsafe { VGA::draw_char(0 + i as u16 * FONT_WIDTH as u16, 0, c, RED) };
|
||||
// }
|
||||
|
||||
// unsafe { VGA::draw_char(0, 0, c, RED) };
|
||||
// unsafe { VGA::draw_char(1, 0, c, RED) };
|
||||
|
||||
unsafe { VGA::draw_char(1, 0, c, RED) };
|
||||
unsafe { VGA::draw_char(1, 0, c, GREEN) };
|
||||
// if (c as u8 > b'~') || ((c as u8) < b' ')
|
||||
// {
|
||||
// X31::write_const::<0x01>();
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// X31::write_const::<0xFFFFFFFFFFFFFFFF>();
|
||||
// };
|
||||
//
|
||||
// if (c as u8 > b'~') || ((c as u8) < b' ')
|
||||
// {
|
||||
// X31::write_const::<0x01>();
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// X31::write_const::<0xFFFFFFFFFFFFFFFF>();
|
||||
// };
|
||||
|
||||
// for i in 0..100
|
||||
// {
|
||||
// unsafe { VGA::write_pixel_unsafe(i, i, WHITE) };
|
||||
// }
|
||||
//
|
||||
// let mut a = core::hint::black_box(true);
|
||||
// let mut x = core::hint::black_box(121);
|
||||
// let mut y = core::hint::black_box(221);
|
||||
|
||||
Reference in New Issue
Block a user