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

4.104.114.84.95
Last change on this file since 2608c9a9 was 2608c9a9, checked in by Jennifer Averett <Jennifer.Averett@…>, on 04/28/05 at 17:47:10

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
RevLine 
[f5e7b4c3]1/*  FPGA.c -- Bridge for second and subsequent generations
[9c448e1]2 *
[f5e7b4c3]3 *  COPYRIGHT (c) 1989-2001.
[9c448e1]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
[b14e2f2]8 *  http://www.rtems.com/license/LICENSE.
[9c448e1]9 *
[6128a4a]10 *  $Id:
[9c448e1]11 */
[9396d1e4]12
[9c448e1]13#include <bsp.h>
14#include <string.h>
15#include <fcntl.h>
16#include <assert.h>
17
[1ae05bf]18#include <rtems/libio.h>
19#include <rtems/libcsupport.h>
20
[9c448e1]21/*
22 *  initialize FPGA
23 */
24void initialize_PCI_bridge ()
25{
26#if (!SCORE603E_USE_DINK)
[dac4208]27  uint16_t         mask, shift, data;
[9c448e1]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(
[dac4208]44  uint16_t         value
[9c448e1]45)
46{
[dac4208]47  uint16_t          *loc;
[9c448e1]48
[dac4208]49  loc = (uint16_t*)SCORE603E_FPGA_MASK_DATA;
[9c448e1]50
51  *loc = value;
52}
53
[dac4208]54uint16_t         get_irq_mask()
[9c448e1]55{
[dac4208]56  uint16_t          *loc;
57  uint16_t          value;
[9c448e1]58
[dac4208]59  loc =  (uint16_t*)SCORE603E_FPGA_MASK_DATA;
[9c448e1]60
61  value = *loc;
62
63  return value;
64}
65
[6128a4a]66void unmask_irq(
[dac4208]67  uint16_t         irq_idx
[9c448e1]68)
69{
[dac4208]70  uint16_t         value;
71  uint32_t         mask_idx = irq_idx;
[9c448e1]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
[6128a4a]88  value &= (~(0x1 << mask_idx));
[9c448e1]89  set_irq_mask( value );
90}
91
92void init_irq_data_register()
93{
[dac4208]94  uint32_t         index;
95  uint32_t         i;
[9c448e1]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
[dac4208]111uint16_t         read_and_clear_PMC_irq(
112  uint16_t            irq
[6128a4a]113)
[9c448e1]114{
[dac4208]115  uint16_t            status_word = irq;
[9c448e1]116
[f309cda]117  status_word = (*BSP_PMC_STATUS_ADDRESS);
[9c448e1]118
119  return status_word;
120}
121
122rtems_boolean Is_PMC_IRQ(
[dac4208]123  uint32_t           pmc_irq,
124  uint16_t           status_word
[9c448e1]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
[dac4208]150uint16_t         read_and_clear_irq()
[9c448e1]151{
[dac4208]152  uint16_t            irq;
[9c448e1]153
154  irq = (*SCORE603E_FPGA_VECT_DATA);
155
156  if ((irq & 0xffff0) != 0x10) {
[6128a4a]157    DEBUG_puts( "ERROR:: no irq data\n");
[9c448e1]158    return (irq | 0x80);
159  }
160
161  irq &=0xf;
162
163  return irq;
164}
Note: See TracBrowser for help on using the repository browser.