The manual
ginnOS
The reference: libc, the libraries and the kernel
Toggle main menu visibility
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
"
17
#include "
kernel/sync/completion.h
"
18
#include "
kernel/sync/mutex.h
"
19
20
typedef
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
26
}
nvme_disk_t
;
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
*/
33
nvme_disk_t
*
nvme_init
(
void
);
block_device.h
block_device_t
struct block_device block_device_t
Definition
block_device.h:5
stdint.h
completion.h
wait for a device: sleep until its interrupt, or poll.
uint64_t
__UINT64_TYPE__ uint64_t
Definition
stdint.h:17
mutex.h
nvme_init
nvme_disk_t * nvme_init(void)
find and set up the first NVMe controller.
Definition
nvme.c:354
phys.h
completion_t
Definition
completion.h:25
mutex_t
sleeping mutex for long critical sections in process context (filesystem and disk I/O).
Definition
mutex.h:20
nvme_disk_t
Definition
nvme.h:21
nvme_disk_t::lock
mutex_t lock
Definition
nvme.h:24
nvme_disk_t::block
block_device_t block
Definition
nvme.h:22
nvme_disk_t::done
completion_t done
Definition
nvme.h:25
nvme_disk_t::sectors
uint64_t sectors
Definition
nvme.h:23
src
drivers
disk
nvme.h
Generated by
1.18.0