Skip to content

Commit

Permalink
Add clear screen in BIOS
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Cliche committed Jun 5, 2024
1 parent a274a98 commit bb99553
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 3 deletions.
2 changes: 1 addition & 1 deletion soc/rtl/mmm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ all: top.bin
clean:
rm -f *.hex *.asc *.json *.bin *.log

top.json: $(SRC)
top.json: $(SRC) prom.mem
make -C ../../src/bios
$(YOSYS) -ql top.log -p 'verilog_defines $(DEFINES) ; read_verilog -sv $(SRC); synth_ecp5 -top $(TOP_MODULE) -json top.json -abc9'

Expand Down
2 changes: 1 addition & 1 deletion soc/rtl/ulx3s/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ all: top.bin
clean:
rm -f *.hex *.asc *.json *.bin *.log

top.json: $(SRC)
top.json: $(SRC) prom.mem
make -C ../../src/bios
$(YOSYS) -ql top.log -p 'verilog_defines $(DEFINES) ; read_verilog -sv $(SRC); synth_ecp5 -top $(TOP_MODULE) -json top.json -abc9'

Expand Down
27 changes: 27 additions & 0 deletions soc/src/bios/program.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
#define RAM_START 0x00000000

#define BASE_IO 0xE0000000
#define BASE_VIDEO 0x1000000

#define LED (BASE_IO + 4)
#define UART_DATA (BASE_IO + 8)
#define UART_STATUS (BASE_IO + 12)
#define CONFIG (BASE_IO + 36)

#define MEM_WRITE(_addr_, _value_) (*((volatile unsigned int *)(_addr_)) = _value_)
#define MEM_READ(_addr_) *((volatile unsigned int *)(_addr_))
Expand Down Expand Up @@ -90,8 +92,33 @@ int receive_program()
return 1;
}

void flush_cache(void)
{
// Flush cache
MEM_WRITE(CONFIG, 0x1);
}

void clear(int color)
{
unsigned int res = MEM_READ(CONFIG);
unsigned hres = res >> 16;
unsigned vres = res & 0xffff;

unsigned int *fb = (unsigned int *)BASE_VIDEO;
unsigned int c = color << 16 | color;
for (unsigned int y = 0; y < vres; y++)
for (unsigned int x = 0; x < hres / 2; x++) {
*fb = c;
fb++;
}

flush_cache();
}

void main(void)
{
clear(0xF333);

if (receive_program())
start_prog();
}
2 changes: 1 addition & 1 deletion soc/src/bios/program.ld
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ SECTIONS {
. = 0x000000;
*(.init);
*(.text);
*(*);
*(.sbss);
. = ALIGN(4);
end = .;
} >ram
Expand Down

0 comments on commit bb99553

Please sign in to comment.