2
skyeye_mach_s3c44b0.c - define machine s3c44b0 for skyeye
3
Copyright (C) 2003 Skyeye Develop Group
4
for help please send mail to <skyeye-developer@lists.gro.clinux.org>
6
This program is free software; you can redistribute it and/or modify
7
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation; either version 2 of the License, or
9
(at your option) any later version.
11
This program is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
GNU General Public License for more details.
16
You should have received a copy of the GNU General Public License
17
along with this program; if not, write to the Free Software
18
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22
* 7/19/2003 init this file.
23
* should be completed. who can do it?
24
* walimis <wlm@student.dlut.edu.cn>
34
//teawater add DBCT_TEST_SPEED 2005.10.04---------------------------------------
40
//AJ2D--------------------------------------------------------------------------
43
/* 2007-01-18 added by Anthony Lee : for new uart device frame */
44
#include "skyeye_uart.h"
46
void s3c44b0_io_write_word (ARMul_State * state, ARMword addr, ARMword data);
47
ARMword s3c44b0_io_read_word (ARMul_State * state, ARMword addr);
49
/* s3c44b0 Internal IO Registers
52
typedef struct s3c44b0_io
54
/*System Manager control */
57
/*Interrupt Controller Registers */
101
int tcmpb[TIMER_NUM]; /*timer5 has no tcmpb register. */
102
int tcmp[TIMER_NUM]; /*timer5 has no tcmpb register. */
103
int tcnto[TIMER_NUM];
107
static s3c44b0_io_t s3c44b0_io;
109
#define io s3c44b0_io
112
#define ENABLE_IRQ ~io.intcon & 0x2
113
#define ENABLE_FIQ ~io.intcon & 0x1
116
s3c44b0_update_int (ARMul_State * state)
118
ARMword requests = io.intpnd & (~io.intmsk & INT_MASK_INIT);
119
state->NfiqSig = (requests & io.intmod) ? LOW : HIGH;
120
state->NirqSig = (requests & ~io.intmod) ? LOW : HIGH;
123
s3c44b0_set_interrupt (unsigned int irq)
126
io.i_ispr = (1 << interrupt);
128
if (ENABLE_IRQ | ENABLE_FIQ) {
129
io.intpnd |= (1 << irq);
133
s3c44b0_io_reset (ARMul_State * state)
135
memset (&s3c44b0_io, 0, sizeof (s3c44b0_io));
137
/*Interrupt register reset */
139
io.intmsk = INT_MASK_INIT;
140
io.i_pslv = 0x1b1b1b1b;
141
io.i_pmst = 0x00001f1b;
142
io.i_cslv = 0x1b1b1b1b;
143
io.i_cmst = 0x0000001b;
146
/*UART*/ io.utrstat0 = io.utrstat1 = 0x6;
149
/* test timer register tcon's bit.
152
timer_op (int n, int op)
155
return TIMER_OP (io.tcon, n, op);
157
if (n == 5 && op == TIMER_OP_RELOAD)
158
return TIMER_OP (io.tcon, n + 1, op - 1);
160
return TIMER_OP (io.tcon, n + 1, op);
164
/* get timer interrupt num.
167
get_timer_int (int i)
171
return TIMER_INT (0);
174
return TIMER_INT (1);
177
return TIMER_INT (2);
180
return TIMER_INT (3);
183
return TIMER_INT (4);
186
return TIMER_INT (5);
192
/*s3c44b0 io_do_cycle*/
194
s3c44b0_io_do_cycle (ARMul_State * state)
198
for (i = 0; i < TIMER_NUM; i++) {
199
if (timer_op (i, TIMER_OP_START)) {
200
if (io.tcnt[i] > 0) {
204
if (io.tcnt[i] == 0) {
205
if (timer_op (i, TIMER_OP_RELOAD)) {
206
io.tcnt[i] = io.tcntb[i];
207
io.tcmp[i] = io.tcmpb[i];
208
io.tcnto[i] = io.tcntb[i];
209
s3c44b0_set_interrupt (get_timer_int
211
s3c44b0_update_int (state);
213
//s3c44b0_set_interrupt(get_timer_int(i));
214
//s3c44b0_update_int(state);
218
/*UART*/ if (!(io.intpnd & INT_URXD0) || !(io.intpnd & INT_URXD1)) {
219
/* 2007-01-18 modified by Anthony Lee : for new uart device frame */
226
if(skyeye_uart_read(-1, &buf, 1, &tv, NULL) > 0)
228
io.urxh0 = io.urxh1 = (int) buf;
229
io.utrstat0 |= UART_LSR_DR;
230
io.utrstat1 |= UART_LSR_DR;
231
if ((io.ucon0 & 0x3) == 0x1) {
232
s3c44b0_set_interrupt (INT_URXD0);
233
s3c44b0_update_int (state);
236
if ((io.ucon1 & 0x3) == 0x1) {
237
s3c44b0_set_interrupt (INT_URXD1);
238
s3c44b0_update_int (state);
243
// s3c44b0_update_int(state);
250
s3c44b0_io_read_byte (ARMul_State * state, ARMword addr)
252
s3c44b0_io_read_word (state, addr);
253
/*printf("SKYEYE: s3c44b0_io_read_byte error\n");
258
s3c44b0_io_read_halfword (ARMul_State * state, ARMword addr)
260
s3c44b0_io_read_word (state, addr);
261
/*printf("SKYEYE: s3c44b0_io_read_halfword error\n");
266
s3c44b0_io_read_word (ARMul_State * state, ARMword addr)
272
printf ("%s (addr = 0x%08x), pc:%x, NumInstrs:%x\n",
273
__FUNCTION__, addr, state->pc, state->NumInstrs);
274
//printf("instr:%x\n",state->loaded);
303
/*find which interrupt is pending */
305
for (i = 0; i < 26; i++) {
306
if (io.intpnd & (1 << i))
328
/*UART*/ case ULCON0:
378
io.utrstat0 &= ~UART_LSR_DR;
382
io.utrstat1 &= ~UART_LSR_DR;
420
SKYEYE_DBG ("%s (addr = 0x%08x)\n", __FUNCTION__, addr);
429
s3c44b0_io_write_byte (ARMul_State * state, ARMword addr, ARMword data)
431
s3c44b0_io_write_word (state, addr, data);
432
/*printf("SKYEYE: s3c44b0_io_write_byte error\n");
437
s3c44b0_io_write_halfword (ARMul_State * state, ARMword addr, ARMword data)
439
s3c44b0_io_write_word (state, addr, data);
440
printf ("SKYEYE: s3c44b0_io_write_halfword error\n");
445
s3c44b0_io_write_word (ARMul_State * state, ARMword addr, ARMword data)
480
io.intpnd &= (~data & INT_MASK_INIT);
482
//s3c44b0_update_int(state);
488
io.intpnd &= (~data & INT_MASK_INIT);
489
//s3c44b0_update_int(state);
491
/*UART*/ case ULCON0:
544
/* 2007-01-18 modified by Anthony Lee : for new uart device frame */
545
skyeye_uart_write(-1, &c, 1, NULL);
547
io.utrstat0 |= UART_LSR_THRE | UART_LSR_TEMT;
548
if ((io.ucon0 & 0xc) == 0x04) {
549
s3c44b0_set_interrupt (INT_UTXD0);
550
s3c44b0_update_int (state);
582
for (i = 0; i < TIMER_NUM; i++) {
583
rel = timer_op (i, TIMER_OP_MANUAL);
584
//if(timer_op(i, TIMER_OP_MANUAL)){
586
io.tcnt[i] = io.tcntb[i];
587
io.tcmp[i] = io.tcmpb[i];
588
io.tcnto[i] = io.tcntb[i];
599
int n = (addr - TCNTB0) / 12;
600
io.tcntb[n] = data * 480;
608
int n = (addr - TCNTB0) / 12;
613
io.tcntb[5] = data; //* 480;
616
SKYEYE_DBG ("%s(0x%08x) = 0x%08x\n", __FUNCTION__, addr,
624
s3c44b0_mach_init (ARMul_State * state, machine_config_t * this_mach)
626
ARMul_SelectProcessor (state, ARM_v4_Prop);
627
state->lateabtSig = HIGH;
631
this_mach->mach_io_do_cycle = s3c44b0_io_do_cycle;
632
this_mach->mach_io_reset = s3c44b0_io_reset;
633
this_mach->mach_io_read_word = s3c44b0_io_read_word;
634
this_mach->mach_io_read_halfword = s3c44b0_io_read_halfword;
635
this_mach->mach_io_read_byte = s3c44b0_io_read_byte;
636
this_mach->mach_io_write_word = s3c44b0_io_write_word;
637
this_mach->mach_io_write_halfword = s3c44b0_io_write_halfword;
638
this_mach->mach_io_write_byte = s3c44b0_io_write_byte;
639
this_mach->mach_update_int = s3c44b0_update_int;
641
/* 2007-01-28 : added by Anthony Lee */
642
this_mach->state = (void *) state;