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

4.104.114.84.95
Last change on this file since 1ae05bf was 1ae05bf, checked in by Joel Sherrill <joel.sherrill@…>, on 11/01/00 at 21:20:47

2000-11-01 Joel Sherrill <joel@…>

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