FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Flashalloc-Cosmos/Flashalloc/ftl_config.c at master · FlashSQL/Flashalloc-Cosmos · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
FlashSQL
/
Flashalloc-Cosmos
Public
forked from
JonghyeokPark/Flashalloc-Cosmos
Notifications
You must be signed in to change notification settings
Fork
0
Star
8
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
Flashalloc-Cosmos
/
Flashalloc
/
ftl_config.c
Copy path
More file actions
More file actions
Latest commit
History
History
History
235 lines (203 loc) · 7.74 KB
Breadcrumbs
Flashalloc-Cosmos
/
Flashalloc
/
ftl_config.c
Copy path
File metadata and controls
235 lines (203 loc) · 7.74 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
//////////////////////////////////////////////////////////////////////////////////
// ftl_config.c for Cosmos+ OpenSSD
// Copyright (c) 2017 Hanyang University ENC Lab.
// Contributed by Yong Ho Song <yhsong@enc.hanyang.ac.kr>
// Jaewook Kwak <jwkwak@enc.hanyang.ac.kr>
// Sangjin Lee <sjlee@enc.hanyang.ac.kr>
//
// This file is part of Cosmos+ OpenSSD.
//
// Cosmos+ OpenSSD is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// Cosmos+ OpenSSD is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Cosmos+ OpenSSD; see the file COPYING.
// If not, see <http://www.gnu.org/licenses/>.
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
// Company: ENC Lab. <http://enc.hanyang.ac.kr>
// Engineer: Jaewook Kwak <jwkwak@enc.hanyang.ac.kr>
//
// Project Name: Cosmos+ OpenSSD
// Design Name: Cosmos+ Firmware
// Module Name: Flash Translation Layer Configuration Manager
// File Name: ftl_config.c
//
// Version: v1.0.0
//
// Description:
// - initialize flash translation layer
// - check configuration options
// - initialize NAND device
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
// Revision History:
//
// * v1.0.0
// - First draft
//////////////////////////////////////////////////////////////////////////////////
#include
<assert.h>
#include
"xil_printf.h"
#include
"memory_map.h"
#include
"t4nsc_ucode.h"
#include
"nsc_driver.h"
#include
"ftl_stats.h"
unsigned
int
storageCapacity_L
;
T4REGS
chCtlReg
[
USER_CHANNELS
];
// (jhpark)
long long
g_ftl_num_write
;
long long
g_ftl_num_gc
;
long long
g_ftl_num_erase
;
long long
g_ftl_num_copy_back
;
long long
g_ftl_num_gather_gc
;
long long
g_ftl_num_gather_cp
;
long long
g_ftl_num_gather_write
;
long long
g_ftl_num_host_write
;
long long
g_ftl_num_trim
;
unsigned
int
trim_flag
;
struct
stats_ftl
stats_ftl
=
{
0
};
void
InitFTL
()
{
CheckConfigRestriction
();
InitChCtlReg
();
InitReqPool
();
InitDependencyTable
();
InitReqScheduler
();
InitNandArray
();
InitAddressMap
();
InitDataBuf
();
InitGcVictimMap
();
// (jhpark): add
g_ftl_num_trim
=
0
;
trim_flag
=
1
;
if
(
USER_BLOCKS_PER_LUN
>
3072
)
storageCapacity_L
=
(
MB_PER_SSD
-
(
MB_PER_MIN_FREE_BLOCK_SPACE
+
mbPerbadBlockSpace
+
MB_PER_OVER_PROVISION_BLOCK_SPACE
))
*
((
1024
*
1024
) /
BYTES_PER_NVME_BLOCK
);
else
storageCapacity_L
=
(
MB_PER_SSD
-
(
MB_PER_MIN_FREE_BLOCK_SPACE
+
MB_PER_OVER_PROVISION_BLOCK_SPACE
))
*
((
1024
*
1024
) /
BYTES_PER_NVME_BLOCK
);
xil_printf
(
"[ storage capacity %d MB ]\r\n"
,
storageCapacity_L
/ ((
1024
*
1024
) /
BYTES_PER_NVME_BLOCK
));
xil_printf
(
"[%d Byte/data region of page]\r\n"
,
BYTES_PER_DATA_REGION_OF_PAGE
);
xil_printf
(
"[ ftl configuration complete. ]\r\n"
);
}
static
void
nfc_install_ucode
(
unsigned
int
*
bram0
)
{
int
i
;
for
(
i
=
0
;
i
<
T4NSCu_Common_CodeWordLength
;
i
++
)
{
bram0
[
i
]
=
T4NSCuCode_Common
[
i
];
}
for
(
i
=
0
;
i
<
T4NSCu_PlainOps_CodeWordLength
;
i
++
)
{
bram0
[
T4NSCu_Common_CodeWordLength
+
i
]
=
T4NSCuCode_PlainOps
[
i
];
}
}
unsigned
int
NSCS
[]
=
{
NSC_0_BASEADDR
,
NSC_1_BASEADDR
,
NSC_2_BASEADDR
,
NSC_3_BASEADDR
,
NSC_4_BASEADDR
,
NSC_5_BASEADDR
,
NSC_6_BASEADDR
,
NSC_7_BASEADDR
,
};
unsigned
int
NSC_UCODES
[]
=
{
NSC_0_UCODEADDR
,
NSC_1_UCODEADDR
,
NSC_2_UCODEADDR
,
NSC_3_UCODEADDR
,
NSC_4_UCODEADDR
,
NSC_5_UCODEADDR
,
NSC_6_UCODEADDR
,
NSC_7_UCODEADDR
};
void
InitChCtlReg
()
{
int
i
;
if
(
USER_CHANNELS
<
1
)
assert
(!
"[WARNING] Configuration Error: Channel [WARNING]"
);
for
(
i
=
0
;
i
<
USER_CHANNELS
;
i
++
)
{
nfc_install_ucode
((
unsigned
int
*
)
NSC_UCODES
[
i
]);
V2FInitializeHandle
(
&
chCtlReg
[
i
], (
void
*
)
NSCS
[
i
]);
nfc_set_dqs_delay
(
i
,
28
);
}
//nfc_set_dqs_delay(0, 31);
//nfc_set_dqs_delay(1, 31);
//nfc_set_dqs_delay(5, 4);
//nfc_set_dqs_delay(6, 18);
}
void
InitNandArray
()
{
unsigned
int
chNo
,
wayNo
,
reqSlotTag
;
int
i
;
for
(
chNo
=
0
;
chNo
<
USER_CHANNELS
;
++
chNo
)
for
(
wayNo
=
0
;
wayNo
<
USER_WAYS
;
++
wayNo
)
{
reqSlotTag
=
GetFromFreeReqQ
();
reqPoolPtr
->
reqPool
[
reqSlotTag
].
reqType
=
REQ_TYPE_NAND
;
reqPoolPtr
->
reqPool
[
reqSlotTag
].
reqCode
=
REQ_CODE_RESET
;
reqPoolPtr
->
reqPool
[
reqSlotTag
].
reqOpt
.
nandAddr
=
REQ_OPT_NAND_ADDR_PHY_ORG
;
reqPoolPtr
->
reqPool
[
reqSlotTag
].
reqOpt
.
dataBufFormat
=
REQ_OPT_DATA_BUF_NONE
;
reqPoolPtr
->
reqPool
[
reqSlotTag
].
reqOpt
.
rowAddrDependencyCheck
=
REQ_OPT_ROW_ADDR_DEPENDENCY_NONE
;
reqPoolPtr
->
reqPool
[
reqSlotTag
].
reqOpt
.
blockSpace
=
REQ_OPT_BLOCK_SPACE_TOTAL
;
reqPoolPtr
->
reqPool
[
reqSlotTag
].
reqOpt
.
forceUnitAccess
=
REQ_OPT_FORCE_UNIT_ACCESS_OFF
;
reqPoolPtr
->
reqPool
[
reqSlotTag
].
reqOpt
.
be_flush_req
=
0
;
reqPoolPtr
->
reqPool
[
reqSlotTag
].
nandInfo
.
physicalCh
=
chNo
;
reqPoolPtr
->
reqPool
[
reqSlotTag
].
nandInfo
.
physicalWay
=
wayNo
;
reqPoolPtr
->
reqPool
[
reqSlotTag
].
nandInfo
.
physicalBlock
=
0
;
//dummy
reqPoolPtr
->
reqPool
[
reqSlotTag
].
nandInfo
.
physicalPage
=
0
;
//dummy
reqPoolPtr
->
reqPool
[
reqSlotTag
].
prevBlockingReq
=
REQ_SLOT_TAG_NONE
;
SelectLowLevelReqQ
(
reqSlotTag
);
reqSlotTag
=
GetFromFreeReqQ
();
reqPoolPtr
->
reqPool
[
reqSlotTag
].
reqType
=
REQ_TYPE_NAND
;
reqPoolPtr
->
reqPool
[
reqSlotTag
].
reqCode
=
REQ_CODE_SET_FEATURE
;
reqPoolPtr
->
reqPool
[
reqSlotTag
].
reqOpt
.
nandAddr
=
REQ_OPT_NAND_ADDR_PHY_ORG
;
reqPoolPtr
->
reqPool
[
reqSlotTag
].
reqOpt
.
dataBufFormat
=
REQ_OPT_DATA_BUF_NONE
;
reqPoolPtr
->
reqPool
[
reqSlotTag
].
reqOpt
.
rowAddrDependencyCheck
=
REQ_OPT_ROW_ADDR_DEPENDENCY_NONE
;
reqPoolPtr
->
reqPool
[
reqSlotTag
].
reqOpt
.
blockSpace
=
REQ_OPT_BLOCK_SPACE_TOTAL
;
reqPoolPtr
->
reqPool
[
reqSlotTag
].
reqOpt
.
forceUnitAccess
=
REQ_OPT_FORCE_UNIT_ACCESS_OFF
;
reqPoolPtr
->
reqPool
[
reqSlotTag
].
reqOpt
.
be_flush_req
=
0
;
reqPoolPtr
->
reqPool
[
reqSlotTag
].
nandInfo
.
physicalCh
=
chNo
;
reqPoolPtr
->
reqPool
[
reqSlotTag
].
nandInfo
.
physicalWay
=
wayNo
;
reqPoolPtr
->
reqPool
[
reqSlotTag
].
nandInfo
.
physicalBlock
=
0
;
//dummy
reqPoolPtr
->
reqPool
[
reqSlotTag
].
nandInfo
.
physicalPage
=
0
;
//dummy
reqPoolPtr
->
reqPool
[
reqSlotTag
].
prevBlockingReq
=
REQ_SLOT_TAG_NONE
;
SelectLowLevelReqQ
(
reqSlotTag
);
}
SyncAllLowLevelReqDone
();
for
(
i
=
0
;
i
<
USER_CHANNELS
;
i
++
)
{
int
j
;
unsigned
char
*
idData
=
(
unsigned
char
*
)(
TEMPORARY_PAY_LOAD_ADDR
+
16
);
V2FReadIdSync
(
&
chCtlReg
[
i
],
0
,
idData
);
printf
(
"Ch %d ReadId: "
,
i
);
for
(
j
=
0
;
j
<
6
;
j
++
)
printf
(
"%x "
,
idData
[
j
]);
printf
(
"\r\n"
);
}
xil_printf
(
"[ NAND device reset complete. ]\r\n"
);
}
void
CheckConfigRestriction
()
{
if
(
USER_CHANNELS
>
NSC_MAX_CHANNELS
)
assert
(!
"[WARNING] Configuration Error: Channel [WARNING]"
);
if
(
USER_WAYS
>
NSC_MAX_WAYS
)
assert
(!
"[WARNING] Configuration Error: WAY [WARNING]"
);
if
(
USER_BLOCKS_PER_LUN
>
MAIN_BLOCKS_PER_LUN
)
assert
(!
"[WARNING] Configuration Error: BLOCK [WARNING]"
);
if
((
BITS_PER_FLASH_CELL
!=
SLC_MODE
))
assert
(!
"[WARNING] Configuration Error: BIT_PER_FLASH_CELL [WARNING]"
);
if
(
RESERVED_DATA_BUFFER_BASE_ADDR
+
0x00200000
>
COMPLETE_FLAG_TABLE_ADDR
)
assert
(!
"[WARNING] Configuration Error: Data buffer size is too large to be allocated to predefined range [WARNING]"
);
if
(
TEMPORARY_PAY_LOAD_ADDR
+
0x00001000
>
DATA_BUFFER_MAP_ADDR
)
assert
(!
"[WARNING] Configuration Error: Metadata for NAND request completion process is too large to be allocated to predefined range [WARNING]"
);
if
(
FTL_MANAGEMENT_END_ADDR
>
DRAM_END_ADDR
)
assert
(!
"[WARNING] Configuration Error: Metadata of FTL is too large to be allocated to DRAM [WARNING]"
);
}
Back
|
FazBrowse Home
|
New Git URL