drivers/firmware/cirrus/test/cs_dsp_mock_wmfw.c
Source file repositories/reference/linux-study-clean/drivers/firmware/cirrus/test/cs_dsp_mock_wmfw.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/firmware/cirrus/test/cs_dsp_mock_wmfw.c- Extension
.c- Size
- 15040 bytes
- Lines
- 479
- Domain
- Driver Families
- Bucket
- drivers/firmware
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
kunit/resource.hkunit/test.hlinux/firmware/cirrus/cs_dsp.hlinux/firmware/cirrus/cs_dsp_test_utils.hlinux/firmware/cirrus/wmfw.hlinux/firmware.hlinux/math.hlinux/overflow.hlinux/string.hlinux/vmalloc.h
Detected Declarations
struct cs_dsp_mock_wmfw_builderstruct wmfw_adsp2_halo_headerstruct wmfw_long_stringstruct wmfw_short_stringfunction cs_dsp_mock_wmfw_format_versionfunction cs_dsp_mock_wmfw_get_firmwarefunction cs_dsp_mock_wmfw_add_raw_blockfunction cs_dsp_mock_wmfw_add_infofunction cs_dsp_mock_wmfw_add_data_blockfunction cs_dsp_mock_wmfw_start_alg_info_blockfunction cs_dsp_mock_wmfw_add_coeff_descfunction cs_dsp_mock_wmfw_end_alg_info_blockfunction cs_dsp_init_adsp2_halo_wmfwfunction cs_dsp_mock_wmfw_init
Annotated Snippet
struct cs_dsp_mock_wmfw_builder {
struct cs_dsp_test *test_priv;
int format_version;
void *buf;
size_t buf_size_bytes;
void *write_p;
size_t bytes_used;
void *alg_data_header;
unsigned int num_coeffs;
};
struct wmfw_adsp2_halo_header {
struct wmfw_header header;
struct wmfw_adsp2_sizes sizes;
struct wmfw_footer footer;
} __packed;
struct wmfw_long_string {
__le16 len;
u8 data[] __nonstring __counted_by(len);
} __packed;
struct wmfw_short_string {
u8 len;
u8 data[] __nonstring __counted_by(len);
} __packed;
KUNIT_DEFINE_ACTION_WRAPPER(vfree_action_wrapper, vfree, void *)
/**
* cs_dsp_mock_wmfw_format_version() - Return format version.
*
* @builder: Pointer to struct cs_dsp_mock_wmfw_builder.
*
* Return: Format version.
*/
int cs_dsp_mock_wmfw_format_version(struct cs_dsp_mock_wmfw_builder *builder)
{
return builder->format_version;
}
EXPORT_SYMBOL_NS_GPL(cs_dsp_mock_wmfw_format_version, "FW_CS_DSP_KUNIT_TEST_UTILS");
/**
* cs_dsp_mock_wmfw_get_firmware() - Get struct firmware wrapper for data.
*
* @builder: Pointer to struct cs_dsp_mock_wmfw_builder.
*
* Return: Pointer to a struct firmware wrapper for the data.
*/
struct firmware *cs_dsp_mock_wmfw_get_firmware(struct cs_dsp_mock_wmfw_builder *builder)
{
struct firmware *fw;
if (!builder)
return NULL;
fw = kunit_kzalloc(builder->test_priv->test, sizeof(*fw), GFP_KERNEL);
KUNIT_ASSERT_NOT_ERR_OR_NULL(builder->test_priv->test, fw);
fw->data = builder->buf;
fw->size = builder->bytes_used;
return fw;
}
EXPORT_SYMBOL_NS_GPL(cs_dsp_mock_wmfw_get_firmware, "FW_CS_DSP_KUNIT_TEST_UTILS");
/**
* cs_dsp_mock_wmfw_add_raw_block() - Add a block to the wmfw file.
*
* @builder: Pointer to struct cs_dsp_mock_bin_builder.
* @block_type: Block type.
* @offset: Offset.
* @payload_data: Pointer to buffer containing the payload data,
* or NULL if no data.
* @payload_len_bytes: Length of payload data in bytes, or zero.
*/
void cs_dsp_mock_wmfw_add_raw_block(struct cs_dsp_mock_wmfw_builder *builder,
int block_type, unsigned int offset,
const void *payload_data, size_t payload_len_bytes)
{
struct wmfw_region *header = builder->write_p;
unsigned int bytes_needed = struct_size_t(struct wmfw_region, data, payload_len_bytes);
KUNIT_ASSERT_TRUE(builder->test_priv->test,
(builder->write_p + bytes_needed) <
(builder->buf + CS_DSP_MOCK_WMFW_BUF_SIZE));
header->offset = cpu_to_le32(offset | (block_type << 24));
header->len = cpu_to_le32(payload_len_bytes);
Annotation
- Immediate include surface: `kunit/resource.h`, `kunit/test.h`, `linux/firmware/cirrus/cs_dsp.h`, `linux/firmware/cirrus/cs_dsp_test_utils.h`, `linux/firmware/cirrus/wmfw.h`, `linux/firmware.h`, `linux/math.h`, `linux/overflow.h`.
- Detected declarations: `struct cs_dsp_mock_wmfw_builder`, `struct wmfw_adsp2_halo_header`, `struct wmfw_long_string`, `struct wmfw_short_string`, `function cs_dsp_mock_wmfw_format_version`, `function cs_dsp_mock_wmfw_get_firmware`, `function cs_dsp_mock_wmfw_add_raw_block`, `function cs_dsp_mock_wmfw_add_info`, `function cs_dsp_mock_wmfw_add_data_block`, `function cs_dsp_mock_wmfw_start_alg_info_block`.
- Atlas domain: Driver Families / drivers/firmware.
- Implementation status: integration implementation candidate.
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.