tools/testing/cxl/test/mock.c
Source file repositories/reference/linux-study-clean/tools/testing/cxl/test/mock.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/cxl/test/mock.c- Extension
.c- Size
- 7639 bytes
- Lines
- 308
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/libnvdimm.hlinux/rculist.hlinux/device.hlinux/export.hlinux/acpi.hlinux/pci.hcxlmem.hcxlpci.hmock.h
Detected Declarations
function register_cxl_mock_opsfunction unregister_cxl_mock_opsfunction put_cxl_mock_opsfunction __wrap_is_acpi_device_nodefunction __wrap_acpi_table_parse_cedtfunction __wrap_acpi_evaluate_integerfunction __wrap_hmat_get_extended_linear_cache_sizefunction __wrap_nvdimm_bus_registerfunction __wrap_devm_cxl_switch_port_decoders_setupfunction __wrap_devm_cxl_endpoint_decoders_setupfunction __wrap_cxl_await_media_readyfunction __wrap_cxl_endpoint_parse_cdatfunction __wrap_region_intersectsfunction __wrap_region_intersects_soft_reservefunction __wrap_walk_hmem_resourcesexport register_cxl_mock_opsexport unregister_cxl_mock_opsexport get_cxl_mock_opsexport put_cxl_mock_opsexport __wrap_is_acpi_device_nodeexport __wrap_acpi_evaluate_integerexport __wrap_hmat_get_extended_linear_cache_sizeexport __wrap_acpi_pci_find_rootexport __wrap_nvdimm_bus_registerexport __wrap_region_intersectsexport __wrap_region_intersects_soft_reserveexport __wrap_walk_hmem_resources
Annotated Snippet
if (!IS_ERR(dport)) {
dport->rcrb.base = rcrb;
dport->rch = true;
}
} else
dport = devm_cxl_add_rch_dport(port, dport_dev, port_id, rcrb);
put_cxl_mock_ops(index);
return dport;
}
EXPORT_SYMBOL_NS_GPL(__wrap_devm_cxl_add_rch_dport, "CXL");
void __wrap_cxl_endpoint_parse_cdat(struct cxl_port *port)
{
int index;
struct cxl_mock_ops *ops = get_cxl_mock_ops(&index);
struct cxl_memdev *cxlmd = to_cxl_memdev(port->uport_dev);
if (ops && ops->is_mock_dev(cxlmd->dev.parent))
ops->cxl_endpoint_parse_cdat(port);
else
cxl_endpoint_parse_cdat(port);
put_cxl_mock_ops(index);
}
EXPORT_SYMBOL_NS_GPL(__wrap_cxl_endpoint_parse_cdat, "CXL");
struct cxl_dport *__wrap_devm_cxl_add_dport_by_dev(struct cxl_port *port,
struct device *dport_dev)
{
int index;
struct cxl_mock_ops *ops = get_cxl_mock_ops(&index);
struct cxl_dport *dport;
if (ops && ops->is_mock_port(port->uport_dev))
dport = ops->devm_cxl_add_dport_by_dev(port, dport_dev);
else
dport = devm_cxl_add_dport_by_dev(port, dport_dev);
put_cxl_mock_ops(index);
return dport;
}
EXPORT_SYMBOL_NS_GPL(__wrap_devm_cxl_add_dport_by_dev, "CXL");
int __wrap_region_intersects(resource_size_t start, size_t size,
unsigned long flags, unsigned long desc)
{
int rc = -1;
int index;
struct cxl_mock_ops *ops = get_cxl_mock_ops(&index);
if (ops)
rc = ops->region_intersects(start, size, flags, desc);
if (rc < 0)
rc = region_intersects(start, size, flags, desc);
put_cxl_mock_ops(index);
return rc;
}
EXPORT_SYMBOL_GPL(__wrap_region_intersects);
int __wrap_region_intersects_soft_reserve(resource_size_t start, size_t size)
{
int rc = -1;
int index;
struct cxl_mock_ops *ops = get_cxl_mock_ops(&index);
if (ops)
rc = ops->region_intersects_soft_reserve(start, size);
if (rc < 0)
rc = region_intersects_soft_reserve(start, size);
put_cxl_mock_ops(index);
return rc;
}
EXPORT_SYMBOL_GPL(__wrap_region_intersects_soft_reserve);
int __wrap_walk_hmem_resources(struct device *host, walk_hmem_fn fn)
{
int index, rc = 0;
bool is_mock = strcmp(dev_name(host), "hmem_platform.1") == 0;
struct cxl_mock_ops *ops = get_cxl_mock_ops(&index);
if (is_mock) {
if (ops)
rc = ops->walk_hmem_resources(host, fn);
} else {
rc = walk_hmem_resources(host, fn);
}
put_cxl_mock_ops(index);
return rc;
Annotation
- Immediate include surface: `linux/libnvdimm.h`, `linux/rculist.h`, `linux/device.h`, `linux/export.h`, `linux/acpi.h`, `linux/pci.h`, `cxlmem.h`, `cxlpci.h`.
- Detected declarations: `function register_cxl_mock_ops`, `function unregister_cxl_mock_ops`, `function put_cxl_mock_ops`, `function __wrap_is_acpi_device_node`, `function __wrap_acpi_table_parse_cedt`, `function __wrap_acpi_evaluate_integer`, `function __wrap_hmat_get_extended_linear_cache_size`, `function __wrap_nvdimm_bus_register`, `function __wrap_devm_cxl_switch_port_decoders_setup`, `function __wrap_devm_cxl_endpoint_decoders_setup`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.