mike@Brl-Bmd.ARPA (03/29/83)
From: Mike Muuss <mike@Brl-Bmd.ARPA> Another nice tid-bit for the Kernel. This one is implemented in V6 and V7s on PDP-11s, but may prove useful on VAXen too. By adding a field off_t b_offset; /* Byte offset on device */ to the buf.h definition of the buf struct, it becomes possible to build device drivers which can deal with seeking to an arbitrary byte offset on the device, and then initiating a DMA. There are a number of device types which it is generally useful to be able to (a) do raw {PHYSIO} transfers on while (b) retaining the ability to seek to an arbitrary byte offset. These include: frame buffers (Our Ikonas driver uses this) display list processors (Our Vector General driver...) RF-11 style disks (Our RF-11 driver...) Slave CPUs (Our HEP LSB driver...) The changes required are quite simple: In addition to adding the definition in buf.h, the following changes are needed: getblk() / bio.c: <at the end> b_offset = ((off_t)blkno)<<BSHIFT; return; swap() / physio.c: bp->b_offset = ((off_t)blkno)<<BSHIFT; (*devsw[....].d_strategy)(bp); physio() / physio.c: bp->b_addr = ... bp->b_xmem = ... bp->b_blkno = u.u_offset>>BSHIFT; bp->b_offset = u.u_offset; and that is all the support required. Converting a driver (for a suitable device) is as simple as finding references to b_blkno and changing them appropriately to b_offset (shifting & masking as necessary). Cheers, -Mike