From 1adbf90e211fc202a0d58d6a69580da497d708a8 Mon Sep 17 00:00:00 2001 From: Maxim Poliakovski Date: Wed, 3 Feb 2021 23:39:19 +0100 Subject: [PATCH] MPC106: use memaccess thoroughly. --- devices/mpc106.cpp | 35 +++-------------------------------- 1 file changed, 3 insertions(+), 32 deletions(-) diff --git a/devices/mpc106.cpp b/devices/mpc106.cpp index 79a684a..5efdfc3 100644 --- a/devices/mpc106.cpp +++ b/devices/mpc106.cpp @@ -178,21 +178,7 @@ uint32_t MPC106::pci_cfg_read(uint32_t reg_offs, uint32_t size) { LOG_F(9, "read from Grackle register %08X\n", reg_offs); #endif - switch (size) { - case 1: - return this->my_pci_cfg_hdr[reg_offs]; - break; - case 2: - return READ_WORD_BE_A(&this->my_pci_cfg_hdr[reg_offs]); - break; - case 4: - return READ_DWORD_BE_A(&this->my_pci_cfg_hdr[reg_offs]); - break; - default: - LOG_F(ERROR, "MPC106 read error: invalid size parameter %d \n", size); - } - - return 0; + return read_mem(&this->my_pci_cfg_hdr[reg_offs], size); } void MPC106::pci_cfg_write(uint32_t reg_offs, uint32_t value, uint32_t size) { @@ -201,23 +187,8 @@ void MPC106::pci_cfg_write(uint32_t reg_offs, uint32_t value, uint32_t size) { #endif // FIXME: implement write-protection for read-only registers - switch (size) { - case 1: - this->my_pci_cfg_hdr[reg_offs] = value & 0xFF; - break; - case 2: - this->my_pci_cfg_hdr[reg_offs] = (value >> 8) & 0xFF; - this->my_pci_cfg_hdr[reg_offs + 1] = value & 0xFF; - break; - case 4: - this->my_pci_cfg_hdr[reg_offs] = (value >> 24) & 0xFF; - this->my_pci_cfg_hdr[reg_offs + 1] = (value >> 16) & 0xFF; - this->my_pci_cfg_hdr[reg_offs + 2] = (value >> 8) & 0xFF; - this->my_pci_cfg_hdr[reg_offs + 3] = value & 0xFF; - break; - default: - LOG_F(ERROR, "MPC106 read error: invalid size parameter %d \n", size); - } + + write_mem(&this->my_pci_cfg_hdr[reg_offs], value, size); if (this->my_pci_cfg_hdr[0xF2] & 8) { #ifdef MPC106_DEBUG