Skip to content

Commit ea5281b

Browse files
author
Uilebheist
committed
Adding a fallback to "uname -m" if nothing else works for CPU detection. Also
added a special case to recognise Virtio block devices on an emulated riscv running Linux FossilOrigin-Name: f02941290cd06abe55092235f6835fa777d18073b2cdabe908e5f99456dd7886
1 parent 641b97e commit ea5281b

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

tool/hardware-detect.tcl

+12-1
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ proc find_device {dev} {
144144
}
145145

146146
if {$name eq ""} { return }
147-
if {$name eq "0x1af4" || $name eq "0x554d4551"} {
147+
if {$name eq "0x1af4" || $name eq "0x554d4551" || $name eq "0x554d4551 (rotational)"} {
148148
# Get the latest Virtio specification with:
149149
# git clone git://git.kernel.org/pub/scm/virt/kvm/mst/virtio-text.git
150150
# sh makehtml.sh
@@ -160,6 +160,7 @@ proc find_device {dev} {
160160
# device type."
161161
#
162162
# 0x554d4551 is what FreeBSD reports for non-PCI virtio devices
163+
# 0x554d4551 is also what Linux reports for riscv PCI virtio devices
163164
puts "Virtio Block Device"
164165
exit 0
165166
}
@@ -208,6 +209,15 @@ proc parse_df {df} {
208209
}
209210
}
210211

212+
proc try_uname_m {} {
213+
# if nothing else works, at least have the processor type...
214+
catch {
215+
set cpu [exec uname -m]
216+
puts [string trim $cpu]
217+
exit 0
218+
}
219+
}
220+
211221
proc try_sysctl {key} {
212222
catch {
213223
set cpu [exec sysctl -n $key]
@@ -279,6 +289,7 @@ if {[llength $argv] == 0} {
279289
try_cpuinfo "/proc/cpuinfo"
280290
}
281291
}
292+
try_uname_m
282293
# if we find out other ways to do this, we add them here
283294
} elseif {[llength $argv] == 1} {
284295
set path [lindex $argv 0]

0 commit comments

Comments
 (0)