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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [hal/] [arm/] [xscale/] [iq80310/] [v2_0/] [src/] [diag/] [pci_bios.h] - Blame information for rev 565

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

Line No. Rev Author Line
1 27 unneback
//=============================================================================
2
//
3
//      pci_bios.h - Cyclone Diagnostics
4
//
5
//=============================================================================
6
//####ECOSGPLCOPYRIGHTBEGIN####
7
// -------------------------------------------
8
// This file is part of eCos, the Embedded Configurable Operating System.
9
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
10
//
11
// eCos is free software; you can redistribute it and/or modify it under
12
// the terms of the GNU General Public License as published by the Free
13
// Software Foundation; either version 2 or (at your option) any later version.
14
//
15
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
16
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
17
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
18
// for more details.
19
//
20
// You should have received a copy of the GNU General Public License along
21
// with eCos; if not, write to the Free Software Foundation, Inc.,
22
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
23
//
24
// As a special exception, if other files instantiate templates or use macros
25
// or inline functions from this file, or you compile this file and link it
26
// with other works to produce a work based on this file, this file does not
27
// by itself cause the resulting work to be covered by the GNU General Public
28
// License. However the source code for this file must still be made available
29
// in accordance with section (3) of the GNU General Public License.
30
//
31
// This exception does not invalidate any other reasons why a work based on
32
// this file might be covered by the GNU General Public License.
33
//
34
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
35
// at http://sources.redhat.com/ecos/ecos-license/
36
// -------------------------------------------
37
//####ECOSGPLCOPYRIGHTEND####
38
//=============================================================================
39
//#####DESCRIPTIONBEGIN####
40
//
41
// Author(s):   Scott Coulter, Jeff Frazier, Eric Breeden
42
// Contributors:
43
// Date:        2001-01-25
44
// Purpose:     
45
// Description: 
46
//
47
//####DESCRIPTIONEND####
48
//
49
//===========================================================================*/
50
 
51
/****************************************************************************/
52
/* File:        pci_bios.h                                                            */
53
/*                                                                          */
54
/* Use:         mon960                                                      */
55
/*                                                                          */
56
/* Purpose:  PCI BIOS Routines                                              */
57
/*                                                                          */
58
/* Remarks:  Conforming to the Revision 2.1 PCI BIOS Specfication           */
59
/*                                                                          */
60
/* Functions Supported:                                                     */
61
/*                                                                          */
62
/*       pci_bios_present()                                                 */
63
/*       find_pci_device()                                                  */
64
/*       find_pci_class_code()                                              */
65
/*       generate_special_cycle()                                           */
66
/*       read_config_byte()                                                 */
67
/*       read_config_word()                                                 */
68
/*       read_config_dword()                                                */
69
/*       write_config_byte()                                                */
70
/*       write_config_word()                                                */
71
/*       write_config_dword()                                               */
72
/*       get_irq_routing_options()                                          */
73
/*       set_pci_irq()                                                      */
74
/*                                                                          */
75
/* History:                                                                 */
76
/*   06Sep00  Scott Coulter             Changed NUM_PCI_BUSES from 31 to 2          */
77
/*   09Sep97  Jim Otto                  Defined NUM_PCI_BUSES                       */
78
/*                                                                          */
79
/*                                                                          */
80
/*                                                                          */
81
/****************************************************************************/
82
 
83
#include "iq80310.h"
84
 
85
#define XINT0 0
86
#define XINT1 1
87
#define XINT2 2
88
#define XINT3 3
89
 
90
/* primary PCI bus definitions */
91
#define PRIMARY_BUS_NUM         0
92
#define PRIMARY_MEM_BASE        0x80000000
93
#define PRIMARY_DAC_BASE        0x84000000
94
#define PRIMARY_IO_BASE         0x90000000
95
#define PRIMARY_MEM_LIMIT       0x83ffffff
96
#define PRIMARY_DAC_LIMIT       0x87ffffff
97
#define PRIMARY_IO_LIMIT        0x9000ffff
98
 
99
 
