• Aucun résultat trouvé

Addressing Micro Channel Adapters

Dans le document WRITING A DEVICE DRIVER FOR AIX VERSION 3 (Page 44-47)

2.5.1 Identifying an Adapter

The first two POS registers for each adapter define what kind of adapter it is.

These two bytes contain a read-only number which uniquely identifies the functions and capabilities of the adapter. A particular make and model of Ethernet adapter might be identified by number Ox1234, while a particular variety of sesl disk controller might be identified by number Ox9876. IBM maintains a central registry for these numbers; even adapters produced by other companies are guaranteed to be uniquely identified by the value of their first two POS registers.

The AIX Version 3 boot process uses the adapter 10 to determine what type of Micro Channel adapter resides in each of the machine's expansion slots; this determines which device drivers are loaded as part of the system.

Note: ---~---~

The unique instance of an adapter (if there are more than one of that same type of adapter) is by the POS 10 and SLOT NUMBER.

Also, the POS 10 identifies only the base adapter and NOT a "daughter board" that may be plugged into that adapter. Therefore, an adapter with more that one kind of daughter board cannot be differentiated unless the POS IDs are different.

2.5.2 Setting Adapter Attributes

The first two POS registers for each Micro Channel slot in the system (POS register

a

and POS register 1) contain the adapter 10, described above. The other POS registers control various attributes of the adapter. These attributes vary from adapter to adapter, but some typical attributes are:

• The Interrupt ReQuest level (IRQ) on which the adapter will generate interrupts (discussed later).

• The beginning I/O address of the adapter's ports.

• The beginning "memory" address of the adapter's RAM and/or ROM (if any).

Other specialized attributes may also be set using the POS registers. The exact bit values used to set various options is dependent on the adapter in question; see the technical information provided with the adapter for specific bit assignments.

2.5.3 Enabling an Adapter

2.5.4 1/0 Macros

The low order bit of POS register 2 (the third register) indicates whether the adapter is enabled or not. If this bit is set to zero (as it is when the system is booted or powered up) then the adapter is disabled; it may not generate interrupts or otherwise make use of the system's resources, nor may the system make use of the adapter's resources. After the adapter has been correctly configured by the device driver and once the device driver is ready to process interrupts from the device, the device driver must modify POS register 2 to set this bit. Once the bit is set, the adapter may generate interrupts and may be the target of input and output requests from the host CPU.

(Note that you should disable your adapter when you are unconfiguring it as well as for detected adapter error conditions that result in the shutdown of your adapter.)

As discussed before ("Micro Channel Overview" on page 2-1), in the RISC System/BOOO, POS registers appear to be virtual memory. They are maintained in a memory segment which is managed by the IOCC hardware component (see "Overview" on page 2-3).

Kernel services exist to manipulate virtual memory, but they should never be used because very convenient C language macros can also be used to do the same job (examples will be given in "Setting POS Registers from within a Device Driver" on page 2-18 and "Simple I/O" on page 2-19). For instance, IOCC_ATT will map the 10CC segment into the device driver's virtual address space and IOCC_DET will unmap (delete) the 10CC segment from that address space. Another macro, POSREG( n,m), will return the address of the nth POS register of the adapter in slot m. This address can be used quite easily as a pOinter to the POS register. Fetching the byte at that address, using the BUSIO_GETC macro, will give the current value of the register, while setting the byte (with the BUSIO_PUTC macro) at that address will modify the POS register.

See

<

sys/mdio.h

>

for POSREG and

<

sys/ioacc.h

>

for BUSIO _ GETC and BUSIO _PUTC.

As discussed above, most Micro Channel adapters provide a number of ports through which they can communicate with host software. Like POS registers, these registers are also memory mapped in the RISC System/6000. The BUSIO_ATT macro will map the I/O segment into a device driver's virtual address space; the address of the port in question (set by the POS process) is used as a displacement within that segment to determine the memory mapped address of the port. Once the address is determined by reading the dds, the port may be accessed through a number of convenient macros provided by AIX Version 3. When the accesses are complete, the BUSIO_DET macro will remove the I/O segment from the virtual address space.

Memory provided on Micro Channel adapters can also be manipulated using the BUSMEM_ATT and BUSMEM_DET macros.

Note that for code running in user mode, like a configuration method (see

"Device Drivers Configuration" on page 6-1), the machine device driver is used to access the 10CC and I/O address spaces. With that device driver, you can directly read or write a POS register, or any adapter port by using the system call 10CTl on /dev/busO with different commands:

• MIOCCGET and MIOCCPUT allow you to read or write in the 10CC address space

• MIOBUSGET and MIOBUSPUT allow you to read or write in the I/O bus address space.

We will see later an example (see "Querying POS Registers from a Configuration Method" on page 2-18) of how to use this device driver.

2.5.4.1 Attach/Detach Macros

In order to access I/O resources with the BUSMEM_ATT, BUSIO_ATT, or IOCC_ATT macros you must supply what is unfortunately called a bus ID. The bus 10 is in fact the value you need to load to a segment register (Le. the whole word shown in Figure 2-4 on page 2-7). This word should not be confused with the Bus Unit IDentification which is the 10 of the 10CC you want to talk to (should always be x'20), and which is part of the bus ID!

The bus 10 value to use when manipulating 10CC resources (POS registers, etc.) is defined in /usrlinclude/sys/iocc.h by the name IOCC_BID. The bus 10 to use when accessing resources on the Micro Channel is never defined in any

documentation; but if you choose the recommended values (see again Figure 2-4 on page 2-7), you will find that:

Dans le document WRITING A DEVICE DRIVER FOR AIX VERSION 3 (Page 44-47)