]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/dev/nvdimm/nvdimm_var.h
MFC r342053
[FreeBSD/FreeBSD.git] / sys / dev / nvdimm / nvdimm_var.h
1 /*-
2  * Copyright (c) 2017 The FreeBSD Foundation
3  * All rights reserved.
4  *
5  * This software was developed by Konstantin Belousov <kib@FreeBSD.org>
6  * under sponsorship from the FreeBSD Foundation.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  *
29  * $FreeBSD$
30  */
31
32 #ifndef __DEV_NVDIMM_VAR_H__
33 #define __DEV_NVDIMM_VAR_H__
34
35 typedef uint32_t nfit_handle_t;
36
37 struct nvdimm_dev {
38         device_t        nv_dev;
39         nfit_handle_t   nv_handle;
40         uint64_t        **nv_flush_addr;
41         int             nv_flush_addr_cnt;
42         int             nv_devs_idx;
43 };
44
45 enum SPA_mapping_type {
46         SPA_TYPE_VOLATILE_MEMORY        = 0,
47         SPA_TYPE_PERSISTENT_MEMORY      = 1,
48         SPA_TYPE_CONTROL_REGION         = 2,
49         SPA_TYPE_DATA_REGION            = 3,
50         SPA_TYPE_VOLATILE_VIRTUAL_DISK  = 4,
51         SPA_TYPE_VOLATILE_VIRTUAL_CD    = 5,
52         SPA_TYPE_PERSISTENT_VIRTUAL_DISK= 6,
53         SPA_TYPE_PERSISTENT_VIRTUAL_CD  = 7,
54 };
55
56 struct SPA_mapping {
57         enum SPA_mapping_type   spa_type;
58         int                     spa_domain;
59         int                     spa_nfit_idx;
60         uint64_t                spa_phys_base;
61         uint64_t                spa_len;
62         uint64_t                spa_efi_mem_flags;
63         void                    *spa_kva;
64         struct cdev             *spa_dev;
65         struct g_geom           *spa_g;
66         struct g_provider       *spa_p;
67         struct bio_queue_head   spa_g_queue;
68         struct mtx              spa_g_mtx;
69         struct mtx              spa_g_stat_mtx;
70         struct devstat          *spa_g_devstat;
71         struct proc             *spa_g_proc;
72         struct vm_object        *spa_obj;
73         bool                    spa_g_proc_run;
74         bool                    spa_g_proc_exiting;
75 };
76
77 struct nvdimm_ns_walk_ctx {
78         ACPI_STATUS     (*func)(ACPI_HANDLE, void *);
79         void            *arg;
80 };
81
82 extern struct SPA_mapping *spa_mappings;
83 extern int spa_mappings_cnt;
84
85 MALLOC_DECLARE(M_NVDIMM);
86
87 struct nvdimm_dev *nvdimm_find_by_handle(nfit_handle_t nv_handle);
88 int nvdimm_iterate_nfit(ACPI_TABLE_NFIT *nfitbl, enum AcpiNfitType type,
89     int (*cb)(void *, void *), void *arg);
90
91 #endif          /* __DEV_NVDIMM_VAR_H__ */