100
/* secondary PCI bus definitions */
101
#define SECONDARY_BUS_NUM       1
102
#define SECONDARY_MEM_BASE      0x88000000
103
#define SECONDARY_DAC_BASE      0x8c000000
104
#define SECONDARY_IO_BASE       0x90010000
105
#define SECONDARY_MEM_LIMIT     0x8bffffff
106
#define SECONDARY_DAC_LIMIT     0x8fffffff
107
#define SECONDARY_IO_LIMIT      0x9001ffff
108
 
109
 
110
#define LAST_SYSPROC 260
111
 
112
#define NUM_PCI_BUSES 2
113
 
114
#ifndef ASM_LANGUAGE
115
 
116
/******************************************************************************
117
*
118
*       Required PCI BIOS Data Structures
119
*
120
*/
121
typedef struct
122
{
123
        int num_devices;
124
        int num_functions;
125
} PCI_DATA;
126
 
127
typedef struct
128
{
129
        int     present_status;  /* set to 0x00 for BIOS present */
130
        int     hardware_mech_config;    /* for accessing config. space */
131
        int     hardware_mech_special;  /* for performing special cycles */
132
        int     if_level_major_ver;      /* in BCD, 0x02 for version 2.1 */
133
        int     if_level_minor_ver;      /* in BCD, 0x01 for version 2.1 */
134
        int     last_pci_bus;    /* numbers start at 0 */
135
} PCI_BIOS_INFO;
136
 
137
/*******************************************************************************
138
*
139
* Type 0 PCI Configuration Space Header
140
*
141
*/
142
 
143
typedef struct
144
{
145
  unsigned short  vendor_id;
146
  unsigned short  device_id;
147
  unsigned short  command;
148
  unsigned short  status;
149
  unsigned char   revision_id;
150
  unsigned char   prog_if;
151
  unsigned char   sub_class;
152
  unsigned char   base_class;
153
  unsigned char   cache_line_size;
154
  unsigned char   latency_timer;
155
  unsigned char   header_type;
156
  unsigned char   bist;
157
  unsigned long   pcibase_addr0;
158
  unsigned long   pcibase_addr1;
159
  unsigned long   pcibase_addr2;
160
  unsigned long   pcibase_addr3;
161
  unsigned long   pcibase_addr4;
162
  unsigned long   pcibase_addr5;
163
  unsigned long   cardbus_cis_ptr;
164
  unsigned short  sub_vendor_id;
165
  unsigned short  sub_device_id;
166
  unsigned long   pcibase_exp_rom;
167
  unsigned long   reserved2[2];
168
  unsigned char   int_line;
169
  unsigned char   int_pin;
170
  unsigned char   min_gnt;
171
  unsigned char   max_lat;
172
} PCI_CONFIG_SPACE_0;
173
 
174
/*******************************************************************************
175
*
176
* PCI Bridge Configuration Space Header
177
*
178
*/
179
 
180
typedef struct
181
{
182
  unsigned short  vendor_id;
183
  unsigned short  device_id;
184
  unsigned short  command;
185
  unsigned short  status;
186
  unsigned char   revision_id;
187
  unsigned char   prog_if;
188
  unsigned char   sub_class;
189
  unsigned char   base_class;
190
  unsigned char   cache_line_size;
191
  unsigned char   latency_timer;
192
  unsigned char   header_type;
193
  unsigned char   bist;
194
  unsigned long   pcibase_addr0;
195
  unsigned long   pcibase_addr1;
196
  unsigned char   primary_busno;
197
  unsigned char   secondary_busno;
198
  unsigned char   subordinate_busno;
199
  unsigned char   secondary_latency_timer;
200
  unsigned char   io_base;
201
  unsigned char   io_limit;
202
  unsigned short  secondary_status;
203
  unsigned short  mem_base;
204
  unsigned short  mem_limit;
205
  unsigned short  pfmem_base;
206
  unsigned short  pfmem_limit;
207
  unsigned long   pfbase_upper32;
208
  unsigned long   pflimit_upper32;
209
  unsigned short  iobase_upper16;
210
  unsigned short  iolimit_upper16;
211
  unsigned short  sub_vendor_id;
212
  unsigned short  sub_device_id;
213
  unsigned long   pcibase_exp_rom;
214
  unsigned char   int_line;
215
  unsigned char   int_pin;
216
  unsigned short  bridge_control;
217
} PCI_CONFIG_SPACE_1;
218
 
