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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [hal/] [i386/] [pcmb/] [v2_0/] [include/] [pcmb_io.h] - Blame information for rev 174

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 27 unneback
#ifndef CYGONCE_PCMB_IO_H
2
#define CYGONCE_PCMB_IO_H
3
 
4
//=============================================================================
5
//
6
//      pcmb_io.h
7
//
8
//      PC Motherboard 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
// Copyright (C) 2002 Gary Thomas
16
//
17
// eCos is free software; you can redistribute it and/or modify it under
18
// the terms of the GNU General Public License as published by the Free
19
// Software Foundation; either version 2 or (at your option) any later version.
20
//
21
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
22
// 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 along
27
// with eCos; if not, write to the Free Software Foundation, Inc.,
28
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
29
//
30
// As a special exception, if other files instantiate templates or use macros
31
// or inline functions from this file, or you compile this file and link it
32
// with other works to produce a work based on this file, this file does not
33
// by itself cause the resulting work to be covered by the GNU General Public
34
// License. However the source code for this file must still be made available
35
// in accordance with section (3) of the GNU General Public License.
36
//
37
// This exception does not invalidate any other reasons why a work based on
38
// this file might be covered by the GNU General Public License.
39
//
40
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
41
// at http://sources.redhat.com/ecos/ecos-license/
42
// -------------------------------------------
43
//####ECOSGPLCOPYRIGHTEND####
44
//==========================================================================
45
//#####DESCRIPTIONBEGIN####
46
//
47
// Author(s):    proven
48
// Contributors: proven, jskov, pjo
49
// Date:         1999-10-15
50
// Purpose:      PC Motherboard IO support
51
// Description:  The macros defined here provide the HAL APIs for handling
52
//               basic IO - specifically PCI config access.
53
//              
54
//####DESCRIPTIONEND####
55
//
56
//==========================================================================
57
 
58
#include <pkgconf/system.h>
59
#include CYGBLD_HAL_PLATFORM_H
60
 
61
#include <cyg/hal/pcmb_io.h>
62
 
63
//----------------------------------------------------------------------------
64
// The PCI resources required by the STPC 
65
// PCI Config registers in IO space
66
 
67
#define STPC_PCI_ADDR_REG  (0xCF8)
68
#define STPC_PCI_DATA_REG  (0xCFC)
69
 
70
//----------------------------------------------------------------------------
71
 
72
// Initialize the PCI bus.
73
#define HAL_PCI_INIT() \
74
CYG_MACRO_START    \
75
CYG_MACRO_END
76
 
77
//----------------------------------------------------------------------------
78
// Compute address necessary to access PCI config space for the given
79
// bus and device.
80
 
81
#define HAL_PCI_CONFIG_ADDRESS( __bus, __devfn, __offset )               \
82
        ((1<<31) | ((__bus) << 16) | ((__devfn) << 8) | ((__offset) & ~3))
83
 
84
//----------------------------------------------------------------------------
85
// Read a value from the PCI configuration space of the appropriate
86
// size at an address composed from the bus, devfn and offset.
87
 
88
#define HAL_PCI_CFG_READ_UINT32( __bus, __devfn, __offset, __val )                              \
89
CYG_MACRO_START                                                                                 \
90
    HAL_WRITE_UINT32(STPC_PCI_ADDR_REG,HAL_PCI_CONFIG_ADDRESS((__bus),(__devfn),(__offset)));   \
91
    HAL_READ_UINT32(STPC_PCI_DATA_REG,(__val));                                                 \
92
CYG_MACRO_END
93
 
94
#define HAL_PCI_CFG_READ_UINT8( __bus, __devfn, __offset, __val )                               \
95
CYG_MACRO_START                                                                                 \
96
    HAL_WRITE_UINT32(STPC_PCI_ADDR_REG,HAL_PCI_CONFIG_ADDRESS((__bus),(__devfn),(__offset)));   \
97
    HAL_READ_UINT8(STPC_PCI_DATA_REG + ((__offset)&3),(__val));                                 \
98
CYG_MACRO_END
99
 
100
#define HAL_PCI_CFG_READ_UINT16( __bus, __devfn, __offset, __val )                              \
101
CYG_MACRO_START                                                                                 \
102
    HAL_WRITE_UINT32(STPC_PCI_ADDR_REG,HAL_PCI_CONFIG_ADDRESS((__bus),(__devfn),(__offset)));   \
