This commit is contained in:
Kirill Zhumarin 2024-06-09 10:11:18 +00:00
parent 3d542da46d
commit 4e84caec79
2 changed files with 85 additions and 48 deletions

View file

@ -1,62 +1,34 @@
import { A } from "@solidjs/router";
import { SWILIB_TOOLS_API } from "~/utils";
import { fetchPhones } from "~/components/Swilib/PhonesTabs";
import { PMB887X_DEV_API, SWILIB_TOOLS_API } from "~/utils";
import { createResource } from "solid-js";
import { Spinner } from "solid-bootstrap";
export async function fetchPhones() {
return (await fetch(`${SWILIB_TOOLS_API}/phones.json`)).json();
}
export async function fetchCpuFiles() {
return (await fetch(`${SWILIB_TOOLS_API}/cpu-files.json`)).json();
}
function ReFiles() {
let [apiResult] = createResource(fetchPhones);
let [phones] = createResource(fetchPhones);
let [cpuFiles] = createResource(fetchCpuFiles);
return (<>
<Show when={apiResult.loading}>
<Show when={phones.loading}>
<Spinner animation="border" role="status">
<span className="visually-hidden">Loading...</span>
</Spinner>
</Show>
<Show when={apiResult.error}>
<Show when={phones.error}>
<div class="alert alert-danger" role="alert">
Can't load data from the server. Please, reload the page.
</div>
</Show>
<Show when={!apiResult.loading && !apiResult.error}>
<h5>CPU IO registers</h5>
<table class="table table-bordered table-hover" style="width: auto">
<thead>
<tr>
<th>
Phone
</th>
<th>
Ghidra
</th>
<th>
IDA Pro
</th>
</tr>
</thead>
<tbody>
<For each={["pmb8876", "pmb8875"]}>{(platform) =>
<tr>
<td>
{platform}
</td>
<td>
<A href={`${SWILIB_TOOLS_API}/registers-${platform}.txt`} target="_blank">
<i class="bi bi-file-earmark-code"></i> registers-{platform}.txt
</A>
</td>
<td>
<A href={`${SWILIB_TOOLS_API}/registers-${platform}.idc`} target="_blank">
<i class="bi bi-file-earmark-code"></i> registers-{platform}.idc
</A>
</td>
</tr>
}</For>
</tbody>
</table>
<Show when={!phones.loading && !phones.error}>
<h5>Swilib data types for dissasembler</h5>
<table class="table table-bordered table-hover" style="width: auto">
<thead>
@ -76,7 +48,7 @@ function ReFiles() {
{platform}
</td>
<td>
<A href={`${SWILIB_TOOLS_API}/swilib-types-${platform}.h`} target="_blank">
<A href={`${SWILIB_TOOLS_API}/swilib-types-${platform}.h`}>
<i class="bi bi-file-earmark-code"></i> swilib-types-{platform}.h
</A>
</td>
@ -85,9 +57,12 @@ function ReFiles() {
</tbody>
</table>
<hr />
<h5>Firmware symbols for dissasembler</h5>
<div class="text-info mb-3">
<i class="bi bi-info-circle"></i> For IDA Pro, only symbol names are available, without associated data types.
</div>
<table class="table table-bordered table-hover" style="width: auto">
<thead>
<tr>
@ -106,7 +81,7 @@ function ReFiles() {
</tr>
</thead>
<tbody>
<For each={apiResult().all}>{(phone) =>
<For each={phones().all}>{(phone) =>
<tr>
<td>
{phone.name}
@ -115,12 +90,12 @@ function ReFiles() {
{phone.platform}
</td>
<td>
<A href={`${SWILIB_TOOLS_API}/symbols-${phone.name}.txt`} target="_blank">
<A href={`${SWILIB_TOOLS_API}/symbols-${phone.name}.txt`}>
<i class="bi bi-file-earmark-code"></i> symbols-{phone.name}.txt
</A>
</td>
<td>
<A href={`${SWILIB_TOOLS_API}/symbols-${phone.name}.idc`} target="_blank">
<A href={`${SWILIB_TOOLS_API}/symbols-${phone.name}.idc`}>
<i class="bi bi-file-earmark-code"></i> symbols-{phone.name}.idc
</A>
</td>
@ -129,6 +104,67 @@ function ReFiles() {
</tbody>
</table>
</Show>
<Show when={cpuFiles.loading}>
<Spinner animation="border" role="status">
<span className="visually-hidden">Loading...</span>
</Spinner>
</Show>
<Show when={cpuFiles.error}>
<div class="alert alert-danger" role="alert">
Can't load data from the server. Please, reload the page.
</div>
</Show>
<Show when={!cpuFiles.loading && !cpuFiles.error}>
<h5>CPU IO registers</h5>
<div class="text-info mb-3">
<i class="bi bi-info-circle"></i> If your device is not listed below, select the generic PMB8875 (for X75 or SG) or PMB8876 (for ELKA or NSG).
</div>
<table class="table table-bordered table-hover" style="width: auto">
<thead>
<tr>
<th>
Device
</th>
<th>
CPU
</th>
<th>
Ghidra
</th>
<th>
IDA Pro
</th>
</tr>
</thead>
<tbody>
<For each={cpuFiles()}>{(file) =>
<tr>
<td>
{file.name}
</td>
<td>
{file.cpu}
</td>
<td>
<A href={`${SWILIB_TOOLS_API}/${file.ghidra}`} download={file.ghidra}>
<i class="bi bi-file-earmark-code"></i> {file.ghidra}
</A>
</td>
<td>
<A href={`${SWILIB_TOOLS_API}/${file.ida}`} download={file.ida}>
<i class="bi bi-file-earmark-code"></i> {file.ida}
</A>
</td>
</tr>
}</For>
</tbody>
</table>
</Show>
</>);
}

View file

@ -1,4 +1,5 @@
export const SWILIB_TOOLS_API = import.meta.env.VITE_SWILIB_TOOLS_API;
export const PMB887X_DEV_API = import.meta.env.VITE_PMB887X_DEV_API;
export function resolveURL(url) {
return `${import.meta.env.BASE_URL}${url}`.replace(/[\/]+/g, '/');