TianoCore EDK2 master
Loading...
Searching...
No Matches
NvmExpressPeiHci.h
Go to the documentation of this file.
1
11#ifndef _NVM_EXPRESS_PEI_HCI_H_
12#define _NVM_EXPRESS_PEI_HCI_H_
13
14//
15// NVME host controller registers operation definitions
16//
17#define NVME_GET_CAP(Private, Cap) NvmeMmioRead (Cap, Private->MmioBase + NVME_CAP_OFFSET, sizeof (NVME_CAP))
18#define NVME_GET_CC(Private, Cc) NvmeMmioRead (Cc, Private->MmioBase + NVME_CC_OFFSET, sizeof (NVME_CC))
19#define NVME_SET_CC(Private, Cc) NvmeMmioWrite (Private->MmioBase + NVME_CC_OFFSET, Cc, sizeof (NVME_CC))
20#define NVME_GET_CSTS(Private, Csts) NvmeMmioRead (Csts, Private->MmioBase + NVME_CSTS_OFFSET, sizeof (NVME_CSTS))
21#define NVME_GET_AQA(Private, Aqa) NvmeMmioRead (Aqa, Private->MmioBase + NVME_AQA_OFFSET, sizeof (NVME_AQA))
22#define NVME_SET_AQA(Private, Aqa) NvmeMmioWrite (Private->MmioBase + NVME_AQA_OFFSET, Aqa, sizeof (NVME_AQA))
23#define NVME_GET_ASQ(Private, Asq) NvmeMmioRead (Asq, Private->MmioBase + NVME_ASQ_OFFSET, sizeof (NVME_ASQ))
24#define NVME_SET_ASQ(Private, Asq) NvmeMmioWrite (Private->MmioBase + NVME_ASQ_OFFSET, Asq, sizeof (NVME_ASQ))
25#define NVME_GET_ACQ(Private, Acq) NvmeMmioRead (Acq, Private->MmioBase + NVME_ACQ_OFFSET, sizeof (NVME_ACQ))
26#define NVME_SET_ACQ(Private, Acq) NvmeMmioWrite (Private->MmioBase + NVME_ACQ_OFFSET, Acq, sizeof (NVME_ACQ))
27#define NVME_GET_VER(Private, Ver) NvmeMmioRead (Ver, Private->MmioBase + NVME_VER_OFFSET, sizeof (NVME_VER))
28#define NVME_SET_SQTDBL(Private, Qid, Sqtdbl) NvmeMmioWrite (Private->MmioBase + NVME_SQTDBL_OFFSET(Qid, Private->Cap.Dstrd), Sqtdbl, sizeof (NVME_SQTDBL))
29#define NVME_SET_CQHDBL(Private, Qid, Cqhdbl) NvmeMmioWrite (Private->MmioBase + NVME_CQHDBL_OFFSET(Qid, Private->Cap.Dstrd), Cqhdbl, sizeof (NVME_CQHDBL))
30
31//
32// Base memory address enum types
33//
34enum {
35 BASEMEM_ASQ,
36 BASEMEM_ACQ,
37 BASEMEM_SQ,
38 BASEMEM_CQ,
39 BASEMEM_PRP,
40 MAX_BASEMEM_COUNT
41};
42
43//
44// All of base memories are 4K(0x1000) alignment
45//
46#define ALIGN(v, a) (UINTN)((((v) - 1) | ((a) - 1)) + 1)
47#define NVME_MEM_BASE(Private) ((UINTN)(Private->Buffer))
48#define NVME_ASQ_BASE(Private) (ALIGN (NVME_MEM_BASE(Private) + ((NvmeBaseMemPageOffset (BASEMEM_ASQ)) * EFI_PAGE_SIZE), EFI_PAGE_SIZE))
49#define NVME_ACQ_BASE(Private) (ALIGN (NVME_MEM_BASE(Private) + ((NvmeBaseMemPageOffset (BASEMEM_ACQ)) * EFI_PAGE_SIZE), EFI_PAGE_SIZE))
50#define NVME_SQ_BASE(Private, Index) (ALIGN (NVME_MEM_BASE(Private) + ((NvmeBaseMemPageOffset (BASEMEM_SQ) + ((Index)*(NVME_MAX_QUEUES-1))) * EFI_PAGE_SIZE), EFI_PAGE_SIZE))
51#define NVME_CQ_BASE(Private, Index) (ALIGN (NVME_MEM_BASE(Private) + ((NvmeBaseMemPageOffset (BASEMEM_CQ) + ((Index)*(NVME_MAX_QUEUES-1))) * EFI_PAGE_SIZE), EFI_PAGE_SIZE))
52#define NVME_PRP_BASE(Private) (ALIGN (NVME_MEM_BASE(Private) + ((NvmeBaseMemPageOffset (BASEMEM_PRP)) * EFI_PAGE_SIZE), EFI_PAGE_SIZE))
53
66 IN OUT VOID *MemBuffer,
67 IN UINTN MmioAddr,
68 IN UINTN Size
69 );
70
83 IN OUT UINTN MmioAddr,
84 IN VOID *MemBuffer,
85 IN UINTN Size
86 );
87
96UINT32
98 IN UINTN BaseMemIndex
99 );
100
113 );
114
129 IN UINT32 NamespaceId,
130 IN VOID *Buffer
131 );
132
139VOID
142 );
143
144#endif
UINT64 UINTN
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
VOID NvmeFreeDmaResource(IN PEI_NVME_CONTROLLER_PRIVATE_DATA *Private)
EFI_STATUS NvmeControllerInit(IN PEI_NVME_CONTROLLER_PRIVATE_DATA *Private)
EFI_STATUS NvmeMmioRead(IN OUT VOID *MemBuffer, IN UINTN MmioAddr, IN UINTN Size)
UINT32 NvmeBaseMemPageOffset(IN UINTN BaseMemIndex)
EFI_STATUS NvmeMmioWrite(IN OUT UINTN MmioAddr, IN VOID *MemBuffer, IN UINTN Size)
EFI_STATUS NvmeIdentifyNamespace(IN PEI_NVME_CONTROLLER_PRIVATE_DATA *Private, IN UINT32 NamespaceId, IN VOID *Buffer)
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29