The manual
ginnOS
The reference: libc, the libraries and the kernel
Loading...
Searching...
No Matches
nvme.h
Go to the documentation of this file.
1#pragma once
2
3/**
4 * @file nvme.h
5 * @brief NVMe disks (PCI class 01:08:02).
6 *
7 * nvme_init sets up the first NVMe controller with one admin queue pair and
8 * one I/O queue pair, and makes namespace 1 a block device of 512-byte
9 * sectors. a process that waits for a command sleeps until the controller
10 * interrupts; during boot, or without an interrupt, the driver polls the
11 * completion queue. namespaces with another sector size are not used.
12 */
13
14#include "block_device.h"
15#include "common/stdint.h"
16#include "kernel/memory/phys.h"
18#include "kernel/sync/mutex.h"
19
20typedef struct
21{
22 block_device_t block; // the block device interface (context points here)
23 uint64_t sectors; // the namespace size in 512-byte sectors
24 mutex_t lock; // one command at a time
25 completion_t done; // the completion queue interrupt
27
28/**
29 * find and set up the first NVMe controller. call after pci_init and
30 * mmio_init.
31 * @return the disk, or NULL if there is none or it cannot be used.
32 */
struct block_device block_device_t
Definition block_device.h:5
wait for a device: sleep until its interrupt, or poll.
__UINT64_TYPE__ uint64_t
Definition stdint.h:17
nvme_disk_t * nvme_init(void)
find and set up the first NVMe controller.
Definition nvme.c:354
Definition completion.h:25
sleeping mutex for long critical sections in process context (filesystem and disk I/O).
Definition mutex.h:20
Definition nvme.h:21
mutex_t lock
Definition nvme.h:24
block_device_t block
Definition nvme.h:22
completion_t done
Definition nvme.h:25
uint64_t sectors
Definition nvme.h:23