source: rtems/c/src/lib/libbsp/powerpc/score603e/irq/FPGA.c @ 2608c9a9

4.104.114.84.9
Last change on this file since 2608c9a9 was 2608c9a9, checked in by Jennifer Averett <Jennifer.Averett@…>, on Apr 28, 2005 at 5:47:10 PM

2005-04-28 Jennifer Averett <jennifer.averett@…>

  • Add/move files for the Update to new exception model. NOTE: These modifications have not been tested on hardware.
  • irq/FPGA.c, irq/irq.c, irq/irq.h, irq/irq_init.c: New files.
  • startup/FPGA.c: Removed.
  • 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
92void init_irq_data_register()
93{
94  uint32_t         index;
95  uint32_t         i;
96
97#if (SCORE603E_USE_DINK)
98  set_irq_mask( 0xffff );
99#endif
100
101  /*
102   * Clear any existing interupts from the vector data register.
103   */
104  for (i=0; i<20; i++) {
105    index =  (*SCORE603E_FPGA_VECT_DATA);
106    if ( (index&0x10) != 0x10 )
107      break;
108  }
109}
110
111uint16_t         read_and_clear_PMC_irq(
112  uint16_t            irq
113)
114{
115  uint16_t            status_word = irq;
116
117  status_word = (*BSP_PMC_STATUS_ADDRESS);
118
119  return status_word;
120}
121
122rtems_boolean Is_PMC_IRQ(
123  uint32_t           pmc_irq,
124  uint16_t           status_word
125)
126{
127  rtems_boolean   result= FALSE;
128
129  switch(pmc_irq) {
130    case SCORE603E_85C30_4_IRQ:
131      result = Is_PMC_85C30_4_IRQ( status_word );
132      break;
133    case SCORE603E_85C30_2_IRQ:
134      result = Is_PMC_85C30_2_IRQ( status_word );
135      break;
136    case SCORE603E_85C30_5_IRQ:
137      result = Is_PMC_85C30_5_IRQ( status_word );
138      break;
139    case SCORE603E_85C30_3_IRQ:
140      result = Is_PMC_85C30_3_IRQ( status_word );
141      break;
142    default:
143      assert( 0 );
144      break;
145  }
146
147  return result;
148}
149
150uint16_t         read_and_clear_irq()
151{
152  uint16_t            irq;
153
154  irq = (*SCORE603E_FPGA_VECT_DATA);
155
156  if ((irq & 0xffff0) != 0x10) {
157    DEBUG_puts( "ERROR:: no irq data\n");
158    return (irq | 0x80);
159  }
160
161  irq &=0xf;
162
163  return irq;
164}
Note: See TracBrowser for help on using the repository browser.