~ari-tczew/ubuntu/lucid/skyeye/sru-lp-464175

« back to all changes in this revision

Viewing changes to arch/arm/mach/skyeye_mach_ep9312.c

  • Committer: Bazaar Package Importer
  • Author(s): Yu Guanghui
  • Date: 2007-02-09 20:24:29 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20070209202429-jknfb98t9ggaoz02
Tags: 1.2.1-2
Disable DBCT again.

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
 *
28
28
 * */
29
29
 
30
 
//koodailar add for mingw 2005.12.18 ----------------------------------------
31
 
#ifdef __MINGW32__
32
 
#include "arch/arm/common/armdefs.h"
33
 
#include "utils/stub/mingw_help.h"
34
 
#else
35
30
#include "armdefs.h"
36
 
#endif
37
 
// end ----------------------------------------------------------------------
38
31
#include "clps9312.h"
39
32
#include "ep9312.h"
40
33
#include "serial_amba.h"
51
44
//AJ2D--------------------------------------------------------------------------
52
45
#endif
53
46
 
 
47
/* 2007-01-18 added by Anthony Lee : for new uart device frame */
 
48
#include "skyeye_uart.h"
 
49
 
 
50
 
54
51
void ep9312_io_write_word (ARMul_State * state, ARMword addr, ARMword data);
55
52
ARMword ep9312_io_read_word (ARMul_State * state, ARMword addr);
56
53
 
121
118
}
122
119
 
123
120
 
124
 
//koodailar add for mingw 2005.12.18 ----------------------------------------
125
 
#ifdef __MINGW32__
126
 
void
127
 
ep9312_io_do_cycle (ARMul_State * state)
128
 
{
129
 
        int i;
130
 
        mingw_start_thread(skyeye_config.uart.fd_in);   
131
 
        /* We must implement TC1, TC2 and TC4 */
132
 
        for (i = 0; i < 2; i++) {
133
 
                if (io.tc[i].value == 0) {
134
 
                        if (io.tc[i].ctl & TC_CTL_MODE)
135
 
                                io.tc[i].value = io.tc[i].load;
136
 
                        else
137
 
                                io.tc[i].value = io.tc[i].mod_value;
138
 
                        io.intsr[0] |= TCOI[i];
139
 
                        ep9312_update_int (state);
140
 
                }
141
 
                else {
142
 
                        io.tc[i].value--;
143
 
                }
144
 
        }
145
 
        io.tc[3].load++;
146
 
 
147
 
        if (!(io.intsr[0] & (UART_RXINTR[iConsole]))
148
 
            && io.uart[iConsole].dr == 0) {
149
 
                if (SDL_SemTryWait(get_mingw_read_sem())==0) 
150
 
                {
151
 
                if(get_mingw_sem_first_time() != 1 && get_mingw_readed() == 1)
152
 
                        { 
153
 
                                unsigned char buf;
154
 
                                int n;
155
 
                                                n = 1;
156
 
                                                buf = get_mingw_char_read();
157
 
                                                set_mingw_readed(0);
158
 
        
159
 
                                if (n) {
160
 
                                        io.uart[iConsole].dr = (int) buf;
161
 
                                        io.intsr[0] |= UART_RXINTR[iConsole];
162
 
                                        io.intmr[0] |= UART_RXINTR[iConsole];
163
 
                                        io.intsr[1] |= INT_UART[iConsole];
164
 
                                        io.intmr[1] |= INT_UART[iConsole];
165
 
                                        io.uart[iConsole].iir |= UART_IIR_RIS;
166
 
                                        io.uart[iConsole].fr &= ~UART_FR_RXFE;
167
 
                                        ep9312_update_int (state);
168
 
                                }
169
 
                        }
170
 
                        SDL_SemPost(get_mingw_read_sem());
171
 
      printf(" \b");
172
 
                        fflush(stdout);
173
 
                }
174
 
        }                       //if (!(io.intsr & URXINT))
175
 
}
176
 
#else
177
 
 
178
 
void
179
 
ep9312_io_do_cycle (ARMul_State * state)
180
 
