12 changes: 10 additions & 2 deletions Source/UnitTests/Core/DSP/HermesBinary.cpp
@@ -1,5 +1,13 @@
// Copyright 2017 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
/* DSP_MIXER -> PCM VOICE SOFTWARE PROCESSOR (8-16 Bits Mono/Stereo Voices)
// Thanks to Duddie for you hard work and documentation
Copyright (c) 2008 Hermes <www.entuwii.net>
All rights reserved.
SPDX-License-Identifier: BSD-3-Clause
*/

#include "HermesBinary.h"

Expand Down
Expand Up @@ -9,7 +9,9 @@ SPDX-License-Identifier: BSD-3-Clause
*/

#include "HermesText.h"

const char s_hermes_text[21370] = R"(
/********************************/
/** REGISTER NAMES **/
/********************************/
Expand Down Expand Up @@ -173,7 +175,7 @@ MEM_SND: equ data_end ; it need 2048 words (4096 bytes)
lri $CONFIG, #0xff
lri $SR,#0
s40
s16
clr15
m0
Expand Down Expand Up @@ -254,7 +256,7 @@ MEM_SND: equ data_end ; it need 2048 words (4096 bytes)
jmp recv_cmd
run_nexttask:
s40
s16
call wait_for_cpu_mail
lrs $29,@CMBL
call wait_for_cpu_mail
Expand Down Expand Up @@ -542,7 +544,11 @@ MEM_SND: equ data_end ; it need 2048 words (4096 bytes)
/////////////////////////////////////
// end of delay time section
/////////////////////////////////////

)" // Work around C2026 on MSVC, which allows at most 16380 single-byte characters in a single
// non-concatenated string literal (but you can concatenate multiple shorter string literals to
// produce a longer string just fine). (This comment is not part of the actual test program,
// and instead there is a single blank line at this location.)
R"(
/* bucle de generacion de samples */
Expand Down Expand Up @@ -655,7 +661,7 @@ MEM_SND: equ data_end ; it need 2048 words (4096 bytes)
cmp
jrl $AR0 //get_sample or get_sample2 method
jrnc $AR0 //get_sample or get_sample2 method
sr @COUNTERH_SMP, $ACH1
sr @COUNTERL_SMP, $ACM1
Expand Down Expand Up @@ -711,7 +717,7 @@ MEM_SND: equ data_end ; it need 2048 words (4096 bytes)
// if addr>addr end get a new buffer (if you uses double buffer)
jge get_new_buffer
jc get_new_buffer
// load samples from dma, return $ar2 with the addr to get the samples and return using $ar0 to the routine to process 8-16bits Mono/Stereo
Expand Down Expand Up @@ -741,7 +747,7 @@ MEM_SND: equ data_end ; it need 2048 words (4096 bytes)
// compares if the current address is >= end address to change the buffer or stops
cmp
jge get_new_buffer
jc get_new_buffer
// load the new sample from the buffer
Expand Down Expand Up @@ -961,8 +967,8 @@ MEM_SND: equ data_end ; it need 2048 words (4096 bytes)
wait_for_dsp_mail:
lrs $ACM1, @DMBH
andf $ACM1, #0x8000
jnz wait_for_dsp_mail
andcf $ACM1, #0x8000
jlz wait_for_dsp_mail
ret
wait_for_cpu_mail:
Expand Down Expand Up @@ -1077,4 +1083,4 @@ MEM_SND: equ data_end ; it need 2048 words (4096 bytes)
clr $ACC0
jmp recv_cmd

)";
8 changes: 8 additions & 0 deletions Source/UnitTests/Core/DSP/HermesText.h
@@ -0,0 +1,8 @@
// Copyright 2022 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later

#pragma once

#include <string>

extern const char s_hermes_text[21370];
20 changes: 12 additions & 8 deletions Source/UnitTests/Core/PageFaultTest.cpp
Expand Up @@ -2,6 +2,7 @@
// SPDX-License-Identifier: GPL-2.0-or-later

#include <chrono>
#include <fmt/format.h>

#include "Common/CommonTypes.h"
#include "Common/Timer.h"
Expand Down Expand Up @@ -79,16 +80,19 @@ TEST(PageFault, PageFault)
perform_invalid_access(data);
auto end = std::chrono::high_resolution_clock::now();

#define AS_NS(diff) \
((unsigned long long)std::chrono::duration_cast<std::chrono::nanoseconds>(diff).count())
auto difference_in_nanoseconds = [](auto start, auto end) {
return std::chrono::duration_cast<std::chrono::nanoseconds>(end - start).count();
};

EMM::UninstallExceptionHandler();
JitInterface::SetJit(nullptr);

printf("page fault timing:\n");
printf("start->HandleFault %llu ns\n", AS_NS(pfjit.m_pre_unprotect_time - start));
printf("UnWriteProtectMemory %llu ns\n",
AS_NS(pfjit.m_post_unprotect_time - pfjit.m_pre_unprotect_time));
printf("HandleFault->end %llu ns\n", AS_NS(end - pfjit.m_post_unprotect_time));
printf("total %llu ns\n", AS_NS(end - start));
fmt::print("page fault timing:\n");
fmt::print("start->HandleFault {} ns\n",
difference_in_nanoseconds(start, pfjit.m_pre_unprotect_time));
fmt::print("UnWriteProtectMemory {} ns\n",
difference_in_nanoseconds(pfjit.m_pre_unprotect_time, pfjit.m_post_unprotect_time));
fmt::print("HandleFault->end {} ns\n",
difference_in_nanoseconds(pfjit.m_post_unprotect_time, end));
fmt::print("total {} ns\n", difference_in_nanoseconds(start, end));
}
2 changes: 2 additions & 0 deletions Source/UnitTests/UnitTests.vcxproj
Expand Up @@ -28,6 +28,7 @@
<ClInclude Include="Core\DSP\DSPTestBinary.h" />
<ClInclude Include="Core\DSP\DSPTestText.h" />
<ClInclude Include="Core\DSP\HermesBinary.h" />
<ClInclude Include="Core\DSP\HermesText.h" />
<ClInclude Include="Core\IOS\ES\TestBinaryData.h" />
<ClInclude Include="Core\PowerPC\TestValues.h" />
</ItemGroup>
Expand Down Expand Up @@ -60,6 +61,7 @@
<ClCompile Include="Core\DSP\DSPTestBinary.cpp" />
<ClCompile Include="Core\DSP\DSPTestText.cpp" />
<ClCompile Include="Core\DSP\HermesBinary.cpp" />
<ClCompile Include="Core\DSP\HermesText.cpp" />
<ClCompile Include="Core\IOS\ES\FormatsTest.cpp" />
<ClCompile Include="Core\IOS\FS\FileSystemTest.cpp" />
<ClCompile Include="Core\MMIOTest.cpp" />
Expand Down