mirror of
https://github.com/opnsense/src.git
synced 2026-05-28 04:12:45 -04:00
nvdimm: initialize SPA uuids statically.
The SPA ids are published numbers, so it's safe (if not a bit annoying) to copy them into a source file. Submitted by: D Scott Phillips <d.scott.phillips@intel.com> Sponsored by: Intel Corporation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D18733
This commit is contained in:
parent
fc4a961a3b
commit
6465f3158a
2 changed files with 51 additions and 37 deletions
|
|
@ -1,6 +1,7 @@
|
|||
/*-
|
||||
* Copyright (c) 2017, 2018 The FreeBSD Foundation
|
||||
* All rights reserved.
|
||||
* Copyright (c) 2018, 2019 Intel Corporation
|
||||
*
|
||||
* This software was developed by Konstantin Belousov <kib@FreeBSD.org>
|
||||
* under sponsorship from the FreeBSD Foundation.
|
||||
|
|
@ -64,6 +65,23 @@ __FBSDID("$FreeBSD$");
|
|||
#include <dev/acpica/acpivar.h>
|
||||
#include <dev/nvdimm/nvdimm_var.h>
|
||||
|
||||
#define UUID_INITIALIZER_VOLATILE_MEMORY \
|
||||
{0x7305944f,0xfdda,0x44e3,0xb1,0x6c,{0x3f,0x22,0xd2,0x52,0xe5,0xd0}}
|
||||
#define UUID_INITIALIZER_PERSISTENT_MEMORY \
|
||||
{0x66f0d379,0xb4f3,0x4074,0xac,0x43,{0x0d,0x33,0x18,0xb7,0x8c,0xdb}}
|
||||
#define UUID_INITIALIZER_CONTROL_REGION \
|
||||
{0x92f701f6,0x13b4,0x405d,0x91,0x0b,{0x29,0x93,0x67,0xe8,0x23,0x4c}}
|
||||
#define UUID_INITIALIZER_DATA_REGION \
|
||||
{0x91af0530,0x5d86,0x470e,0xa6,0xb0,{0x0a,0x2d,0xb9,0x40,0x82,0x49}}
|
||||
#define UUID_INITIALIZER_VOLATILE_VIRTUAL_DISK \
|
||||
{0x77ab535a,0x45fc,0x624b,0x55,0x60,{0xf7,0xb2,0x81,0xd1,0xf9,0x6e}}
|
||||
#define UUID_INITIALIZER_VOLATILE_VIRTUAL_CD \
|
||||
{0x3d5abd30,0x4175,0x87ce,0x6d,0x64,{0xd2,0xad,0xe5,0x23,0xc4,0xbb}}
|
||||
#define UUID_INITIALIZER_PERSISTENT_VIRTUAL_DISK \
|
||||
{0x5cea02c9,0x4d07,0x69d3,0x26,0x9f,{0x44,0x96,0xfb,0xe0,0x96,0xf9}}
|
||||
#define UUID_INITIALIZER_PERSISTENT_VIRTUAL_CD \
|
||||
{0x08018188,0x42cd,0xbb48,0x10,0x0f,{0x53,0x87,0xd5,0x3d,0xed,0x3d}}
|
||||
|
||||
struct SPA_mapping *spa_mappings;
|
||||
int spa_mappings_cnt;
|
||||
|
||||
|
|
@ -79,52 +97,64 @@ nvdimm_spa_count(void *nfitsubtbl __unused, void *arg)
|
|||
|
||||
static struct nvdimm_SPA_uuid_list_elm {
|
||||
const char *u_name;
|
||||
const char *u_id_str;
|
||||
struct uuid u_id;
|
||||
const bool u_usr_acc;
|
||||
} nvdimm_SPA_uuid_list[] = {
|
||||
[SPA_TYPE_VOLATILE_MEMORY] = {
|
||||
.u_name = "VOLA MEM ",
|
||||
.u_id_str = UUID_VOLATILE_MEMORY,
|
||||
.u_id = UUID_INITIALIZER_VOLATILE_MEMORY,
|
||||
.u_usr_acc = true,
|
||||
},
|
||||
[SPA_TYPE_PERSISTENT_MEMORY] = {
|
||||
.u_name = "PERS MEM",
|
||||
.u_id_str = UUID_PERSISTENT_MEMORY,
|
||||
.u_id = UUID_INITIALIZER_PERSISTENT_MEMORY,
|
||||
.u_usr_acc = true,
|
||||
},
|
||||
[SPA_TYPE_CONTROL_REGION] = {
|
||||
.u_name = "CTRL RG ",
|
||||
.u_id_str = UUID_CONTROL_REGION,
|
||||
.u_id = UUID_INITIALIZER_CONTROL_REGION,
|
||||
.u_usr_acc = false,
|
||||
},
|
||||
[SPA_TYPE_DATA_REGION] = {
|
||||
.u_name = "DATA RG ",
|
||||
.u_id_str = UUID_DATA_REGION,
|
||||
.u_id = UUID_INITIALIZER_DATA_REGION,
|
||||
.u_usr_acc = true,
|
||||
},
|
||||
[SPA_TYPE_VOLATILE_VIRTUAL_DISK] = {
|
||||
.u_name = "VIRT DSK",
|
||||
.u_id_str = UUID_VOLATILE_VIRTUAL_DISK,
|
||||
.u_id = UUID_INITIALIZER_VOLATILE_VIRTUAL_DISK,
|
||||
.u_usr_acc = true,
|
||||
},
|
||||
[SPA_TYPE_VOLATILE_VIRTUAL_CD] = {
|
||||
.u_name = "VIRT CD ",
|
||||
.u_id_str = UUID_VOLATILE_VIRTUAL_CD,
|
||||
.u_id = UUID_INITIALIZER_VOLATILE_VIRTUAL_CD,
|
||||
.u_usr_acc = true,
|
||||
},
|
||||
[SPA_TYPE_PERSISTENT_VIRTUAL_DISK] = {
|
||||
.u_name = "PV DSK ",
|
||||
.u_id_str = UUID_PERSISTENT_VIRTUAL_DISK,
|
||||
.u_id = UUID_INITIALIZER_PERSISTENT_VIRTUAL_DISK,
|
||||
.u_usr_acc = true,
|
||||
},
|
||||
[SPA_TYPE_PERSISTENT_VIRTUAL_CD] = {
|
||||
.u_name = "PV CD ",
|
||||
.u_id_str = UUID_PERSISTENT_VIRTUAL_CD,
|
||||
.u_id = UUID_INITIALIZER_PERSISTENT_VIRTUAL_CD,
|
||||
.u_usr_acc = true,
|
||||
},
|
||||
};
|
||||
|
||||
enum SPA_mapping_type
|
||||
nvdimm_spa_type_from_uuid(struct uuid *uuid)
|
||||
{
|
||||
int j;
|
||||
|
||||
for (j = 0; j < nitems(nvdimm_SPA_uuid_list); j++) {
|
||||
if (uuidcmp(uuid, &nvdimm_SPA_uuid_list[j].u_id) != 0)
|
||||
continue;
|
||||
return (j);
|
||||
}
|
||||
return (SPA_TYPE_UNKNOWN);
|
||||
}
|
||||
|
||||
static vm_memattr_t
|
||||
nvdimm_spa_memattr(struct SPA_mapping *spa)
|
||||
{
|
||||
|
|
@ -539,49 +569,31 @@ nvdimm_spa_parse(void *nfitsubtbl, void *arg)
|
|||
{
|
||||
ACPI_NFIT_SYSTEM_ADDRESS *nfitaddr;
|
||||
struct SPA_mapping *spa;
|
||||
int error, *i, j;
|
||||
enum SPA_mapping_type spa_type;
|
||||
int error, *i;
|
||||
|
||||
i = arg;
|
||||
spa = &spa_mappings[*i];
|
||||
spa = &spa_mappings[(*i)++];
|
||||
nfitaddr = nfitsubtbl;
|
||||
|
||||
for (j = 0; j < nitems(nvdimm_SPA_uuid_list); j++) {
|
||||
/* XXXKIB: is ACPI UUID representation compatible ? */
|
||||
if (uuidcmp((struct uuid *)&nfitaddr->RangeGuid,
|
||||
&nvdimm_SPA_uuid_list[j].u_id) != 0)
|
||||
continue;
|
||||
error = nvdimm_spa_init_one(spa, nfitaddr, j);
|
||||
if (error != 0)
|
||||
nvdimm_spa_fini_one(spa);
|
||||
break;
|
||||
}
|
||||
if (j == nitems(nvdimm_SPA_uuid_list) && bootverbose) {
|
||||
spa_type = nvdimm_spa_type_from_uuid(
|
||||
(struct uuid *)&nfitaddr->RangeGuid);
|
||||
if (spa_type == SPA_TYPE_UNKNOWN) {
|
||||
printf("Unknown SPA UUID %d ", nfitaddr->RangeIndex);
|
||||
printf_uuid((struct uuid *)&nfitaddr->RangeGuid);
|
||||
printf("\n");
|
||||
return (0);
|
||||
}
|
||||
(*i)++;
|
||||
error = nvdimm_spa_init_one(spa, nfitaddr, spa_type);
|
||||
if (error != 0)
|
||||
nvdimm_spa_fini_one(spa);
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
nvdimm_spa_init1(ACPI_TABLE_NFIT *nfitbl)
|
||||
{
|
||||
struct nvdimm_SPA_uuid_list_elm *sle;
|
||||
int error, i;
|
||||
|
||||
for (i = 0; i < nitems(nvdimm_SPA_uuid_list); i++) {
|
||||
sle = &nvdimm_SPA_uuid_list[i];
|
||||
error = parse_uuid(sle->u_id_str, &sle->u_id);
|
||||
if (error != 0) {
|
||||
if (bootverbose)
|
||||
printf("nvdimm_identify: error %d parsing "
|
||||
"known SPA UUID %d %s\n", error, i,
|
||||
sle->u_id_str);
|
||||
return (error);
|
||||
}
|
||||
}
|
||||
|
||||
error = nvdimm_iterate_nfit(nfitbl, ACPI_NFIT_TYPE_SYSTEM_ADDRESS,
|
||||
nvdimm_spa_count, &spa_mappings_cnt);
|
||||
if (error != 0)
|
||||
|
|
|
|||
|
|
@ -60,6 +60,7 @@ enum SPA_mapping_type {
|
|||
SPA_TYPE_VOLATILE_VIRTUAL_CD = 5,
|
||||
SPA_TYPE_PERSISTENT_VIRTUAL_DISK= 6,
|
||||
SPA_TYPE_PERSISTENT_VIRTUAL_CD = 7,
|
||||
SPA_TYPE_UNKNOWN = 127,
|
||||
};
|
||||
|
||||
struct SPA_mapping {
|
||||
|
|
@ -88,6 +89,7 @@ extern int spa_mappings_cnt;
|
|||
|
||||
MALLOC_DECLARE(M_NVDIMM);
|
||||
|
||||
enum SPA_mapping_type nvdimm_spa_type_from_uuid(struct uuid *);
|
||||
struct nvdimm_dev *nvdimm_find_by_handle(nfit_handle_t nv_handle);
|
||||
int nvdimm_iterate_nfit(ACPI_TABLE_NFIT *nfitbl, enum AcpiNfitType type,
|
||||
int (*cb)(void *, void *), void *arg);
|
||||
|
|
|
|||
Loading…
Reference in a new issue