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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [hal/] [arm/] [xscale/] [iq80321/] [current/] [include/] [plf_io.h] - Blame information for rev 786

Details | Compare with Previous | View Log

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