drivers/video/fbdev/sbuslib.c
Source file repositories/reference/linux-study-clean/drivers/video/fbdev/sbuslib.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/video/fbdev/sbuslib.c- Extension
.c- Size
- 6913 bytes
- Lines
- 289
- Domain
- Driver Families
- Bucket
- drivers/video
- 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.
- 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/compat.hlinux/export.hlinux/kernel.hlinux/module.hlinux/string.hlinux/fb.hlinux/mm.hlinux/uaccess.hlinux/of.hasm/fbio.hsbuslib.h
Detected Declarations
function Copyrightfunction sbusfb_mmapsizefunction sbusfb_mmap_helperfunction sbusfb_ioctl_helperfunction sbusfb_compat_ioctlexport sbusfb_fill_varexport sbusfb_mmap_helperexport sbusfb_ioctl_helperexport sbusfb_compat_ioctl
Annotated Snippet
if (map[i].voff == off+page) {
map_size = sbusfb_mmapsize(map[i].size, fbsize);
#ifdef __sparc_v9__
#define POFF_MASK (PAGE_MASK|0x1UL)
#else
#define POFF_MASK (PAGE_MASK)
#endif
map_offset = (physbase + map[i].poff) & POFF_MASK;
break;
}
if (!map_size) {
page += PAGE_SIZE;
continue;
}
if (page + map_size > size)
map_size = size - page;
r = io_remap_pfn_range(vma,
vma->vm_start + page,
MK_IOSPACE_PFN(iospace,
map_offset >> PAGE_SHIFT),
map_size,
vma->vm_page_prot);
if (r)
return -EAGAIN;
page += map_size;
}
return 0;
}
EXPORT_SYMBOL(sbusfb_mmap_helper);
int sbusfb_ioctl_helper(unsigned long cmd, unsigned long arg,
struct fb_info *info,
int type, int fb_depth, unsigned long fb_size)
{
switch(cmd) {
case FBIOGTYPE: {
struct fbtype __user *f = (struct fbtype __user *) arg;
if (put_user(type, &f->fb_type) ||
put_user(info->var.yres, &f->fb_height) ||
put_user(info->var.xres, &f->fb_width) ||
put_user(fb_depth, &f->fb_depth) ||
put_user(0, &f->fb_cmsize) ||
put_user(fb_size, &f->fb_cmsize))
return -EFAULT;
return 0;
}
case FBIOPUTCMAP_SPARC: {
struct fbcmap __user *c = (struct fbcmap __user *) arg;
struct fb_cmap cmap;
u16 red, green, blue;
u8 red8, green8, blue8;
unsigned char __user *ured;
unsigned char __user *ugreen;
unsigned char __user *ublue;
unsigned int index, count, i;
if (get_user(index, &c->index) ||
get_user(count, &c->count) ||
get_user(ured, &c->red) ||
get_user(ugreen, &c->green) ||
get_user(ublue, &c->blue))
return -EFAULT;
cmap.len = 1;
cmap.red = &red;
cmap.green = &green;
cmap.blue = &blue;
cmap.transp = NULL;
for (i = 0; i < count; i++) {
int err;
if (get_user(red8, &ured[i]) ||
get_user(green8, &ugreen[i]) ||
get_user(blue8, &ublue[i]))
return -EFAULT;
red = red8 << 8;
green = green8 << 8;
blue = blue8 << 8;
cmap.start = index + i;
err = fb_set_cmap(&cmap, info);
if (err)
return err;
}
return 0;
}
case FBIOGETCMAP_SPARC: {
Annotation
- Immediate include surface: `linux/compat.h`, `linux/export.h`, `linux/kernel.h`, `linux/module.h`, `linux/string.h`, `linux/fb.h`, `linux/mm.h`, `linux/uaccess.h`.
- Detected declarations: `function Copyright`, `function sbusfb_mmapsize`, `function sbusfb_mmap_helper`, `function sbusfb_ioctl_helper`, `function sbusfb_compat_ioctl`, `export sbusfb_fill_var`, `export sbusfb_mmap_helper`, `export sbusfb_ioctl_helper`, `export sbusfb_compat_ioctl`.
- Atlas domain: Driver Families / drivers/video.
- Implementation status: integration 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.