mirror of
https://github.com/genodelabs/genode.git
synced 2025-01-31 08:25:38 +00:00
sd_card: return capacity in 512kByte blocks
The returned capacity had different semantics dependent on the card type. For HIGH_CAPACITY cards, the memory capacity is specified in 512kB blocks. So we should also return 512kB blocks for STANDARD_CAPACITY cards. Issue #1925
This commit is contained in:
parent
063a603948
commit
338cfe5a94
@ -442,7 +442,7 @@ namespace Sd_card {
|
||||
* Extract capacity information from CSD register
|
||||
*
|
||||
* \throw Detection_failed
|
||||
* \return capacity in 512-byte blocks
|
||||
* \return capacity in 512-kByte blocks
|
||||
*/
|
||||
size_t _sd_card_device_size(Csd const csd)
|
||||
{
|
||||
@ -453,7 +453,6 @@ namespace Sd_card {
|
||||
*/
|
||||
|
||||
if (Csd3::Version::get(csd.csd3) == Csd3::Version::STANDARD_CAPACITY) {
|
||||
|
||||
/*
|
||||
* Calculation of the capacity according to the
|
||||
* "Physical Layer Simplified Specification Version 4.10",
|
||||
@ -462,12 +461,14 @@ namespace Sd_card {
|
||||
size_t const read_bl_len = Csd2::V1_read_bl_len::get(csd.csd2);
|
||||
size_t const c_size = (Csd2::V1_c_size_hi::get(csd.csd2) << 2)
|
||||
| Csd1::V1_c_size_lo::get(csd.csd1);
|
||||
|
||||
size_t const c_size_mult = Csd1::V1_c_size_mult::get(csd.csd1);
|
||||
size_t const mult = 1 << (c_size_mult + 2);
|
||||
size_t const block_len = 1 << read_bl_len;
|
||||
size_t const capacity = (c_size + 1)*mult*block_len;
|
||||
size_t const capacity512KiB = capacity / (512 * 1024);
|
||||
|
||||
return capacity;
|
||||
return capacity512KiB;
|
||||
}
|
||||
|
||||
if (Csd3::Version::get(csd.csd3) == Csd3::Version::HIGH_CAPACITY)
|
||||
|
Loading…
x
Reference in New Issue
Block a user