Skip to content

Commit 417463b

Browse files
committed
[fw-isoldr]Added NAOMI hardware support.
Also minor improvements.
1 parent 0a1d1a9 commit 417463b

File tree

5 files changed

+30
-16
lines changed

5 files changed

+30
-16
lines changed

firmware/isoldr/loader/dev/sd/sci.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -359,14 +359,15 @@ sci_result_t sci_init(uint32_t baud_rate, sci_mode_t mode, sci_clock_t clock_src
359359
else if(mode == SCI_MODE_SPI) {
360360
/* Use 512 bytes DMA buffer for SPI operations by default,
361361
because it's sector size of SD cards. */
362-
#ifdef __DREAMCAST__
363-
/* On Dreamcast, we use GPIO for CS (anyway need soldering all pins),
364-
because RTS can be used for VS-link cable */
365-
sci_configure_spi(SCI_SPI_CS_GPIO, 512);
366-
#else
367-
/* On Naomi, we use SCIF RTS for CS, because no GPIO pins on CN1 connector */
368-
sci_configure_spi(SCI_SPI_CS_RTS, 512);
369-
#endif
362+
if(is_dreamcast()) {
363+
/* On Dreamcast, we use GPIO for CS (anyway need soldering all pins),
364+
because RTS can be used for VS-link cable */
365+
sci_configure_spi(SCI_SPI_CS_GPIO, 512);
366+
}
367+
else {
368+
/* On NAOMI, we use SCIF RTS for CS, because no GPIO pins on CN1 connector */
369+
sci_configure_spi(SCI_SPI_CS_RTS, 512);
370+
}
370371
/* Set CA bit for 8-bit synchronous mode */
371372
scsmr1 |= SCSMR_CA;
372373
}

firmware/isoldr/loader/include/main.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
#define HOLLY_REV_VA1 0x10
6969
#define HOLLY_REV_VA0 0x0b
7070
#define holly_revision() (*(vuint32 *)NONCACHED_ADDR(0x005f689c))
71+
#define is_dreamcast() (*(vuint32 *)NONCACHED_ADDR(0x005f74b0) == 0)
7172

7273
#define GPIO_PIN_RESET_BUTTON 0
7374

@@ -94,7 +95,7 @@ char *relative_filename(char *filename);
9495
void descramble(uint8 *source, uint8 *dest, uint32 size);
9596

9697
void *search_memory(const uint8 *key, uint32 key_size);
97-
int patch_memory(const uint32 key, const uint32 val);
98+
int patch_memory(const uint32 key, const uint32 val, const uint32 range);
9899
void apply_patch_list();
99100
void rom_memcpy(void* dst, void* src, size_t cnt);
100101

firmware/isoldr/loader/main.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* DreamShell ISO Loader
3-
* (c)2009-2024 SWAT <http://www.dc-swat.ru>
3+
* (c)2009-2025 SWAT <http://www.dc-swat.ru>
44
*/
55

66
#include <main.h>
@@ -40,7 +40,7 @@ int main(int argc, char *argv[]) {
4040
timer_ns_enable();
4141
#endif
4242

43-
int emu_all_sc = 0;
43+
int emu_all_sc = is_dreamcast() ? 0 : 1;
4444

4545
if (IsoInfo->syscalls == 0) {
4646
if(loader_addr < ISOLDR_DEFAULT_ADDR_LOW
@@ -136,6 +136,13 @@ int main(int argc, char *argv[]) {
136136
gdc_syscall_patch();
137137
}
138138

139+
if(!is_dreamcast() && IsoInfo->exec.type == BIN_TYPE_KATANA) {
140+
argc = patch_memory(0xff800030, (uint32)(&IsoInfo->cdda_offset[0]), 0);
141+
LOGF("Patch GPIO register: %d\n", argc);
142+
argc = patch_memory(0xffe80000, (uint32)(&IsoInfo->cdda_offset[1]), 0);
143+
LOGF("Patch SCIF register: %d\n", argc);
144+
}
145+
139146
#ifdef HAVE_EXPT
140147
if(IsoInfo->exec.type == BIN_TYPE_WINCE && IsoInfo->use_irq) {
141148
uint32 vbr_offset = *((uint32 *)NONCACHED_ADDR(IsoInfo->exec.addr + 0x0c)) + 0x30;

firmware/isoldr/loader/syscalls.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -742,6 +742,11 @@ static int init_cmd() {
742742
spi_init();
743743
}
744744
#endif
745+
746+
if(!is_dreamcast() && IsoInfo->exec.type == BIN_TYPE_KATANA) {
747+
patch_memory(0xff800030, (uint32)(&IsoInfo->cdda_offset[0]), 5 << 20);
748+
patch_memory(0xffe80000, (uint32)(&IsoInfo->cdda_offset[1]), 0);
749+
}
745750
return CMD_STAT_COMPLETED;
746751
}
747752

@@ -1587,6 +1592,6 @@ void gdc_syscall_patch(void) {
15871592
size += second_offset;
15881593
icache_flush_range(CACHED_ADDR(SYSCALLS_FW_GDC_ADDR), size);
15891594
} else {
1590-
patch_memory(CACHED_ADDR(SYSCALLS_FW_GDC_ENTRY_ADDR), (uint32)gdc_redir);
1595+
patch_memory(CACHED_ADDR(SYSCALLS_FW_GDC_ENTRY_ADDR), (uint32)gdc_redir, 0);
15911596
}
15921597
}

firmware/isoldr/loader/utils.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,8 @@ uint Load_BootBin() {
168168
}
169169

170170
void rom_memcpy(void* dst, void* src, size_t cnt) {
171+
irq_disable_scoped();
172+
171173
#if defined(DEV_TYPE_IDE) || defined(DEV_TYPE_GD)
172174
do {} while(pre_read_xfer_busy());
173175
#endif
@@ -400,11 +402,10 @@ void *search_memory(const uint8 *key, uint32 key_size) {
400402
return NULL;
401403
}
402404

403-
404-
int patch_memory(const uint32 key, const uint32 val) {
405+
int patch_memory(const uint32 key, const uint32 val, const uint32 range) {
405406

406407
uint32 exec_addr = NONCACHED_ADDR(IsoInfo->exec.addr);
407-
uint32 end_loc = exec_addr + IsoInfo->exec.size;
408+
uint32 end_loc = exec_addr + (range ? range : IsoInfo->exec.size);
408409
uint8 *k = (uint8 *)&key;
409410
uint8 *v = (uint8 *)&val;
410411
int count = 0;
@@ -423,7 +424,6 @@ int patch_memory(const uint32 key, const uint32 val) {
423424
return count;
424425
}
425426

426-
427427
void apply_patch_list() {
428428
if(!IsoInfo->patch_addr[0]) {
429429
return;

0 commit comments

Comments
 (0)