219
typedef union
220
{
221
  PCI_CONFIG_SPACE_0  pci0_config;
222
  PCI_CONFIG_SPACE_1  pci1_config;
223
} PCI_CONFIG_SPACE;
224
 
225
#define CONFIG_MECHANISM_1      1
226
#define CONFIG_MECHANISM_2      2
227
 
228
typedef struct
229
{
230
        int     bus_number;  /* 0...255 */
231
  int   device_number;  /* Device number on bus */
232
  int   function_number;  /* Function number on device */
233
} PCI_DEVICE_LOCATION;
234
 
235
 
236
typedef struct
237
{
238
        int     bus_number;  /* 0...255 */
239
  int   device_number;  /* Device number on bus */
240
  int   inta_link;  /* Which ints. are or'd together */
241
  int   inta_bitmap;  /* Which XINT connected to */
242
  int   intb_link;  /* Which ints. are or'd together */
243
  int   intb_bitmap;  /* Which XINT connected to */
244
  int   intc_link;  /* Which ints. are or'd together */
245
  int   intc_bitmap;  /* Which XINT connected to */
246
  int   intd_link;  /* Which ints. are or'd together */
247
  int   intd_bitmap;  /* Which XINT connected to */
248
  int   slot_number;  /* Physical slot (1 - NUM_PCI_SLOTS) */
249
} SLOT_IRQ_ROUTING;
250
 
251
 
252
/* Link values used to indicate which PCI interrupts are wire OR'ed together, the
253
   value 0 indicates no connection to an interrupt controller and should not be used */
254
 
255
#define LINK_XINT0      1
256
#define LINK_XINT1      2
257
#define LINK_XINT2      3
258
#define LINK_XINT3      4
259
#define LINK_XINT4      5
260
#define LINK_XINT5      6
261
#define LINK_XINT6      7
262
#define LINK_XINT7      8
263
 
264
#define INTA            1
265
#define INTB            2
266
#define INTC            3
267
#define INTD            4
268
 
269
#define INTA_PTR        0
270
#define INTB_PTR        1
271
#define INTC_PTR        2
272
#define INTD_PTR        3
273
 
274
#define SLOT0           0
275
#define SLOT1           1
276
#define SLOT2           2
277
#define SLOT3           3
278
 
279
/* PCI Errors - Status Registers */
280
#define PARITY_ERROR            0x8000
281
#define SERR_ERROR                      0x4000
282
#define MASTER_ABORT            0x2000
283
#define TARGET_ABORT_M  0x1000
284
#define TARGET_ABORT_T  0x0800
285
#define MASTER_PAR_ERR  0x0100
286
 
287
/* PCI Errors - PCI Interrupt Status Registers */
288
#define SERR_ASSERTED   0x00000400
289
#define ATU_PERR                0x00000200
290
#define ATU_BIST_ERR    0x00000100
291
#define IB_MA_ABORT             0x00000080
292
#define BRIDGE_PERR             0x00000020
293
#define PSERR_FAULT             0x00000010
294
#define MA_FAULT                0x00000008
295
#define TA_M_FAULT              0x00000004
296
#define TA_T_FAULT              0x00000002
297
#define PAR_FAULT               0x00000001
298
 
299
/* Generic PCI Constants */
300
#define MAX_PCI_BUSES                           31
301
#define MAX_DEVICE_NUMBER                       31
302
#define MAX_FUNCTION_NUMBER                     8
303
#define DEVS_PER_BRIDGE                         6
304
#define STANDARD_HEADER                         0
305
#define PCITOPCI_HEADER                         1
306
#define NUM_PCI_SLOTS                           4
307
#define MULTIFUNCTION_DEVICE            (1 << 7)
308
#define MAX_SUB_BUSNO                           0xff
309
#define LATENCY_VALUE                           0x0f
310
#define FIRST_DEVICE_NUM                        5
311
#define LAST_DEVICE_NUM                         8
312
#define SLOTS_PER_BUS                           4
313
 
