serial_transfer: disable maple debugging

This commit is contained in:
Zack Buhman 2024-12-16 11:20:13 -06:00
parent 8f95b5a2b2
commit d74804f2b3
6 changed files with 31 additions and 11 deletions

View File

@ -103,10 +103,10 @@ endef
$(AS) $(AARCH) $(AFLAGS) $(DEBUG) $< -o $@
%.o: %.c
$(CC) $(CARCH) $(CFLAGS) -std=c23 $(OPT) $(DEBUG) $(DEPFLAGS) -MF ${<}.d -c $< -o $@
$(CC) $(CARCH) $(CFLAGS) -std=gnu23 $(OPT) $(DEBUG) $(DEPFLAGS) -MF ${<}.d -c $< -o $@
%.o: %.cpp
$(CXX) $(CARCH) $(CFLAGS) $(CXXFLAGS) $(OPT) $(DEBUG) $(DEPFLAGS) -MF ${<}.d -c $< -o $@
$(CXX) $(CARCH) $(CFLAGS) -std=c++23 $(CXXFLAGS) $(OPT) $(DEBUG) $(DEPFLAGS) -MF ${<}.d -c $< -o $@
%.elf:
$(LD) $(LDFLAGS) -L $(LIB) -T $(LDSCRIPT) $^ -o $@

View File

@ -3,11 +3,9 @@ GENERATED ?=
AARCH = --isa=sh4 --little
CARCH = -m4-single-only -ml
CARCH ?= -m4-single-only -ml
CFLAGS += -mfsca -funsafe-math-optimizations -ffast-math
CXXFLAGS += -std=c++23
OBJARCH = -O elf32-shl -B sh4
TARGET = sh4-none-elf-

View File

@ -388,9 +388,9 @@ SERIAL_TRANSFER_OBJ = \
example/serial_transfer.o \
sh7091/serial.o \
serial_load.o \
maple/maple.o \
font/portfolio_6x8/portfolio_6x8.data.o \
crc32.o
# maple/maple.o \
# font/portfolio_6x8/portfolio_6x8.data.o \
example/serial_transfer.elf: LDSCRIPT = $(LIB)/loader.lds
example/serial_transfer.elf: $(START_OBJ) $(SERIAL_TRANSFER_OBJ)

View File

@ -405,11 +405,13 @@ void main()
constexpr uint32_t serial_speed = 0;
serial_load::init(serial_speed);
/*
const uint8_t * font = reinterpret_cast<const uint8_t *>(&_binary_font_portfolio_6x8);
auto renderer0 = maple::display::font_renderer(font);
framebuffer[0] = renderer0.fb;
auto renderer1 = maple::display::font_renderer(font);
framebuffer[1] = renderer1.fb;
*/
// reset serial status
sh7091.SCIF.SCFSR2 = 0;
@ -463,10 +465,11 @@ void main()
}
}
//serial::string(".");
serial_load::tick(poll_state);
render(renderer0, renderer1);
//render(renderer0, renderer1);
poll_state.want_start = 1;
handle_maple(poll_state);
//poll_state.want_start = 1;
//handle_maple(poll_state);
}
}

View File

@ -2,10 +2,14 @@
#include "sh7091/serial.hpp"
#include "sh7091/serial_dma.hpp"
#include "sh7091/cache.hpp"
#include "serial_load.hpp"
#include "crc32.h"
#include "align.hpp"
#include "memory.hpp"
namespace serial_load {
struct state state;
@ -162,7 +166,7 @@ void recv(struct maple_poll_state& poll_state, uint8_t c)
}
}
// invalid command
move(&state.buf.u8[0], &state.buf.u8[1], state.len - 1);
memory::move(&state.buf.u8[0], &state.buf.u8[1], state.len - 1);
state.len -= 1;
break;
}
@ -185,6 +189,16 @@ void tick(struct maple_poll_state& poll_state)
if (dar1 > state.reply_crc.offset) {
uint32_t len = dar1 - state.reply_crc.offset;
const uint8_t * buf = reinterpret_cast<const uint8_t *>(state.reply_crc.offset);
const uint8_t * buf32 = reinterpret_cast<const uint8_t *>((state.reply_crc.offset / 32) * 32); // round down
// purge operand cache blocks for the data written by DMA, rounding up twice
for (uint32_t i = 0; i < align_32byte(len) + 32; i += 32) {
asm volatile ("ocbp @%0"
: // output
: "r" (reinterpret_cast<uint32_t>(&buf32[i])) // input
);
}
state.reply_crc.value = crc32_update(state.reply_crc.value, buf, len);
state.reply_crc.offset += len;
}
@ -248,6 +262,9 @@ void tick(struct maple_poll_state& poll_state)
if ((sh7091.SCIF.SCFSR2 & transmission_end) != transmission_end)
return;
// clear the cache before jumping
cache::init();
const uint32_t dest = state.buf.arg[0];
jump_to_func(dest);

View File

@ -12,10 +12,12 @@ namespace cache {
void init()
{
for (int i = 0; i < 256; i++) {
// clear all V bits of the IC address array
sh7091_ic_a[i][0] = 0;
}
for (int i = 0; i < 512; i++) {
// clear all V bits of the OC address array
sh7091_oc_a[i][0] = 0;
}