Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
qemu
提交
72af9170
Q
qemu
项目概览
openeuler
/
qemu
通知
10
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Q
qemu
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
72af9170
编写于
5月 05, 2009
作者:
E
Edgar E. Iglesias
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
ETRAX: Simplify serport control logic.
Signed-off-by:
N
Edgar E. Iglesias
<
edgar.iglesias@gmail.com
>
上级
f2964260
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
44 addition
and
83 deletion
+44
-83
hw/etraxfs_ser.c
hw/etraxfs_ser.c
+44
-83
未找到文件。
hw/etraxfs_ser.c
浏览文件 @
72af9170
...
...
@@ -30,16 +30,17 @@
#define D(x)
#define RW_TR_CTRL 0x00
#define RW_TR_DMA_EN 0x04
#define RW_REC_CTRL 0x08
#define RW_DOUT 0x1c
#define RS_STAT_DIN 0x20
#define R_STAT_DIN 0x24
#define RW_INTR_MASK 0x2c
#define RW_ACK_INTR 0x30
#define R_INTR 0x34
#define R_MASKED_INTR 0x38
#define RW_TR_CTRL (0x00 / 4)
#define RW_TR_DMA_EN (0x04 / 4)
#define RW_REC_CTRL (0x08 / 4)
#define RW_DOUT (0x1c / 4)
#define RS_STAT_DIN (0x20 / 4)
#define R_STAT_DIN (0x24 / 4)
#define RW_INTR_MASK (0x2c / 4)
#define RW_ACK_INTR (0x30 / 4)
#define R_INTR (0x34 / 4)
#define R_MASKED_INTR (0x38 / 4)
#define R_MAX (0x3c / 4)
#define STAT_DAV 16
#define STAT_TR_IDLE 22
...
...
@@ -51,30 +52,20 @@ struct etrax_serial
CharDriverState
*
chr
;
qemu_irq
*
irq
;
/* This pending thing is a hack. */
int
pending_tx
;
/* Control registers. */
uint32_t
rw_tr_ctrl
;
uint32_t
rw_tr_dma_en
;
uint32_t
rw_rec_ctrl
;
uint32_t
rs_stat_din
;
uint32_t
r_stat_din
;
uint32_t
rw_intr_mask
;
uint32_t
rw_ack_intr
;
uint32_t
r_intr
;
uint32_t
r_masked_intr
;
uint32_t
regs
[
R_MAX
];
};
static
void
ser_update_irq
(
struct
etrax_serial
*
s
)
{
s
->
r_intr
&=
~
(
s
->
rw_ack_intr
);
s
->
r_masked_intr
=
s
->
r_intr
&
s
->
rw_intr_mask
;
D
(
printf
(
"irq_mask=%x r_intr=%x rmi=%x airq=%x
\n
"
,
s
->
rw_intr_mask
,
s
->
r_intr
,
s
->
r_masked_intr
,
s
->
rw_ack_intr
));
qemu_set_irq
(
s
->
irq
[
0
],
!!
s
->
r_masked_intr
);
s
->
rw_ack_intr
=
0
;
s
->
regs
[
R_INTR
]
&=
~
(
s
->
regs
[
RW_ACK_INTR
]);
s
->
regs
[
R_MASKED_INTR
]
=
s
->
regs
[
R_INTR
]
&
s
->
regs
[
RW_INTR_MASK
];
qemu_set_irq
(
s
->
irq
[
0
],
!!
s
->
regs
[
R_MASKED_INTR
]);
s
->
regs
[
RW_ACK_INTR
]
=
0
;
}
static
uint32_t
ser_readl
(
void
*
opaque
,
target_phys_addr_t
addr
)
...
...
@@ -83,40 +74,20 @@ static uint32_t ser_readl (void *opaque, target_phys_addr_t addr)
D
(
CPUState
*
env
=
s
->
env
);
uint32_t
r
=
0
;
addr
>>=
2
;
switch
(
addr
)
{
case
RW_TR_CTRL
:
r
=
s
->
rw_tr_ctrl
;
break
;
case
RW_TR_DMA_EN
:
r
=
s
->
rw_tr_dma_en
;
break
;
case
RS_STAT_DIN
:
r
=
s
->
rs_stat_din
;
/* clear dav. */
s
->
rs_stat_din
&=
~
(
1
<<
STAT_DAV
);
break
;
case
R_STAT_DIN
:
r
=
s
->
rs_stat_din
;
break
;
case
RW_ACK_INTR
:
D
(
printf
(
"load rw_ack_intr=%x
\n
"
,
s
->
rw_ack_intr
));
r
=
s
->
rw_ack_intr
;
r
=
s
->
regs
[
RS_STAT_DIN
];
break
;
case
RW_INTR_MASK
:
r
=
s
->
rw_intr_mask
;
break
;
case
R_INTR
:
D
(
printf
(
"load r_intr=%x
\n
"
,
s
->
r_intr
));
r
=
s
->
r_intr
;
break
;
case
R_MASKED_INTR
:
D
(
printf
(
"load r_maked_intr=%x
\n
"
,
s
->
r_masked_intr
));
r
=
s
->
r_masked_intr
;
case
RS_STAT_DIN
:
r
=
s
->
regs
[
addr
];
/* Read side-effect: clear dav. */
s
->
regs
[
addr
]
&=
~
(
1
<<
STAT_DAV
);
break
;
default:
D
(
printf
(
"%s %x
\n
"
,
__func__
,
addr
));
r
=
s
->
regs
[
addr
];
D
(
printf
(
"%s %x=%x
\n
"
,
__func__
,
addr
,
r
));
break
;
}
return
r
;
...
...
@@ -129,36 +100,26 @@ ser_writel (void *opaque, target_phys_addr_t addr, uint32_t value)
unsigned
char
ch
=
value
;
D
(
CPUState
*
env
=
s
->
env
);
D
(
printf
(
"%s %x %x
\n
"
,
__func__
,
addr
,
value
));
addr
>>=
2
;
switch
(
addr
)
{
case
RW_TR_CTRL
:
D
(
printf
(
"rw_tr_ctrl=%x
\n
"
,
value
));
s
->
rw_tr_ctrl
=
value
;
break
;
case
RW_TR_DMA_EN
:
D
(
printf
(
"rw_tr_dma_en=%x
\n
"
,
value
));
s
->
rw_tr_dma_en
=
value
;
break
;
case
RW_DOUT
:
qemu_chr_write
(
s
->
chr
,
&
ch
,
1
);
s
->
r
_intr
|=
1
;
s
->
r
egs
[
R_INTR
]
|=
1
;
s
->
pending_tx
=
1
;
s
->
regs
[
addr
]
=
value
;
break
;
case
RW_ACK_INTR
:
D
(
printf
(
"rw_ack_intr=%x
\n
"
,
value
));
s
->
rw_ack_intr
=
value
;
if
(
s
->
pending_tx
&&
(
s
->
rw_ack_intr
&
1
))
{
s
->
r_intr
|=
1
;
s
->
regs
[
addr
]
=
value
;
if
(
s
->
pending_tx
&&
(
s
->
regs
[
addr
]
&
1
))
{
s
->
regs
[
R_INTR
]
|=
1
;
s
->
pending_tx
=
0
;
s
->
r
w_ack_intr
&=
~
1
;
s
->
r
egs
[
addr
]
&=
~
1
;
}
break
;
case
RW_INTR_MASK
:
D
(
printf
(
"r_intr_mask=%x
\n
"
,
value
));
s
->
rw_intr_mask
=
value
;
break
;
default:
D
(
printf
(
"%s %x %x
\n
"
,
__func__
,
addr
,
value
))
;
s
->
regs
[
addr
]
=
value
;
break
;
}
ser_update_irq
(
s
);
...
...
@@ -178,10 +139,10 @@ static void serial_receive(void *opaque, const uint8_t *buf, int size)
{
struct
etrax_serial
*
s
=
opaque
;
s
->
r
_intr
|=
8
;
s
->
r
s_stat_din
&=
~
0xff
;
s
->
r
s_stat_din
|=
(
buf
[
0
]
&
0xff
);
s
->
r
s_stat_din
|=
(
1
<<
STAT_DAV
);
/* dav. */
s
->
r
egs
[
R_INTR
]
|=
8
;
s
->
r
egs
[
RS_STAT_DIN
]
&=
~
0xff
;
s
->
r
egs
[
RS_STAT_DIN
]
|=
(
buf
[
0
]
&
0xff
);
s
->
r
egs
[
RS_STAT_DIN
]
|=
(
1
<<
STAT_DAV
);
/* dav. */
ser_update_irq
(
s
);
}
...
...
@@ -191,10 +152,10 @@ static int serial_can_receive(void *opaque)
int
r
;
/* Is the receiver enabled? */
r
=
s
->
r
w_rec_ctrl
&
1
;
r
=
s
->
r
egs
[
RW_REC_CTRL
]
&
1
;
/* Pending rx data? */
r
|=
!
(
s
->
r
_intr
&
8
);
r
|=
!
(
s
->
r
egs
[
R_INTR
]
&
8
);
return
r
;
}
...
...
@@ -216,12 +177,12 @@ void etraxfs_ser_init(CPUState *env, qemu_irq *irq, CharDriverState *chr,
s
->
chr
=
chr
;
/* transmitter begins ready and idle. */
s
->
r
s_stat_din
|=
(
1
<<
STAT_TR_RDY
);
s
->
r
s_stat_din
|=
(
1
<<
STAT_TR_IDLE
);
s
->
r
egs
[
RS_STAT_DIN
]
|=
(
1
<<
STAT_TR_RDY
);
s
->
r
egs
[
RS_STAT_DIN
]
|=
(
1
<<
STAT_TR_IDLE
);
qemu_chr_add_handlers
(
chr
,
serial_can_receive
,
serial_receive
,
serial_event
,
s
);
ser_regs
=
cpu_register_io_memory
(
0
,
ser_read
,
ser_write
,
s
);
cpu_register_physical_memory
(
base
,
0x3c
,
ser_regs
);
cpu_register_physical_memory
(
base
,
R_MAX
*
4
,
ser_regs
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录