{"id":29675827,"url":"https://github.com/oxidecomputer/hif","last_synced_at":"2025-07-22T23:38:51.215Z","repository":{"id":45557944,"uuid":"384997249","full_name":"oxidecomputer/hif","owner":"oxidecomputer","description":"HIF: The Hubris/Humility Interchange Format","archived":false,"fork":false,"pushed_at":"2023-09-19T16:14:43.000Z","size":37,"stargazers_count":11,"open_issues_count":1,"forks_count":4,"subscribers_count":25,"default_branch":"master","last_synced_at":"2025-02-10T00:58:06.504Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/oxidecomputer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-07-11T16:23:07.000Z","updated_at":"2024-04-24T15:31:25.000Z","dependencies_parsed_at":"2022-08-23T09:40:11.784Z","dependency_job_id":null,"html_url":"https://github.com/oxidecomputer/hif","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/oxidecomputer/hif","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oxidecomputer%2Fhif","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oxidecomputer%2Fhif/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oxidecomputer%2Fhif/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oxidecomputer%2Fhif/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oxidecomputer","download_url":"https://codeload.github.com/oxidecomputer/hif/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oxidecomputer%2Fhif/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266591233,"owners_count":23953082,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-07-22T23:38:50.314Z","updated_at":"2025-07-22T23:38:51.193Z","avatar_url":"https://github.com/oxidecomputer.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# hif\n\n## HIF: The Hubris/Humility Interchange Format\n\nWhen debugging Hubris, we have found it handy to get a task to execute as\na proxy for an external task.  This was born as an ad hoc facility to\ninduce I2C transactions, effected by the debugger stopping the target and\nwriting parameters to well-known memory locations; as our need for proxy\nbehavior became more sophisticated, it became clear that we needed\nsomething more general purpose.  HIF represents a simple, stack-based\nmachine that can be executed in a memory-constrained no-std environment.\nWhile this was designed to accommodate Hubris and Humility, there is\nnothing specific to either, and may well have other uses.\n\n### Machine model\n\nThe HIF machine model consists of program text consisting of an array of\n`Op` structures denoting operations; a stack of 32-bit values for\narguments and variables; a finite number of branch targets corresponding\nto declared labels in program text; and an append-only return stack that\nconsists of an array of `FunctionResult` enums.  Of note, this model has\nno registers (though such extensions are clearly possible).\n\n### Paramaterization and errors\n\nAs much as possible, HIF tries to be *mechanism* rather than *policy*,\nleaving it up to the entity that interprets HIF to parametarize the\nmachine model (stack size, return area size) and enforce any run-time\nlimits on executed operations.  If errors are encountered in execution\n(due to either illegal operations or running against limits), an error is\nexplicitly returned.\n\n### Serialization/Deserialization\n\nIt is an essential constraint of HIF that it can execute in a `no_std`\nenvironment; for deserialization (of program text) and serialization (of\nthe return stack), HIF uses [postcard](https://crates.io/crates/postcard).\n\n### Functions\n\nA function is denoted by a `TargetFunction` structure that contains a\n`u8` index into the `functions` array passed into `execute`.  HIF makes no\nassumption about what these functions are or how they are discovered; if\nthe program text attempts to call an invalid function, an error returned.\nFunctions themselves are implemented by whomever is calling `execute`; they\ntake the stack, a slice that is a read-only memory, and the (mutable)\nreturn stack as arguments.  Functions are expected to return a failure if\nthe stack contains an incorrect number of arguments, or if the function\nattempts to access memory not contained in the read-only slice, or if the\nreturn stack is too small to contain the return value(s).  Functions do\nnot consume arguments from the stack; callers must explicitly drop\nparameters from the stack if they are no longer needed.\n\n### Labels\n\nThe `Op::Label` operation denotes a target for a branch, allowing\nbranches to be symbolic rather than in terms of text offsets.  Labels are\ncreated on the stack; the number of labels is a const generic paramater to\n`execute`.\n\n### Stack manipulation operations\n\nHIF offers basic stack manipulation operations like `Op::Push`,\n`Op::Dup`, `Op::Swap` and `Op::Drop`.  The call stack is one of\n`Option\u003cu32\u003e`; `Op::PushNone` pushes `None`, while all other push\noperations ultimately push `Some\u003cu32\u003e`.\n\n### Arithmetic operations\n\nHIF offers a paucity of arithmetic operations.  These operations consume\nthe top two elements of the stack, and push the result.\n\n\nLicense: MPL-2.0\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foxidecomputer%2Fhif","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foxidecomputer%2Fhif","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foxidecomputer%2Fhif/lists"}