pci negator working, factorial not

This commit is contained in:
Ciro Santilli
2017-06-17 13:15:49 +01:00
parent f662a9105f
commit f48c636577
9 changed files with 242 additions and 242 deletions

8
rootfs_overlay/README.md Normal file
View File

@@ -0,0 +1,8 @@
# rootfs_overlay
This directory copied into the target filesystem.
We use it to for things like:
- customized configuration files
- userland module test scripts

View File

@@ -1,7 +1,7 @@
#!/bin/sh
insmod /character_device.ko
major="$(grep lkmc_character_device /proc/devices | cut -d ' ' -f 1)"
mknod /character_device.dev c $major 0
cat /character_device.dev
/mknoddev.sh character_device
cat /dev/lkmc_character_device
# => abcd
rm /dev/lkmc_character_device
rmmod character_device

4
rootfs_overlay/mknoddev.sh Executable file
View File

@@ -0,0 +1,4 @@
#!/bin/sh
dev="lkmc_$1"
major="$(grep "$dev" /proc/devices | cut -d ' ' -f 1)"
mknod "/dev/$dev" c "$major" 0

30
rootfs_overlay/pci.sh Executable file
View File

@@ -0,0 +1,30 @@
#!/bin/sh
set -ex
# Setup.
insmod /pci.ko
/mknoddev.sh pci
# Identifiction.
dd bs=4 status=none if=/dev/lkmc_pci count=1 skip=0 | od -An -t x1
# => 010000ed
# Negator.
dd bs=4 status=none if=/dev/lkmc_pci count=1 skip=1 | od -An -t x1
printf '\xF0\xF0\xF0\xF0' | dd bs=4 status=none of=/dev/lkmc_pci count=1 seek=1
dd bs=4 status=none if=/dev/lkmc_pci count=1 skip=1 | od -An -t x1
# => 0F0F0F0F
# Factorial calculator.
# factorial(0xC) = 0x1c8cfc00
printf '\x00\x00\x00\x0C' | dd bs=4 status=none of=/dev/lkmc_pci count=1 seek=2
printf '\x00\x00\x00\x00' | dd bs=4 status=none of=/dev/lkmc_pci count=1 seek=8
sleep 1
dd bs=4 status=none if=/dev/lkmc_pci count=1 skip=2 | od -An -t x1
dd bs=4 status=none if=/dev/lkmc_pci count=1 skip=8 | od -An -t x1
# => 1c8cfc00
# Teardown.
rm /dev/lkmc_pci
rmmod pci