Add PLIC tests to preinit

This commit is contained in:
Rodrigo Arias 2024-09-05 14:52:47 +02:00
parent bbf85438b3
commit ee9ecac8ed

View File

@ -173,16 +173,88 @@
set -x set -x
ip addr (
cat /proc/interrupts echo "--- Testing threshold register init value"
# Ensure that reading a few times the threshold value
# always gives the same initial value 0
t1=$(devmem 0x40a00000) # Read context 1 threshold value
t2=$(devmem 0x40a00000) # Read context 1 threshold value
t3=$(devmem 0x40a00000) # Read context 1 threshold value
found="$t1 $t2 $t3"
expected="0x00000000 0x00000000 0x00000000"
if [ "$found" = "$expected" ]; then
echo "--- Threshold init value: OK"
else
echo "found =$found"
echo "expected=$expected"
echo "--- Threshold init value: FAIL"
fi
)
modprobe xxvnet_carv (
echo "--- Testing threshold register stability"
# Write the priority register of an interrupt and ensure
# the threshold register didn't change
devmem 0x40a00000 32 0 # Write context 1 threshold value 0
t1=$(devmem 0x40a00000) # Read context 1 threshold value
devmem 0x40800010 32 5 # Write source 4 priority value 5
t2=$(devmem 0x40a00000) # Read context 1 threshold value
found="$t1 $t2"
expected="0x00000000 0x00000000"
if [ "$found" = "$expected" ]; then
echo "--- Threshold stability: OK"
else
echo "found =$found"
echo "expected=$expected"
echo "--- Threshold stability: FAIL"
fi
)
plictool -c2 (
plictool -c2 echo "--- Testing claim register"
plictool -c2
ip addr # Use aux timer on source 4 for this one
pending=$(devmem 0x40801000) # Dump pending bits of sources 0-31
# Ensure the aux timer is pending
if [ "$pending" = "0x00000018" ]; then
# Make sure the priority is higher than the threshold
devmem 0x40800010 32 0x10 # Write source 4 priority value 16
devmem 0x40802080 32 0x10 # Enable source 4 in context 1
# Writing the threshold has to be last, otherwise it will change
devmem 0x40a00000 32 0 # Write context 1 threshold value 0
c1=$(devmem 0x40a01004) # Claim context 1
c2=$(devmem 0x40a01004) # Claim context 1
c3=$(devmem 0x40a01004) # Claim context 1
found="$c1 $c2 $c3"
expected="0x00000004 0x00000004 0x00000004"
if [ "$found" = "$expected" ]; then
echo "--- Testing claim register: OK"
else
echo "found =$found"
echo "expected=$expected"
echo "--- Testing claim register: FAIL"
fi
else
echo "unknown pending bits: $pending"
echo "--- Testing claim register: SKIP"
fi
)
echo "all done, waiting forever..."
while [ 1 ]; do sleep 9999; done
# ip addr
# cat /proc/interrupts
# modprobe xxvnet_carv
# plictool -c2
# plictool -c2
# plictool -c2
# ip addr
exec /init exec /init
''; '';