Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 23 additions & 10 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,24 +110,37 @@ jobs:
needs: check
strategy:
matrix:
arch: [x64, arm64]
runs-on: macos-14
include:
- arch: x64
os: macos-15-intel
host_arch: x86_64
- arch: arm64
os: macos-15
host_arch: arm64
runs-on: ${{matrix.os}}
steps:
- name: Customize Software
- name: Verify Runner Toolchain
shell: bash
run: |
brew install llvm@18
- name: Customize Software
if: ${{ matrix.arch == 'x64' }}
run: |
softwareupdate --install-rosetta --agree-to-license
arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
arch -x86_64 /usr/local/bin/brew install llvm@18
actual_arch="$(uname -m)"
echo "Host architecture: ${actual_arch}"
test "${actual_arch}" = "${{matrix.host_arch}}"

llvm_root="$(brew --prefix llvm@18)"
echo "LLVM root: ${llvm_root}"
test -x "${llvm_root}/bin/clang++"
- name: Checkout
uses: actions/checkout@v6
- name: CMake Configure
run: cmake -B ${{github.workspace}}/BUILD -G "Ninja" -DCMAKE_BUILD_TYPE=Release -DREDUMPER_VERSION_BUILD=${{needs.check.outputs.build_number}} -DCMAKE_TOOLCHAIN_FILE="cmake/toolchains/macos-${{matrix.arch}}.cmake"
- name: CMake Build
run: cmake --build ${{github.workspace}}/BUILD --config Release
- name: Verify Architecture
shell: bash
run: |
binary_arch="$(lipo -archs "${{github.workspace}}/BUILD/redumper")"
echo "Binary architecture: ${binary_arch}"
test "${binary_arch}" = "${{matrix.host_arch}}"
- name: CTest
working-directory: ${{github.workspace}}/BUILD
run: ctest -C Release --output-on-failure --verbose
Expand Down
2 changes: 1 addition & 1 deletion cd/cd_common.ixx
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ export SPTD::Status read_sector(SPTD &sptd, uint8_t *sector, bool &unscrambled,
if(drive_config.read_method == ReadMethod::D8)
{
auto sub_code = drive_config.sector_order == SectorOrder::DATA_SUB ? READ_CDDA_SubCode::DATA_SUB : READ_CDDA_SubCode::DATA_C2_SUB;
status = cmd_read_cdda(sptd, sector_buffer.data(), CD_RAW_DATA_SIZE, lba, sectors_count, sub_code);
status = cmd_read_cdda(sptd, sector_buffer.data(), layout.size, lba, sectors_count, sub_code);
}
else
{
Expand Down
9 changes: 4 additions & 5 deletions cmake/toolchains/macos-x64.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# cross-compiling for x64 using native system compiler
# native x64 compilation
execute_process(COMMAND brew --prefix llvm@18 OUTPUT_VARIABLE LLVM_ROOT OUTPUT_STRIP_TRAILING_WHITESPACE)

set(CMAKE_SYSTEM_NAME Darwin)
Expand All @@ -9,9 +9,8 @@ set(CMAKE_PREFIX_PATH "${LLVM_ROOT}")
set(CMAKE_OSX_DEPLOYMENT_TARGET "12.0")
execute_process(COMMAND xcrun --sdk macosx --show-sdk-path OUTPUT_VARIABLE CMAKE_OSX_SYSROOT OUTPUT_STRIP_TRAILING_WHITESPACE)

# use x64 LLVM libc++ instead of system, arch -x86_64 ensures x64 libs
execute_process(COMMAND arch -x86_64 /usr/local/bin/brew --prefix llvm@18 OUTPUT_VARIABLE LLVM_X64_ROOT OUTPUT_STRIP_TRAILING_WHITESPACE)
set(CMAKE_EXE_LINKER_FLAGS_INIT "-L${LLVM_X64_ROOT}/lib/c++")
# use x64 LLVM libc++ instead of system
set(CMAKE_EXE_LINKER_FLAGS_INIT "-L${LLVM_ROOT}/lib/c++")

# used in CMakeLists.txt to bundle libc++ with the application
set(LLVM_LIB_PATH "${LLVM_X64_ROOT}/lib" CACHE PATH "Path to LLVM libraries")
set(LLVM_LIB_PATH "${LLVM_ROOT}/lib" CACHE PATH "Path to LLVM libraries")
91 changes: 90 additions & 1 deletion debug.ixx
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,95 @@ export int redumper_debug(Context &ctx, Options &options)
std::filesystem::path physical_path(image_prefix + ".physical");
std::filesystem::path sub_path(image_prefix + ".subcode");

if(1)
Comment thread
superg marked this conversation as resolved.
{
SPTD sptd(options.drive, options.scsi_timeout);

auto drive_query = cmd_drive_query(sptd);
bool monitor_mode = drive_query.vendor_id == "PLEXTOR" && drive_query.product_id == "MONT";
bool firmware_mode = drive_query.vendor_id == "PLEXTOR" && drive_query.product_id.find("PX-W5224A") != std::string::npos;

LOG("Plextor boot-state probe");
LOG(" inquiry: {} {} {}", drive_query.vendor_id, drive_query.product_id, drive_query.product_revision_level);
LOG(" active mode: {}", monitor_mode ? "recovery monitor" : firmware_mode ? "normal firmware" : "unknown");

uint8_t port_mask = 0;
for(uint8_t mode = 0; mode <= 4; ++mode)
{
uint8_t cdb[12] = {};
cdb[0] = 0xde;
cdb[1] = mode;

uint8_t response[2] = {};
if(auto status = sptd.sendCommand(cdb, sizeof(cdb), response, sizeof(response)).first; status.status_code)
Comment thread
superg marked this conversation as resolved.
throw_line("DE mode {} probe failed, SCSI ({})", mode, SPTD::StatusMessage(status));

LOG(" DE mode {}: {:02x} {:02x} ({})", mode, response[0], response[1], (uint8_t)(response[0] ^ response[1]) == 0xff ? "complement valid" : "complement invalid");
if(mode == 0)
port_mask = response[0];
}

LOG(" P0.1: {}", port_mask & 0x01 ? "low" : "high");
LOG(" P0.2: {}", port_mask & 0x02 ? "low" : "high");
LOG(" P0.6: {}", port_mask & 0x04 ? "low" : "high");
LOG(" P0.0: {}", port_mask & 0x08 ? "low" : "high");
LOG(" P0.5: {}", port_mask & 0x10 ? "low" : "high");

uint8_t cdb[12] = {};
cdb[0] = 0xf5;
cdb[5] = 0xff;
cdb[6] = 0xc0;
cdb[7] = 0x1e;
cdb[9] = 2;

uint8_t configuration[2] = {};
if(auto status = sptd.sendCommand(cdb, sizeof(cdb), configuration, sizeof(configuration)).first; status.status_code)
throw_line("F5 configuration read failed, SCSI ({})", SPTD::StatusMessage(status));

uint8_t configuration_value = configuration[1];
uint32_t low_count = std::popcount((uint32_t)(port_mask & 0x07));
bool visible_recovery_gates = low_count < 2 && ((port_mask & 0x04) == 0 || configuration_value != 0) && configuration_value != 0x11 && configuration_value != 0x12;

LOG(" configuration entry 0x0f at 0x00ffc01e: {:02x} {:02x}", configuration[0], configuration[1]);
LOG(" forced-recovery gates excluding P1.6: {}", visible_recovery_gates ? "pass" : "fail");
LOG(" P1.6: not observable through DE/F5");
LOG("");
}

if(0)
{
SPTD sptd(options.drive, options.scsi_timeout);

auto read_memory = [&sptd](uint32_t address, uint16_t length)
{
uint8_t cdb[12] = {};
cdb[0] = 0xf5;
cdb[4] = (uint8_t)(address >> 24);
cdb[5] = (uint8_t)(address >> 16);
cdb[6] = (uint8_t)(address >> 8);
cdb[7] = (uint8_t)address;
cdb[8] = (uint8_t)(length >> 8);
cdb[9] = (uint8_t)length;

std::vector<uint8_t> data(length);
if(auto status = sptd.sendCommand(cdb, sizeof(cdb), data.data(), data.size()).first; status.status_code)
throw_line("F5 memory read failed at 0x{:08x}, SCSI ({})", address, SPTD::StatusMessage(status));

return data;
};

std::vector<uint8_t> high_memory;
high_memory.reserve(0x10000);
for(uint32_t address = 0x00ff0000; address < 0x01000000; address += 0x4000)
{
LOG("reading memory at 0x{:08x}", address);
auto chunk = read_memory(address, 0x4000);
high_memory.insert(high_memory.end(), chunk.begin(), chunk.end());
}
write_vector("read_memory_ff0000.debug", high_memory);
LOG("");
}

if(0)
{
// auto ss = read_vector("security_sector3.debug");
Expand Down Expand Up @@ -305,7 +394,7 @@ export int redumper_debug(Context &ctx, Options &options)
}

// MEDIATEK cache dump extract
if(1)
if(0)
{
std::vector<uint8_t> cache = read_vector(cache_path);

Expand Down
Loading