sound/isa/gus/gus_dram.c
Source file repositories/reference/linux-study-clean/sound/isa/gus/gus_dram.c
File Facts
- System
- Linux kernel
- Corpus path
sound/isa/gus/gus_dram.c- Extension
.c- Size
- 2150 bytes
- Lines
- 84
- Domain
- Driver Families
- Bucket
- sound/isa
- 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.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/time.hsound/core.hsound/gus.hsound/info.h
Detected Declarations
function Copyrightfunction snd_gus_dram_writefunction snd_gus_dram_peekfunction snd_gus_dram_read
Annotated Snippet
if (gus->interwave) {
guard(spinlock_irqsave)(&gus->reg_lock);
snd_gf1_write8(gus, SNDRV_GF1_GB_MEMORY_CONTROL, 0x01);
snd_gf1_dram_addr(gus, address);
outsb(GUSP(gus, DRAM), buffer, size1);
address += size1;
} else {
pbuffer = buffer;
size2 = size1;
while (size2--)
snd_gf1_poke(gus, address++, *pbuffer++);
}
size -= size1;
_buffer += size1;
}
return 0;
}
int snd_gus_dram_write(struct snd_gus_card *gus, char __user *buffer,
unsigned int address, unsigned int size)
{
return snd_gus_dram_poke(gus, buffer, address, size);
}
static int snd_gus_dram_peek(struct snd_gus_card *gus, char __user *_buffer,
unsigned int address, unsigned int size,
int rom)
{
unsigned int size1, size2;
char buffer[256], *pbuffer;
while (size > 0) {
size1 = size > sizeof(buffer) ? sizeof(buffer) : size;
if (gus->interwave) {
guard(spinlock_irqsave)(&gus->reg_lock);
snd_gf1_write8(gus, SNDRV_GF1_GB_MEMORY_CONTROL, rom ? 0x03 : 0x01);
snd_gf1_dram_addr(gus, address);
insb(GUSP(gus, DRAM), buffer, size1);
snd_gf1_write8(gus, SNDRV_GF1_GB_MEMORY_CONTROL, 0x01);
address += size1;
} else {
pbuffer = buffer;
size2 = size1;
while (size2--)
*pbuffer++ = snd_gf1_peek(gus, address++);
}
if (copy_to_user(_buffer, buffer, size1))
return -EFAULT;
size -= size1;
_buffer += size1;
}
return 0;
}
int snd_gus_dram_read(struct snd_gus_card *gus, char __user *buffer,
unsigned int address, unsigned int size,
int rom)
{
return snd_gus_dram_peek(gus, buffer, address, size, rom);
}
Annotation
- Immediate include surface: `linux/time.h`, `sound/core.h`, `sound/gus.h`, `sound/info.h`.
- Detected declarations: `function Copyright`, `function snd_gus_dram_write`, `function snd_gus_dram_peek`, `function snd_gus_dram_read`.
- Atlas domain: Driver Families / sound/isa.
- Implementation status: source implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
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.