drivers/sh/intc/access.c
Source file repositories/reference/linux-study-clean/drivers/sh/intc/access.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/sh/intc/access.c- Extension
.c- Size
- 6629 bytes
- Lines
- 247
- Domain
- Driver Families
- Bucket
- drivers/sh
- 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
linux/io.hinternals.h
Detected Declarations
function Copyrightfunction intc_get_regfunction intc_set_field_from_handlefunction intc_get_field_from_handlefunction test_8function test_16function test_32function write_8function write_16function write_32function modify_8function modify_16function modify_32function intc_mode_fieldfunction intc_mode_zerofunction intc_mode_prio
Annotated Snippet
#include <linux/io.h>
#include "internals.h"
unsigned long intc_phys_to_virt(struct intc_desc_int *d, unsigned long address)
{
struct intc_window *window;
int k;
/* scan through physical windows and convert address */
for (k = 0; k < d->nr_windows; k++) {
window = d->window + k;
if (address < window->phys)
continue;
if (address >= (window->phys + window->size))
continue;
address -= window->phys;
address += (unsigned long)window->virt;
return address;
}
/* no windows defined, register must be 1:1 mapped virt:phys */
return address;
}
unsigned int intc_get_reg(struct intc_desc_int *d, unsigned long address)
{
unsigned int k;
address = intc_phys_to_virt(d, address);
for (k = 0; k < d->nr_reg; k++) {
if (d->reg[k] == address)
return k;
}
BUG();
return 0;
}
unsigned int intc_set_field_from_handle(unsigned int value,
unsigned int field_value,
unsigned int handle)
{
unsigned int width = _INTC_WIDTH(handle);
unsigned int shift = _INTC_SHIFT(handle);
value &= ~(((1 << width) - 1) << shift);
value |= field_value << shift;
return value;
}
unsigned long intc_get_field_from_handle(unsigned int value, unsigned int handle)
{
unsigned int width = _INTC_WIDTH(handle);
unsigned int shift = _INTC_SHIFT(handle);
unsigned int mask = ((1 << width) - 1) << shift;
return (value & mask) >> shift;
}
static unsigned long test_8(unsigned long addr, unsigned long h,
unsigned long ignore)
{
void __iomem *ptr = (void __iomem *)addr;
return intc_get_field_from_handle(__raw_readb(ptr), h);
}
static unsigned long test_16(unsigned long addr, unsigned long h,
unsigned long ignore)
{
void __iomem *ptr = (void __iomem *)addr;
return intc_get_field_from_handle(__raw_readw(ptr), h);
}
static unsigned long test_32(unsigned long addr, unsigned long h,
unsigned long ignore)
{
void __iomem *ptr = (void __iomem *)addr;
return intc_get_field_from_handle(__raw_readl(ptr), h);
}
static unsigned long write_8(unsigned long addr, unsigned long h,
unsigned long data)
{
void __iomem *ptr = (void __iomem *)addr;
__raw_writeb(intc_set_field_from_handle(0, data, h), ptr);
Annotation
- Immediate include surface: `linux/io.h`, `internals.h`.
- Detected declarations: `function Copyright`, `function intc_get_reg`, `function intc_set_field_from_handle`, `function intc_get_field_from_handle`, `function test_8`, `function test_16`, `function test_32`, `function write_8`, `function write_16`, `function write_32`.
- Atlas domain: Driver Families / drivers/sh.
- 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.