|
27 | 27 | use iTXTech\SimpleFramework\Util\StringUtil;
|
28 | 28 |
|
29 | 29 | class SiliconMotionSSD extends Generator{
|
| 30 | + private const CONTROLLERS = [ |
| 31 | + "2258XT" => null, |
| 32 | + "2259XT" => null, |
| 33 | + "2258" => null, |
| 34 | + "58XT" => "2258XT", |
| 35 | + "2259AB" => "2259", |
| 36 | + "2258AB" => "2258" |
| 37 | + ]; |
| 38 | + |
30 | 39 | public static function getDirName() : string{
|
31 | 40 | return "smssd";
|
32 | 41 | }
|
33 | 42 |
|
34 | 43 | public static function merge(Fdb $fdb, string $data, string $filename) : void{
|
35 | 44 | $controller = "SM" . explode("_", $filename)[0];
|
| 45 | + //新版本SM2258XT的Flash.SET格式变成更加完整的列表,包含SM2258系列,SM2259系列的配置 |
| 46 | + //标识前缀也变为 B |
| 47 | + $prefix = $controller == "SM2258XT" ? "B" : "A"; |
| 48 | + //部分支持不在新版列表中体现,比如SKHY16nm/14nm,Kioxia BiCS2等 |
| 49 | + if($controller == "SM2258XTLEGACY"){ |
| 50 | + $controller = "SM2258XT"; |
| 51 | + } |
36 | 52 | $fdb->getInfo()->addController($controller);
|
37 | 53 | $data = explode("\r\n", $data);
|
38 | 54 | foreach($data as $k => $config){
|
39 |
| - if(StringUtil::startsWith($config, "A") and |
40 |
| - !StringUtil::startsWith($data[$k + 1], "A") and |
| 55 | + if(StringUtil::startsWith($config, $prefix) and |
| 56 | + !StringUtil::startsWith($data[$k + 1], $prefix) and |
41 | 57 | !StringUtil::endsWith($config, "[END]")){
|
42 | 58 | list($flash, $info) = explode("=", $data[$k + 1], 2);
|
43 | 59 | list($vendor, $density, $pn) = explode(",", $flash, 3);
|
| 60 | + //更正错误厂商命名 |
44 | 61 | $vendor = str_replace(
|
45 | 62 | ["hynix", "stm", "power flash"],
|
46 | 63 | ["skhynix", "st", "powerchip"],
|
47 | 64 | strtolower($vendor));
|
| 65 | + if($prefix == "B"){ |
| 66 | + $matches = []; |
| 67 | + preg_match_all('/(?<=\(SM)[^)]+/', $pn, $matches); |
| 68 | + $matches = $matches[0]; |
| 69 | + if(count($matches) > 0){ |
| 70 | + $matches = $matches[0]; |
| 71 | + if(in_array($matches, array_keys(self::CONTROLLERS))){ |
| 72 | + $con = "SM" . (self::CONTROLLERS[$matches] ?? $matches); |
| 73 | + } |
| 74 | + } |
| 75 | + if(isset($con)){//在prefix为B的模式下,只有有主控后缀的才被加入FDB |
| 76 | + $controller = $con; |
| 77 | + unset($con); |
| 78 | + }else{ |
| 79 | + continue; |
| 80 | + } |
| 81 | + } |
48 | 82 | $pn = trim(preg_replace('/\(.*?\)/', '', $pn));
|
49 | 83 | if($vendor == "sandisk"){
|
50 | 84 | if(StringUtil::startsWith($pn, "SNDK ") and strlen(substr($pn, 5)) > 5){
|
@@ -83,10 +117,11 @@ public static function merge(Fdb $fdb, string $data, string $filename) : void{
|
83 | 117 | for($i = 0; $i < 6; $i++){
|
84 | 118 | $id .= $rawId[$i];
|
85 | 119 | }
|
86 |
| - |
87 |
| - $fdb->getPartNumber($vendor, $pn, true) |
88 |
| - ->addFlashId($id) |
89 |
| - ->addController($controller); |
| 120 | + if($pn != "TSB"){ |
| 121 | + $fdb->getPartNumber($vendor, $pn, true) |
| 122 | + ->addFlashId($id) |
| 123 | + ->addController($controller); |
| 124 | + } |
90 | 125 | $fdb->getIddb()->getFlashId($id, true)->addController($controller);
|
91 | 126 | }
|
92 | 127 | }
|
|
0 commit comments