oxidecomputer / amd-apcb

AMD Generic Encapsulated Software Architecture Platform Security Processor Configuration Block manipulation library
Mozilla Public License 2.0
13 stars 1 forks source link

sharable documentation on the fields and meanings #98

Open daym opened 12 months ago

daym commented 12 months ago

hanetzer asked:

any kind of sharable documentation on the fields and meanings and such?

daym commented 12 months ago

Yeah, we could add some more documentation on what the entire structs mean and what the PSP is doing with them overall.

As for fields, there are docstrings on a lot of fields--and using cargo doc, you should see them (the documents created by cargo doc describe the public interface). These docstrings are also in the JSON schema generated by the schemars feature, and of course are in the source code (mostly in src/ondisk.rs ).

hanetzer commented 12 months ago

nice, yeah. As much as I appreciate source, I'm not a native rust speaker, so making heads and tails of it is tricky for me. where do the json schemas end up? and what filetype is that?

daym commented 11 months ago

You can make it dump the schema via this program:

use std::error::Error;
use std::fs::File;
use std::io::BufWriter;
use std::io::Write;
use schemars::schema_for;
use amd_apcb::Apcb;

fn main() -> Result<(), Box<dyn Error>> {
    let schema = schema_for!(Apcb);
    let file = File::create("/tmp/Q.json")?;
    let mut writer = BufWriter::new(file);
    serde_json::to_writer(&mut writer, &schema)?;
    writer.flush()?;
    Ok(())
}

The result is a json schema (in json). You can use any JSON schema aware editor to edit your config files. I use IntelliJ IDEA. You can associate the schema in the editor at the bottom statusbar. If you use emacs, there is also https://emacs-lsp.github.io/lsp-mode/page/lsp-json/ . For vi, there is https://github.com/Quramy/vison .

To be clear, you open up the config you already have in the editor and then you associate a schema with that file in the editor program.

image

image

image

There's a program to generate the schema out of the box (and the entire flash editing), but it's in review.