1
- /* Copyright (c) 2020 ARM Limited
1
+ /* Copyright (c) 2020-2021 ARM Limited
2
2
* SPDX-License-Identifier: Apache-2.0
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
19
19
#include " blockdevice/internal/SFDP.h"
20
20
21
21
class TestSFDP : public testing ::Test {
22
- protected:
23
- struct mbed ::sfdp_smptbl_info smptbl;
24
-
25
- /* *
26
- * Construct Mbed OS SFDP info.
27
- * Normally this is parsed from the flash-chips's
28
- * raw SFDP table bytes, but for unit test we construct
29
- * SFDP info manually
30
- */
31
- virtual void SetUp ()
32
- {
33
- // The mock flash supports 4KB, 32KB and 64KB erase types
34
- smptbl.erase_type_size_arr [0 ] = 4 * 1024 ;
35
- smptbl.erase_type_size_arr [1 ] = 32 * 1024 ;
36
- smptbl.erase_type_size_arr [2 ] = 64 * 1024 ;
37
-
38
- // The mock flash has three regions, with address ranges:
39
- // * 0 to 64KB - 1B
40
- // * 64KB to 256KB - 1B
41
- // * 256KB to 1024KB - 1B
42
- smptbl.region_high_boundary [0 ] = 64 * 1024 - 1 ;
43
- smptbl.region_high_boundary [1 ] = 256 * 1024 - 1 ;
44
- smptbl.region_high_boundary [2 ] = 1024 * 1024 - 1 ;
45
-
46
- // Bitfields indicating which regions support which erase types
47
- smptbl.region_erase_types_bitfld [0 ] = 0b0001 ; // 4KB only
48
- smptbl.region_erase_types_bitfld [1 ] = 0b0111 ; // 64KB, 32KB, 4KB
49
- smptbl.region_erase_types_bitfld [2 ] = 0b0110 ; // 64KB, 32KB
50
- }
51
22
};
52
23
53
24
/* *
@@ -63,6 +34,25 @@ TEST_F(TestSFDP, TestEraseTypeAlgorithm)
63
34
int region = 1 ;
64
35
int type;
65
36
37
+ // The mock flash supports 4KB, 32KB and 64KB erase types
38
+ struct mbed ::sfdp_smptbl_info smptbl;
39
+ smptbl.erase_type_size_arr [0 ] = 4 * 1024 ;
40
+ smptbl.erase_type_size_arr [1 ] = 32 * 1024 ;
41
+ smptbl.erase_type_size_arr [2 ] = 64 * 1024 ;
42
+
43
+ // The mock flash has three regions, with address ranges:
44
+ // * 0 to 64KB - 1B
45
+ // * 64KB to 256KB - 1B
46
+ // * 256KB to 1024KB - 1B
47
+ smptbl.region_high_boundary [0 ] = 64 * 1024 - 1 ;
48
+ smptbl.region_high_boundary [1 ] = 256 * 1024 - 1 ;
49
+ smptbl.region_high_boundary [2 ] = 1024 * 1024 - 1 ;
50
+
51
+ // Bitfields indicating which regions support which erase types
52
+ smptbl.region_erase_types_bitfld [0 ] = 0b0001 ; // 4KB only
53
+ smptbl.region_erase_types_bitfld [1 ] = 0b0111 ; // 64KB, 32KB, 4KB
54
+ smptbl.region_erase_types_bitfld [2 ] = 0b0110 ; // 64KB, 32KB
55
+
66
56
// Expected outcome:
67
57
// * The starting position 92KB is 4KB-aligned
68
58
// * The next position 96KB (92KB + 4KB) is 32KB-aligned
0 commit comments