Miscellaneous Entry Points
This section discusses the dump(9E) and print(9E) entry points.
dump() Entry Point (Block Drivers)
The dump(9E) entry point is used to copy a portion of virtual address space directly to the specified device in the case of a system failure. It is also used to copy the state of the kernel out to disk during a checkpoint operation (see the cpr(7) and dump(9E) man pages). It must be capable of performing this operation without the use of interrupts, since they are disabled during the checkpoint operation.
int dump(dev_t dev, caddr_t addr, daddr_t blkno, int nblk) |
dev is the device number of the device to dump to, addr is the base kernel virtual address at which to start the dump, blkno is the first block to dump to, and nblk is the number of blocks to dump. The dump depends upon the existing driver working properly.
print() Entry Point (Block Drivers)
int print(dev_t dev, char *str) |
The print(9E) entry point is called by the system to display a message about an exception it has detected. print(9E) should call cmn_err(9F) to post the message to the console on behalf of the system. Here is an example:
static int xxprint(dev_t dev, char *str) { cmn_err(CE_CONT, "xx: %s\n", str); return (0); } |
Disk Device Drivers
Disk devices represent an important class of block device drivers.
Disk ioctls
Solaris disk drivers need to support a minimum set of ioctl commands specific to Solaris disk drivers. These I/O controls are specified in the dkio(7) manual page. Disk I/O controls transfer disk information to or from the device driver. A Solaris disk device is one that is supported by disk utility commands such as format(1M) and newfs(1M). Table 11-1 lists the mandatory Sun disk I/O controls.
Table 11-1 Mandatory Solaris Disk ioctls
ioctl | Description |
---|---|
DKIOCINFO | Returns information describing the disk controller |
DKIOCGAPART | Returns a disk's partition map |
DKIOCSAPART | Sets a disk's partition map |
DKIOCGGEOM | Returns a disk's geometry |
DKIOCSGEOM | Sets a disk's geometry |
DKIOCGVTOC | Returns a disk's Volume Table of Contents |
DKIOCSVTOC | Sets a disk's Volume Table of Contents |
Disk Performance
The Solaris DDI/DKI provides facilities to optimize I/O transfers for improved file system performance. It supports a mechanism to manage the list of I/O requests so as to optimize disk access for a file system. See "Asynchronous Data Transfers (Block Drivers)" for a description of enqueuing an I/O request.
The diskhd structure is used to manage a linked list of I/O requests.
struct diskhd { long b_flags; /* not used, needed for consistency*/ struct buf *b_forw, *b_back; /* queue of unit queues */ struct buf *av_forw, *av_back; /* queue of bufs for this unit */ long b_bcount; /* active flag */ }; |
The diskhd data structure has two buf pointers that the driver can manipulate. The av_forw pointer points to the first active I/O request. The second pointer, av_back, points to the last active request on the list.
A pointer to this structure is passed as an argument to disksort(9F), along with a pointer to the current buf structure being processed. The disksort(9F) routine is used to sort the buf requests in a fashion that optimizes disk seek and then inserts the buf pointer into the diskhd list. The disksort(9F) program uses the value that is in b_resid of the buf structure as a sort key. The driver is responsible for setting this value. Most Sun disk drivers use the cylinder group as the sort key. This tends to optimize the file system read-ahead accesses.
Once data has been added to the diskhd list, the device needs to transfer the data. If the device is not busy processing a request, the xxstart() routine pulls the first buf structure off the diskhd list and starts a transfer.
If the device is busy, the driver should return from the xxstrategy() entry point. Once the hardware is done with the data transfer, it generates an interrupt. The driver's interrupt routine is then called to service the device. After servicing the interrupt, the driver can then call the start() routine to process the next buf structure in the diskhd list.