OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [hal/] [arm/] [xscale/] [iq80321/] [v2_0/] [include/] [plf_io.h] - Blame information for rev 594

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 27 unneback
#ifndef CYGONCE_PLF_IO_H
2
#define CYGONCE_PLF_IO_H
3
 
4
//=============================================================================
5
//
6
//      plf_io.h
7
//
8
//      Platform specific IO support
9
//
10
//=============================================================================
11
//####ECOSGPLCOPYRIGHTBEGIN####
12
// -------------------------------------------
13
// This file is part of eCos, the Embedded Configurable Operating System.
14
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
15
//
16
// eCos is free software; you can redistribute it and/or modify it under
17
// the terms of the GNU General Public License as published by the Free
18
// Software Foundation; either version 2 or (at your option) any later version.
19
//
20
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
21
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
22
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
23
// for more details.
24
//
25
// You should have received a copy of the GNU General Public License along
26
// with eCos; if not, write to the Free Software Foundation, Inc.,
27
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
28
//
29
// As a special exception, if other files instantiate templates or use macros
30
// or inline functions from this file, or you compile this file and link it
31
// with other works to produce a work based on this file, this file does not
32
// by itself cause the resulting work to be covered by the GNU General Public
33
// License. However the source code for this file must still be made available
34
// in accordance with section (3) of the GNU General Public License.
35
//
36
// This exception does not invalidate any other reasons why a work based on
37
// this file might be covered by the GNU General Public License.
38
//
39
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
40
// at http://sources.redhat.com/ecos/ecos-license/
41
// -------------------------------------------
42
//####ECOSGPLCOPYRIGHTEND####
43
//=============================================================================
44
//#####DESCRIPTIONBEGIN####
45
//
46
// Author(s):    msalter
47
// Contributors: msalter
48
// Date:         2002-01-10
49
// Purpose:      Intel IQ80321 PCI IO support macros
50
// Description: 
51
// Usage:        #include <cyg/hal/plf_io.h>
52
//
53
//####DESCRIPTIONEND####
54
//
55
//=============================================================================
56
 
57
#include <pkgconf/hal.h>
58
#include <cyg/hal/hal_io.h>             // IO macros
59
#include <cyg/hal/iq80321.h>
60
#include CYGBLD_HAL_PLF_INTS_H
61
 
62
// Initialize the PCI bus.
63
externC void cyg_hal_plf_pci_init(void);
64
#define HAL_PCI_INIT() cyg_hal_plf_pci_init()
65
 
66
//-----------------------------------------------------------------------------
67
// Resources
68
 
69
#define _PCI_MEM_BASE       0x80000000
70
#define _PCI_MEM_DAC_BASE   0x00000000
71
#define _PCI_IO_BASE        0x90000000
72
#define _PCI_MEM_LIMIT      0x83ffffff
73
#define _PCI_IO_LIMIT       0x9000ffff
74
 
75
extern cyg_uint32 hal_pci_alloc_base_memory;
76
extern cyg_uint32 hal_pci_alloc_base_io;
77
 
78
extern cyg_uint32 hal_pci_physical_memory_base;
79
extern cyg_uint32 hal_pci_physical_io_base;
80
 
81
extern cyg_uint32 hal_pci_inbound_window_base;
82
extern cyg_uint32 hal_pci_inbound_window_mask;
83
 
84
#define HAL_PCI_PHYSICAL_MEMORY_BASE hal_pci_physical_memory_base
85
#define HAL_PCI_PHYSICAL_IO_BASE     hal_pci_physical_io_base
86
 
87
// Map PCI device resources starting from these addresses in PCI space.
88
#define HAL_PCI_ALLOC_BASE_MEMORY hal_pci_alloc_base_memory
89
#define HAL_PCI_ALLOC_BASE_IO     hal_pci_alloc_base_io
90
 
91
#ifdef CYGSEM_HAL_ARM_IQ80321_FAB_C
92
#define __INTA_ROUTING CYGNUM_HAL_INTERRUPT_XINT0
93
#define __INTB_ROUTING CYGNUM_HAL_INTERRUPT_XINT1
94
 
95
#define __NIC_PUB  3
96
#define __NIC_PRIV 5
97
 
