~galfy/helenos/bird-port-mainline

« back to all changes in this revision

Viewing changes to uspace/srv/pci/libpci/types.h

  • Committer: Martin Decky
  • Date: 2009-08-04 11:19:19 UTC
  • Revision ID: martin@uranus.dsrg.hide.ms.mff.cuni.cz-20090804111919-evyclddlr3v5lhmp
Initial import

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *      The PCI Library -- Types and Format Strings
 
3
 *
 
4
 *      Copyright (c) 1997--2005 Martin Mares <mj@ucw.cz>
 
5
 *
 
6
 *      May 8, 2006 - Modified and ported to HelenOS by Jakub Jermar.
 
7
 *
 
8
 *      Can be freely distributed and used under the terms of the GNU GPL.
 
9
 */
 
10
 
 
11
#include <sys/types.h>
 
12
 
 
13
#ifndef PCI_HAVE_Uxx_TYPES
 
14
 
 
15
typedef uint8_t u8;
 
16
typedef uint16_t u16;
 
17
typedef uint32_t u32;
 
18
 
 
19
#ifdef PCI_HAVE_64BIT_ADDRESS
 
20
#include <limits.h>
 
21
#if ULONG_MAX > 0xffffffff
 
22
typedef unsigned long u64;
 
23
#define PCI_U64_FMT "l"
 
24
#else
 
25
typedef unsigned long long u64;
 
26
#define PCI_U64_FMT "ll"
 
27
#endif
 
28
#endif
 
29
 
 
30
#endif                          /* PCI_HAVE_Uxx_TYPES */
 
31
 
 
32
#ifdef PCI_HAVE_64BIT_ADDRESS
 
33
typedef u64 pciaddr_t;
 
34
#define PCIADDR_T_FMT "%08" PCI_U64_FMT "x"
 
35
#define PCIADDR_PORT_FMT "%04" PCI_U64_FMT "x"
 
36
#else
 
37
typedef u32 pciaddr_t;
 
38
#define PCIADDR_T_FMT "%08x"
 
39
#define PCIADDR_PORT_FMT "%04x"
 
40
#endif
 
41
 
 
42
#ifdef PCI_ARCH_SPARC64
 
43
/* On sparc64 Linux the kernel reports remapped port addresses and IRQ numbers */
 
44
#undef PCIADDR_PORT_FMT
 
45
#define PCIADDR_PORT_FMT PCIADDR_T_FMT
 
46
#define PCIIRQ_FMT "%08x"
 
47
#else
 
48
#define PCIIRQ_FMT "%d"
 
49
#endif