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
15 changes: 13 additions & 2 deletions apps/cli/src/builder/nvram.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,21 @@ import {
MissingNvramSourceError,
NVRAM_ALIGNMENT,
type NvramConfig,
nvramHasImage,
nvramImageFilename,
} from "../config.js";

/**
* Filename, relative to the build destination directory, of the image backing an nvram.
*/
export const nvramImageFilename = (label: string): string => `${label}.raw`;

/**
* Whether an nvram is backed by an image file. A pristine nvram needs no image, as
* cartesi-machine fills its range with zeros. A `shared` one does, as there must be a file for
* the guest writes to be persisted to.
*/
export const nvramHasImage = (nvram: NvramConfig): boolean =>
nvram.filename !== undefined || nvram.shared === true;

export const build = async (
label: string,
nvram: NvramConfig,
Expand Down
2 changes: 1 addition & 1 deletion apps/cli/src/commands/shell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ExecaError } from "execa";
import fs from "fs-extra";
import path from "node:path";
import { getApplicationConfig, getContextPath } from "../base.js";
import { nvramHasImage, nvramImageFilename } from "../config.js";
import { nvramHasImage, nvramImageFilename } from "../builder/nvram.js";
import { bootMachine } from "../machine.js";

export const createShellCommand = () => {
Expand Down
Loading
Loading