Skip to content

Commit 6da691f

Browse files
joevtdingusdev
authored andcommitted
atimach64gx: Change logging.
1 parent 8f64d35 commit 6da691f

2 files changed

Lines changed: 35 additions & 27 deletions

File tree

devices/video/atimach64gx.cpp

Lines changed: 34 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
3434

3535
#include <string>
3636

37+
namespace loguru {
38+
enum : Verbosity {
39+
Verbosity_ATIMACH64 = loguru::Verbosity_9,
40+
Verbosity_ATIINTERRUPT = loguru::Verbosity_9,
41+
Verbosity_ATICURSOR = loguru::Verbosity_9
42+
};
43+
}
44+
3745
/* Human readable Mach64 HW register names for easier debugging. */
3846
static const std::map<uint16_t, std::string> mach64_reg_names = {
3947
#define one_reg_name(x) {ATI_ ## x, #x}
@@ -106,7 +114,7 @@ static const std::map<uint16_t, std::string> mach64_reg_names = {
106114
#undef one_reg_name
107115
};
108116

109-
static const std::map<uint16_t, std::string> rgb514_reg_names = {
117+
static const std::map<uint16_t, std::string> rgb514_ind_reg_names = {
110118
#define one_reg_name(x) {Rgb514::x, #x}
111119
one_reg_name(MISC_CLK_CNTL),
112120
one_reg_name(HOR_SYNC_POS),
@@ -288,7 +296,7 @@ bool AtiMach64Gx::pci_io_read(uint32_t offset, uint32_t size, uint32_t* res)
288296
// CONFIG_CNTL is accessible from I/O space only
289297
if ((offset >> 2) == ATI_CONFIG_CNTL) {
290298
result = read_mem(((uint8_t *)&this->config_cntl) + (offset & 3), size);
291-
LOG_F(WARNING, "%s: read %s %04x.%c = %0*x", this->name.c_str(),
299+
LOG_F(ATIMACH64, "%s: read %s %04x.%c = %0*x", this->name.c_str(),
292300
get_reg_name(offset >> 2), offset, SIZE_ARG(size), size * 2, (uint32_t)result);
293301
} else {
294302
result = BYTESWAP_SIZED(this->read_reg(offset, size), size);
@@ -407,27 +415,27 @@ uint32_t AtiMach64Gx::read_reg(uint32_t reg_offset, uint32_t size)
407415
int_cntl_count++;
408416
else {
409417
if (int_cntl_count > 1)
410-
LOG_F(WARNING, "%s: read %s %04x.%c = %0*x (%lld times)", this->name.c_str(),
418+
LOG_F(ATIINTERRUPT, "%s: read %s %04x.%c = %0*x (%lld times)", this->name.c_str(),
411419
get_reg_name(reg_num), reg_offset, SIZE_ARG(size), size * 2, (uint32_t)last_int_cntl_val, int_cntl_count);
412-
LOG_F(WARNING, "%s: read %s %04x.%c = %0*x", this->name.c_str(),
420+
LOG_F(ATIINTERRUPT, "%s: read %s %04x.%c = %0*x", this->name.c_str(),
413421
get_reg_name(reg_num), reg_offset, SIZE_ARG(size), size * 2, (uint32_t)result);
414422
int_cntl_count = 1;
415423
last_int_cntl_val = int_cntl_val;
416424
}
417425
}
418426
else {
419427
last_int_cntl_val = -1;
420-
LOG_F(WARNING, "%s: read %s %04x.%c = %0*x", this->name.c_str(),
428+
LOG_F(ATIMACH64, "%s: read %s %04x.%c = %0*x", this->name.c_str(),
421429
get_reg_name(reg_num), reg_offset, SIZE_ARG(size), size * 2, (uint32_t)result);
422430
}
423431

424432
return static_cast<uint32_t>(result);
425433
}
426434

427-
#define WRITE_VALUE_AND_LOG() \
435+
#define WRITE_VALUE_AND_LOG(level) \
428436
do { \
429437
this->regs[reg_num] = new_value; \
430-
LOG_F(9, "%s: write %s %04x.%c = %0*x = %08x", this->name.c_str(), \
438+
LOG_F(level, "%s: write %s %04x.%c = %0*x = %08x", this->name.c_str(), \
431439
get_reg_name(reg_num), reg_offset, SIZE_ARG(size), size * 2, \
432440
(uint32_t)extract_bits<uint64_t>(value, offset * 8, size * 8), new_value \
433441
); \
@@ -452,15 +460,14 @@ void AtiMach64Gx::write_reg(uint32_t reg_offset, uint32_t value, uint32_t size)
452460
switch (reg_num) {
453461
case ATI_CRTC_H_TOTAL_DISP:
454462
new_value = value;
455-
LOG_F(9, "%s: ATI_CRTC_H_TOTAL_DISP set to 0x%08X", this->name.c_str(), value);
456463
break;
457464
case ATI_CRTC_VLINE_CRNT_VLINE:
458465
new_value = old_value;
459466
insert_bits<uint32_t>(new_value, value, ATI_CRTC_VLINE, ATI_CRTC_VLINE_size);
460467
break;
461468
case ATI_CRTC_OFF_PITCH:
462469
new_value = value;
463-
WRITE_VALUE_AND_LOG();
470+
WRITE_VALUE_AND_LOG(ATIMACH64);
464471
this->crtc_update();
465472
return;
466473
case ATI_CRTC_INT_CNTL:
@@ -530,7 +537,8 @@ void AtiMach64Gx::write_reg(uint32_t reg_offset, uint32_t value, uint32_t size)
530537
bits_read_only |= bits_not_AKed; // the not AKed bits will remain unchanged
531538

532539
new_value = (old_value & bits_read_only) | (new_value & ~bits_read_only);
533-
break;
540+
WRITE_VALUE_AND_LOG(ATIINTERRUPT);
541+
return;
534542
}
535543
case ATI_CRTC_GEN_CNTL:
536544
{
@@ -558,8 +566,6 @@ void AtiMach64Gx::write_reg(uint32_t reg_offset, uint32_t value, uint32_t size)
558566

559567
new_value = (old_value & bits_read_only) | (new_value & ~bits_read_only);
560568

561-
WRITE_VALUE_AND_LOG();
562-
563569
if (bit_changed(old_value, new_value, ATI_CRTC_DISPLAY_DIS)) {
564570
if (bit_set(new_value, ATI_CRTC_DISPLAY_DIS)) {
565571
this->blank_on = true;
@@ -569,6 +575,8 @@ void AtiMach64Gx::write_reg(uint32_t reg_offset, uint32_t value, uint32_t size)
569575
}
570576
}
571577

578+
WRITE_VALUE_AND_LOG(ATIMACH64);
579+
572580
if (bit_changed(old_value, new_value, ATI_CRTC_ENABLE)) {
573581
draw_fb = true;
574582
this->crtc_update();
@@ -579,7 +587,7 @@ void AtiMach64Gx::write_reg(uint32_t reg_offset, uint32_t value, uint32_t size)
579587
case ATI_OVR_WID_LEFT_RIGHT:
580588
case ATI_OVR_WID_TOP_BOTTOM:
581589
new_value = value;
582-
WRITE_VALUE_AND_LOG();
590+
WRITE_VALUE_AND_LOG(ATIMACH64);
583591
if (value != 0) {
584592
LOG_F(ERROR, "%s: Unhandled value 0x%08x.", this->name.c_str(), value);
585593
}
@@ -589,14 +597,14 @@ void AtiMach64Gx::write_reg(uint32_t reg_offset, uint32_t value, uint32_t size)
589597
new_value = value;
590598
this->cursor_dirty = true;
591599
draw_fb = true;
592-
WRITE_VALUE_AND_LOG();
600+
WRITE_VALUE_AND_LOG(ATICURSOR);
593601
return;
594602
case ATI_CUR_OFFSET:
595603
new_value = value;
596604
if (old_value != new_value)
597605
this->cursor_dirty = true;
598606
draw_fb = true;
599-
WRITE_VALUE_AND_LOG();
607+
WRITE_VALUE_AND_LOG(ATICURSOR);
600608
return;
601609
case ATI_CUR_HORZ_VERT_OFF:
602610
new_value = value;
@@ -606,16 +614,16 @@ void AtiMach64Gx::write_reg(uint32_t reg_offset, uint32_t value, uint32_t size)
606614
)
607615
this->cursor_dirty = true;
608616
draw_fb = true;
609-
WRITE_VALUE_AND_LOG();
617+
WRITE_VALUE_AND_LOG(ATICURSOR);
610618
return;
611619
case ATI_CUR_HORZ_VERT_POSN:
612620
new_value = value;
613621
draw_fb = true;
614-
WRITE_VALUE_AND_LOG();
622+
WRITE_VALUE_AND_LOG(ATICURSOR);
615623
return;
616624
case ATI_DAC_REGS:
617625
new_value = old_value; // no change
618-
WRITE_VALUE_AND_LOG();
626+
WRITE_VALUE_AND_LOG(ATIMACH64);
619627
if (size == 1) { // only byte accesses are allowed for DAC registers
620628
int dac_reg_addr = ((this->regs[ATI_DAC_CNTL] & 1) << 2) | offset;
621629
rgb514_write_reg(dac_reg_addr, extract_bits<uint32_t>(value, offset * 8, 8));
@@ -642,7 +650,7 @@ void AtiMach64Gx::write_reg(uint32_t reg_offset, uint32_t value, uint32_t size)
642650
break;
643651
}
644652

645-
WRITE_VALUE_AND_LOG();
653+
WRITE_VALUE_AND_LOG(ATIMACH64);
646654
}
647655

648656
uint32_t AtiMach64Gx::read(uint32_t rgn_start, uint32_t offset, int size)
@@ -928,7 +936,7 @@ int AtiMach64Gx::device_postinit()
928936
#endif
929937
0;
930938

931-
LOG_F(WARNING, "%s: irq_line_state:%d do_interrupt:%d CRTC_INT_CNTL:%08x",
939+
LOG_F(ATIINTERRUPT, "%s: irq_line_state:%d do_interrupt:%d CRTC_INT_CNTL:%08x",
932940
this->name.c_str(), irq_line_state, do_interrupt,
933941
this->regs[ATI_CRTC_INT_CNTL]);
934942

@@ -976,21 +984,21 @@ void AtiMach64Gx::rgb514_write_reg(uint8_t reg_addr, uint8_t value)
976984
}
977985
}
978986

979-
const char* AtiMach64Gx::rgb514_get_reg_name(uint32_t reg_addr)
987+
const char* AtiMach64Gx::rgb514_get_ind_reg_name(uint32_t reg_addr)
980988
{
981-
auto iter = rgb514_reg_names.find(reg_addr);
982-
if (iter != rgb514_reg_names.end()) {
989+
auto iter = rgb514_ind_reg_names.find(reg_addr);
990+
if (iter != rgb514_ind_reg_names.end()) {
983991
return iter->second.c_str();
984992
} else {
985-
return "unknown rgb514 register";
993+
return "unknown indirect rgb514 register";
986994
}
987995
}
988996

989997
void AtiMach64Gx::rgb514_write_ind_reg(uint8_t reg_addr, uint8_t value)
990998
{
991999
this->dac_regs[reg_addr] = value;
992-
LOG_F(WARNING, "%s.rgb514: write %s %04x.b = %02x", this->name.c_str(),
993-
rgb514_get_reg_name(reg_addr), reg_addr, value
1000+
LOG_F(ATIMACH64, "%s.rgb514: write %s %04x.b = %02x", this->name.c_str(),
1001+
rgb514_get_ind_reg_name(reg_addr), reg_addr, value
9941002
);
9951003

9961004
switch (reg_addr) {

devices/video/atimach64gx.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class AtiMach64Gx : public PCIDevice, public VideoCtrlBase {
6060
protected:
6161
void notify_bar_change(int bar_num);
6262
const char* get_reg_name(uint32_t reg_offset);
63-
const char* rgb514_get_reg_name(uint32_t reg_offset);
63+
const char* rgb514_get_ind_reg_name(uint32_t reg_offset);
6464
bool io_access_allowed(uint32_t offset);
6565
uint32_t read_reg(uint32_t reg_offset, uint32_t size);
6666
void write_reg(uint32_t reg_offset, uint32_t value, uint32_t size);

0 commit comments

Comments
 (0)