mirror of https://github.com/inolen/redream.git
make memcpy functions fallback to 8-bit copy to fix HLE bios syscalls
This commit is contained in:
parent
3243219bcf
commit
478c39d542
|
@ -207,7 +207,7 @@ static void bios_validate_flash(struct bios *bios) {
|
|||
}
|
||||
}
|
||||
|
||||
static int bios_boot(struct bios *bios) {
|
||||
static void bios_boot(struct bios *bios) {
|
||||
struct dreamcast *dc = bios->dc;
|
||||
struct flash *flash = dc->flash;
|
||||
struct gdrom *gd = dc->gdrom;
|
||||
|
@ -221,8 +221,8 @@ static int bios_boot(struct bios *bios) {
|
|||
LOG_INFO("bios_boot using hle bootstrap");
|
||||
|
||||
if (!gdrom_has_disc(gd)) {
|
||||
LOG_WARNING("bios_boot failed, no disc is loaded");
|
||||
return 0;
|
||||
LOG_FATAL("bios_boot failed, no disc is loaded");
|
||||
return;
|
||||
}
|
||||
|
||||
/* load IP.BIN bootstrap */
|
||||
|
@ -235,8 +235,8 @@ static int bios_boot(struct bios *bios) {
|
|||
int read = gdrom_read_sectors(gd, data_session.fad, 16, GD_SECTOR_ANY,
|
||||
GD_MASK_DATA, tmp, sizeof(tmp));
|
||||
if (!read) {
|
||||
LOG_WARNING("bios_boot failed to copy IP.BIN");
|
||||
return 0;
|
||||
LOG_FATAL("bios_boot failed to copy IP.BIN");
|
||||
return;
|
||||
}
|
||||
|
||||
sh4_memcpy_to_guest(dc->mem, BOOT1_ADDR, tmp, read);
|
||||
|
@ -251,9 +251,9 @@ static int bios_boot(struct bios *bios) {
|
|||
uint8_t *tmp = malloc(len);
|
||||
int read = gdrom_read_bytes(gd, fad, len, tmp, len);
|
||||
if (read != len) {
|
||||
LOG_WARNING("bios_boot failed to copy bootfile");
|
||||
LOG_FATAL("bios_boot failed to copy bootfile");
|
||||
free(tmp);
|
||||
return 0;
|
||||
return;
|
||||
}
|
||||
|
||||
sh4_memcpy_to_guest(dc->mem, BOOT2_ADDR, tmp, read);
|
||||
|
@ -291,8 +291,6 @@ static int bios_boot(struct bios *bios) {
|
|||
|
||||
/* start executing at license screen code inside of ip.bin */
|
||||
ctx->pc = 0xac008300;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int bios_post_init(struct device *dev) {
|
||||
|
@ -331,7 +329,8 @@ int bios_invalid_instr(struct bios *bios) {
|
|||
/* if an actual boot rom wasn't loaded into memory, a valid instruction won't
|
||||
exist at 0x0, causing an immediate trap on start */
|
||||
if (pc == 0x0) {
|
||||
return bios_boot(bios);
|
||||
bios_boot(bios);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int handled = 1;
|
||||
|
|
|
@ -173,8 +173,6 @@ enum {
|
|||
#define define_memcpy(space) \
|
||||
void space##_memcpy(struct memory *mem, uint32_t dst, uint32_t src, \
|
||||
int size) { \
|
||||
CHECK(size % 4 == 0); \
|
||||
\
|
||||
uint8_t *pdst = NULL; \
|
||||
mmio_write_cb write = NULL; \
|
||||
mmio_write_string_cb write_string = NULL; \
|
||||
|
@ -195,10 +193,10 @@ enum {
|
|||
} else { \
|
||||
uint32_t end = src + size; \
|
||||
while (src < end) { \
|
||||
uint32_t data = read(mem->dc->space, src, 0xffffffff); \
|
||||
write(mem->dc->space, dst, data, 0xffffffff); \
|
||||
src += 4; \
|
||||
dst += 4; \
|
||||
uint8_t data = read(mem->dc->space, src, 0xff); \
|
||||
write(mem->dc->space, dst, data, 0xff); \
|
||||
src++; \
|
||||
dst++; \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
@ -206,8 +204,6 @@ enum {
|
|||
#define define_memcpy_to_host(space) \
|
||||
void space##_memcpy_to_host(struct memory *mem, void *ptr, uint32_t src, \
|
||||
int size) { \
|
||||
CHECK(size % 4 == 0); \
|
||||
\
|
||||
uint8_t *pdst = ptr; \
|
||||
uint8_t *psrc = NULL; \
|
||||
mmio_read_cb read = NULL; \
|
||||
|
@ -221,37 +217,35 @@ enum {
|
|||
} else { \
|
||||
uint32_t end = src + size; \
|
||||
while (src < end) { \
|
||||
*(uint32_t *)pdst = read(mem->dc->space, src, 0xffffffff); \
|
||||
pdst += 4; \
|
||||
src += 4; \
|
||||
*pdst = read(mem->dc->space, src, 0xff); \
|
||||
pdst++; \
|
||||
src++; \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
#define define_memcpy_to_guest(space) \
|
||||
void space##_memcpy_to_guest(struct memory *mem, uint32_t dst, \
|
||||
const void *ptr, int size) { \
|
||||
CHECK(size % 4 == 0); \
|
||||
\
|
||||
const uint8_t *psrc = ptr; \
|
||||
uint8_t *pdst = NULL; \
|
||||
mmio_write_cb write = NULL; \
|
||||
mmio_write_string_cb write_string = NULL; \
|
||||
space##_lookup_ex(mem, dst, NULL, &pdst, NULL, &write, NULL, \
|
||||
&write_string); \
|
||||
\
|
||||
if (pdst) { \
|
||||
memcpy(pdst, psrc, size); \
|
||||
} else if (write_string) { \
|
||||
write_string(mem->dc->space, dst, psrc, size); \
|
||||
} else { \
|
||||
uint32_t end = dst + size; \
|
||||
while (dst < end) { \
|
||||
write(mem->dc->space, dst, *(uint32_t *)psrc, 0xffffffff); \
|
||||
psrc += 4; \
|
||||
dst += 4; \
|
||||
} \
|
||||
} \
|
||||
#define define_memcpy_to_guest(space) \
|
||||
void space##_memcpy_to_guest(struct memory *mem, uint32_t dst, \
|
||||
const void *ptr, int size) { \
|
||||
const uint8_t *psrc = ptr; \
|
||||
uint8_t *pdst = NULL; \
|
||||
mmio_write_cb write = NULL; \
|
||||
mmio_write_string_cb write_string = NULL; \
|
||||
space##_lookup_ex(mem, dst, NULL, &pdst, NULL, &write, NULL, \
|
||||
&write_string); \
|
||||
\
|
||||
if (pdst) { \
|
||||
memcpy(pdst, psrc, size); \
|
||||
} else if (write_string) { \
|
||||
write_string(mem->dc->space, dst, psrc, size); \
|
||||
} else { \
|
||||
uint32_t end = dst + size; \
|
||||
while (dst < end) { \
|
||||
write(mem->dc->space, dst, *psrc, 0xff); \
|
||||
psrc++; \
|
||||
dst++; \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
#define define_write_bytes(space, name, data_type) \
|
||||
|
|
Loading…
Reference in New Issue