* DEALINGS IN THE SOFTWARE.
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <stdlib.h>
#include <stdio.h>
-#include <err.h>
#include <unistd.h>
+#include <inttypes.h>
+
+#ifdef HAVE_ERR_H
+#include <err.h>
+#else
+# include <errno.h>
+# include <string.h>
+# define err(exitcode, format, args...) \
+ errx(exitcode, format ": %s", ## args, strerror(errno))
+# define errx(exitcode, format, args...) \
+ { warnx(format, ## args); exit(exitcode); }
+# define warn(format, args...) \
+ warnx(format ": %s", ## args, strerror(errno))
+# define warnx(format, args...) \
+ fprintf(stderr, format "\n", ## args)
+#endif
#include "pciaccess.h"
+#include "pciaccess_private.h"
static void
print_pci_bridge( const struct pci_bridge_info * info )
{
- printf( " Bus: primary=%02x, secondary=%02x, subordinate=%02x, "
- "sec-latency=%u\n",
+ printf( " Bus: primary=%02"PRIx8", secondary=%02"PRIx8", subordinate=%02"PRIx8", "
+ "sec-latency=%"PRIu8"\n",
info->primary_bus,
info->secondary_bus,
info->subordinate_bus,
info->secondary_latency_timer );
- printf( " I/O behind bridge: %08x-%08x\n",
+ printf( " I/O behind bridge: %08"PRIx32"-%08"PRIx32"\n",
info->io_base,
info->io_limit );
- printf( " Memory behind bridge: %08x-%08x\n",
+ printf( " Memory behind bridge: %08"PRIx32"-%08"PRIx32"\n",
info->mem_base,
info->mem_limit );
- printf( " Prefetchable memory behind bridge: %08llx-%08llx\n",
+ printf( " Prefetchable memory behind bridge: %08"PRIx64"-%08"PRIx64"\n",
info->prefetch_mem_base,
info->prefetch_mem_limit );
}
pci_device_probe( dev );
for ( i = 0 ; i < 6 ; i++ ) {
if ( dev->regions[i].base_addr != 0 ) {
- printf( " BASE%u 0x%08x SIZE %d %s",
+ printf( " BASE%u 0x%0*"PRIxPTR" SIZE %zu %s",
i,
+ dev->regions[i].is_64 ? 16 : 8,
(intptr_t) dev->regions[i].base_addr,
(size_t) dev->regions[i].size,
- (dev->regions[i].is_IO) ? "I/O" : "MEM" );
+ (dev->regions[i].is_IO) ? "I/O" :
+ ((dev->regions[i].is_64) ? "MEM64" : "MEM"));
if ( ! dev->regions[i].is_IO ) {
if ( dev->regions[i].is_prefetchable ) {
}
if ( dev->rom_size ) {
- printf( " BASEROM 0x%08x addr 0x%08x\n",
- 0, 0 );
+ struct pci_device_private *priv =
+ (struct pci_device_private *) dev;
+
+ printf( " BASEROM 0x%08"PRIxPTR" SIZE %zu\n",
+ (intptr_t) priv->rom_base, (size_t) dev->rom_size);
}
pci_device_cfg_read_u8( dev, & int_pin, 61 );