
Applied Micro Circuits Corporation
6195 Lusk Blvd., San Diego, CA 92121 (619) 450-9333
15-53
PCI CONTROLLER
S5933
S5933
PCI CONTROLLER
Introduction
This appendix provides information useful to software
developers working with AMCC’s S5933 PCI control-
ler. It describes a software method of interfacing a
PCI device using the S5933 in a host computer; this
method consists of a series of C-language routines to
access the PCI device using the PCI BIOS. This ap-
pendix also demonstrates several ways to make use
of the special features of the S5933 PCI controller,
including mailboxes, FIFO transfers, bus master
transfers, nvRAM access and endian conversion.
Organization
A library of C-language callable routines are pre-
sented for managing a PCI device using a S5933 PCI
controller, organized in a logical progression of imple-
mentation. This progression begins with PCI BIOS
initialization, device initialization, and finally proceeds
to data transfer via PIO and Bus Master DMA meth-
ods.
A software program to manage a PCI device may
use the PCI BIOS as specified in the PCI BIOS
Specification. This interface provides a hardware-in-
dependent method of communicating with PCI de-
vices in a host computer. A C-language callable
interfacing to the PCI BIOS is shown in this docu-
ment.
The source code presented in this document is writ-
ten entirely in Borland C/C++ Version 3.1. Other
vendor’s C-language compilers can be used, with the
appropriate modifications for low-level register ac-
cess and software interrupt generation. Program frag-
ments and calling sequences are shown throughout.
The complete source code for the PCI BIOS interface
routines is contained at the end of Appendix A.
Low-Level Access via Borland C
The source code uses the PCI BIOS to access the
device in a hardware-independent manner. Using the
PCI BIOS, however, necessitates low-level access to
processor registers and software interrupts. Borland
C/C++ provides easy methods of accessing registers
using the pseudo-register variables and software in-
terrupts using the function geninterrupt().
A hardware register can be accessed via the pseudo-
register variables. These pseudo-registers are
formed by pre-pending an underscore to the register
name in uppercase. For example, the AX register is
accessed with the variable name _AX.
Caution: The register is not guaranteed to remain
as assigned. This requires careful examination of
the resulting assembler output. All of the routines
in this document have been verified to retain the
values of the pseudo-registers until used by the
PCI BIOS interrupt or saved in a temporary vari-
able in the necessary order. If the routines are
subjected to ANY optimizations, the resulting as-
sembler code must be examined to insure the
registers are still valid.
Also, some of the PCI BIOS routines require the use
of the 32-bit registers (EAX, EBX, ECX, EDX). This
means that the (-3) option on the BCC command line
option must be used. The following command com-
piles the routines described in this appendix:
BCC -3 PCILIB.C
Invoking a software interrupt is also easy in Borland
C/C++ using the library function geninterrupt(). The
syntax to invoke the PCI BIOS software interrupt is:
geninterrupt(0x1a);
Identification of PCI Devices
A set of three PCI BIOS functions may be used to
determine the existence of a specific device on the
PCI bus. These functions include pci_bios_present,
find_pci_device and find_pci_class_code. The
pci_bios_present function determines the presence
of the PCI BIOS in the host computer. If this function
indicates that the PCI BIOS does not exist, then the
remainder of the PCI BIOS functions will not work.
The find_pci_device function determines if a specific
device
exists
in
the
PCI
system.
The
find_pci_class_code determines if a device with a
specific class code exists in the system. These three
functions are described in detail in the following sec-
tions.
pci_bios_present
The primary purpose of this function is to determine
the presence of the PCI BIOS in the host computer.
Secondary purposes are to determine various PCI
hardware characteristics of the host computer. A C-
language
prototype
for
this
function
is:
int pci_bios_present(byte *hardware_mechanism,
word *interface_level_version,
byte *last_pci_bus_number);
The return value from this function indicates if the
PCI BIOS is present on the host system. If the value
SUCCESSFUL is returned, the PCI BIOS is present,
otherwise not.