Skip to content

Commit ec2653a

Browse files
committed
Store vga code and font data in RAM, as flash is too slow
It looks like the pixel generating loop is nearly exhausting the time budget, and there is no margin left for flash cache misses. I had to increase the RAM reserved for the BIOS from 16k to 24k. This might be excessive. Perhaps it is possibe to extract a smaller selection of really timing critical code and move only that to RAM?
1 parent 6905718 commit ec2653a

5 files changed

Lines changed: 8 additions & 2 deletions

File tree

memory.x

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ MEMORY {
2525
/*
2626
* This is the bottom of the four striped banks of SRAM in the RP2040.
2727
*/
28-
RAM_OS : ORIGIN = 0x20000000, LENGTH = 0x3C000
28+
RAM_OS : ORIGIN = 0x20000000, LENGTH = 0x3A000
2929
/*
3030
* This is the top of the four striped banks of SRAM in the RP2040.
3131
*/
32-
RAM : ORIGIN = 0x2003C000, LENGTH = 16K
32+
RAM : ORIGIN = 0x2003A000, LENGTH = 24K
3333
/*
3434
* This is the fifth bank, a 4KB block. We use this for Core 0 Stack.
3535
*/

src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1545,6 +1545,7 @@ extern "C" fn time_ticks_per_second() -> common::Ticks {
15451545
/// Called when DMA raises IRQ0; i.e. when a DMA transfer to the pixel FIFO or
15461546
/// the timing FIFO has completed.
15471547
#[interrupt]
1548+
#[link_section = ".data"]
15481549
fn DMA_IRQ_0() {
15491550
unsafe {
15501551
vga::irq();

src/vga/font16.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ pub static FONT: super::Font = super::Font {
3636
};
3737

3838
/// Our font data - arranged as 256 glyphs of 1 byte/row x 16 row/glyph.
39+
#[link_section = ".data"]
3940
static DATA: [u8; 256 * 16] = [
4041
// Char::Null
4142
0b0000_0000,

src/vga/font8.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ pub static FONT: super::Font = super::Font {
3838
};
3939

4040
/// Our font data - arranged as 256 glyphs of 1 byte/row x 8 row/glyph.
41+
#[link_section = ".data"]
4142
static DATA: [u8; 256 * 8] = [
4243
// Char::Null
4344
0b0000_0000,

src/vga/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -693,6 +693,7 @@ pub fn get_num_scan_lines() -> u16 {
693693
/// # Safety
694694
///
695695
/// Only run this function on Core 1.
696+
#[link_section = ".data"]
696697
unsafe extern "C" fn core1_main() -> u32 {
697698
CORE1_START_FLAG.store(true, Ordering::Relaxed);
698699

@@ -721,6 +722,7 @@ unsafe extern "C" fn core1_main() -> u32 {
721722
/// # Safety
722723
///
723724
/// Only call this from the DMA IRQ handler.
725+
#[link_section = ".data"]
724726
pub unsafe fn irq() {
725727
let dma: &mut super::pac::DMA = match DMA_PERIPH.as_mut() {
726728
Some(dma) => dma,
@@ -813,6 +815,7 @@ impl RenderEngine {
813815
}
814816
}
815817

818+
#[link_section = ".data"]
816819
pub fn poll(&mut self) {
817820
if DMA_READY.load(Ordering::Relaxed) {
818821
DMA_READY.store(false, Ordering::Relaxed);

0 commit comments

Comments
 (0)