103
    HAL_READ_UINT16(STPC_PCI_DATA_REG + ((__offset)&2),(__val));                                \
104
CYG_MACRO_END
105
 
106
//----------------------------------------------------------------------------
107
// Write a value to the PCI configuration space of the appropriate
108
// size at an address composed from the bus, devfn and offset.
109
 
110
#define HAL_PCI_CFG_WRITE_UINT32( __bus, __devfn, __offset, __val )                             \
111
CYG_MACRO_START                                                                                 \
112
    HAL_WRITE_UINT32(STPC_PCI_ADDR_REG,HAL_PCI_CONFIG_ADDRESS((__bus),(__devfn),(__offset)));   \
113
    HAL_WRITE_UINT32(STPC_PCI_DATA_REG,(__val));                                                \
114
CYG_MACRO_END
115
 
116
#define HAL_PCI_CFG_WRITE_UINT8( __bus, __devfn, __offset, __val )                              \
117
CYG_MACRO_START                                                                                 \
118
    HAL_WRITE_UINT32(STPC_PCI_ADDR_REG,HAL_PCI_CONFIG_ADDRESS((__bus),(__devfn),(__offset)));   \
119
    HAL_WRITE_UINT8(STPC_PCI_DATA_REG+(__offset & 3),(__val));                                  \
120
CYG_MACRO_END
121
 
122
#define HAL_PCI_CFG_WRITE_UINT16( __bus, __devfn, __offset, __val )                             \
123
CYG_MACRO_START                                                                                 \
124
    HAL_WRITE_UINT32(STPC_PCI_ADDR_REG,HAL_PCI_CONFIG_ADDRESS((__bus),(__devfn),(__offset)));   \
125
    HAL_WRITE_UINT16(STPC_PCI_DATA_REG+(__offset & 2),(__val));                                 \
126
CYG_MACRO_END
127
 
128
 
129
//-----------------------------------------------------------------------------
130
// Resources
131
 
132
#ifdef CYGSEM_HAL_I386_PC_LARGE_PCI_SPACE
133
// Use unrestricted PCI space
134
#define CYG_PCI_MAX_BUS                     256
135
#define CYG_PCI_MIN_DEV                       0
136
#define CYG_PCI_MAX_DEV                      32
137
#define CYG_PCI_MAX_FN                        8
138
#endif
139
 
140
// This is where the PCI spaces are mapped in the CPU's address space.
141
// In the PC the PCI address space is mapped 1-1 into the CPU physical
142
// address space, so these values are both zero.
143
 
144
#define HAL_PCI_PHYSICAL_MEMORY_BASE    0x00000000
145
#define HAL_PCI_PHYSICAL_IO_BASE        0x0000
146
 
147
// Map PCI device resources starting from these addresses in PCI space.
148
// These are the addresses in PCI space where we should map device
149
// memory.  Since there is RAM and other devices in low memory and IO
150
// space, we allocate from high addresses. In most PC platforms, the
151
// BIOS will have actually allocated the PCI devices before we start,
152
// so these values are actually academic.
153
 
154
#define HAL_PCI_ALLOC_BASE_MEMORY  0xf0000000
155
#define HAL_PCI_ALLOC_BASE_IO      0xDF00
156
 
157
//----------------------------------------------------------------------------
158
// Translate the PCI interrupt requested by the device (INTA#, INTB#,
159
// INTC# or INTD#) to the associated CPU interrupt (i.e., HAL vector).
160
 
161
#define HAL_PCI_TRANSLATE_INTERRUPT( __bus, __devfn, __vec, __valid)            \
162
CYG_MACRO_START                                                                 \
163
        HAL_PCI_CFG_READ_UINT8((__bus),(__devfn),CYG_PCI_CFG_INT_LINE,(__vec)); \
164
        if(__vec<=15) __valid=1;                                                \
165
        else __valid=0;                                                         \
166
        __vec += 0x20;                                                          \
167
CYG_MACRO_END
168
 
169
//-----------------------------------------------------------------------------
170
// CMOS RAM access
171
 
172
#define HAL_CMOS_ADDRESS        0x70    // CMOS address register
173
#define HAL_CMOS_DATA           0x71    // CMOS data register
174
 
