drivers/staging/most/dim2/hal.c
Source file repositories/reference/linux-study-clean/drivers/staging/most/dim2/hal.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/staging/most/dim2/hal.c- Extension
.c- Size
- 23149 bytes
- Lines
- 972
- Domain
- Driver Families
- Bucket
- drivers/staging
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
hal.herrors.hreg.hlinux/io.hlinux/kernel.h
Detected Declarations
struct async_tx_dbrstruct lld_global_vars_tfunction Copyrightfunction dim_on_errorfunction dbr_get_mask_sizefunction alloc_dbrfunction free_dbrfunction dim2_transfer_madrfunction dim2_clear_dbrfunction dim2_read_ctrfunction dim2_write_ctr_maskfunction dim2_write_ctrfunction dim2_clear_ctrfunction dim2_configure_catfunction dim2_clear_catfunction dim2_configure_cdtfunction dim2_rpcfunction dim2_clear_cdtfunction dim2_configure_adtfunction dim2_clear_adtfunction dim2_start_ctrl_asyncfunction dim2_start_isoc_syncfunction dim2_clear_ctramfunction dim2_configure_channelfunction dim2_clear_channelfunction norm_pcfunction dbrcnt_initfunction dbrcnt_enqfunction dim_dbr_spacefunction state_initfunction check_channel_addressfunction check_packet_lengthfunction check_bytes_per_framefunction dim_norm_ctrl_async_buffer_sizefunction norm_isoc_buffer_sizefunction norm_sync_buffer_sizefunction dim2_cleanupfunction dim2_initializefunction dim2_is_mlb_lockedfunction service_channelfunction isoc_initfunction sync_initfunction channel_initfunction channel_service_interruptfunction channel_startfunction channel_servicefunction channel_detach_buffersfunction dim_startup
Annotated Snippet
struct async_tx_dbr {
u8 ch_addr;
u16 rpc;
u16 wpc;
u16 rest_size;
u16 sz_queue[CDT0_RPC_MASK + 1];
};
struct lld_global_vars_t {
bool dim_is_initialized;
bool mcm_is_initialized;
struct dim2_regs __iomem *dim2; /* DIM2 core base address */
struct async_tx_dbr atx_dbr;
u32 fcnt;
u32 dbr_map[DBR_MAP_SIZE];
};
static struct lld_global_vars_t g = { false };
/* -------------------------------------------------------------------------- */
static int dbr_get_mask_size(u16 size)
{
int i;
for (i = 0; i < 6; i++)
if (size <= (DBR_BLOCK_SIZE << i))
return 1 << i;
return 0;
}
/**
* alloc_dbr() - Allocates DBR memory.
* @size: Allocating memory size.
* Returns: Offset in DBR memory by success or DBR_SIZE if out of memory.
*/
static int alloc_dbr(u16 size)
{
int mask_size;
int i, block_idx = 0;
if (size <= 0)
return DBR_SIZE; /* out of memory */
mask_size = dbr_get_mask_size(size);
if (mask_size == 0)
return DBR_SIZE; /* out of memory */
for (i = 0; i < DBR_MAP_SIZE; i++) {
u32 const blocks = DIV_ROUND_UP(size, DBR_BLOCK_SIZE);
u32 mask = ~((~(u32)0) << blocks);
do {
if ((g.dbr_map[i] & mask) == 0) {
g.dbr_map[i] |= mask;
return block_idx * DBR_BLOCK_SIZE;
}
block_idx += mask_size;
/* do shift left with 2 steps in case mask_size == 32 */
mask <<= mask_size - 1;
} while ((mask <<= 1) != 0);
}
return DBR_SIZE; /* out of memory */
}
static void free_dbr(int offs, int size)
{
int block_idx = offs / DBR_BLOCK_SIZE;
u32 const blocks = DIV_ROUND_UP(size, DBR_BLOCK_SIZE);
u32 mask = ~((~(u32)0) << blocks);
mask <<= block_idx % 32;
g.dbr_map[block_idx / 32] &= ~mask;
}
/* -------------------------------------------------------------------------- */
static void dim2_transfer_madr(u32 val)
{
writel(val, &g.dim2->MADR);
/* wait for transfer completion */
while ((readl(&g.dim2->MCTL) & 1) != 1)
continue;
writel(0, &g.dim2->MCTL); /* clear transfer complete */
}
static void dim2_clear_dbr(u16 addr, u16 size)
Annotation
- Immediate include surface: `hal.h`, `errors.h`, `reg.h`, `linux/io.h`, `linux/kernel.h`.
- Detected declarations: `struct async_tx_dbr`, `struct lld_global_vars_t`, `function Copyright`, `function dim_on_error`, `function dbr_get_mask_size`, `function alloc_dbr`, `function free_dbr`, `function dim2_transfer_madr`, `function dim2_clear_dbr`, `function dim2_read_ctr`.
- Atlas domain: Driver Families / drivers/staging.
- Implementation status: source 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.