Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
drivers
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MLA98
drivers
Commits
78ab3862
Unverified
Commit
78ab3862
authored
Jan 04, 2018
by
Ian Douglas Scott
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move capacity reading to seperate method
parent
c78d4dcf
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
9 deletions
+16
-9
ahcid/src/ahci/disk_atapi.rs
ahcid/src/ahci/disk_atapi.rs
+16
-9
No files found.
ahcid/src/ahci/disk_atapi.rs
View file @
78ab3862
...
...
@@ -50,6 +50,19 @@ impl DiskATAPI {
buf
:
buf
})
}
fn
read_capacity
(
&
mut
self
)
->
Result
<
(
u32
,
u32
)
>
{
// TODO: only query when needed (disk changed)
let
mut
cmd
=
[
0
;
16
];
cmd
[
0
]
=
SCSI_READ_CAPACITY
;
self
.port
.packet
(
&
cmd
,
8
,
&
mut
self
.clb
,
&
mut
self
.ctbas
,
&
mut
self
.buf
)
?
;
let
blk_count
=
BigEndian
::
read_u32
(
&
self
.buf
[
0
..
4
]);
let
blk_size
=
BigEndian
::
read_u32
(
&
self
.buf
[
4
..
8
]);
Ok
((
blk_count
,
blk_size
))
}
}
impl
Disk
for
DiskATAPI
{
...
...
@@ -58,16 +71,10 @@ impl Disk for DiskATAPI {
}
fn
size
(
&
mut
self
)
->
u64
{
let
mut
cmd
=
[
0
;
16
];
cmd
[
0
]
=
SCSI_READ_CAPACITY
;
if
let
Err
(
_
)
=
self
.port
.packet
(
&
cmd
,
8
,
&
mut
self
.clb
,
&
mut
self
.ctbas
,
&
mut
self
.buf
)
{
return
0
;
// XXX
match
self
.read_capacity
()
{
Ok
((
blk_count
,
blk_size
))
=>
(
blk_count
as
u64
)
*
(
blk_size
as
u64
),
Err
(
_
)
=>
0
// XXX
}
let
blk_count
=
BigEndian
::
read_u32
(
&
self
.buf
[
0
..
4
]);
let
blk_size
=
BigEndian
::
read_u32
(
&
self
.buf
[
4
..
8
]);
(
blk_count
as
u64
)
*
(
blk_size
as
u64
)
}
fn
read
(
&
mut
self
,
_
block
:
u64
,
_
buffer
:
&
mut
[
u8
])
->
Result
<
usize
>
{
...
...
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