1 |
27 |
unneback |
#ifndef CYGONCE_PCI_HW_H
|
2 |
|
|
#define CYGONCE_PCI_HW_H
|
3 |
|
|
//=============================================================================
|
4 |
|
|
//
|
5 |
|
|
// pci_hw.h
|
6 |
|
|
//
|
7 |
|
|
// PCI hardware library
|
8 |
|
|
//
|
9 |
|
|
//=============================================================================
|
10 |
|
|
//####ECOSGPLCOPYRIGHTBEGIN####
|
11 |
|
|
// -------------------------------------------
|
12 |
|
|
// This file is part of eCos, the Embedded Configurable Operating System.
|
13 |
|
|
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
|
14 |
|
|
//
|
15 |
|
|
// eCos is free software; you can redistribute it and/or modify it under
|
16 |
|
|
// the terms of the GNU General Public License as published by the Free
|
17 |
|
|
// Software Foundation; either version 2 or (at your option) any later version.
|
18 |
|
|
//
|
19 |
|
|
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
|
20 |
|
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
21 |
|
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
22 |
|
|
// for more details.
|
23 |
|
|
//
|
24 |
|
|
// You should have received a copy of the GNU General Public License along
|
25 |
|
|
// with eCos; if not, write to the Free Software Foundation, Inc.,
|
26 |
|
|
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
27 |
|
|
//
|
28 |
|
|
// As a special exception, if other files instantiate templates or use macros
|
29 |
|
|
// or inline functions from this file, or you compile this file and link it
|
30 |
|
|
// with other works to produce a work based on this file, this file does not
|
31 |
|
|
// by itself cause the resulting work to be covered by the GNU General Public
|
32 |
|
|
// License. However the source code for this file must still be made available
|
33 |
|
|
// in accordance with section (3) of the GNU General Public License.
|
34 |
|
|
//
|
35 |
|
|
// This exception does not invalidate any other reasons why a work based on
|
36 |
|
|
// this file might be covered by the GNU General Public License.
|
37 |
|
|
//
|
38 |
|
|
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
|
39 |
|
|
// at http://sources.redhat.com/ecos/ecos-license/
|
40 |
|
|
// -------------------------------------------
|
41 |
|
|
//####ECOSGPLCOPYRIGHTEND####
|
42 |
|
|
//=============================================================================
|
43 |
|
|
//#####DESCRIPTIONBEGIN####
|
44 |
|
|
//
|
45 |
|
|
// Author(s): jskov, from design by nickg
|
46 |
|
|
// Contributors: jskov
|
47 |
|
|
// Date: 1999-08-09
|
48 |
|
|
// Purpose: PCI hardware configuration access
|
49 |
|
|
// Usage:
|
50 |
|
|
// #include <cyg/io/pci_hw.h>
|
51 |
|
|
// Description:
|
52 |
|
|
// This API is used by the PCI library to access the PCI bus
|
53 |
|
|
// configuration space. Although this should not normally be
|
54 |
|
|
// necessary, this API may also be used by device driver or
|
55 |
|
|
// application code to perform PCI bus operations not supported
|
56 |
|
|
// by the PCI library.
|
57 |
|
|
//
|
58 |
|
|
//####DESCRIPTIONEND####
|
59 |
|
|
//
|
60 |
|
|
//=============================================================================
|
61 |
|
|
|
62 |
|
|
// Rely on hal_io.h to include plf_io.h if it exists for the selected target.
|
63 |
|
|
#include <cyg/hal/hal_io.h> // HAL_PCI_ macros
|
64 |
|
|
|
65 |
|
|
#ifdef HAL_PCI_INIT
|
66 |
|
|
|
67 |
|
|
// This varible selects whether the PCI library gets built (requires
|
68 |
|
|
// HAL_PCI_INIT to be defined by the platform io header file)
|
69 |
|
|
#define CYG_PCI_PRESENT
|
70 |
|
|
|
71 |
|
|
#include <cyg/infra/cyg_type.h>
|
72 |
|
|
|
73 |
|
|
#include <cyg/io/pci_cfg.h>
|
74 |
|
|
|
75 |
|
|
|
76 |
|
|
// This is the lowest level where devfns are used.
|
77 |
|
|
#define CYG_PCI_DEV_MAKE_DEVFN(__dev, __fn) (((__dev)<<3)|(__fn))
|
78 |
|
|
#define CYG_PCI_DEV_GET_DEV(__devfn) ((__devfn>>3)&0x1f)
|
79 |
|
|
#define CYG_PCI_DEV_GET_FN(__devfn) (__devfn&0x7)
|
80 |
|
|
|
81 |
|
|
// Some buggy PCI chips force us to ignore certain devices so that
|
82 |
|
|
// they may be handled specially.
|
83 |
|
|
#ifdef HAL_PCI_IGNORE_DEVICE
|
84 |
|
|
#define CYG_PCI_IGNORE_DEVICE(__bus, __dev, __fn) \
|
85 |
|
|
HAL_PCI_IGNORE_DEVICE((__bus), (__dev), (__fn))
|
86 |
|
|
#else
|
87 |
|
|
#define CYG_PCI_IGNORE_DEVICE(__bus, __dev, __fn) 0
|
88 |
|
|
#endif
|
89 |
|
|
|
90 |
|
|
|
91 |
|
|
// Init
|
92 |
|
|
externC void cyg_pcihw_init(void);
|
93 |
|
|
|
94 |
|
|
// Read functions
|
95 |
|
|
externC void cyg_pcihw_read_config_uint8( cyg_uint8 bus, cyg_uint8 devfn,
|
96 |
|
|
cyg_uint8 offset, cyg_uint8 *val);
|
97 |
|
|
externC void cyg_pcihw_read_config_uint16( cyg_uint8 bus, cyg_uint8 devfn,
|
98 |
|
|
cyg_uint8 offset, cyg_uint16 *val);
|
99 |
|
|
externC void cyg_pcihw_read_config_uint32( cyg_uint8 bus, cyg_uint8 devfn,
|
100 |
|
|
cyg_uint8 offset, cyg_uint32 *val);
|
101 |
|
|
|
102 |
|
|
// Write functions
|
103 |
|
|
externC void cyg_pcihw_write_config_uint8( cyg_uint8 bus, cyg_uint8 devfn,
|
104 |
|
|
cyg_uint8 offset, cyg_uint8 val);
|
105 |
|
|
externC void cyg_pcihw_write_config_uint16( cyg_uint8 bus, cyg_uint8 devfn,
|
106 |
|
|
cyg_uint8 offset, cyg_uint16 val);
|
107 |
|
|
externC void cyg_pcihw_write_config_uint32( cyg_uint8 bus, cyg_uint8 devfn,
|
108 |
|
|
cyg_uint8 offset, cyg_uint32 val);
|
109 |
|
|
|
110 |
|
|
// Interrupt translation
|
111 |
|
|
externC cyg_bool cyg_pcihw_translate_interrupt( cyg_uint8 bus, cyg_uint8 devfn,
|
112 |
|
|
CYG_ADDRWORD *vec);
|
113 |
|
|
|
114 |
|
|
#endif // ifdef HAL_PCI_INIT
|
115 |
|
|
|
116 |
|
|
//-----------------------------------------------------------------------------
|
117 |
|
|
#endif // ifndef CYGONCE_PCI_HW_H
|
118 |
|
|
// End of pci_hw.h
|
119 |
|
|
|