| ... | @@ -188,6 +188,77 @@ test "cpuinfo: PowerPC" { | ... | @@ -188,6 +188,77 @@ test "cpuinfo: PowerPC" { |
| 188 | ); | 188 | ); |
| 189 | } | 189 | } |
| 190 | | 190 | |
| | 191 | const S390xCpuinfoImpl = struct { |
| | 192 | model: ?*const Target.Cpu.Model = null, |
| | 193 | |
| | 194 | const cpu_names = .{ |
| | 195 | // z900: 2064, 2066 |
| | 196 | // z990: 2084, 2086 |
| | 197 | // z9: 2094, 2096 |
| | 198 | |
| | 199 | .{ "2097", &Target.s390x.cpu.z10 }, |
| | 200 | .{ "2098", &Target.s390x.cpu.z10 }, |
| | 201 | .{ "2817", &Target.s390x.cpu.z196 }, |
| | 202 | .{ "2818", &Target.s390x.cpu.z196 }, |
| | 203 | .{ "2827", &Target.s390x.cpu.zEC12 }, |
| | 204 | .{ "2828", &Target.s390x.cpu.zEC12 }, |
| | 205 | .{ "2964", &Target.s390x.cpu.z13 }, |
| | 206 | .{ "2965", &Target.s390x.cpu.z13 }, |
| | 207 | .{ "3906", &Target.s390x.cpu.z14 }, |
| | 208 | .{ "3907", &Target.s390x.cpu.z14 }, |
| | 209 | .{ "8561", &Target.s390x.cpu.z15 }, |
| | 210 | .{ "8562", &Target.s390x.cpu.z15 }, |
| | 211 | .{ "3931", &Target.s390x.cpu.z16 }, |
| | 212 | .{ "3932", &Target.s390x.cpu.z16 }, |
| | 213 | .{ "9175", &Target.s390x.cpu.z17 }, |
| | 214 | .{ "9176", &Target.s390x.cpu.z17 }, |
| | 215 | }; |
| | 216 | |
| | 217 | fn line_hook(self: *S390xCpuinfoImpl, key: []const u8, value: []const u8) !bool { |
| | 218 | if (mem.eql(u8, key, "machine")) { |
| | 219 | inline for (cpu_names) |pair| { |
| | 220 | if (mem.eql(u8, value, pair[0])) { |
| | 221 | self.model = pair[1]; |
| | 222 | break; |
| | 223 | } |
| | 224 | } |
| | 225 | |
| | 226 | return false; |
| | 227 | } |
| | 228 | |
| | 229 | return true; |
| | 230 | } |
| | 231 | |
| | 232 | fn finalize(self: *const S390xCpuinfoImpl, arch: Target.Cpu.Arch) ?Target.Cpu { |
| | 233 | const model = self.model orelse return null; |
| | 234 | return Target.Cpu{ |
| | 235 | .arch = arch, |
| | 236 | .model = model, |
| | 237 | .features = model.features, |
| | 238 | }; |
| | 239 | } |
| | 240 | }; |
| | 241 | |
| | 242 | const S390xCpuinfoParser = CpuinfoParser(S390xCpuinfoImpl); |
| | 243 | |
| | 244 | test "cpuinfo: S390x" { |
| | 245 | try testParser(S390xCpuinfoParser, .s390x, &Target.s390x.cpu.z15, |
| | 246 | \\physical id : 5 |
| | 247 | \\core id : 5 |
| | 248 | \\book id : 5 |
| | 249 | \\drawer id : 5 |
| | 250 | \\dedicated : 0 |
| | 251 | \\address : 5 |
| | 252 | \\siblings : 1 |
| | 253 | \\cpu cores : 1 |
| | 254 | \\version : FF |
| | 255 | \\identification : 09DD98 |
| | 256 | \\machine : 8561 |
| | 257 | \\cpu MHz dynamic : 5200 |
| | 258 | \\cpu MHz static : 5200 |
| | 259 | ); |
| | 260 | } |
| | 261 | |
| 191 | const ArmCpuinfoImpl = struct { | 262 | const ArmCpuinfoImpl = struct { |
| 192 | const num_cores = 4; | 263 | const num_cores = 4; |
| 193 | | 264 | |
| ... | @@ -414,6 +485,9 @@ pub fn detectNativeCpuAndFeatures(io: Io) ?Target.Cpu { | ... | @@ -414,6 +485,9 @@ pub fn detectNativeCpuAndFeatures(io: Io) ?Target.Cpu { |
| 414 | .riscv64, .riscv32 => { | 485 | .riscv64, .riscv32 => { |
| 415 | return RiscvCpuinfoParser.parse(current_arch, &file_reader.interface) catch null; | 486 | return RiscvCpuinfoParser.parse(current_arch, &file_reader.interface) catch null; |
| 416 | }, | 487 | }, |
| | 488 | .s390x => { |
| | 489 | return S390xCpuinfoParser.parse(current_arch, &file_reader.interface) catch null; |
| | 490 | }, |
| 417 | else => {}, | 491 | else => {}, |
| 418 | } | 492 | } |
| 419 | | 493 | |