DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
SVR5

cm_read_devconfig16(D3)


cm_read_devconfig16 -- read word from board's NVRAM extension information

Synopsis

   #include <sys/confmgr.h>
   #include <sys/ddi.h>
   

int cm_read_devconfig16(rm_key_t key, size_t offset, ushort_t *buf)

Description

cm_read_devconfig16( ) is used to read a word (2-bytes) from the NVRAM extension information associated with a selected board instance. The extension information is specific to the bus and type of the board and exactly what information is read is determined by the bus driver (for example, the PCI bus driver).

Drivers should not use this routine to read standard board parameters directly. Rather, such parameters should be acquired with cm_getval(D3) requests.

Arguments


key
Resource manager key selecting a particular board instance.

offset
Offset from the beginning of the board's device configuration space to start the read.

buf
Buffer to hold data to be read.

Return values

cm_read_devconfig16 returns 0 for success. The following errnos are returned for failure:

EINVAL
if rm_key is invalid, buf is NULL or the read fails.

ENOENT
if the board is installed in an ISA bus or the bus doesn't provide the specified level of granularity.

Note, even though the UnixWare 2 interface, cm_read_devconfig, cm_read_devconfig(D3) function, supports all levels of granularity, this interface is limited to those "inherent" on the system (In other words, there are bios calls to support them directly).

Usage

The caller must not have a resource manager transaction pending (see cm_begin_trans(D3)) when this function is called.

Examples

   #define PCI_COMMAND_OFFSET 4
   #define PCI_COMMAND_IO 0x0001
   #define PCI_COMMAND_MEM 0x0002
   #define PCI_COMMAND_MASTER 0x0004
   

uint pnt_pci_master(rm_key_t key) { ulong cmd = 0;

/* get the pci command register */ if (cm_read_devconfig16(key, PCI_COMMAND_OFFSET, (void *)&cmd) == -1) { cmn_err(CE_WARN, "pnt_pci_master: cm_read_devconfig16 failed"); } cmn_err(CE_NOTE, "key %x pci command %x\n", key, cmd);

/* enable busmastering in the pci command register */ if (! (cmd & PCI_COMMAND_MASTER)) { cmd |= PCI_COMMAND_MASTER; if ((cm_write_devconfig16(key, PCI_COMMAND_OFFSET, (void *)&cmd)) == 0) { cmn_err(CE_WARN, "pnt_pci_master: cm_write_devconfig16 failed"); if (cm_read_devconfig16(key, PCI_COMMAND_OFFSET, (void *)&cmd) == -1) { cmn_err(CE_WARN, "pnt_pci_master: cm_read_devconfig16 failed - verify"); } if (! (cmd & PCI_COMMAND_MASTER)) { cmn_err(CE_WARN, "pnt_pci_master: set master failed"); return(0); } } } return(1); }

Context and synchronization

All contexts.

Hardware applicability

All

Version applicability

ddi: 7.1, 7.1mp, 8, 8mp

Differences between versions

In DDI versions 7 and 7.1mp, the offset argument is cast as size_t rather than an off_t. When porting drivers from earlier DDI versions, it is not necessary to modify the type of the offset argument.

References

cm_devconfig_size(D3), cm_getbrdkey(D3), cm_getval(D3), cm_read_devconfig(D3), cm_read_devconfig8(D3), cm_read_devconfig32(D3), cm_write_devconfig(D3), cm_write_devconfig8(D3), cm_write_devconfig16(D3), cm_write_devconfig32(D3), eisa_parse_devconfig(D3), eisa(D4), eisa(D5), mca(D5), pci(D5)

``Autoconfiguration'' in HDK Technical Reference


19 June 2005
© 2005 The SCO Group, Inc. All rights reserved.
OpenServer 6 and UnixWare (SVR5) HDK - June 2005