'\"macro stdmacro
.if n .pH ddi_dki.getvec @(#)getvec	40.6 of 10/10/89
.\" Copyright 1989 AT&T
.de IX
.ie '\\n(.z'' .tm .Index: \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9	\\n%
.el \\!.IX \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9
..
.nr X
.if \nX=0 .ds x} getvec D3D "3B2" "DDI" "\&"
.if \nX=1 .ds x} getvec D3D "3B2" "DDI"
.if \nX=2 .ds x} getvec D3D "" "\&"
.if \nX=3 .ds x} getvec "" "" "\&"
.TH \*(x}
.IX "\f4getvec\fP(D3D)"
.SH "NAME" 
\f4getvec\f1 \- get an interrupt vector for a virtual feature card address
.SH SYNOPSIS 
.nf
.na
\f4unsigned char getvec(long \f2baddr\f4);\f1
.ad
.fi
.SH "ARGUMENTS" 
.RS 0n 10
.IP "\f2baddr\f1" 10n
A virtual feature card address.
.RE
.SH DESCRIPTION 
\f4getvec\f1 returns an interrupt vector for a specified virtual feature card
address.  \f4getvec\f1 is used in an \f4init\f1(D2D) routine.
.SP
\f3NOTE:\f1
If the feature card address is \f40\f1, a divide-by-zero
error can occur.
.SH "RETURN VALUE" 
Under all conditions, an \f4unsigned char\f1 numeric value is returned.
The only abnormal return value is a number not logical for the
circumstances.
.SH "LEVEL" 
Base Only  (Do not call from an interrupt routine)
.SH EXAMPLE 
.IX "\f4getvec\fP(D3D), example"
.IX "\f4init\fP(D2D), example"
.P
With a 3B2
computer, each device that generates an interrupt must be given an interrupt
vector location code.  During system initialization, the driver \f4init\f1
routine gets the interrupt vector location code (line 17) and stores the code
in a predefined address on the interface card (an address on the card in the
range of \f40x0\f1 to \f40x200000\f1 can be defined to hold the code).
.P
When a device generates an interrupt, the interface card presents the code to
the CPU, which uses it to locate the interrupt handling routine(s) of the
driver.
.ne 4
.P
.nf
.ft 4
.ps 7
 1  struct  device  {             /* physical device registers layout   */
 2          char      reserve[4]; /* reserve space on card              */
 3          ushort    control;    /* physical device control word       */
 4          char      status;     /* physical device status word        */
 5          char      ivec_num;   /* device interrupt vector number in  */
 6                                /* 0xf0; subdevice reporting in 0x0f  */
 7          paddr_t   addr;       /* address of data to be read/written */
 8          int       count;      /* amount of data to be read/written  */
 9  }; /* end device */
10
11  extern struct device *xx_addr[]; /* physical dev registers location */
12
13  xx_init()
14  {
15                                        /* get device register struct */
16      register struct device *rp = xx_addr[0];
17      rp->ivec_num = getvec(xx_addr[0]); /* get interrupt vector code */
18
19  } /* end xx_init */
.ps
.ft 1
.fi
.P
.FG "getvec \- get an interrupt vector"
