mirror of
https://github.com/dingusdev/dingusppc.git
synced 2025-01-11 05:29:43 +00:00
Further logging code.
This commit is contained in:
parent
e9a616ffeb
commit
d91950e582
@ -14,6 +14,7 @@
|
||||
- clarify what to do in the case of unaligned memory accesses
|
||||
*/
|
||||
|
||||
#include <thirdparty/loguru.hpp>
|
||||
#include <iostream>
|
||||
#include <cstdint>
|
||||
#include <cinttypes>
|
||||
@ -57,12 +58,12 @@ AddressMapEntry last_ptab_area = { 0 };
|
||||
ret = entry->devobj->read((ADDR) - entry->start, (SIZE)); \
|
||||
} \
|
||||
else { \
|
||||
printf("Please check your address map!\n"); \
|
||||
LOG_F(ERROR, "Please check your address map! \n"); \
|
||||
ret = (UNVAL); \
|
||||
} \
|
||||
} \
|
||||
else { \
|
||||
printf("WARNING: read from unmapped memory at 0x%08X!\n", (ADDR)); \
|
||||
LOG_F(WARNING, "Read from unmapped memory at 0x%08X!\n", (ADDR)); \
|
||||
ret = (UNVAL); \
|
||||
} \
|
||||
} \
|
||||
@ -86,11 +87,11 @@ AddressMapEntry last_ptab_area = { 0 };
|
||||
entry->devobj->write((ADDR) - entry->start, (VAL), (SIZE)); \
|
||||
} \
|
||||
else { \
|
||||
printf("Please check your address map!\n"); \
|
||||
LOG_F(ERROR, "Please check your address map!\n"); \
|
||||
} \
|
||||
} \
|
||||
else { \
|
||||
printf("WARNING: write to unmapped memory at 0x%08X!\n", (ADDR)); \
|
||||
LOG_F(WARNING, "Write to unmapped memory at 0x%08X!\n", (ADDR)); \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
@ -165,7 +166,7 @@ static inline uint8_t* calc_pteg_addr(uint32_t hash)
|
||||
return last_ptab_area.mem_ptr + (pteg_addr - last_ptab_area.start);
|
||||
}
|
||||
else {
|
||||
printf("SOS: no page table region was found at %08X!\n", pteg_addr);
|
||||
LOG_F(ERROR, "SOS: no page table region was found at %08X!\n", pteg_addr);
|
||||
exit(-1); // FIXME: ugly error handling, must be the proper exception!
|
||||
}
|
||||
}
|
||||
@ -188,7 +189,7 @@ static bool search_pteg(uint8_t* pteg_addr, uint8_t** ret_pte_addr,
|
||||
if (pte_check == READ_DWORD_BE_A(pteg_addr)) {
|
||||
if (match_found) {
|
||||
if ((READ_DWORD_BE_A(pteg_addr) & 0xFFFFF07B) != pte_word2_check) {
|
||||
printf("Multiple PTEs with different RPN/WIMG/PP found!\n");
|
||||
LOG_F(ERROR, "Multiple PTEs with different RPN/WIMG/PP found!\n");
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
@ -220,7 +221,7 @@ static uint32_t page_address_translate(uint32_t la, bool is_instr_fetch,
|
||||
|
||||
sr_val = ppc_state.ppc_sr[(la >> 28) & 0x0F];
|
||||
if (sr_val & 0x80000000) {
|
||||
printf("Direct-store segments not supported, LA=%0xX\n", la);
|
||||
LOG_F(ERROR, "Direct-store segments not supported, LA=%0xX\n", la);
|
||||
exit(-1); // FIXME: ugly error handling, must be the proper exception!
|
||||
}
|
||||
|
||||
@ -363,10 +364,10 @@ static uint32_t ppc_mmu_addr_translate(uint32_t la, int is_write)
|
||||
|
||||
static void mem_write_unaligned(uint32_t addr, uint32_t value, uint32_t size)
|
||||
{
|
||||
printf("WARNING! Attempt to write unaligned %d bytes to 0x%08X\n", size, addr);
|
||||
LOG_F(WARNING, "Attempt to write unaligned %d bytes to 0x%08X\n", size, addr);
|
||||
|
||||
if (((addr & 0xFFF) + size) > 0x1000) {
|
||||
printf("SOS! Cross-page unaligned write, addr=%08X, size=%d\n", addr, size);
|
||||
LOG_F(ERROR, "SOS! Cross-page unaligned write, addr=%08X, size=%d\n", addr, size);
|
||||
exit(-1); //FIXME!
|
||||
} else {
|
||||
/* data address translation if enabled */
|
||||
@ -425,7 +426,7 @@ void mem_write_dword(uint32_t addr, uint32_t value)
|
||||
void mem_write_qword(uint32_t addr, uint64_t value)
|
||||
{
|
||||
if (addr & 7) {
|
||||
printf("SOS! Attempt to write unaligned QWORD to 0x%08X\n", addr);
|
||||
LOG_F(ERROR, "SOS! Attempt to write unaligned QWORD to 0x%08X\n", addr);
|
||||
exit(-1); //FIXME!
|
||||
}
|
||||
|
||||
@ -441,10 +442,10 @@ static uint32_t mem_grab_unaligned(uint32_t addr, uint32_t size)
|
||||
{
|
||||
uint32_t ret = 0;
|
||||
|
||||
printf("WARNING! Attempt to read unaligned %d bytes from 0x%08X\n", size, addr);
|
||||
LOG_F(WARNING, "Attempt to read unaligned %d bytes from 0x%08X\n", size, addr);
|
||||
|
||||
if (((addr & 0xFFF) + size) > 0x1000) {
|
||||
printf("SOS! Cross-page unaligned read, addr=%08X, size=%d\n", addr, size);
|
||||
LOG_F(ERROR, "SOS! Cross-page unaligned read, addr=%08X, size=%d\n", addr, size);
|
||||
exit(-1); //FIXME!
|
||||
} else {
|
||||
/* data address translation if enabled */
|
||||
@ -515,7 +516,7 @@ uint64_t mem_grab_qword(uint32_t addr)
|
||||
uint64_t ret;
|
||||
|
||||
if (addr & 7) {
|
||||
printf("SOS! Attempt to read unaligned QWORD at 0x%08X\n", addr);
|
||||
LOG_F(ERROR, "SOS! Attempt to read unaligned QWORD at 0x%08X\n", addr);
|
||||
exit(-1); //FIXME!
|
||||
}
|
||||
|
||||
@ -551,7 +552,7 @@ uint8_t* quickinstruction_translate(uint32_t addr)
|
||||
ppc_set_cur_instruction(real_addr);
|
||||
}
|
||||
else {
|
||||
printf("WARNING: attempt to execute code at %08X!\n", addr);
|
||||
LOG_F(WARNING, "attempt to execute code at %08X!\n", addr);
|
||||
exit(-1); // FIXME: ugly error handling, must be the proper exception!
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
// General opcodes for the processor - ppcopcodes.cpp
|
||||
|
||||
#include <thirdparty/loguru.hpp>
|
||||
#include <iostream>
|
||||
#include <cstring>
|
||||
#include <cinttypes>
|
||||
@ -1795,22 +1796,22 @@ void ppc_sync() {
|
||||
}
|
||||
|
||||
void ppc_icbi() {
|
||||
std::cout << "Oops. Placeholder for icbi." << std::endl;
|
||||
LOG_F(WARNING, "Placeholder for icbi. \n");
|
||||
}
|
||||
|
||||
void ppc_dcbf() {
|
||||
std::cout << "Oops. Placeholder for dcbf." << std::endl;
|
||||
LOG_F(WARNING, "Placeholder for dcbf. \n");
|
||||
}
|
||||
|
||||
void ppc_dcbi() {
|
||||
#ifdef PROFILER
|
||||
supervisor_inst_num++;
|
||||
#endif
|
||||
std::cout << "Oops. Placeholder for dcbi." << std::endl;
|
||||
LOG_F(WARNING, "Placeholder for dcbi. \n");
|
||||
}
|
||||
|
||||
void ppc_dcbst() {
|
||||
std::cout << "Oops. Placeholder for dcbst." << std::endl;
|
||||
LOG_F(WARNING, "Placeholder for dcbst. \n");
|
||||
}
|
||||
|
||||
void ppc_dcbt() {
|
||||
@ -2258,7 +2259,7 @@ void ppc_lswi() {
|
||||
ppc_store_result_regd();
|
||||
break;
|
||||
default:
|
||||
printf("Something really horrible happened with lswi.");
|
||||
LOG_F(ERROR, "Something really horrible happened with lswi. \n");
|
||||
}
|
||||
if (shift_times == 3) {
|
||||
shift_times = 0;
|
||||
@ -2307,7 +2308,7 @@ void ppc_lswx() {
|
||||
ppc_store_result_regd();
|
||||
break;
|
||||
default:
|
||||
printf("Something really horrible happened with lswx.");
|
||||
LOG_F(ERROR, "Something really horrible happened with lswx. \n");
|
||||
}
|
||||
if (shift_times == 3) {
|
||||
shift_times = 0;
|
||||
@ -2347,7 +2348,7 @@ void ppc_stswi() {
|
||||
mem_write_byte(ppc_effective_address, strwrd_replace_value);
|
||||
break;
|
||||
default:
|
||||
printf("Something really horrible happened with stswi.");
|
||||
LOG_F(ERROR, "Something really horrible happened with stswi. \n");
|
||||
}
|
||||
if (shift_times == 3) {
|
||||
shift_times = 0;
|
||||
@ -2385,7 +2386,7 @@ void ppc_stswx() {
|
||||
mem_write_byte(ppc_effective_address, strwrd_replace_value);
|
||||
break;
|
||||
default:
|
||||
printf("Something really horrible happened with stswx.");
|
||||
LOG_F(ERROR, "Something really horrible happened with stswx. \n");
|
||||
}
|
||||
if (shift_times == 3) {
|
||||
shift_times = 0;
|
||||
@ -2409,33 +2410,33 @@ void ppc_tlbie() {
|
||||
reg_b = (ppc_cur_instruction >> 11) & 31;
|
||||
uint32_t vps = ppc_state.ppc_gpr[reg_b] & 0xFFFF000;
|
||||
**/
|
||||
printf("Placeholder for tlbie \n");
|
||||
LOG_F(WARNING, "Placeholder for tlbie \n");
|
||||
}
|
||||
|
||||
void ppc_tlbia() {
|
||||
#ifdef PROFILER
|
||||
supervisor_inst_num++;
|
||||
#endif
|
||||
printf("Placeholder for tlbia \n");
|
||||
LOG_F(WARNING, "Placeholder for tlbia \n");
|
||||
}
|
||||
|
||||
void ppc_tlbld() {
|
||||
#ifdef PROFILER
|
||||
supervisor_inst_num++;
|
||||
#endif
|
||||
printf("Placeholder for tlbld - 603 only \n");
|
||||
LOG_F(WARNING, "Placeholder for tlbld - 603 only \n");
|
||||
}
|
||||
|
||||
void ppc_tlbli() {
|
||||
#ifdef PROFILER
|
||||
supervisor_inst_num++;
|
||||
#endif
|
||||
printf("Placeholder for tlbli - 603 only \n");
|
||||
LOG_F(WARNING, "Placeholder for tlbli - 603 only \n");
|
||||
}
|
||||
|
||||
void ppc_tlbsync() {
|
||||
#ifdef PROFILER
|
||||
supervisor_inst_num++;
|
||||
#endif
|
||||
printf("Placeholder for tlbsync \n");
|
||||
LOG_F(WARNING, "Placeholder for tlbsync \n");
|
||||
}
|
@ -10,6 +10,7 @@
|
||||
Author: Max Poliakovski
|
||||
*/
|
||||
|
||||
#include <thirdparty/loguru.hpp>
|
||||
#include <iostream>
|
||||
#include <cstring>
|
||||
#include <cinttypes>
|
||||
|
@ -5,6 +5,7 @@
|
||||
//if you want to distribute this.
|
||||
//(divingkatae#1017 or powermax#2286 on Discord)
|
||||
|
||||
#include <thirdparty/loguru.hpp>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <cstring>
|
||||
@ -52,13 +53,13 @@ void NVram::init() {
|
||||
|
||||
ifstream f(this->file_name, ios::in | ios::binary);
|
||||
|
||||
if (f.fail() || !f.read(sig, sizeof(NVRAM_FILE_ID)) ||
|
||||
!f.read((char *)&data_size, sizeof(data_size)) ||
|
||||
memcmp(sig, NVRAM_FILE_ID, sizeof(NVRAM_FILE_ID)) ||
|
||||
data_size != this->ram_size ||
|
||||
if (f.fail() || !f.read(sig, sizeof(NVRAM_FILE_ID)) || \
|
||||
!f.read((char *)&data_size, sizeof(data_size)) || \
|
||||
memcmp(sig, NVRAM_FILE_ID, sizeof(NVRAM_FILE_ID)) || \
|
||||
data_size != this->ram_size || \
|
||||
!f.read((char *)this->storage, this->ram_size))
|
||||
{
|
||||
cout << "WARN: Could not restore NVRAM content from the given file." << endl;
|
||||
LOG_F(WARNING, "Could not restore NVRAM content from the given file. \n");
|
||||
memset(this->storage, 0, sizeof(this->ram_size));
|
||||
}
|
||||
|
||||
|
@ -223,18 +223,18 @@ void ViaCuda::cuda_error_response(uint32_t error)
|
||||
void ViaCuda::cuda_process_packet()
|
||||
{
|
||||
if (this->in_count < 2) {
|
||||
cout << "Cuda: invalid packet (too few data)!" << endl;
|
||||
LOG_F(ERROR, "Cuda: invalid packet (too few data)! \n");
|
||||
return;
|
||||
}
|
||||
|
||||
switch(this->in_buf[0]) {
|
||||
case CUDA_PKT_ADB:
|
||||
cout << "Cuda: ADB packet received" << endl;
|
||||
LOG_F(INFO, "Cuda: ADB packet received \n");
|
||||
break;
|
||||
case CUDA_PKT_PSEUDO:
|
||||
cout << "Cuda: pseudo command packet received" << endl;
|
||||
cout << "Command: " << hex << (uint32_t)(this->in_buf[1]) << endl;
|
||||
cout << "Data count: " << dec << this->in_count << endl;
|
||||
LOG_F(INFO, "Cuda: pseudo command packet received \n");
|
||||
LOG_F(INFO, "Command: %x \n", (uint32_t)(this->in_buf[1]));
|
||||
LOG_F(INFO, "Data count: %d \n ", this->in_count);
|
||||
for (int i = 0; i < this->in_count; i++) {
|
||||
cout << hex << (uint32_t)(this->in_buf[i]) << ", ";
|
||||
}
|
||||
@ -242,7 +242,7 @@ void ViaCuda::cuda_process_packet()
|
||||
cuda_pseudo_command(this->in_buf[1], this->in_count - 2);
|
||||
break;
|
||||
default:
|
||||
cout << "Cuda: unsupported packet type = " << dec << (uint32_t)(this->in_buf[0]) << endl;
|
||||
LOG_F(ERROR, "Cuda: unsupported packet type = %d \n", (uint32_t)(this->in_buf[0]));
|
||||
}
|
||||
}
|
||||
|
||||
@ -280,11 +280,11 @@ void ViaCuda::cuda_pseudo_command(int cmd, int data_count)
|
||||
}
|
||||
break;
|
||||
case CUDA_OUT_PB0: /* undocumented call! */
|
||||
cout << "Cuda: send " << dec << (int)(this->in_buf[2]) << " to PB0" << endl;
|
||||
LOG_F(INFO, "Cuda: send %d to PB0 \n", (int)(this->in_buf[2]));
|
||||
cuda_response_header(CUDA_PKT_PSEUDO, 0);
|
||||
break;
|
||||
default:
|
||||
cout << "Cuda: unsupported pseudo command 0x" << hex << cmd << endl;
|
||||
LOG_F(ERROR, "Cuda: unsupported pseudo command 0x%x \n", cmd);
|
||||
cuda_error_response(CUDA_ERR_BAD_CMD);
|
||||
}
|
||||
}
|
||||
@ -304,7 +304,7 @@ void ViaCuda::i2c_simple_transaction(uint8_t dev_addr, const uint8_t *in_buf,
|
||||
}
|
||||
break;
|
||||
default:
|
||||
cout << "Unsupported I2C device 0x" << hex << (int)dev_addr << endl;
|
||||
LOG_F(ERROR, "Unsupported I2C device 0x%x \n", (int)dev_addr);
|
||||
cuda_error_response(CUDA_ERR_I2C);
|
||||
}
|
||||
}
|
||||
@ -315,7 +315,7 @@ void ViaCuda::i2c_comb_transaction(uint8_t dev_addr, uint8_t sub_addr,
|
||||
int tr_type = dev_addr1 & 1;
|
||||
|
||||
if ((dev_addr & 0xFE) != (dev_addr1 & 0xFE)) {
|
||||
cout << "I2C combined, dev_addr mismatch!" << endl;
|
||||
LOG_F(ERROR, "I2C combined, dev_addr mismatch! \n");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -323,8 +323,8 @@ void ViaCuda::i2c_comb_transaction(uint8_t dev_addr, uint8_t sub_addr,
|
||||
case 0xAE: /* SDRAM EEPROM, no clue which one */
|
||||
if (tr_type) { /* read */
|
||||
if (sub_addr != 2) {
|
||||
cout << "Unsupported read position 0x" << hex << (int)sub_addr
|
||||
<< " in SDRAM EEPROM 0x" << hex << (int)dev_addr1;
|
||||
LOG_F(ERROR, "Unsupported read position 0x%x in SDRAM EEPROM 0x%x", \
|
||||
(int)sub_addr, (int)dev_addr1);
|
||||
return;
|
||||
}
|
||||
/* FIXME: hardcoded SPD EEPROM values! This should be a proper
|
||||
@ -338,7 +338,7 @@ void ViaCuda::i2c_comb_transaction(uint8_t dev_addr, uint8_t sub_addr,
|
||||
}
|
||||
break;
|
||||
default:
|
||||
cout << "Unsupported I2C device 0x" << hex << (int)dev_addr1 << endl;
|
||||
LOG_F(ERROR, "Unsupported I2C device 0x%x \n", (int)dev_addr1);
|
||||
cuda_error_response(CUDA_ERR_I2C);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user