Skip to content

Instantly share code, notes, and snippets.

NVMe I/O Completion

Background

NVMe (Non-Volatile Memory Express) is a host-to-device protocol for PCIe-attached storage. The driver talks to the controller through paired ring buffers in host memory:

  • SQ (Submission Queue): host writes commands here.
  • CQ (Completion Queue): controller writes completion records here.
  • SQE (Submission Queue Entry): one 64-byte command in the SQ. Each SQE has a 1-byte opcode, a 2-byte CID (Command Identifier) chosen by the host so the host can match a completion back to the request, and 16 dwords of parameters labeled cdw0 through cdw15. cdw11 is "Command Dword 11", a per-opcode parameter slot.
  • CQE (Completion Queue Entry): one 16-byte completion record in the CQ. Each CQE carries the CID it completes, a status code, and a phase bit that flips each time the controller wraps the ring, so the host can tell fresh entries from stale ones without polling a separate index.
@ -0,0 +1,489 @@
# ESP32-RPi Gateway Hardware Architecture
## Overview
ESP32 board controls Raspberry Pi power and captures UART output for automated testing in GitHub Actions CI/CD.
## Block Diagram
```
┌─────────────────────────────────────────────────────────────────────────┐
11:21:56.291315 Start executing
11:21:56.303406 Start configuration. IsELF = True, Target = VMware
11:21:56.348444 Starting kernel 'GraphicTest'
11:21:56.349530 Running task 'IL2CPU'
11:21:56.402665 Msg: Executing command line 'dotnet "run" "--no-build" " -- " "KernelPkg:" "EnableDebug:True" "EnableStackCorruptionDetection:True" "StackCorruptionDetectionLevel:AllInstructions" "DebugMode:Source" "TraceAssemblies:User" "DebugCom:1" "TargetAssembly:C:\Cosmos\Cosmos\Tests\Cosmos.TestRunner\bin\Debug\net6.0\win-x86\GraphicTest.dll" "OutputFilename:C:\Cosmos\Cosmos\Tests\Cosmos.TestRunner\bin\Debug\net6.0\win-x86\WorkingDirectory\GraphicTest\Kernel.asm" "EnableLogging:True" "EmitDebugSymbols:True" "IgnoreDebugStubAttribute:False" "AllowComments:True" "References:C:\Cosmos\Cosmos\source\Cosmos.Debug.Hosts\obj\Debug\netstandard2.0\HyperVServer\Cosmos.Debug.HyperVServer.dll" "References:C:\Cosmos\Cosmos\source\Cosmos.Debug.Hosts\obj\Debug\netstandard2.0\HyperVServer\System.Management.Automation.dl
using System;
using System.Text;
using Sys = Cosmos.System;
using System.Net.Sockets;
using System.Net;
namespace GraphicTest
{
class TcpServer
{
using Cosmos.HAL;
using Cosmos.System.Network.Config;
using Cosmos.System.Network.IPv4;
using Cosmos.System.Network.IPv4.TCP;
using Cosmos.System.Network.IPv4.UDP.DHCP;
using System;
using System.Text;
using Sys = Cosmos.System;
namespace NetworkTest
using Cosmos.HAL;
using Cosmos.HAL.BlockDevice;
using Cosmos.System.FileSystem;
using Cosmos.System.FileSystem.VFS;
using Cosmos.System.Network;
using Cosmos.System.Network.ARP;
using Cosmos.System.Network.Config;
using Cosmos.System.Network.IPv4;
using Cosmos.System.Network.IPv4.TCP;
using Cosmos.System.Network.IPv4.TCP.FTP;
using Cosmos.HAL;
using Cosmos.System.Network;
using Cosmos.System.Network.ARP;
using Cosmos.System.Network.Config;
using Cosmos.System.Network.IPv4;
using Cosmos.System.Network.IPv4.TCP;
using Cosmos.System.Network.IPv4.UDP;
using Cosmos.System.Network.IPv4.UDP.DHCP;
using Cosmos.System.Network.IPv4.UDP.DNS;
using Cosmos.TestRunner;
@valentinbreiz
valentinbreiz / Kernel.cs
Created May 21, 2021 12:52
Cosmos TcpClient test
using Cosmos.HAL;
using Cosmos.System.Network;
using Cosmos.System.Network.ARP;
using Cosmos.System.Network.Config;
using Cosmos.System.Network.IPv4;
using Cosmos.System.Network.IPv4.TCP;
using Cosmos.System.Network.IPv4.UDP;
using Cosmos.System.Network.IPv4.UDP.DHCP;
using Cosmos.System.Network.IPv4.UDP.DNS;
using Cosmos.TestRunner;
@valentinbreiz
valentinbreiz / CosmosAssembler.cs
Last active June 2, 2018 00:41
Enable VBE VESA in Cosmos IL2CPU
using Cosmos.Build.Common;
using Cosmos.Core.DebugStub;
using IL2CPU.API.Attribs;
using System;
using System.Collections.Generic;
using System.IO;
using XSharp;
using XSharp.Assembler;
using XSharp.Assembler.x86;
using static XSharp.XSRegisters;