source: rtems/c/src/lib/libbsp/powerpc/score603e/startup/FPGA.c @ dac4208

4.104.114.84.95
Last change on this file since dac4208 was dac4208, checked in by Ralf Corsepius <ralf.corsepius@…>, on Mar 31, 2004 at 3:47:07 AM

2004-03-31 Ralf Corsepius <ralf_corsepius@…>

  • PCI_bus/PCI.c, PCI_bus/PCI.h, PCI_bus/flash.c, PCI_bus/universe.c, clock/clock.c, console/85c30.c, console/console.c, console/consolebsp.h, include/bsp.h, include/gen2.h, startup/FPGA.c, startup/Hwr_init.c, startup/bspstart.c, startup/genpvec.c, startup/spurious.c, startup/vmeintr.c, timer/timer.c, tod/tod.c: Convert to using c99 fixed size types.
  • Property mode set to 100644
File size: 2.9 KB
Line 
1/*  FPGA.c -- Bridge for second and subsequent generations
2 *
3 *  COPYRIGHT (c) 1989-2001.
4 *  On-Line Applications Research Corporation (OAR).
5 *
6 *  The license and distribution terms for this file may in
7 *  the file LICENSE in this distribution or at
8 *  http://www.rtems.com/license/LICENSE.
9 *
10 *  $Id:
11 */
12
13#include <bsp.h>
14#include <string.h>
15#include <fcntl.h>
16#include <assert.h>
17
18#include <rtems/libio.h>
19#include <rtems/libcsupport.h>
20
21/*
22 *  initialize FPGA
23 */
24void initialize_PCI_bridge ()
25{
26#if (!SCORE603E_USE_DINK)
27  uint16_t         mask, shift, data;
28
29  shift = SCORE603E_85C30_0_IRQ - Score_IRQ_First;
30  mask = 1 << shift;
31
32  shift = SCORE603E_85C30_1_IRQ - Score_IRQ_First;
33  mask  = mask & (1 << shift);
34
35  data = *SCORE603E_FPGA_MASK_DATA;
36  data = ~mask;
37
38  *SCORE603E_FPGA_MASK_DATA = data;
39#endif
40
41}
42
43void set_irq_mask(
44  uint16_t         value
45)
46{
47  uint16_t          *loc;
48
49  loc = (uint16_t*)SCORE603E_FPGA_MASK_DATA;
50
51  *loc = value;
52}
53
54uint16_t         get_irq_mask()
55{
56  uint16_t          *loc;
57  uint16_t          value;
58
59  loc =  (uint16_t*)SCORE603E_FPGA_MASK_DATA;
60
61  value = *loc;
62
63  return value;
64}
65
66void unmask_irq( 
67  uint16_t         irq_idx
68)
69{
70  uint16_t         value;
71  uint32_t         mask_idx = irq_idx;
72
73  value = get_irq_mask();
74
75#if (HAS_PMC_PSC8)
76  switch (irq_idx + Score_IRQ_First ) {
77    case SCORE603E_85C30_4_IRQ:
78    case SCORE603E_85C30_2_IRQ:
79    case SCORE603E_85C30_5_IRQ:
80    case SCORE603E_85C30_3_IRQ:
81      mask_idx = SCORE603E_PCI_IRQ_0 - Score_IRQ_First;
82      break;
83    default:
84      break;
85  }
86#endif
87
88  value &= (~(0x1 << mask_idx)); 
89  set_irq_mask( value );
90}
91
92
93void init_irq_data_register()
94{
95  uint32_t         index;
96  uint32_t         i;
97
98#if (SCORE603E_USE_DINK)
99  set_irq_mask( 0xffff );
100#endif
101
102  /*
103   * Clear any existing interupts from the vector data register.
104   */
105  for (i=0; i<20; i++) {
106    index =  (*SCORE603E_FPGA_VECT_DATA);
107    if ( (index&0x10) != 0x10 )
108      break;
109  }
110}
111
112uint16_t         read_and_clear_PMC_irq(
113  uint16_t            irq
114) 
115{
116  uint16_t            status_word = irq;
117
118  status_word = (*SCORE603E_PMC_STATUS_ADDRESS);
119
120  return status_word;
121}
122
123rtems_boolean Is_PMC_IRQ(
124  uint32_t           pmc_irq,
125  uint16_t           status_word
126)
127{
128  rtems_boolean   result= FALSE;
129
130  switch(pmc_irq) {
131    case SCORE603E_85C30_4_IRQ:
132      result = Is_PMC_85C30_4_IRQ( status_word );
133      break;
134    case SCORE603E_85C30_2_IRQ:
135      result = Is_PMC_85C30_2_IRQ( status_word );
136      break;
137    case SCORE603E_85C30_5_IRQ:
138      result = Is_PMC_85C30_5_IRQ( status_word );
139      break;
140    case SCORE603E_85C30_3_IRQ:
141      result = Is_PMC_85C30_3_IRQ( status_word );
142      break;
143    default:
144      assert( 0 );
145      break;
146  }
147
148  return result;
149}
150
151uint16_t         read_and_clear_irq()
152{
153  uint16_t            irq;
154
155  irq = (*SCORE603E_FPGA_VECT_DATA);
156
157  if ((irq & 0xffff0) != 0x10) {
158    DEBUG_puts( "ERROR:: no irq data\n");   
159    return (irq | 0x80);
160  }
161
162  irq &=0xf;
163
164  return irq;
165}
Note: See TracBrowser for help on using the repository browser.