> ## Documentation Index
> Fetch the complete documentation index at: https://kernel.mvhcloud.com/llms.txt
> Use this file to discover all available pages before exploring further.

# MVH Kernel Diagnostics Shell Commands — Full Reference

> Reference for kernel diagnostics commands: meminfo, heapinfo, cpuinfo, features, irqstat, pagetable, dmesg, ps, devices, lspci, statics, and more.

MVH Kernel exposes a rich set of diagnostics commands that give you direct visibility into the physical memory allocator, the kernel heap, CPU capabilities, interrupt counters, page-table state, and the structured kernel log. You can run every command at the `mvh>` prompt without any arguments unless documented otherwise.

***

## meminfo

Print a detailed breakdown of physical memory from the PMM (Physical Memory Manager), including page-level counters and allocator statistics.

**Syntax**

```sh theme={null}
meminfo
```

**Output includes**

* `MemTotal` / `MemUsed` / `MemAvailable` — physical memory in KiB
* `Reserved` — pages reserved by the kernel image and hardware
* `HeapTotal` / `HeapUsed` — kernel heap in KiB
* `PageAlloc` / `PageFree` — total page allocation and free request counts
* `PageFailures` — count of failed page allocation attempts
* `PagePeak` — peak number of pages in use simultaneously
* `MappedPages` — current VMM-mapped page count

**Example**

```text theme={null}
mvh> meminfo
MemTotal:     130048 KiB
MemUsed:       12288 KiB
MemAvailable: 117760 KiB
Reserved:       2048 KiB
HeapTotal:      1024 KiB
HeapUsed:        128 KiB
PageAlloc:      3072
PageFree:       2944
PageFailures:      0
PagePeak:       3072 pages
MappedPages:     512
```

***

## free

Print a concise one-line memory summary covering both physical pages and heap allocations.

**Syntax**

```sh theme={null}
free
```

**Example**

```text theme={null}
mvh> free
              total       used       free
Memory:   130048 KiB  12288 KiB  117760 KiB
Heap:       1024 KiB    128 KiB  allocations: 47
```

***

## heapinfo

Print extended kernel heap statistics, including fragmentation information and error counters introduced in v1.1.2.

**Syntax**

```sh theme={null}
heapinfo
```

**Output includes**

| Field                | Description                                                         |
| -------------------- | ------------------------------------------------------------------- |
| Heap total           | Total heap size in bytes                                            |
| Heap used            | Bytes currently allocated                                           |
| Heap free payload    | Bytes available in free blocks                                      |
| Largest free block   | Size of the single largest free contiguous block                    |
| Blocks / free blocks | Total block count and count of free blocks                          |
| Allocations active   | Live allocation count                                               |
| Allocation failures  | Count of `kmalloc` calls that returned null                         |
| Invalid frees        | Count of `kfree` calls on invalid pointers (heap hardening, v1.1.2) |
| Integrity            | `valid` if canary checks pass; `CORRUPTED` if the heap is damaged   |

**Example**

```text theme={null}
mvh> heapinfo
Heap total:          1048576 bytes
Heap used:            131072 bytes
Heap free payload:    917504 bytes
Largest free block:   917504 bytes
Blocks/free blocks:   24/16
Allocations active:   47
Allocation failures:   0
Invalid frees:         0
Integrity:           valid
```

***

## heaptest

Run the built-in heap allocator self-test. The test performs a series of allocations, writes, reads, and frees to verify that the allocator is functioning correctly.

**Syntax**

```sh theme={null}
heaptest
```

**Example**

```text theme={null}
mvh> heaptest
Heap self-test passed
```

***

## cpuinfo

Display extended CPU diagnostics. This command combines the CPU panel from `statics` with additional low-level fields added in v1.1.2, including TSC frequency, XSAVE area size, microcode version, and a hardware-RNG sample.

**Syntax**

```sh theme={null}
cpuinfo
```

**Output includes**

| Field                     | Description                                                                                                      |
| ------------------------- | ---------------------------------------------------------------------------------------------------------------- |
| Vendor                    | CPU vendor string (e.g. `GenuineIntel`)                                                                          |
| Model                     | CPU brand string                                                                                                 |
| Family / Model / Stepping | CPUID topology identifiers                                                                                       |
| APIC ID                   | Local APIC identifier of the boot processor                                                                      |
| Logical CPUs              | Logical processor count from CPUID                                                                               |
| Cache                     | L1D, L1I, L2, and L3 sizes in KiB                                                                                |
| Temperature               | Die temperature in °C from Intel DTS or AMD SMN/northbridge Tctl; `not available from this CPU/platform` in QEMU |
| TSC                       | Current TSC value (hex) and estimated TSC frequency in Hz                                                        |
| XSAVE area                | XSAVE state area size in bytes                                                                                   |
| Microcode                 | Microcode revision (hex) if safely exposed; otherwise `not exposed safely by this platform`                      |
| Hardware RNG              | A 64-bit sample from RDRAND if available                                                                         |

