From 37d163cd1bfcd6d8aa1241f8ea4c2e64f6e6074a Mon Sep 17 00:00:00 2001 From: yz70s Date: Mon, 6 Jan 2020 18:04:52 +0100 Subject: naomi: give the ability to activate the cpus in the dimm board to test it (nw) In naomigh.h change constant work_mode to 1 and build again. For now it cannot access the gdrom drive but the communication with the pic should work (routine at c0273cc in the default bios) --- src/mame/machine/naomigd.cpp | 33 +++++++++++++++++++++++++-------- src/mame/machine/naomigd.h | 2 ++ 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/src/mame/machine/naomigd.cpp b/src/mame/machine/naomigd.cpp index 34b8364eaf9..4de880b3548 100644 --- a/src/mame/machine/naomigd.cpp +++ b/src/mame/machine/naomigd.cpp @@ -493,7 +493,7 @@ WRITE32_MEMBER(naomi_gdrom_board::memorymanager_w) else src = src + 0x0c000000; dst = dst - 0x10000000; - ddtdata.buffer = dimm_data + dst; // TODO: access des encrypted data + ddtdata.buffer = dimm_des_data + dst; ddtdata.source = src; ddtdata.length = len; ddtdata.size = 4; @@ -510,7 +510,7 @@ WRITE32_MEMBER(naomi_gdrom_board::memorymanager_w) else dst = dst + 0xc000000; src = src - 0x10000000; - ddtdata.buffer = dimm_data + src; // TODO: access des encrypted data + ddtdata.buffer = dimm_des_data + src; ddtdata.destination = dst; ddtdata.length = len; ddtdata.size = 4; @@ -799,6 +799,7 @@ void naomi_gdrom_board::device_start() naomi_board::device_start(); dimm_data = nullptr; + dimm_des_data = nullptr; dimm_data_size = 0; char name[128]; @@ -808,6 +809,15 @@ void naomi_gdrom_board::device_start() uint8_t netpic = 0; + logerror("Work mode is %d\n", work_mode); + if (work_mode != 0) + { + dimm_command = 0; + dimm_offsetl = 0; + dimm_parameterl = 0; + dimm_parameterh = 0; + } + if(picdata) { if(picdata.length() >= 0x4000) { printf("Real PIC binary found\n"); @@ -903,22 +913,26 @@ void naomi_gdrom_board::device_start() uint32_t file_rounded_size = (file_size + 2047) & -2048; for (dimm_data_size = 4096; dimm_data_size < file_rounded_size; dimm_data_size <<= 1); dimm_data = auto_alloc_array(machine(), uint8_t, dimm_data_size); + if (work_mode == 0) + dimm_des_data = dimm_data; + else + dimm_des_data = auto_alloc_array(machine(), uint8_t, dimm_data_size); if (dimm_data_size != file_rounded_size) memset(dimm_data + file_rounded_size, 0, dimm_data_size - file_rounded_size); - // read encrypted data into dimm_data + // read encrypted data into dimm_des_data uint32_t sectors = file_rounded_size / 2048; for (uint32_t sec = 0; sec != sectors; sec++) - cdrom_read_data(gdromfile, file_start + sec, dimm_data + 2048 * sec, CD_TRACK_MODE1); + cdrom_read_data(gdromfile, file_start + sec, dimm_des_data + 2048 * sec, CD_TRACK_MODE1); uint32_t des_subkeys[32]; des_generate_subkeys(rev64(key), des_subkeys); + // decrypt read data from dimm_des_data to dimm_data for (int i = 0; i < file_rounded_size; i += 8) - write_from_qword(dimm_data + i, rev64(des_encrypt_decrypt(true, rev64(read_to_qword(dimm_data + i)), des_subkeys))); + write_from_qword(dimm_data + i, rev64(des_encrypt_decrypt(true, rev64(read_to_qword(dimm_des_data + i)), des_subkeys))); } - // decrypt loaded data cdrom_close(gdromfile); if(!dimm_data) @@ -992,8 +1006,11 @@ void naomi_gdrom_board::device_add_mconfig(machine_config &config) m_i2c1->set_e0(1); m_i2c1->set_wc(1); EEPROM_93C46_8BIT(config, m_eeprom, 0); - m_maincpu->set_disable(); - m_securitycpu->set_disable(); + if (work_mode == 0) + { + m_maincpu->set_disable(); + m_securitycpu->set_disable(); + } } // DIMM firmwares: diff --git a/src/mame/machine/naomigd.h b/src/mame/machine/naomigd.h index 78269e77a2b..8ba2b20e2bf 100644 --- a/src/mame/machine/naomigd.h +++ b/src/mame/machine/naomigd.h @@ -93,6 +93,7 @@ protected: private: enum { FILENAME_LENGTH=24 }; + const int work_mode = 0; // set to 1 and rebuild to enable the cpus required_device m_maincpu; required_device m_securitycpu; @@ -118,6 +119,7 @@ private: uint32_t memctl_regs[0x100 / 4]; // Note: voluntarily not saved into the state + uint8_t *dimm_des_data; uint8_t *dimm_data; uint32_t dimm_data_size; -- cgit v1.2.3