175
#define HAL_READ_CMOS( __addr, __val )                  \
176
CYG_MACRO_START                                         \
177
{                                                       \
178
    HAL_WRITE_UINT8( HAL_CMOS_ADDRESS, __addr );        \
179
    HAL_READ_UINT8( HAL_CMOS_DATA, (__val) );           \
180
}                                                       \
181
CYG_MACRO_END
182
 
183
#define HAL_WRITE_CMOS( __addr, __val )                 \
184
CYG_MACRO_START                                         \
185
{                                                       \
186
    HAL_WRITE_UINT8( HAL_CMOS_ADDRESS, __addr );        \
187
    HAL_WRITE_UINT8( HAL_CMOS_DATA, (__val) );          \
188
}                                                       \
189
CYG_MACRO_END
190
 
191
//-----------------------------------------------------------------------------
192
// Debug macros
193
// Some simple macros for writing useful info to a PC ASCII display
194
 
195
#define PC_WRITE_SCREEN( __pos, __ch ) \
196
                       (*((short *)(0xB8000)+((__pos)%(80*25))) = (0x0700+(__ch)))
197
 
198
#define PC_SCREEN_LINE( __line ) ((__line)*80)
199
 
200
#define PC_WRITE_SCREEN_8( __pos, __val )                       \
201
{                                                               \
202
    char __hex[] = "0123456789ABCDEF";                          \
203
    PC_WRITE_SCREEN( (__pos), __hex[((int)(__val)>>4)&0xF] );        \
204
    PC_WRITE_SCREEN( ((__pos)+1), __hex[(int)(__val)&0xF] );         \
205
}
206
 
207
#define PC_WRITE_SCREEN_16( __pos, __val )      \
208
    PC_WRITE_SCREEN_8( __pos, (int)(__val)>>8 );     \
209
    PC_WRITE_SCREEN_8( (__pos)+2, (int)(__val) );
210
 
211
#define PC_WRITE_SCREEN_32( __pos, __val )      \
212
    PC_WRITE_SCREEN_16( __pos, (int)(__val)>>16 );   \
213
    PC_WRITE_SCREEN_16( (__pos)+4, (int)(__val) );
214
 
215
//-----------------------------------------------------------------------------
216
// IDE interface macros
217
//
218
#define HAL_IDE_NUM_CONTROLLERS 2
219
 
220
// Initialize the IDE controller(s).
221
#define HAL_IDE_INIT()
222
 
223
#define __PCMB_IDE_PRI_CMD   0x1f0
224
#define __PCMB_IDE_PRI_CTL   0x3f4
225
#define __PCMB_IDE_SEC_CMD   0x170
226
#define __PCMB_IDE_SEC_CTL   0x374
227
 
228
#define __CMD_ADDR(__n) ((__n) ? __PCMB_IDE_SEC_CMD : __PCMB_IDE_PRI_CMD)
229
#define __CTL_ADDR(__n) ((__n) ? __PCMB_IDE_SEC_CTL : __PCMB_IDE_PRI_CTL)
230
 
231
#define HAL_IDE_READ_UINT8( __ctlr, __regno, __val )  \
232
    HAL_READ_UINT8(__CMD_ADDR(__ctlr) + (__regno), (__val))
233
#define HAL_IDE_READ_UINT16( __ctlr, __regno, __val )  \
234
    HAL_READ_UINT16(__CMD_ADDR(__ctlr) + (__regno), (__val))
235
#define HAL_IDE_READ_ALTSTATUS( __ctlr, __val )  \
236
    HAL_READ_UINT16(__CTL_ADDR(__ctlr) + 2, (__val))
237
 
238
#define HAL_IDE_WRITE_UINT8( __ctlr, __regno, __val )  \
239
    HAL_WRITE_UINT8(__CMD_ADDR(__ctlr) + (__regno), (__val))
240
#define HAL_IDE_WRITE_UINT16( __ctlr, __regno, __val )  \
241
    HAL_WRITE_UINT16(__CMD_ADDR(__ctlr) + (__regno), (__val))
242
#define HAL_IDE_WRITE_CONTROL( __ctlr, __val )  \
243
    HAL_WRITE_UINT16(__CTL_ADDR(__ctlr) + 2, (__val))
244
 
245
 
246
//-----------------------------------------------------------------------------
247
// end of pcmb_io.h
248
#endif // CYGONCE_PCMB_IO_H

powered by: WebSVN 2.1.0

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