<Note>
  CPU temperature reading requires Intel Digital Thermal Sensor MSRs, AMD Family 10h–16h northbridge Tctl, or AMD Family 17h–1Ah SMN Tctl. QEMU does not expose a usable thermal sensor, so the field reports `not available from this CPU/platform` in emulated environments.
</Note>

**Example**

```text theme={null}
mvh> cpuinfo
+---------------------- CPU ----------------------+
| Architecture : x86_64
| Vendor       : GenuineIntel
| Model        : Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
| Logical CPUs : 12
| APIC ID      : 0
| Family/Model : 6/158 stepping 10
| Local APIC   : xAPIC enabled at 0xFEE00000000000000
| Temperature  : not available from this CPU/platform
| Cache        : L1D 32 KiB, L1I 32 KiB, L2 256 KiB, L3 12288 KiB
| CPU features : SSE SSE2 AVX AVX2
| Core status  : state, not CPU usage
| Core 0 : RUNNING     boot processor
| Core 1 : DETECTED    not started
+-------------------------------------------------+
TSC:          0x000000012A4F8C30
TSC estimate: 2600000000 Hz
XSAVE area:   576 bytes
Microcode:    not exposed safely by this platform
Hardware RNG: 0xA3F29D1C77BE4012
```

***

## features

List every CPUID capability flag and the active kernel protection settings. Each line shows `[yes]` or `[ no]` next to the feature name and a short description.

**Syntax**

```sh theme={null}
features
```

**Reported flags**

CPU hardware features: FPU, TSC, MSR, APIC, MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, AES, AVX, AVX2, AVX-512F, XSAVE, RDRAND, RDSEED, x2APIC, PAT, MTRR, NX, LONG MODE.

Kernel protection summary line reports: WP (supervisor write-protect), NX, SMEP, SMAP, UMIP.

**Example**

```text theme={null}
mvh> features
CPU hardware features
  [yes] FPU - floating-point calculations
  [yes] TSC - CPU timestamp counter
  [yes] MSR - model-specific registers
  [yes] APIC - advanced interrupt controller
  [yes] SSE - streaming SIMD instructions
  [yes] SSE2 - extended SIMD instructions
  [ no] AVX-512F - 512-bit vector foundation
  [yes] XSAVE - extended CPU state save/restore
  [yes] NX - non-executable memory pages
  ...

Kernel protection: WP on, NX on, SMEP on, SMAP on, UMIP on
Additional detected cores require SMP startup support.
```

***

## irqstat

Print per-vector interrupt statistics. Counters are read atomically with interrupts briefly disabled to avoid a torn read.

**Syntax**

```sh theme={null}
irqstat
```

**Output includes**

| Field                  | Description                                   |
| ---------------------- | --------------------------------------------- |
| Interrupt total        | Cumulative interrupt count across all vectors |
| Timer IRQ0 / vector 32 | Count of PIT timer interrupts (100 Hz)        |
| Spurious IRQs          | Count of spurious 8259 PIC interrupts         |

**Example**

```text theme={null}
mvh> irqstat
Interrupt total:     18432
Timer IRQ0/vector32: 18430
Spurious IRQs:           2
```

***

## pagetable

Query the VMM page table for a set of key virtual addresses and display their physical address mappings and page flags. The addresses probed are: `0x0` (null guard, expected unmapped), `0x1000`, the kernel end address, and the page-aligned kernel end address.

**Syntax**

```sh theme={null}
pagetable
```

**Example**

```text theme={null}
mvh> pagetable
VA 0x0000000000000000: unmapped
VA 0x0000000000001000: PA 0x0000000000001000 flags 0x8000000000000003
VA 0x000000000010E000: PA 0x000000000010E000 flags 0x8000000000000003
VA 0x000000000010F000: PA 0x000000000010F000 flags 0x8000000000000003
```

The null page at `VA 0x0` is unmapped by design — accessing it generates a page fault, which is captured by the exception handler.

***

## pagetest

Run the VMM (Virtual Memory Manager) self-test. The test exercises dynamic 4 KiB page mapping, unmapping, and lookup, and verifies that the null-page guard is correctly enforced.

**Syntax**

```sh theme={null}
pagetest
```

**Example**

```text theme={null}
mvh> pagetest
Page allocator self-test passed
```

***

## dmesg

Dump the kernel log ring buffer. The ring holds up to 16 KiB of structured, timestamped entries written by the kernel during boot and operation. Each entry includes a log level (INFO, WARN, ERROR) and an optional category tag.

**Syntax**

```sh theme={null}
dmesg
```

**Example**

```text theme={null}
mvh> dmesg
[  0.00] INFO  hardware abstraction layer initialized
[  0.00] INFO  physical memory manager initialized
[  0.00] INFO  paging protections and null guard initialized
[  0.00] INFO  kernel heap initialized
[  0.00] INFO  VFS mounted ramfs root
[  0.00] INFO  device manager initialized
```

***

## ps

List all registered kernel tasks. Each row shows the PID, priority, execution state, task name, and the PIT tick at which the task was created.

**Syntax**

```sh theme={null}
ps
```

**Task states:** `UNUSED`, `RUNNING`, `READY`, `SLEEPING`, `STOPPED`.

**Example**

```text theme={null}
mvh> ps
PID  PRI  STATE      NAME
1    1    RUNNING    kernel-shell
```

***

## devices

List all devices registered in the kernel device registry, showing the device ID, type, name, and online/offline status.

**Syntax**

```sh theme={null}
devices
```

**Example**

```text theme={null}
mvh> devices
ID  TYPE        STATE   NAME
1   CPU         ONLINE  boot-cpu
2   INTERRUPT   ONLINE  8259-pic
3   TIMER       ONLINE  8254-pit
4   INPUT       ONLINE  ps2-keyboard
5   DISPLAY     ONLINE  vga-text
6   SERIAL      ONLINE  uart-com1
7   CLOCK       ONLINE  cmos-rtc
8   BUS         ONLINE  pci-config
9   FILESYSTEM  ONLINE  ramfs-root
```

***

## lspci

Scan the PCI configuration space and list every discovered device with its bus/slot/function address, vendor and device IDs, and a class name.

**Syntax**

```sh theme={null}
lspci
```

**Example**

```text theme={null}
mvh> lspci
0:0.0  8086:1237  Host Bridge
0:1.0  8086:7000  ISA Bridge
0:1.1  8086:7010  IDE Controller
0:2.0  1234:1111  VGA Compatible Controller
```

If no PCI devices are found, the shell prints `No PCI devices found.`

***

## drivers

List all drivers compiled into the kernel and their responsibilities.

**Syntax**

```sh theme={null}
drivers
```

**Example**

```text theme={null}
mvh> drivers
Loaded kernel drivers
  vga-text-cursor       display and hardware cursor
  ps2-keyboard-en-us    keyboard, Shift, Caps, Ctrl
  serial-uart-16550     COM1 debug output
  x86-cpuid             CPU detection
  cmos-rtc              real-time clock
  pci-config            PCI device discovery
  x86-idt-pic           interrupt controller
  x86-exceptions        CPU exception handling
  pit-8254              system timer
  ramfs                 volatile filesystem
  device-manager        kernel device registry
```

***

## statics

Open the full-screen live system monitor. The monitor displays a RAM usage bar with used/free/total figures in MiB, and a per-core CPU status panel listing each logical processor's execution state. Press **Q** or **Ctrl+C** to exit and return to the `mvh>` prompt.

**Syntax**

```sh theme={null}
statics
```

<Tip>
  Use `statics` to get a quick overview of memory pressure and CPU topology. The panel shows actual execution state rather than simulated usage bars, so the values are accurate.
</Tip>

***

## paniccodes

List all stable kernel panic codes and their meanings. These codes appear in the top line of a kernel panic dump on both VGA and the serial console, making them easy to identify in crash logs.

**Syntax**

```sh theme={null}
paniccodes
```

**Example**

```text theme={null}
mvh> paniccodes
MVH panic code format
  MVH-KERNEL-0001  explicit kernel panic
  MVH-EX-00        divide error
  MVH-EX-06        invalid opcode
  MVH-EX-08        double fault
  MVH-EX-0D        general protection fault
  MVH-EX-0E        page fault
  MVH-EX-12        machine check
  MVH-EX-15        control protection
Crash output includes vector, decoded error flags, CR0-CR4, registers and stack trace.
```

A crash dump includes the panic code, the exception vector, decoded hardware error-code flags, control registers (CR0–CR4), all general-purpose registers (RAX–R15, RIP, RFLAGS), and a bounded frame-pointer stack trace.