314
/* PCI command register bits */
315
#define PCI_CMD_IOSPACE                 (1 << 0)
316
#define PCI_CMD_MEMSPACE                (1 << 1)
317
#define PCI_CMD_BUS_MASTER              (1 << 2)
318
#define PCI_CMD_SPECIAL                 (1 << 3)
319
#define PCI_CMD_MWI_ENAB                (1 << 4)
320
#define PCI_CMD_VGA_SNOOP               (1 << 5)
321
#define PCI_CMD_PARITY                  (1 << 6)
322
#define PCI_CMD_WAIT_CYC                (1 << 7)
323
#define PCI_CMD_SERR_ENAB               (1 << 8)
324
#define PCI_CMD_FBB_ENAB                (1 << 9)
325
 
326
/* Bridge Command Register Bit Definitions*/
327
#define BRIDGE_IOSPACE_ENAB             (1 << 0)
328
#define BRIDGE_MEMSPACE_ENAB    (1 << 1)
329
#define BRIDGE_MASTER_ENAB              (1 << 2)
330
#define BRIDGE_WAIT_CYCLE               (1 << 7)
331
#define BRIDGE_SERR_ENAB                (1 << 8)
332
 
333
/* Bridge Control Register Bit Definitions */
334
#define BRIDGE_PARITY_ERR               (1 << 0)
335
#define BRIDGE_SEER_ENAB                (1 << 1)
336
#define BRIDGE_MASTER_ABORT             (1 << 5)
337
 
338
/* configuration offsets */
339
#define VENDOR_ID_OFFSET        0x00
340
#define DEVICE_ID_OFFSET        0x02
341
#define COMMAND_OFFSET          0x04
342
#define STATUS_OFFSET           0x06
343
#define REVISION_OFFSET         0x08
344
#define PROG_IF_OFFSET          0x09
345
#define SUB_CLASS_OFFSET        0x0a
346
#define BASE_CLASS_OFFSET       0x0b
347
#define CACHE_LINE_OFFSET       0x0c
348
#define LATENCY_TIMER_OFFSET    0x0d
349
#define HEADER_TYPE_OFFSET      0x0e
350
#define BIST_OFFSET             0x0f
351
#define REGION0_BASE_OFFSET     0x10
352
#define REGION1_BASE_OFFSET     0x14
353
#define REGION2_BASE_OFFSET     0x18
354
#define PRIMARY_BUSNO_OFFSET    0x18
355
#define SECONDARY_BUSNO_OFFSET  0x19
356
#define SUBORD_BUSNO_OFFSET             0x1a
357
#define SECONDARY_LAT_OFFSET    0x1b
358
#define REGION3_BASE_OFFSET     0x1c
359
#define IO_BASE_OFFSET                  0x1c
360
#define IO_LIMIT_OFFSET                 0x1d
361
#define SECONDARY_STAT_OFFSET   0x1e
362
#define REGION4_BASE_OFFSET     0x20
363
#define MEMORY_BASE_OFFSET              0x20
364
#define MEMORY_LIMIT_OFFSET             0x22
365
#define REGION5_BASE_OFFSET     0x24
366
#define PREF_MEM_BASE_OFFSET    0x24
367
#define PREF_MEM_LIMIT_OFFSET   0x26
368
#define CARDBUS_CISPTR_OFFSET   0x28
369
#define PREF_BASE_UPPER_OFFSET  0x28
370
#define SUB_VENDOR_ID_OFFSET    0x2c
371
#define PREF_LIMIT_UPPER_OFFSET 0x2c
372
#define SUB_DEVICE_ID_OFFSET    0x2e
373
#define EXP_ROM_OFFSET          0x30
374
#define IO_BASE_UPPER_OFFSET    0x30
375
#define IO_LIMIT_UPPER_OFFSET   0x32
376
#define CAP_PTR_OFFSET                  0x34
377
#define TYPE1_EXP_ROM_OFFSET    0x38
378
#define INT_LINE_OFFSET         0x3c
379
#define INT_PIN_OFFSET          0x3d
380
#define MIN_GNT_OFFSET          0x3e
381
#define BRIDGE_CTRL_OFFSET              0x3e
382
#define MAX_LAT_OFFSET          0x3f
383
 
