Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
drivers
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Liam Naddell
drivers
Commits
74ed054d
Unverified
Commit
74ed054d
authored
Jan 07, 2018
by
Jeremy Soller
Committed by
GitHub
Jan 07, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #23 from ids1024/dma
ahci: refactor duplicated ATA command code into a method
parents
6394b1b5
c8154e76
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
77 additions
and
148 deletions
+77
-148
disk_ata.rs
ahcid/src/ahci/disk_ata.rs
+4
-4
hba.rs
ahcid/src/ahci/hba.rs
+73
-144
No files found.
ahcid/src/ahci/disk_ata.rs
View file @
74ed054d
...
...
@@ -62,14 +62,14 @@ impl Disk for DiskATA {
let
mut
sector
:
usize
=
0
;
while
sectors
-
sector
>=
255
{
self
.port
.
ata_dma
(
block
+
sector
as
u64
,
255
,
false
,
&
mut
self
.clb
,
&
mut
self
.ctbas
,
&
mut
self
.buf
)
?
;
self
.port
.
dma_read_write
(
block
+
sector
as
u64
,
255
,
false
,
&
mut
self
.clb
,
&
mut
self
.ctbas
,
&
mut
self
.buf
)
?
;
unsafe
{
ptr
::
copy
(
self
.buf
.as_ptr
(),
buffer
.as_mut_ptr
()
.offset
(
sector
as
isize
*
512
),
255
*
512
);
}
sector
+=
255
;
}
if
sector
<
sectors
{
self
.port
.
ata_dma
(
block
+
sector
as
u64
,
sectors
-
sector
,
false
,
&
mut
self
.clb
,
&
mut
self
.ctbas
,
&
mut
self
.buf
)
?
;
self
.port
.
dma_read_write
(
block
+
sector
as
u64
,
sectors
-
sector
,
false
,
&
mut
self
.clb
,
&
mut
self
.ctbas
,
&
mut
self
.buf
)
?
;
unsafe
{
ptr
::
copy
(
self
.buf
.as_ptr
(),
buffer
.as_mut_ptr
()
.offset
(
sector
as
isize
*
512
),
(
sectors
-
sector
)
*
512
);
}
...
...
@@ -86,7 +86,7 @@ impl Disk for DiskATA {
while
sectors
-
sector
>=
255
{
unsafe
{
ptr
::
copy
(
buffer
.as_ptr
()
.offset
(
sector
as
isize
*
512
),
self
.buf
.as_mut_ptr
(),
255
*
512
);
}
if
let
Err
(
err
)
=
self
.port
.
ata_dma
(
block
+
sector
as
u64
,
255
,
true
,
&
mut
self
.clb
,
&
mut
self
.ctbas
,
&
mut
self
.buf
)
{
if
let
Err
(
err
)
=
self
.port
.
dma_read_write
(
block
+
sector
as
u64
,
255
,
true
,
&
mut
self
.clb
,
&
mut
self
.ctbas
,
&
mut
self
.buf
)
{
return
Err
(
err
);
}
...
...
@@ -95,7 +95,7 @@ impl Disk for DiskATA {
if
sector
<
sectors
{
unsafe
{
ptr
::
copy
(
buffer
.as_ptr
()
.offset
(
sector
as
isize
*
512
),
self
.buf
.as_mut_ptr
(),
(
sectors
-
sector
)
*
512
);
}
if
let
Err
(
err
)
=
self
.port
.
ata_dma
(
block
+
sector
as
u64
,
sectors
-
sector
,
true
,
&
mut
self
.clb
,
&
mut
self
.ctbas
,
&
mut
self
.buf
)
{
if
let
Err
(
err
)
=
self
.port
.
dma_read_write
(
block
+
sector
as
u64
,
sectors
-
sector
,
true
,
&
mut
self
.clb
,
&
mut
self
.ctbas
,
&
mut
self
.buf
)
{
return
Err
(
err
);
}
...
...
ahcid/src/ahci/hba.rs
View file @
74ed054d
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment