# medhansh5/janus architecture

> Architecture diagram of the GitHub repository medhansh5/janus, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-23). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/medhansh5/janus
- Repository: https://github.com/medhansh5/janus

## Overview

Janus is a security-first x86_64 microkernel: boot establishes the kernel environment, then Ring 3 tasks request privileged operations through the syscall ABI. The kernel dispatches calls to IPC and capability checks, while task scheduling, memory management, and hardware interrupt handling support execution. PCI discovery and scoped device access are documented capabilities. The graph reflects sampled kernel modules and README-described behavior; userspace drivers and init are documented, but their implementations are not present in the supplied tree.

Main entry points: [`kernel/src/ipc.rs`](https://github.com/medhansh5/janus/blob/main/kernel/src/ipc.rs) (IPC Dispatch), [`kernel/src/idt.rs`](https://github.com/medhansh5/janus/blob/main/kernel/src/idt.rs) (Interrupt Dispatch), [`kernel/src/syscall.rs`](https://github.com/medhansh5/janus/blob/main/kernel/src/syscall.rs) (Syscall ABI), [`bootloader/src/main.rs`](https://github.com/medhansh5/janus/blob/main/bootloader/src/main.rs) (Bootloader)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_boot["Boot Handoff"]
  node_bootloader["Bootloader<br/>[main.rs]"]
  node_bootinfo["Boot Info<br/>[lib.rs]"]
  node_kernelmain["Kernel Bootstrap<br/>[main.rs]"]
end

subgraph group_boundary["Kernel Boundary"]
  node_syscall["Syscall ABI<br/>[syscall.rs]"]
  node_capability["Capability Table<br/>[capability.rs]"]
  node_ipc["IPC Dispatch<br/>[ipc.rs]"]
end

subgraph group_execution["Task Execution"]
  node_task["Task Scheduler<br/>[task.rs]"]
  node_memory["Frame Allocator<br/>[memory.rs]"]
  node_paging["Virtual Memory<br/>[paging.rs]"]
  node_gdt["GDT and TSS<br/>[gdt.rs]"]
end

subgraph group_hardware["Hardware Services"]
  node_idt["Interrupt Dispatch<br/>[idt.rs]"]
  node_pic["PIC Routing<br/>[pic.rs]"]
  node_pci["PCI Discovery<br/>[pci.rs]"]
end

node_firmware(("UEFI Firmware"))
node_user(("Ring 3 Task"))
node_driver["Userspace Driver"]

node_firmware -->|"starts"| node_bootloader
node_bootloader -.->|"hands off"| node_kernelmain
node_bootinfo -.->|"provides boot data"| node_kernelmain
node_user -->|"invokes"| node_syscall
node_syscall -->|"dispatches calls"| node_ipc
node_ipc -->|"checks handles"| node_capability
node_ipc -->|"blocks or wakes"| node_task
node_task -->|"updates stack"| node_gdt
node_paging -->|"allocates frames"| node_memory
node_idt -->|"uses selectors"| node_gdt
node_idt -->|"acknowledges IRQ"| node_pic
node_idt -->|"wakes IRQ waiters"| node_ipc
node_driver -->|"uses capabilities"| node_syscall
node_driver -.->|"accesses scoped devices"| node_pci

click node_bootloader "https://github.com/medhansh5/janus/blob/main/bootloader/src/main.rs"
click node_bootinfo "https://github.com/medhansh5/janus/blob/main/boot-info/src/lib.rs"
click node_kernelmain "https://github.com/medhansh5/janus/blob/main/kernel/src/main.rs"
click node_syscall "https://github.com/medhansh5/janus/blob/main/kernel/src/syscall.rs"
click node_capability "https://github.com/medhansh5/janus/blob/main/kernel/src/capability.rs"
click node_ipc "https://github.com/medhansh5/janus/blob/main/kernel/src/ipc.rs"
click node_task "https://github.com/medhansh5/janus/blob/main/kernel/src/task.rs"
click node_memory "https://github.com/medhansh5/janus/blob/main/kernel/src/memory.rs"
click node_paging "https://github.com/medhansh5/janus/blob/main/kernel/src/paging.rs"
click node_gdt "https://github.com/medhansh5/janus/blob/main/kernel/src/gdt.rs"
click node_idt "https://github.com/medhansh5/janus/blob/main/kernel/src/idt.rs"
click node_pic "https://github.com/medhansh5/janus/blob/main/kernel/src/pic.rs"
click node_pci "https://github.com/medhansh5/janus/blob/main/kernel/src/pci.rs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_bootloader,node_bootinfo,node_kernelmain,node_driver toneBlue
class node_syscall,node_capability,node_ipc toneAmber
class node_task,node_memory,node_paging,node_gdt toneMint
class node_idt,node_pic,node_pci,node_user toneRose
class node_firmware toneIndigo
```

## Components

### Boot Handoff

- [Bootloader](https://github.com/medhansh5/janus/blob/main/bootloader/src/main.rs): `bootloader/src/main.rs`
- [Boot Info](https://github.com/medhansh5/janus/blob/main/boot-info/src/lib.rs): `boot-info/src/lib.rs`
- [Kernel Bootstrap](https://github.com/medhansh5/janus/blob/main/kernel/src/main.rs): `kernel/src/main.rs`

### Kernel Boundary

- [Syscall ABI](https://github.com/medhansh5/janus/blob/main/kernel/src/syscall.rs): `kernel/src/syscall.rs`
- [Capability Table](https://github.com/medhansh5/janus/blob/main/kernel/src/capability.rs): `kernel/src/capability.rs`
- [IPC Dispatch](https://github.com/medhansh5/janus/blob/main/kernel/src/ipc.rs): `kernel/src/ipc.rs`

### Task Execution

- [Task Scheduler](https://github.com/medhansh5/janus/blob/main/kernel/src/task.rs): `kernel/src/task.rs`
- [Frame Allocator](https://github.com/medhansh5/janus/blob/main/kernel/src/memory.rs): `kernel/src/memory.rs`
- [Virtual Memory](https://github.com/medhansh5/janus/blob/main/kernel/src/paging.rs): `kernel/src/paging.rs`
- [GDT and TSS](https://github.com/medhansh5/janus/blob/main/kernel/src/gdt.rs): `kernel/src/gdt.rs`

### Hardware Services

- [Interrupt Dispatch](https://github.com/medhansh5/janus/blob/main/kernel/src/idt.rs): `kernel/src/idt.rs`
- [PIC Routing](https://github.com/medhansh5/janus/blob/main/kernel/src/pic.rs): `kernel/src/pic.rs`
- [PCI Discovery](https://github.com/medhansh5/janus/blob/main/kernel/src/pci.rs): `kernel/src/pci.rs`

### Other components

- **UEFI Firmware**
- **Ring 3 Task**
- **Userspace Driver**

## Connections

- UEFI Firmware → Bootloader: starts (evidence: `README.md`)
- Bootloader → Kernel Bootstrap: hands off
- Boot Info → Kernel Bootstrap: provides boot data
- Ring 3 Task → Syscall ABI: invokes (evidence: `README.md`)
- Syscall ABI → IPC Dispatch: dispatches calls (evidence: `kernel/src/syscall.rs`)
- IPC Dispatch → Capability Table: checks handles (evidence: `kernel/src/ipc.rs`)
- IPC Dispatch → Task Scheduler: blocks or wakes (evidence: `kernel/src/ipc.rs`)
- Task Scheduler → GDT and TSS: updates stack (evidence: `kernel/src/task.rs`)
- Virtual Memory → Frame Allocator: allocates frames (evidence: `kernel/src/paging.rs`)
- Interrupt Dispatch → GDT and TSS: uses selectors (evidence: `kernel/src/idt.rs`)
- Interrupt Dispatch → PIC Routing: acknowledges IRQ (evidence: `kernel/src/idt.rs`)
- Interrupt Dispatch → IPC Dispatch: wakes IRQ waiters (evidence: `kernel/src/idt.rs`)
- Userspace Driver → Syscall ABI: uses capabilities (evidence: `README.md`)
- Userspace Driver → PCI Discovery: accesses scoped devices