384
typedef struct
385
{
386
        SLOT_IRQ_ROUTING  info[NUM_PCI_SLOTS];
387
} PCI_IRQ_ROUTING_TABLE;
388
 
389
 
390
/******************************************************************************
391
*
392
*       Return values from BIOS Calls
393
*
394
*/
395
 
396
#define SUCCESSFUL                                       0
397
#define DEVICE_NOT_FOUND                        -1
398
#define BAD_VENDOR_ID                           -2
399
#define FUNC_NOT_SUPPORTED                      -3
400
#define BUFFER_TOO_SMALL                        -4
401
#define SET_FAILED                                      -5
402
#define BAD_REGISTER_NUMBER                     -6
403
 
404
 
405
/******************************************************************************
406
*
407
*       BIOS Function Prototypes
408
*
409
*/
410
 
411
STATUS pci_bios_present (PCI_BIOS_INFO *info);
412
 
413
STATUS find_pci_device (int     device_id, int vendor_id, int index);
414
 
415
STATUS find_pci_class_code (int class_code, int index);
416
 
417
STATUS generate_special_cycle (int bus_number, int special_cycle_data);
418
 
419
STATUS read_config_byte (int bus_number, int device_number, int function_number, int register_number,   /* 0,1,2,...,255 */
420
                                                                                                        UINT8   *data);
421
 
422
STATUS read_config_word (int bus_number, int device_number, int function_number, int register_number,   /* 0,2,4,...,254 */
423
                                                                                                        UINT16 *data);
424
 
425
STATUS read_config_dword (int bus_number, int device_number, int function_number, int register_number,  /* 0,4,8,...,252 */
426
                                                                                                        UINT32 *data);
427
 
428
STATUS write_config_byte (int bus_number, int device_number, int function_number, int register_number,  /* 0,1,2,...,255 */
429
                                                                                                        UINT8   data);
430
 
431
STATUS write_config_word (int bus_number, int device_number, int function_number, int register_number,  /* 0,2,4,...,254 */
432
                                                                                                        UINT16 data);
433
 
434
STATUS write_config_dword (int bus_number, int device_number, int function_number, int register_number, /* 0,4,8,...,252 */
435
                                                                                                                UINT32 data);
436
 
437
STATUS get_irq_routing_options (PCI_IRQ_ROUTING_TABLE *table);
438
 
439
STATUS set_pci_irq (int int_pin, int irq_num, int       bus_dev);
440
 
441
 
442
/******************************************************************************
443
*
444
* sysPciIsrConnect - connect a routine to an PCI interrupt
445
*
446
* This function uses the Breeze System Services.  Parameters are left
447
* unchanged in the global registers just as the service call expects.
448
* Likewise, the return value of the service call is left unmodified.
449
*
450
* intline is the PCI interrupt line PCI_INTA - PCI_INTD
451
*
452
* bus is the PCI bus the targeted device is on
453
*
454
* device is the targeted device for the PCI interrupt
455
*
456
* handler is an interrupt handler which accepts an integer as an argument and
457
*       returns 0 if no interrupt was serviced and 1 if an interrupt was
458
*       serviced (necessary for interrupt sharing).
459
*
460
* arg is the argument to be passed to the handler when called.
461
*
462
*/
463
STATUS sysPciIsrConnect (int intline,
464
                                                 int bus,
465
                                                 int device,
466
                                                 int (*handler)(int),
467
                                                 int arg);
468
 
469
 
470
/******************************************************************************
471
*
472
* sysPciIsrDisconnect - disconnect a routine from an PCI interrupt
473
*
474
* This function uses the Breeze System Services.  Parameters are left
475
* unchanged in the global registers just as the service call expects.
476
* Likewise, the return value of the service call is left unmodified.
477
*
478
* intline is the PCI interrupt line INTA - INTD
479
*
480
* bus is the PCI bus the targeted device is on
481
*
482
* device is the PCI device sourcing the interrupt
483
*
484
                                                                                                                                                                                                                                                                                                                                                                                                                                                                           */
485
STATUS sysPciIsrDisconnect (int intline,
486
                                                        int bus,
487
                                                        int device);
488
 
489
#endif  /* ASM_LANGUAGE */
490
 

powered by: WebSVN 2.1.0

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