Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
qemu
提交
da221327
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看板
提交
da221327
编写于
12月 15, 2011
作者:
P
Paolo Bonzini
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
ahci: use new DMA helpers
Signed-off-by:
N
Paolo Bonzini
<
pbonzini@redhat.com
>
上级
84a69356
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
13 addition
and
69 deletion
+13
-69
hw/ide/ahci.c
hw/ide/ahci.c
+13
-69
未找到文件。
hw/ide/ahci.c
浏览文件 @
da221327
...
...
@@ -428,55 +428,6 @@ static void ahci_reg_init(AHCIState *s)
}
}
static
uint32_t
read_from_sglist
(
uint8_t
*
buffer
,
uint32_t
len
,
QEMUSGList
*
sglist
)
{
uint32_t
i
=
0
;
uint32_t
total
=
0
,
once
;
ScatterGatherEntry
*
cur_prd
;
uint32_t
sgcount
;
cur_prd
=
sglist
->
sg
;
sgcount
=
sglist
->
nsg
;
for
(
i
=
0
;
len
&&
sgcount
;
i
++
)
{
once
=
MIN
(
cur_prd
->
len
,
len
);
cpu_physical_memory_read
(
cur_prd
->
base
,
buffer
,
once
);
cur_prd
++
;
sgcount
--
;
len
-=
once
;
buffer
+=
once
;
total
+=
once
;
}
return
total
;
}
static
uint32_t
write_to_sglist
(
uint8_t
*
buffer
,
uint32_t
len
,
QEMUSGList
*
sglist
)
{
uint32_t
i
=
0
;
uint32_t
total
=
0
,
once
;
ScatterGatherEntry
*
cur_prd
;
uint32_t
sgcount
;
DPRINTF
(
-
1
,
"total: 0x%x bytes
\n
"
,
len
);
cur_prd
=
sglist
->
sg
;
sgcount
=
sglist
->
nsg
;
for
(
i
=
0
;
len
&&
sgcount
;
i
++
)
{
once
=
MIN
(
cur_prd
->
len
,
len
);
DPRINTF
(
-
1
,
"write 0x%x bytes to 0x%lx
\n
"
,
once
,
(
long
)
cur_prd
->
base
);
cpu_physical_memory_write
(
cur_prd
->
base
,
buffer
,
once
);
cur_prd
++
;
sgcount
--
;
len
-=
once
;
buffer
+=
once
;
total
+=
once
;
}
return
total
;
}
static
void
check_cmd
(
AHCIState
*
s
,
int
port
)
{
AHCIPortRegs
*
pr
=
&
s
->
dev
[
port
].
port_regs
;
...
...
@@ -802,9 +753,8 @@ static void process_ncq_command(AHCIState *s, int port, uint8_t *cmd_fis,
DPRINTF
(
port
,
"tag %d aio read %"
PRId64
"
\n
"
,
ncq_tfs
->
tag
,
ncq_tfs
->
lba
);
bdrv_acct_start
(
ncq_tfs
->
drive
->
port
.
ifs
[
0
].
bs
,
&
ncq_tfs
->
acct
,
(
ncq_tfs
->
sector_count
-
1
)
*
BDRV_SECTOR_SIZE
,
BDRV_ACCT_READ
);
dma_acct_start
(
ncq_tfs
->
drive
->
port
.
ifs
[
0
].
bs
,
&
ncq_tfs
->
acct
,
&
ncq_tfs
->
sglist
,
BDRV_ACCT_READ
);
ncq_tfs
->
aiocb
=
dma_bdrv_read
(
ncq_tfs
->
drive
->
port
.
ifs
[
0
].
bs
,
&
ncq_tfs
->
sglist
,
ncq_tfs
->
lba
,
ncq_cb
,
ncq_tfs
);
...
...
@@ -816,9 +766,8 @@ static void process_ncq_command(AHCIState *s, int port, uint8_t *cmd_fis,
DPRINTF
(
port
,
"tag %d aio write %"
PRId64
"
\n
"
,
ncq_tfs
->
tag
,
ncq_tfs
->
lba
);
bdrv_acct_start
(
ncq_tfs
->
drive
->
port
.
ifs
[
0
].
bs
,
&
ncq_tfs
->
acct
,
(
ncq_tfs
->
sector_count
-
1
)
*
BDRV_SECTOR_SIZE
,
BDRV_ACCT_WRITE
);
dma_acct_start
(
ncq_tfs
->
drive
->
port
.
ifs
[
0
].
bs
,
&
ncq_tfs
->
acct
,
&
ncq_tfs
->
sglist
,
BDRV_ACCT_WRITE
);
ncq_tfs
->
aiocb
=
dma_bdrv_write
(
ncq_tfs
->
drive
->
port
.
ifs
[
0
].
bs
,
&
ncq_tfs
->
sglist
,
ncq_tfs
->
lba
,
ncq_cb
,
ncq_tfs
);
...
...
@@ -1023,12 +972,12 @@ static int ahci_start_transfer(IDEDMA *dma)
is_write
?
"writ"
:
"read"
,
size
,
is_atapi
?
"atapi"
:
"ata"
,
has_sglist
?
""
:
"o"
);
if
(
is_write
&&
has_sglist
&&
(
s
->
data_ptr
<
s
->
data_end
)
)
{
read_from_sglist
(
s
->
data_ptr
,
size
,
&
s
->
sg
);
}
if
(
!
is_write
&&
has_sglist
&&
(
s
->
data_ptr
<
s
->
data_end
))
{
write_to_sglist
(
s
->
data_ptr
,
size
,
&
s
->
sg
);
if
(
has_sglist
&&
size
)
{
if
(
is_write
)
{
dma_buf_write
(
s
->
data_ptr
,
size
,
&
s
->
sg
);
}
else
{
dma_buf_read
(
s
->
data_ptr
,
size
,
&
s
->
sg
);
}
}
/* update number of transferred bytes */
...
...
@@ -1067,14 +1016,9 @@ static int ahci_dma_prepare_buf(IDEDMA *dma, int is_write)
{
AHCIDevice
*
ad
=
DO_UPCAST
(
AHCIDevice
,
dma
,
dma
);
IDEState
*
s
=
&
ad
->
port
.
ifs
[
0
];
int
i
;
ahci_populate_sglist
(
ad
,
&
s
->
sg
);
s
->
io_buffer_size
=
0
;
for
(
i
=
0
;
i
<
s
->
sg
.
nsg
;
i
++
)
{
s
->
io_buffer_size
+=
s
->
sg
.
sg
[
i
].
len
;
}
s
->
io_buffer_size
=
s
->
sg
.
size
;
DPRINTF
(
ad
->
port_no
,
"len=%#x
\n
"
,
s
->
io_buffer_size
);
return
s
->
io_buffer_size
!=
0
;
...
...
@@ -1092,9 +1036,9 @@ static int ahci_dma_rw_buf(IDEDMA *dma, int is_write)
}
if
(
is_write
)
{
write_to_sglist
(
p
,
l
,
&
s
->
sg
);
dma_buf_read
(
p
,
l
,
&
s
->
sg
);
}
else
{
read_from_sglist
(
p
,
l
,
&
s
->
sg
);
dma_buf_write
(
p
,
l
,
&
s
->
sg
);
}
/* update number of transferred bytes */
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录