98
#define __SLOT_PUB  4
99
#define __SLOT_PRIV 6
100
#else
101
#define __INTA_ROUTING CYGNUM_HAL_INTERRUPT_XINT2
102
#define __INTB_ROUTING CYGNUM_HAL_INTERRUPT_XINT3
103
 
104
#define __NIC_PUB  8
105
#define __NIC_PRIV 4
106
 
107
#define __SLOT_PUB  2
108
#define __SLOT_PRIV 6
109
#endif
110
 
111
// Translate the PCI interrupt requested by the device (INTA#, INTB#,
112
// INTC# or INTD#) to the associated CPU interrupt (i.e., HAL vector).
113
#define HAL_PCI_TRANSLATE_INTERRUPT( __bus, __devfn, __vec, __valid)           \
114
    CYG_MACRO_START                                                            \
115
    cyg_uint32 __dev = CYG_PCI_DEV_GET_DEV(__devfn);                           \
116
    cyg_uint32 __fn  = CYG_PCI_DEV_GET_FN(__devfn);                            \
117
    cyg_uint32 __xbus = ((*ATU_PCIXSR >> 8) & 0xff);                           \
118
    if (__xbus == 0xff) __xbus = 0;                                            \
119
    __valid = false;                                                           \
120
    if (__fn==0 && (__dev==__NIC_PUB || __dev==__NIC_PRIV) && __bus==__xbus) { \
121
        __vec = CYGNUM_HAL_INTERRUPT_ETHERNET;                                 \
122
        __valid = true;                                                        \
123
    } else {                                                                   \
124
        cyg_uint8 __req;                                                       \
125
        HAL_PCI_CFG_READ_UINT8(__bus, __devfn, CYG_PCI_CFG_INT_PIN, __req);    \
126
        switch(__req) {                                                        \
127
          case 1: /* INTA */                                                   \
128
            __vec=CYGNUM_HAL_INTERRUPT_XINT0; __valid=true; break;             \
129
          case 2: /* INTB */                                                   \
130
            __vec=CYGNUM_HAL_INTERRUPT_XINT1; __valid=true; break;             \
131
        }                                                                      \
132
    }                                                                          \
133
    CYG_MACRO_END
134
 
135
// SDRAM is aliased as uncached memory for drivers.
136
#ifdef CYG_HAL_MEMORY_MAP_NORMAL
137
#define CYGARC_UNCACHED_ADDRESS(_x_) \
138
  (((((unsigned long)(_x_)) >> 29)==0x0) ? (((unsigned long)(_x_))|0xC0000000) : (_x_))
139
#else
140
#define CYGARC_UNCACHED_ADDRESS(_x_) \
141
  (((((unsigned long)(_x_)) >> 29)==0x5) ? (((unsigned long)(_x_))+0x20000000) : (_x_))
142
#endif
143
 
144
#define CYGARC_VIRT_TO_BUS(_x_) \
145
  (((unsigned long)(_x_) & 0x1fffffff) | hal_pci_inbound_window_base)
146
#define CYGARC_BUS_TO_VIRT(_x_) \
147
  (((unsigned long)(_x_) & hal_pci_inbound_window_mask) | 0xC0000000)
148
 
149
 
150
static inline unsigned cygarc_physical_address(unsigned va)
151
{
152
    unsigned *ram_mmutab = (unsigned *)(SDRAM_BASE | 0x4000);
153
    unsigned pte;
154
 
155
    pte = ram_mmutab[va >> 20];
156
 
157
    return (pte & 0xfff00000) | (va & 0xfffff);
158
}
159
 
160
#define CYGARC_PHYSICAL_ADDRESS(_x_) cygarc_physical_address(_x_)
161
 
162
#ifdef CYG_HAL_MEMORY_MAP_NORMAL
163
static inline unsigned cygarc_virtual_address(unsigned pa)
164
{
165
    if (0xa0000000 <= pa && pa < 0xc0000000)
166
        return pa - 0xa0000000;
167
    if (pa < 0x90100000)
168
        return pa + 0x20000000;
169
    return pa;
170
}
171
 
172
#define CYGARC_VIRTUAL_ADDRESS(_x_) cygarc_virtual_address(_x_)
173
#else
174
#define CYGARC_VIRTUAL_ADDRESS(_x_) (_x_)
175
#endif    
176
 
177
 
178
 
179
//-----------------------------------------------------------------------------
180
// end of plf_io.h
181
#endif // CYGONCE_PLF_IO_H

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.