Skip to content

Commit 4bfc1b9

Browse files
committed
Remove printchar, printflush, and drawflush instructions from MLOGSYS
1 parent bbf2799 commit 4bfc1b9

File tree

12 files changed

+51
-95
lines changed

12 files changed

+51
-95
lines changed

README.md

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -121,20 +121,15 @@ This non-standard extension adds instructions to control the mlogv32 processor's
121121

122122
The MLOG instructions are encoded with an I-type instruction format using the _custom-0_ opcode. The zero-extended immediate is used as a minor opcode (funct12) for implementation reasons.
123123

124-
The MLOGSYS instruction is used for simple system controls, including `printchar`, `printflush`, `drawflush`, and icache initialization.
124+
The MLOGSYS instruction is used for simple system controls, currently only including icache initialization.
125125

126126
The `mlogsys.icache` instruction uses register _rs1_ as the number of bytes to decode. This can be generated by using a linker script to find the end address of the `.text` section and load it using `li`. The actual number of bytes decoded will be the smallest of _rs1_, the size of the icache, and the size of ROM.
127127

128-
FIXME: `printflush` and `drawflush` are broken with subframe :(
128+
| funct12 | rs1 | name |
129+
| ------- | ------ | --------------------- |
130+
| 0 | length | Initialize ROM icache |
129131

130-
| funct12 | rs1 | name |
131-
| ------- | ------- | --------------------- |
132-
| 0 | length | Initialize ROM icache |
133-
| 1 | char | `printchar` |
134-
| 2 | `00000` | `printflush` |
135-
| 3 | `00000` | `drawflush` |
136-
137-
The MLOGDRAW instruction is used for drawing graphics using the Mlog `draw` instruction. Arguments are passed to this instruction using registers _rs1_, a1, a2, a3, a4, and a5 as necessary.
132+
The MLOGDRAW instruction is used for drawing graphics using the Mlog `draw` instruction. Arguments are passed to this instruction using registers _rs1_, a1, a2, a3, a4, and a5 as necessary. Due to subframe constraints, `drawflush` is executed after every `draw` call.
138133

139134
| funct12 | rs1 | a1 | a2 | a3 | a4 | a5 | name |
140135
| ------- | ------- | ----- | ----- | ------ | -------- | -------- | ---------------- |

asm/print.s

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,21 @@ _start:
33
la s0, msg
44
li s1, 0
55
la s2, msg_len
6+
7+
# UART0
8+
li a0, 0xf0000010
9+
10+
li t0, 0b111
11+
sb t0, 8(a0) # FCR
612

713
loop:
814
lbu t0, 0(s0)
9-
.insn i CUSTOM_0, 0, zero, t0, 1 # printchar
15+
sb t0, 0(a0) # THR
1016

1117
addi s0, s0, 1
1218
addi s1, s1, 1
1319
blt s1, s2, loop
1420

15-
.insn i CUSTOM_0, 0, zero, zero, 2 # printflush
16-
1721
# halt
1822
li t0, 0xfffffff0
1923
sw zero, 0(t0)

coremark/mlogv32/xmlogsys.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
#define MLOGSYS_printchar(c) asm volatile (".insn i CUSTOM_0, 0, zero, %0, 1" : : "r" (c) )
2-
#define MLOGSYS_printflush() asm volatile (".insn i CUSTOM_0, 0, zero, zero, 2" : : )
3-
#define MLOGSYS_drawflush() asm volatile (".insn i CUSTOM_0, 0, zero, zero, 3" : : )
4-
51
#define _declare_MLOGDRAW_0(NAME) \
62
void MLOGDRAW_ ## NAME ()
73

rust/examples/demo/src/main.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ fn main() -> ! {
3838
draw_rect(28, 12, 2, 12);
3939
draw_rect(32, 12, 8, 2);
4040

41-
draw_flush();
42-
4341
let cycle1 = cycle::read();
4442
let instret1 = instret::read();
4543
let time1 = time::read();
@@ -51,7 +49,5 @@ fn main() -> ! {
5149
print_str("\ntime 1: ");
5250
print_str(buf.format(time1));
5351

54-
print_flush();
55-
5652
halt()
5753
}

rust/examples/sortKB/src/main.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ fn main() -> ! {
4343
{
4444
printer.print_char(uart1.uart_mut().read_byte() as char);
4545
printer.flush();
46-
draw_flush();
4746
}
4847

4948
spin_loop();
@@ -81,7 +80,6 @@ impl DisplayPrinter {
8180
draw_reset();
8281
draw_clear(0, 0, 0);
8382
draw_col(0xffffffff);
84-
draw_flush();
8583
}
8684

8785
pub fn print_str(&mut self, s: &str) {

rust/examples/timer/src/main.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use core::{cell::RefCell, hint};
55

66
use critical_section::Mutex;
77
use itoa::Buffer;
8-
use mlogv32::io::{print_flush, print_str};
8+
use mlogv32::io::print_str;
99
use riscv::{
1010
interrupt::{self, Interrupt},
1111
register::mie,
@@ -42,7 +42,6 @@ fn machine_timer() {
4242

4343
let mut buf = Buffer::new();
4444
print_str(buf.format(mtime));
45-
print_flush();
4645
});
4746
}
4847

rust/mlogv32/src/graphics.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -206,12 +206,3 @@ pub fn draw_reset() {
206206
);
207207
};
208208
}
209-
210-
pub fn draw_flush() {
211-
unsafe {
212-
asm!(
213-
".insn i CUSTOM_0, 0, zero, zero, 3",
214-
options(nomem, preserves_flags, nostack),
215-
);
216-
};
217-
}

rust/mlogv32/src/io.rs

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use core::{arch::asm, hint, slice};
1+
use core::{hint, slice};
22

33
use embassy_hal_internal::atomic_ring_buffer::RingBuffer;
44
use uart::{Data, FifoControl, LineStatus, Uart, address::MmioAddress};
@@ -11,23 +11,9 @@ pub fn print_str(msg: &str) {
1111
}
1212
}
1313

14-
pub fn print_char(c: char) {
15-
unsafe {
16-
asm!(
17-
".insn i CUSTOM_0, 0, zero, {}, 1",
18-
in(reg) c as u32,
19-
options(nomem, preserves_flags, nostack),
20-
);
21-
};
22-
}
23-
24-
pub fn print_flush() {
25-
unsafe {
26-
asm!(
27-
".insn i CUSTOM_0, 0, zero, zero, 2",
28-
options(nomem, preserves_flags, nostack),
29-
);
30-
}
14+
pub fn print_char(_c: char) {
15+
// FIXME: printchar instruction no longer exists, set up println impl similar to esp-println
16+
// https://github.com/esp-rs/esp-hal/tree/84bb51215d261913f00239ecd0ed38fcd8296d0e/esp-println
3117
}
3218

3319
// TODO: create Peripherals struct?

rust/mlogv32/src/panic_handler.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::halt;
2-
use crate::io::{print_flush, print_str};
2+
use crate::io::print_str;
33
use core::panic::PanicInfo;
44

55
#[panic_handler]
@@ -21,7 +21,5 @@ fn panic(info: &PanicInfo) -> ! {
2121
}
2222
}
2323

24-
print_flush();
25-
2624
halt();
2725
}

rust/mlogv32/src/prelude.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
pub use crate::io::print_str;
2-
3-
pub use crate::{halt, io::print_flush, sleep, sleep_n};
1+
pub use crate::{halt, io::print_str, sleep, sleep_n};

0 commit comments

Comments
 (0)