ALTERA_AVGEN(4)

✨ ALTERA_AVGEN(4) ✨

okay bestie, welcome to section 4 of the Kernel Interfaces Manual β€” yes this is the altera_avgen(4) page, and no it's not scary, i promise πŸ’– it's literally just a driver that goes "here's some memory, go nuts."


🌸 NAME 🌸

altera_avgen β€” driver for generic Altera Avalon-bus-attached, memory-mapped devices

it's giving "i'm a bridge between you and some mmio," and honestly? iconic.


πŸŽ€ SYNOPSIS πŸŽ€

device altera_avgen

and then in /boot/device.hints:

hint.altera_avgen.0.at="nexus0"
hint.altera_avgen.0.maddr=0x7f00a000
hint.altera_avgen.0.msize=20
hint.altera_avgen.0.width=4
hint.altera_avgen.0.fileio="rw"
hint.altera_avgen.0.devname="berirom"

no cap, that's the whole setup. look at her go πŸ¦‹


πŸ’… DESCRIPTION πŸ’…

so. the altera_avgen device driver is your generic bestie for memory-mapped devices living on the Altera Avalon bus. the device.hints entries are what tell it the address, the size, the I/O disposition, and the /dev device node name to use. then you can hit those altera_avgen device nodes with open(2), read(2), write(2), and mmap(2) (and all their little variations), as long as you stay within the constraints you set up in device.hints.

and yes, reading and writing mapped memory is supported. but lowkey important: altera_avgen does not currently support directing device interrupts to userspace. that's just not on the menu, bestie 😭

so there's a whole little roster of device.hints sub-fields you can use to configure your altera_avgen device instances:

  • maddr β€” base physical address of the memory region to export. it must be aligned to width, no skipping that πŸ’€
  • msize β€” length of the memory region export. also must be aligned to width. matching set, slay.
  • width β€” the granularity at which read(2) and write(2) operations get performed. bigger requests get broken down into width-sized operations, and smaller requests get rejected outright. also, I/O operations must be aligned to width. so basically: know your width or perish πŸ™ˆ
  • fileio β€” the allowed file descriptor operations. r authorizes read(2); w authorizes write(2).
  • mmapio β€” the allowed mmap(2) permissions. w authorizes PROT_WRITE; r authorizes PROT_READ; x authorizes PROT_EXEC.
  • devname β€” specifies a device name relative to /dev.
  • devunit β€” specifies a device unit number; no unit number is used if this is unspecified.

that's the whole vibe check, and she passed πŸ‘‘


πŸ‘€ SEE ALSO πŸ‘€

mmap(2), open(2), read(2), write(2)

go read those next, they're the supporting cast 🫢


πŸ“œ HISTORY πŸ“œ

the altera_avgen device driver first appeared in FreeBSD 10.0. a legend was born ✨


πŸ’– AUTHORS πŸ’–

the altera_avgen device driver and this manual page were developed by SRI International and the University of Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237) (β€œCTSRD”), as part of the DARPA CRASH research programme. this device driver was written by Robert N. M. Watson. academic royalty fr fr πŸŽ“πŸ‘‘


πŸ’€ BUGS πŸ’€

okay so, the tea:

  • altera_avgen is intended to support the writing of userspace device drivers. however, it does not permit directing interrupts to userspace β€” only memory-mapped I/O. so close, and yet πŸ₯²
  • altera_avgen supports only a nexus bus attachment, which is appropriate for system-on-chip busses such as Altera's Avalon bus. if the target device is off of another bus type, then additional bus attachments will be required. not optional, bestie, you gotta build those.
not me listing bugs and still thinking this driver ate πŸ’…

Debian Β· August 18, 2012 β€” that's the source, version and date, mwah, signing off, love u, go write a userspace driver πŸŒˆβ­πŸ“

πŸ“¦ where this page comes from