{
181
 
        int i;
182
 
        
183
 
        /* We must implement TC1, TC2 and TC4 */
184
 
        for (i = 0; i < 2; i++) {
185
 
                if (io.tc[i].value == 0) {
186
 
                        if (io.tc[i].ctl & TC_CTL_MODE)
187
 
                                io.tc[i].value = io.tc[i].load;
188
 
                        else
189
 
                                io.tc[i].value = io.tc[i].mod_value;
190
 
                        io.intsr[0] |= TCOI[i];
191
 
                        ep9312_update_int (state);
192
 
                }
193
 
                else {
194
 
                        io.tc[i].value--;
195
 
                }
196
 
        }
197
 
        io.tc[3].load++;
198
 
 
199
 
        if (!(io.intsr[0] & (UART_RXINTR[iConsole]))
200
 
            && io.uart[iConsole].dr == 0) {
201
 
                fd_set rfds;
 
121
void
 
122
ep9312_io_do_cycle (ARMul_State * state)
 
123
{
 
124
        int i;
 
125
        
 
126
        /* We must implement TC1, TC2 and TC4 */
 
127
        for (i = 0; i < 2; i++) {
 
128
                if (io.tc[i].value == 0) {
 
129
                        if (io.tc[i].ctl & TC_CTL_MODE)
 
130
                                io.tc[i].value = io.tc[i].load;
 
131
                        else
 
132
                                io.tc[i].value = io.tc[i].mod_value;
 
133
                        io.intsr[0] |= TCOI[i];
 
134
                        ep9312_update_int (state);
 
135
                }
 
136
                else {
 
137
                        io.tc[i].value--;
 
138
                }
 
139
        }
 
140
        io.tc[3].load++;
 
141
 
 
142
        if (!(io.intsr[0] & (UART_RXINTR[iConsole]))
 
143
            && io.uart[iConsole].dr == 0) {
 
144
                /* 2007-01-18 modified by Anthony Lee : for new uart device frame */
202
145
                struct timeval tv;
 
146
                unsigned char buf;
203
147
 
204
 
                FD_ZERO (&rfds);
205
 
                FD_SET (skyeye_config.uart.fd_in, &rfds);
206
148
                tv.tv_sec = 0;
207
149
                tv.tv_usec = 0;
208
150
 
209
 
                if (select
210
 
                    (skyeye_config.uart.fd_in + 1, &rfds, NULL, NULL,
211
 
                     &tv) == 1) {
212
 
                        unsigned char buf;
213
 
                        int n;
214
 
                        n = read (skyeye_config.uart.fd_in, &buf, 1);
215
 
 
216
 
                        if (n) {
217
 
                                io.uart[iConsole].dr = (int) buf;
218
 
                                io.intsr[0] |= UART_RXINTR[iConsole];
219
 
                                io.intmr[0] |= UART_RXINTR[iConsole];
220
 
                                io.intsr[1] |= INT_UART[iConsole];
221
 
                                io.intmr[1] |= INT_UART[iConsole];
222
 
                                io.uart[iConsole].iir |= UART_IIR_RIS;
223
 
                                io.uart[iConsole].fr &= ~UART_FR_RXFE;
224
 
                                ep9312_update_int (state);
225
 
                        }
 
151
                if(skyeye_uart_read(-1, &buf, 1, &tv, NULL) > 0)
 
152
                {
 
153
                        io.uart[iConsole].dr = (int) buf;
 
154
                        io.intsr[0] |= UART_RXINTR[iConsole];
 
155
                        io.intmr[0] |= UART_RXINTR[iConsole];
 
156
                        io.intsr[1] |= INT_UART[iConsole];
 
157
                        io.intmr[1] |= INT_UART[iConsole];
 
158
                        io.uart[iConsole].iir |= UART_IIR_RIS;
 
159
                        io.uart[iConsole].fr &= ~UART_FR_RXFE;
 
160
                        ep9312_update_int (state);
226
161
                }
227
162
        }                       //if (!(io.intsr & URXINT))
228
163
}
229
 
#endif
230
 
// end ----------------------------------------------------------------------   
 
164
 
231
165
 
232
166
static void
233
167
ep9312_uart_read (ARMul_State * state, u32 offset, u32 * data, int index)
281
215
        case UART_DR:
282
216
                {
283
217
                        char c = data;
284
 
                        write (skyeye_config.uart.fd_out, &c, 1);
 
218
 
 
219
                        /* 2007-01-18 modified by Anthony Lee : for new uart device frame */
 
220
                        skyeye_uart_write(-1, &c, 1, NULL);
285
221
                }
286
222
        case UART_RSR:
287
223
                //case UART_ECR: