Skip to main content

Crate fic

Crate fic 

Source
Expand description

Fiducia Language Compiler

A Rust compiler for the Fiducia language, targeting seL4 Microkit systems. Fiducia describes system architecture (memory regions, protection domains, channels) in .fis files and per-PD implementations (imports, memory mappings) in .fi files, then compiles them to the System Description Format (SDF) XML consumed by Microkit.

§Fiducia Language Specification

Fiducia is a system-architecture language for seL4 Microkit embedded systems. It separates system structure (memory, isolation domains, channels) from per-domain behaviour (imported C/Pancake code, memory mappings, boot-time initialisation).

§Project Layout

A Fiducia project is a directory containing:

  • Exactly one .fis file — the system description
  • One .fi file per protection domain named in the System declaration (filename stem must match the PD name, e.g. eth_outer.fi implements eth_outer)
  • The foreign sources the programs import (import "c/eth.h" as eth;): .h/.c (C), .rs (Rust crate root), .pnk (Pancake). fic reads them to learn their exported functions, so eth.send(..) is checked against c/eth.h at --check time
my_project/
  system.fis          # system description
  eth_outer.fi        # implements PD eth_outer
  eth_inner.fi        # implements PD eth_inner
  dd.fi               # implements PD dd
  c/eth.h, c/eth.c    # a driver: the header is the interface, the .c is linked

§Comments

Both .fis and .fi files support C-style comments:

// line comment
/* block comment */

§Numeric Literals

All addresses, sizes, and priorities are written as integer literals:

  • Decimal — 100, 254, 1000
  • Hexadecimal — 0x1000, 0x200000, 0xFE00_0000
  • Underscores are allowed as digit separators in hex literals: 0x3_000_000

§Quick Start

Parse a system description:

let input = r#"
MemoryRegion uart(0x1000);
ProtectionDomain driver(100);
ProtectionDomain app(200);
Chan notify = driver <-> app;
System = driver ||| app;
"#;

let system = fic::parser::parse_system(input).unwrap();
assert_eq!(system.protection_domains.len(), 2);

Lower to SDF IR and inspect:

let system = fic::parser::parse_system("ProtectionDomain test(100, 7); MemoryRegion buf(0x1000);").unwrap();
// One program per protection domain, by position; every program binds
// both kernel entry points, its handler here awaiting the PD's IRQ.
let programs = vec![fic::parser::parse_program(
    "@bind(microkit.init) proc Init() { Skip; }\n\
     @bind(microkit.notified) proc Notified() { irq?7 -> Notified(); }",
).unwrap()];
let rawast = fic::ast::RawAst { system, programs };
let (env, tenv) = fic::frontend::data_layer(&rawast).unwrap();
let front = fic::frontend::front_end(&rawast, &mut fic::foreign::ForeignModules::new(), env, tenv).unwrap();
let args = microkit_tool::argparse::Args {
  sdf_path: std::path::Path::new("").to_path_buf(),
  board: "qemu_virt_aarch64".to_string(),
  config: "debug".to_string(),
  report_path: std::path::Path::new("report.txt").to_path_buf(),
  capdl_json_path: None,
  viper_output_dir: None,
  output_path: std::path::Path::new("test.img").to_path_buf(),
  search_paths: vec![],
  requested_image_type: microkit_tool::argparse::RequestedImageType::Unspecified,
  override_kernel: None,
};
let sdk = microkit_tool::sdk::Sdk::discover().unwrap();
let config = microkit_tool::sel4::Config::build_kernel_config(&args, &sdk).unwrap();

let sdf = fic::microkit::to_sdf(&config, &front.tenv).unwrap();
assert_eq!(sdf.memory_regions.len(), 1);
assert_eq!(sdf.memory_regions[0].name, "buf");

Parse a program implementation:

let input = r#"
import "eth.c" as eth;
Mapping ring_buffer(ring_buffer_outer, "rw", false);
"#;

let program = fic::parser::parse_program(input).unwrap();
assert_eq!(program.imports.len(), 1);
assert_eq!(program.mappings.len(), 1);

Modules§

ast
The AST: the nodes the parsers produce for a .fis (the system description) and a .fi (a protection domain’s program), one file per node family, flat-re-exported here, and RawAst, the project: the one node over both, so neither file imports the other. parser/ depends on this module, never the reverse.
base
base, what every layer after resolution shares: the ids and arenas (id.rs), a dbg argument (dbg.rs), a type as written with its names resolved (types.rs), the references a body’s names resolve to (refs.rs), and the declarations resolution fixes and typing never changes (env.rs). rast and tast each define the declarations that change between them; neither owns these.
c_backend
The C backend: each PD’s translation unit, its Orchestration printed as one C state machine.
ccfg
The communicating control-flow graph (Ccfg), the IR every backend reads.
emit
Emit targets: lower the compiled AST to output formats.
error
Compiler diagnostic types for the Fiducia language.
foreign
Foreign declarations: the functions a program can call through an import "file" as alias;, and the readers that produce them from the imported source. No toolchain is embedded beyond what a reader itself needs (libclang for C; the Pancake reader and this module’s own types need nothing).
frontend
The front end: a project parsed (parse), resolved (resolve) and typed (front_end), printing the progress lines. Contracts (contracts), information flow and WF2 run only for the targets that need them.
microkit
seL4 Microkit, the platform fic targets: a PD’s kernel entry points (EntryPoints), the system as Microkit’s SDF (to_sdf) and the bootable image built from both (Image).
middle
The middle end (middle): the typed AST lowered to every program’s graphs, and the checks and passes over them. The backends read what it returns.
parser
Parser module for the Fiducia language
rast
rast, the resolved AST: the program as written, with every name an id.
tast
tast, the typed AST: rast with every declaration and expression carrying its type, as two parts: TyEnv, the typed environment (the declarations), and Bodies, the typed bodies.
ty
What tast’s types are built from: foreign lowers foreign-language spellings to fic scalars, one implementation per language; width is a fic width’s Rust integer type, and value a constant’s value in it.
wfcheck
The well-formedness checks (WellFormed.lean, Microkit.lean): the hypotheses of the flattening theorem and the backends that no typing rule states.
xta_backend
The XTA backend: the UPPAAL timed-automata model (--emit=xta).