diff --git a/app/DTNode.tsx b/app/DTNode.tsx
index 5cdf221..2813e65 100644
--- a/app/DTNode.tsx
+++ b/app/DTNode.tsx
@@ -1,16 +1,122 @@
import { memo, useState } from "react";
import { Handle, NodeProps, Position } from "reactflow";
+import compatDb from "./compat-db.json";
-const style = {
- // wordWrap: "break-word",
- whiteSpace: "pre-wrap" as "pre-wrap", // This is weird, TypoScripto...
- padding: 4,
- border: "2px solid",
- background: "#0c0c0c",
- color: "#fff",
- width: 150,
- fontSize: 11,
- fontFamily: "Fira Code",
+type DTStatus = "okay" | "disabled";
+
+type DotColor = "blue" | "red";
+
+const getDotColor = (status?: DTStatus): DotColor | null => {
+ switch(status) {
+ case "okay": return "blue";
+ case "disabled": return "red";
+ default: return null;
+ }
+}
+
+export const Dot: FC<{ status?: DTStatus }> = ({ status }) => {
+ if (!status) {
+ return null;
+ }
+ const color = getDotColor(status);
+ return (
+
+
+
+ );
+};
+
+const docsbaseUrl = "https://docs.kernel.org"
+const dtBaseUrl = "https://www.kernel.org/doc/Documentation/devicetree/bindings";
+
+type DocsCategory = "binding" | "docs";
+
+type DocsEntry = {
+ category: DocsCategory;
+ path: string;
+};
+
+const getBaseUrl = (category: DocsCategory): string => {
+ switch(category) {
+ case "binding": return dtBaseUrl;
+ case "docs": return docsbaseUrl;
+ }
+};
+
+const getDocUrl = (compat: string) => {
+ const res = compat.split(";").find((c) => !!compatDb[c]);
+ if (!res) {
+ return null;
+ }
+ const d = compatDb[res];
+ const baseUrl = getBaseUrl(d.category);
+ return `${baseUrl}/${d.path}`;
+}
+
+const Compat: FC<{ compat?: string; }> = ({ compat }) => {
+ if (!compat) {
+ return null;
+ }
+ const docUrl = getDocUrl(compat);
+
+ if (!docUrl) {
+ return compat;
+ }
+
+ return (
+
+ {compat}
+
+
+ );
+};
+
+export const DataNode: FC<{ data: object; status?: DTStatus }> = ({
+ data,
+ status,
+}) => {
+ if (!data) {
+ return null;
+ }
+
+ return (
+
+ {data.label}
+ {data.baseAddr}
+
+
+
+
+ );
};
const DTNode = ({
@@ -19,13 +125,7 @@ const DTNode = ({
targetPosition = Position.Top,
sourcePosition = Position.Bottom
}: NodeProps) => {
- const [hovered, setHovered] = useState(false);
-
- const hoverOn = () => setHovered(true);
- const hoverOff = () => setHovered(false);
-
- const borderColor = hovered ? "#987987" : "#789789";
- const borderStyle = hovered ? "dotted" : "solid";
+ const { status, ...nData } = data;
return (
<>
-
- {data?.label}
-
+
{
const clks = getProp(n, "clocks");
const cnames = getStringProp(n, "clock-names");
const compat = getStringProp(n, "compatible");
+ const status = getStringProp(n, "status");
return {
name,
...(phandle ? { phandle: phandle[0] } : null),
@@ -89,6 +91,7 @@ const transformNode = (n: DTNode): DTNode => {
...(clks ? { clks } : null),
...(cnames ? { cnames } : null),
...(compat ? { compat } : null),
+ ...(status ? { status } : null),
};
};
@@ -150,7 +153,11 @@ export const getNodesEdges = (tree: DTNode) => {
y: baseY + d * NODE_HEIGHT,
},
data: {
- label: `${name}\n${baseAddr}\n${n.size}`,
+ label: name,
+ baseAddr,
+ size: n.size,
+ compat: n.compat,
+ status: n.status,
},
});
let offset = baseX;