Commit 32c2bae6 authored by Flyinghead's avatar Flyinghead
Browse files

dynarecs,reios: use new logging

parent 71e29121
......@@ -329,8 +329,8 @@ u32 DynaRBI::Relink()
}
else
{
printf("SLOW COND PATH %d\n", oplist.empty() ? -1 : oplist[oplist.size()-1].op);
LoadSh4Reg_mem(r4,reg_sr_T);
INFO_LOG(DYNAREC, "SLOW COND PATH %d", oplist.empty() ? -1 : oplist[oplist.size()-1].op);
LoadSh4Reg_mem(r4, reg_sr_T);
}
}
......@@ -464,7 +464,7 @@ u32 DynaRBI::Relink()
}
default:
printf("Error, Relink() Block Type: %X\n", BlockType);
ERROR_LOG(DYNAREC, "Error, Relink() Block Type: %X", BlockType);
verify(false);
break;
}
......@@ -523,7 +523,7 @@ void ngen_Binary(shil_opcode* op, BinaryOP dtop, BinaryOPImm dtopimm)
}
else
{
printf("ngen_Bin ??? %d \n",op->rs2.type);
ERROR_LOG(DYNAREC, "ngen_Bin ??? %d", op->rs2.type);
verify(false);
}
......@@ -890,7 +890,7 @@ u32* ngen_readm_fail_v2(u32* ptrv,u32* regs,u32 fault_addr)
if (offs==-1)
{
printf("%08X : invalid size\n",ptr[0]);
ERROR_LOG(DYNAREC, "%08X : invalid size", fop);
die("can't decode opcode\n");
}
......@@ -913,7 +913,7 @@ u32* ngen_readm_fail_v2(u32* ptrv,u32* regs,u32 fault_addr)
}
else
{
printf("fail raddr %08X {@%08X}:(\n",ptr[0].full,regs[1]);
ERROR_LOG(DYNAREC, "fail raddr %08X {@%08X}:(", ptr[0].full, regs[1]);
die("Invalid opcode: vmem fixup\n");
}
//from mem op
......@@ -1054,7 +1054,7 @@ eReg GenMemAddr(shil_opcode* op,eReg raddr=r0)
}
else if (!op->rs3.is_null())
{
printf("rs3: %08X\n",op->rs3.type);
ERROR_LOG(DYNAREC, "rs3: %08X", op->rs3.type);
die("invalid rs3");
}
else if (op->rs1.is_imm())
......@@ -2185,7 +2185,7 @@ void ngen_compile_opcode(RuntimeBlockInfo* block, shil_opcode* op, bool staging,
break;
__default:
printf("@@\tError, Default case (0x%X) in ngen_CompileBlock!\n", op->op);
ERROR_LOG(DYNAREC, "@@ Error, Default case (0x%X) in ngen_CompileBlock!", op->op);
verify(false);
break;
}
......@@ -2363,7 +2363,7 @@ void ngen_Compile_arm(RuntimeBlockInfo* block,bool force_checks, bool reset, boo
*/
void ngen_init_arm(void)
{
printf("Initializing the ARM32 dynarec\n");
INFO_LOG(DYNAREC, "Initializing the ARM32 dynarec");
verify(FPCB_OFFSET == -0x2100000 || FPCB_OFFSET == -0x4100000);
verify(rcb_noffs(p_sh4rcb->fpcb) == FPCB_OFFSET);
......@@ -2431,7 +2431,7 @@ void ngen_init_arm(void)
BX(LR);
}
printf("readm helpers: up to %08X\n",EMIT_GET_PTR());
INFO_LOG(DYNAREC, "readm helpers: up to %p", EMIT_GET_PTR());
emit_SetBaseAddr();
......
......@@ -134,7 +134,7 @@ void ngen_mainloop(void* v_cntx)
void ngen_init_arm64()
{
printf("Initializing the ARM64 dynarec\n");
INFO_LOG(DYNAREC, "Initializing the ARM64 dynarec");
ngen_FailedToFindBlock = &ngen_FailedToFindBlock_nommu;
}
......@@ -1347,6 +1347,7 @@ public:
#if 0
if (rewrite && block != NULL)
{
INFO_LOG(DYNAREC, "BLOCK %08x", block->vaddr);
Instruction* instr_start = (Instruction*)block->code;
// Instruction* instr_end = GetLabelAddress<Instruction*>(&code_end);
Instruction* instr_end = (Instruction*)((u8 *)block->code + block->host_code_size);
......@@ -1356,7 +1357,7 @@ public:
Instruction* instr;
for (instr = instr_start; instr < instr_end; instr += kInstructionSize) {
decoder.Decode(instr);
printf("VIXL\t %p:\t%s\n",
INFO_LOG(DYNAREC, "VIXL %p: %s",
reinterpret_cast<void*>(instr),
disasm.GetOutput());
}
......
......@@ -23,7 +23,7 @@ extern int mips_counter;
extern int cycle_counter;
void ngen_blockcheckfail_CC(u32 pc) {
printf("REC CPP: SMC invalidation at %08X\n", pc);
INFO_LOG(DYNAREC, "REC CPP: SMC invalidation at %08X", pc);
rdv_BlockCheckFail(pc);
}
int idxnxx = 0;
......@@ -1050,7 +1050,7 @@ opcodeExec* createType(const CC_pars_t& prms, void* fun, shil_opcode* opcode) {
if (!funs.count(fun)) {
funs[fun] = funs_id_count++;
printf("DEFINE %s: FAST_po(%s)\n", getCTN(&createType<CTR>).c_str(), shil_opcode_name(opcode->op));
INFO_LOG(DYNAREC, "DEFINE %s: FAST_po(%s)", getCTN(&createType<CTR>).c_str(), shil_opcode_name(opcode->op));
}
typedef typename CTR::opex thetype;
......@@ -1681,7 +1681,7 @@ public:
ptrsg[opcode_index] = unmap[nm](CC_pars, ccfn, op);
else
{
printf("IMPLEMENT CC_CALL CLASS: %s\n", nm.c_str());
INFO_LOG(DYNAREC, "IMPLEMENT CC_CALL CLASS: %s", nm.c_str());
ptrsg[opcode_index] = new opcodeDie();
}
}
......
......@@ -2161,14 +2161,14 @@ bool ngen_Rewrite(unat& host_pc, unat, unat)
RuntimeBlockInfoPtr block = bm_GetBlock2((void *)host_pc);
if (block == NULL)
{
printf("ngen_Rewrite: Block at %p not found\n", (void *)host_pc);
WARN_LOG(DYNAREC, "ngen_Rewrite: Block at %p not found", (void *)host_pc);
return false;
}
u8 *code_ptr = (u8*)host_pc;
auto it = block->memory_accesses.find(code_ptr);
if (it == block->memory_accesses.end())
{
printf("ngen_Rewrite: memory access at %p not found (%lu entries)\n", code_ptr, block->memory_accesses.size());
WARN_LOG(DYNAREC, "ngen_Rewrite: memory access at %p not found (%lu entries)", code_ptr, block->memory_accesses.size());
return false;
}
u32 opid = it->second;
......
......@@ -18,7 +18,7 @@
#define SWAP32(a) ((((a) & 0xff) << 24) | (((a) & 0xff00) << 8) | (((a) >> 8) & 0xff00) | (((a) >> 24) & 0xff))
#define debugf(...) //printf(__VA_ARGS__)
#define debugf(...) DEBUG_LOG(REIOS, __VA_ARGS__)
gdrom_hle_state_t gd_hle_state = { 0xffffffff, 2, BIOS_INACTIVE };
......@@ -29,7 +29,7 @@ static void GDROM_HLE_ReadSES()
u32 ba = gd_hle_state.params[2];
u32 bb = gd_hle_state.params[3];
printf("GDROM_HLE_ReadSES: doing nothing w/ %d, %d, %d, %d\n", s, b, ba, bb);
WARN_LOG(REIOS, "GDROM_HLE_ReadSES: doing nothing w/ %d, %d, %d, %d", s, b, ba, bb);
}
static void GDROM_HLE_ReadTOC()
......@@ -37,7 +37,7 @@ static void GDROM_HLE_ReadTOC()
u32 area = gd_hle_state.params[0];
u32 dest = gd_hle_state.params[1];
debugf("GDROM READ TOC : %X %X\n", area, dest);
debugf("GDROM READ TOC : %X %X", area, dest);
if (area == DoubleDensity && libGDR_GetDiscType() != GdRom)
{
// Only GD-ROM has a high-density area but no error is reported
......@@ -114,7 +114,7 @@ static void GDROM_HLE_ReadDMA()
u32 b = gd_hle_state.params[2];
u32 u = gd_hle_state.params[3];
debugf("GDROM: DMA READ Sector=%d, Num=%d, Buffer=0x%08X, Unk01=0x%08X\n", s, n, b, u);
debugf("GDROM: DMA READ Sector=%d, Num=%d, Buffer=0x%08X, Unk01=0x%08X", s, n, b, u);
read_sectors_to<false>(b, s, n);
gd_hle_state.result[2] = 0;
......@@ -128,7 +128,7 @@ static void GDROM_HLE_ReadPIO()
u32 b = gd_hle_state.params[2];
u32 u = gd_hle_state.params[3];
debugf("GDROM: PIO READ Sector=%d, Num=%d, Buffer=0x%08X, Unk01=0x%08X\n", s, n, b, u);
debugf("GDROM: PIO READ Sector=%d, Num=%d, Buffer=0x%08X, Unk01=0x%08X", s, n, b, u);
read_sectors_to<true>(b, s, n);
gd_hle_state.result[2] = n * 2048;
......@@ -140,7 +140,7 @@ static void GDCC_HLE_GETSCD() {
u32 size = gd_hle_state.params[1];
u32 dest = gd_hle_state.params[2];
debugf("GDROM: GETSCD format %x size %x dest %08x\n", format, size, dest);
INFO_LOG(REIOS, "GDROM: GETSCD format %x size %x dest %08x", format, size, dest);
if (cdda.playing)
gd_hle_state.cur_sector = cdda.CurrAddr.FAD;
......@@ -243,7 +243,7 @@ static void GD_HLE_Command(u32 cc)
switch(cc)
{
case GDCC_GETTOC:
debugf("GDROM: *FIXME* CMD GETTOC\n");
debugf("GDROM: *FIXME* CMD GETTOC");
break;
case GDCC_GETTOC2:
......@@ -255,7 +255,7 @@ static void GD_HLE_Command(u32 cc)
break;
case GDCC_INIT:
debugf("GDROM: CMD INIT\n");
debugf("GDROM: CMD INIT");
gd_hle_state.multi_callback = 0;
gd_hle_state.multi_read_count = 0;
break;
......@@ -281,11 +281,11 @@ static void GD_HLE_Command(u32 cc)
case GDCC_PLAY_SECTOR:
debugf("GDROM: CMD PLAYSEC?\n");
debugf("GDROM: CMD PLAYSEC?");
break;
case GDCC_RELEASE:
debugf("GDROM: CMD RELEASE?\n");
debugf("GDROM: CMD RELEASE?");
break;
case GDCC_STOP:
......@@ -295,7 +295,7 @@ static void GD_HLE_Command(u32 cc)
break;
case GDCC_SEEK:
debugf("GDROM: CMD SEEK\n");
debugf("GDROM: CMD SEEK");
cdda.playing = false;
SecNumber.Status = GD_PAUSE;
break;
......@@ -308,7 +308,7 @@ static void GD_HLE_Command(u32 cc)
u32 start_fad, end_fad, dummy;
libGDR_GetTrack(first_track, start_fad, dummy);
libGDR_GetTrack(last_track, dummy, end_fad);
debugf("GDROM: CMD PLAY first_track %x last_track %x repeats %x start_fad %x end_fad %x param4 %x\n", first_track, last_track, repeats,
debugf("GDROM: CMD PLAY first_track %x last_track %x repeats %x start_fad %x end_fad %x param4 %x", first_track, last_track, repeats,
start_fad, end_fad, gd_hle_state.params[3]);
cdda.playing = true;
cdda.StartAddr.FAD = start_fad;
......@@ -321,7 +321,7 @@ static void GD_HLE_Command(u32 cc)
break;
case GDCC_PAUSE:
debugf("GDROM: CMD PAUSE\n");
debugf("GDROM: CMD PAUSE");
cdda.playing = false;
SecNumber.Status = GD_PAUSE;
break;
......@@ -331,7 +331,7 @@ static void GD_HLE_Command(u32 cc)
u32 sector = gd_hle_state.params[0];
u32 num = gd_hle_state.params[1];
debugf("GDROM: CMD READ Sector=%d, Num=%d\n", sector, num);
debugf("GDROM: CMD READ Sector=%d, Num=%d", sector, num);
gd_hle_state.status = BIOS_DATA_AVAIL;
gd_hle_state.multi_read_sector = sector;
gd_hle_state.multi_read_count = num * 2048;
......@@ -349,7 +349,7 @@ static void GD_HLE_Command(u32 cc)
case GDCC_REQ_MODE:
{
u32 dest = gd_hle_state.params[0];
debugf("GDROM: REQ_MODE dest:%x\n", dest);
debugf("GDROM: REQ_MODE dest:%x", dest);
WriteMem32(dest, GD_HardwareInfo.speed);
WriteMem32(dest + 4, (GD_HardwareInfo.standby_hi << 8) | GD_HardwareInfo.standby_lo);
WriteMem32(dest + 8, GD_HardwareInfo.read_flags);
......@@ -367,7 +367,7 @@ static void GD_HLE_Command(u32 cc)
u32 read_flags = gd_hle_state.params[2];
u32 read_retry = gd_hle_state.params[3];
debugf("GDROM: SET_MODE speed %x standby %x read_flags %x read_retry %x\n", speed, standby, read_flags, read_retry);
debugf("GDROM: SET_MODE speed %x standby %x read_flags %x read_retry %x", speed, standby, read_flags, read_retry);
GD_HardwareInfo.speed = speed;
GD_HardwareInfo.standby_hi = (standby & 0xff00) >> 8;
......@@ -384,7 +384,7 @@ static void GD_HLE_Command(u32 cc)
{
u32 dest = gd_hle_state.params[0];
debugf("GDROM: GDCC_GET_VER dest %x\n", dest);
debugf("GDROM: GDCC_GET_VER dest %x", dest);
char ver[] = "GDC Version 1.10 1999-03-31 ";
u32 len = (u32)strlen(ver);
......@@ -407,7 +407,7 @@ static void GD_HLE_Command(u32 cc)
u32 dst2 = gd_hle_state.params[2];
u32 dst3 = gd_hle_state.params[3];
debugf("GDROM: GDCC_REQ_STAT dst0=%08x dst1=%08x dst2=%08x dst3=%08x\n", dst0, dst1, dst2, dst3);
debugf("GDROM: GDCC_REQ_STAT dst0=%08x dst1=%08x dst2=%08x dst3=%08x", dst0, dst1, dst2, dst3);
// bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0
// byte | | | | | | | |
......@@ -460,7 +460,7 @@ static void GD_HLE_Command(u32 cc)
u32 num = gd_hle_state.params[1];
bool dma = cc == GDCC_MULTI_DMAREAD;
debugf("GDROM: MULTI_%sREAD Sector=%d, Num=%d\n", dma ? "DMA" : "PIO", sector, num);
debugf("GDROM: MULTI_%sREAD Sector=%d, Num=%d", dma ? "DMA" : "PIO", sector, num);
gd_hle_state.status = BIOS_DATA_AVAIL;
gd_hle_state.multi_read_sector = sector;
......@@ -480,7 +480,7 @@ static void GD_HLE_Command(u32 cc)
u32 dest = gd_hle_state.params[0];
u32 size = gd_hle_state.params[1];
bool dma = cc == GDCC_REQ_DMA_TRANS;
debugf("GDROM: REQ_%s_TRANS dest %x size %x\n", dma ? "DMA" : "PIO",
debugf("GDROM: REQ_%s_TRANS dest %x size %x", dma ? "DMA" : "PIO",
dest, size);
if (dma)
multi_xfer<true>();
......@@ -490,7 +490,7 @@ static void GD_HLE_Command(u32 cc)
break;
default:
printf("GDROM: Unknown GDROM CC:%X\n", cc);
printf("GDROM: Unknown GDROM CC:%X", cc);
break;
}
if (gd_hle_state.status == BIOS_ACTIVE)
......@@ -514,7 +514,7 @@ void gdrom_hle_op()
// r5 = pointer to parameter block for the command, can be NULL if the command does not take parameters
//
// Returns: a request id (>=0) if successful, negative error code if failed
debugf("GDROM: HLE SEND COMMAND CC:%X param ptr: %X bios status %d\n", r[4], r[5], gd_hle_state.status);
debugf("GDROM: HLE SEND COMMAND CC:%X param ptr: %X bios status %d", r[4], r[5], gd_hle_state.status);
if (gd_hle_state.status != BIOS_INACTIVE)
{
r[0] = 0;
......@@ -586,13 +586,13 @@ void gdrom_hle_op()
gd_hle_state.last_request_id = 0xFFFFFFFF;
}
}
debugf("GDROM: HLE CHECK COMMAND REQID:%X param ptr: %X -> %X : %x %x %x %x\n", r[4], r[5], r[0],
debugf("GDROM: HLE CHECK COMMAND REQID:%X param ptr: %X -> %X : %x %x %x %x", r[4], r[5], r[0],
gd_hle_state.result[0], gd_hle_state.result[1], gd_hle_state.result[2], gd_hle_state.result[3]);
break;
case GDROM_MAIN:
// In order for enqueued commands to get processed, this function must be called a few times.
debugf("GDROM: HLE GDROM_MAIN\n");
debugf("GDROM: HLE GDROM_MAIN");
if (gd_hle_state.status == BIOS_ACTIVE || (gd_hle_state.status == BIOS_DATA_AVAIL && gd_hle_state.command == GDCC_REQ_PIO_TRANS))
{
GD_HLE_Command(gd_hle_state.command);
......@@ -601,7 +601,7 @@ void gdrom_hle_op()
case GDROM_INIT:
// Initialize the GDROM subsystem. Should be called before any requests are enqueued.
debugf("GDROM: HLE GDROM_INIT\n");
debugf("GDROM: HLE GDROM_INIT");
gd_hle_state.last_request_id = 0xFFFFFFFF;
gd_hle_state.next_request_id = 2;
gd_hle_state.status = BIOS_INACTIVE;
......@@ -609,7 +609,7 @@ void gdrom_hle_op()
case GDROM_RESET:
// Resets the drive.
debugf("GDROM: HLE GDROM_RESET\n");
debugf("GDROM: HLE GDROM_RESET");
gd_hle_state.last_request_id = 0xFFFFFFFF;
gd_hle_state.status = BIOS_INACTIVE;
break;
......@@ -634,7 +634,7 @@ void gdrom_hle_op()
WriteMem32(r[4] + 4, GdRom);
else
WriteMem32(r[4] + 4, libGDR_GetDiscType());
debugf("GDROM: HLE GDROM_CHECK_DRIVE r4:%X -> %x %x\n", r[4], ReadMem32(r[4]), ReadMem32(r[4] + 4));
debugf("GDROM: HLE GDROM_CHECK_DRIVE r4:%X -> %x %x", r[4], ReadMem32(r[4]), ReadMem32(r[4] + 4));
r[0] = 0;
break;
......@@ -645,7 +645,7 @@ void gdrom_hle_op()
// r4 = request id
//
// Returns: zero if successful, nonzero if failure
debugf("GDROM: HLE GDROM_ABORT_COMMAND r4:%X\n",r[4]);
debugf("GDROM: HLE GDROM_ABORT_COMMAND r4:%X",r[4]);
if (r[4] == gd_hle_state.last_request_id
&& (gd_hle_state.status == BIOS_DATA_AVAIL || gd_hle_state.status == BIOS_ACTIVE))
{
......@@ -672,7 +672,7 @@ void gdrom_hle_op()
// 3 Sector size in bytes (normally 2048)
//
// Returns: zero if successful, -1 if failure
debugf("GDROM: HLE GDROM_SECTOR_MODE PTR_r4:%X\n",r[4]);
debugf("GDROM: HLE GDROM_SECTOR_MODE PTR_r4:%X",r[4]);
for(int i=0; i<4; i++) {
SecMode[i] = ReadMem32(r[4]+(i<<2));
debugf("%08X", SecMode[i]);
......@@ -681,7 +681,7 @@ void gdrom_hle_op()
break;
case GDROM_G1_DMA_END:
debugf("GDROM: G1_DMA_END callback %x arg %x\n", r[4], r[5]);
debugf("GDROM: G1_DMA_END callback %x arg %x", r[4], r[5]);
gd_hle_state.multi_callback = r[4];
gd_hle_state.multi_callback_arg = r[5];
r[0] = 0;
......@@ -696,7 +696,7 @@ void gdrom_hle_op()
case GDROM_REQ_DMA_TRANS:
gd_hle_state.params[0] = ReadMem32(r[5]);
gd_hle_state.params[1] = ReadMem32(r[5] + 4);
debugf("GDROM: REQ_DMA_TRANS req_id %x dest %x size %x\n",
debugf("GDROM: REQ_DMA_TRANS req_id %x dest %x size %x",
r[4], gd_hle_state.params[0], gd_hle_state.params[1]);
if (gd_hle_state.status != BIOS_DATA_AVAIL || gd_hle_state.params[1] > gd_hle_state.multi_read_count)
......@@ -713,7 +713,7 @@ void gdrom_hle_op()
case GDROM_REQ_PIO_TRANS:
gd_hle_state.params[0] = ReadMem32(r[5]);
gd_hle_state.params[1] = ReadMem32(r[5] + 4);
debugf("GDROM: REQ_PIO_TRANS req_id %x dest %x size %x\n",
debugf("GDROM: REQ_PIO_TRANS req_id %x dest %x size %x",
r[4], gd_hle_state.params[0], gd_hle_state.params[1]);
if (gd_hle_state.status != BIOS_DATA_AVAIL || gd_hle_state.params[1] > gd_hle_state.multi_read_count)
{
......@@ -729,7 +729,7 @@ void gdrom_hle_op()
case GDROM_CHECK_DMA_TRANS:
{
u32 len_addr = r[5];
debugf("GDROM: CHECK_DMA_TRANS req_id %x len_addr %x -> %x\n", r[4], len_addr, gd_hle_state.multi_read_count);
debugf("GDROM: CHECK_DMA_TRANS req_id %x len_addr %x -> %x", r[4], len_addr, gd_hle_state.multi_read_count);
if (gd_hle_state.status == BIOS_DATA_AVAIL)
{
WriteMem32(len_addr, gd_hle_state.multi_read_count);
......@@ -743,7 +743,7 @@ void gdrom_hle_op()
break;
case GDROM_SET_PIO_CALLBACK:
debugf("GDROM: SET_PIO_CALLBACK callback %x arg %x\n", r[4], r[5]);
debugf("GDROM: SET_PIO_CALLBACK callback %x arg %x", r[4], r[5]);
gd_hle_state.multi_callback = r[4];
gd_hle_state.multi_callback_arg = r[5];
r[0] = 0;
......@@ -752,7 +752,7 @@ void gdrom_hle_op()
case GDROM_CHECK_PIO_TRANS:
{
u32 len_addr = r[5];
debugf("GDROM: CHECK_PIO_TRANS req_id %x len_addr %x -> %x\n", r[4], len_addr, gd_hle_state.multi_read_count);
debugf("GDROM: CHECK_PIO_TRANS req_id %x len_addr %x -> %x", r[4], len_addr, gd_hle_state.multi_read_count);
if (gd_hle_state.status == BIOS_DATA_AVAIL)
{
WriteMem32(len_addr, gd_hle_state.multi_read_count);
......@@ -766,7 +766,7 @@ void gdrom_hle_op()
break;
default:
printf("GDROM: Unknown SYSCALL: %X\n",r[7]);
WARN_LOG(REIOS, "GDROM: Unknown SYSCALL: %X",r[7]);
break;
}
}
......@@ -777,7 +777,7 @@ void gdrom_hle_op()
case MISC_INIT:
// Initializes all the syscall vectors to their default values.
// Returns: zero
printf("GDROM: MISC_INIT not implemented\n");
debugf("GDROM: MISC_INIT not implemented");
r[0] = 0;
break;
......@@ -789,11 +789,11 @@ void gdrom_hle_op()
// r5 = pointer to handler function, or NULL to clear
//
// Returns: zero if successful, -1 if setting/clearing the handler fails
printf("GDROM: MISC_SETVECTOR not implemented\n");
debugf("GDROM: MISC_SETVECTOR not implemented");
break;
default:
printf("GDROM: Unknown MISC command %x\n", r[7]);
debugf("GDROM: Unknown MISC command %x", r[7]);
break;
}
}
......
......@@ -24,7 +24,7 @@
#include <map>
#define debugf(...) //printf(__VA_ARGS__)
#define debugf(...) DEBUG_LOG(REIOS, __VA_ARGS__)
#define dc_bios_syscall_system 0x8C0000B0
#define dc_bios_syscall_font 0x8C0000B4
......@@ -60,6 +60,14 @@ static void reios_pre_init()
}
}
static u32 decode_iso733(iso733_t v)
{
return ((v >> 56) & 0x000000FF)
| ((v >> 40) & 0x0000FF00)
| ((v >> 24) & 0x00FF0000)
| ((v >> 8) & 0xFF000000);
}
static bool reios_locate_bootfile(const char* bootfile="1ST_READ.BIN")
{
reios_pre_init();
......@@ -75,13 +83,13 @@ static bool reios_locate_bootfile(const char* bootfile="1ST_READ.BIN")
if (pvd->type == 1 && !memcmp(pvd->id, ISO_STANDARD_ID, strlen(ISO_STANDARD_ID)) && pvd->version == 1)
{
debugf("iso9660 PVD found\n");
u32 lba = pvd->root_directory_record.extent & 0xffffffff;
u32 len = pvd->root_directory_record.size & 0xffffffff;
INFO_LOG(REIOS, "iso9660 PVD found");
u32 lba = decode_iso733(pvd->root_directory_record.extent);
u32 len = decode_iso733(pvd->root_directory_record.size);
data_len = ((len + 2047) / 2048) * 2048;
debugf("iso9660 root_directory, FAD: %d, len: %d\n", 150 + lba, data_len);
INFO_LOG(REIOS, "iso9660 root_directory, FAD: %d, len: %d", 150 + lba, data_len);
libGDR_ReadSector(temp, 150 + lba, data_len / 2048, 2048);
}
else {
......@@ -99,10 +107,10 @@ static bool reios_locate_bootfile(const char* bootfile="1ST_READ.BIN")
if ((dir->file_flags & ISO_DIRECTORY) == 0 && memcmp(dir->filename.str + 1, bootfile, bootfile_len) == 0)
{
debugf("Found %.*s at offset %X\n", bootfile_len, bootfile, i);
INFO_LOG(REIOS, "Found %.*s at offset %X", bootfile_len, bootfile, i);
u32 lba = dir->extent & 0xffffffff;
u32 len = dir->size & 0xffffffff;
u32 lba = decode_iso733(dir->extent);
u32 len = decode_iso733(dir->size);
if (!memcmp(bootfile, "0WINCEOS.BIN", 12))
{
......@@ -110,8 +118,8 @@ static bool reios_locate_bootfile(const char* bootfile="1ST_READ.BIN")
len -= 2048;
}
debugf("file LBA: %d\n", lba);
debugf("file LEN: %d\n", len);
INFO_LOG(REIOS, "file LBA: %d", lba);
INFO_LOG(REIOS, "file LEN: %d", len);
if (descrambl)
descrambl_file(lba + 150, len, GetMemPtr(0x8c010000, 0));
......@@ -177,6 +185,10 @@ char* reios_disk_id() {
memcpy(&reios_software_company[0], &buf[112], 16 * sizeof(char));
memcpy(&reios_software_name[0], &buf[128], 128 * sizeof(char));
reios_windows_ce = memcmp("0WINCEOS.BIN", &reios_boot_filename[0], 12) == 0;
INFO_LOG(REIOS, "hardware %.16s maker %.16s device %.16s area %.8s periph %.8s product %.10s version %.6s date %.16s boot %.16s softco %.16s name %.128s",
reios_hardware_id, reios_maker_id, reios_device_info, reios_area_symbols,
reios_peripherals, reios_product_number, reios_product_version,
reios_releasedate, reios_boot_filename, reios_software_company, reios_software_name);
return reios_product_number;
}
......@@ -188,7 +200,7 @@ static void reios_sys_system() {
{
case 0: //SYSINFO_INIT
{
debugf("reios_sys_system: SYSINFO_INIT\n");
debugf("reios_sys_system: SYSINFO_INIT");
// 0x00-0x07: system_id
// 0x08-0x0c: system_props
// 0x0d-0x0f: padding (zeroed out)
......@@ -215,19 +227,19 @@ static void reios_sys_system() {
break;
case 2: //SYSINFO_ICON
debugf("reios_sys_system: SYSINFO_ICON\n");
debugf("reios_sys_system: SYSINFO_ICON");
// r4 = icon number (0-9, but only 5-9 seems to really be icons)
// r5 = destination buffer (704 bytes in size)
r[0] = 704;
break;
case 3: //SYSINFO_ID
debugf("reios_sys_system: SYSINFO_ID\n");
debugf("reios_sys_system: SYSINFO_ID");
r[0] = 0x8c000068;
break;
default:
printf("reios_sys_system: unhandled cmd %d\n", cmd);
WARN_LOG(REIOS, "reios_sys_system: unhandled cmd %d", cmd);
break;
}
}
......@@ -238,22 +250,22 @@ static void reios_sys_font() {
switch (cmd)
{
case 0: // FONTROM_ADDRESS
debugf("FONTROM_ADDRESS\n");
debugf("FONTROM_ADDRESS");
r[0] = FONT_TABLE_ADDR; // in ROM
break;
case 1: // FONTROM_LOCK
debugf("FONTROM_LOCK\n");
debugf("FONTROM_LOCK");
r[0] = 0;
break;
case 2: // FONTROM_UNLOCK
debugf("FONTROM_UNLOCK\n");
debugf("FONTROM_UNLOCK");
r[0] = 0;
break;
default:
printf("reios_sys_font cmd %x\n", cmd);
WARN_LOG(REIOS, "reios_sys_font cmd %x", cmd);
break;
}
}
......@@ -276,7 +288,7 @@ static void reios_sys_flashrom() {
u32 part = r[4];
u32 dest = r[5];
debugf("reios_sys_flashrom: FLASHROM_INFO part %d dest %08x\n", part, dest);
debugf("reios_sys_flashrom: FLASHROM_INFO part %d dest %08x", part, dest);
if (part < FLASH_PT_NUM)
{
......@@ -306,7 +318,7 @@ static void reios_sys_flashrom() {
u32 dest = r[5];
u32 size = r[6];
debugf("reios_sys_flashrom: FLASHROM_READ offs %x dest %08x size %x\n", offset, dest, size);
debugf("reios_sys_flashrom: FLASHROM_READ offs %x dest %08x size %x", offset, dest, size);
for (int i = 0; i < size; i++)
WriteMem8(dest++, flashrom->Read8(offset + i));