-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathbuild_install_driver
More file actions
executable file
·166 lines (155 loc) · 5.8 KB
/
Copy pathbuild_install_driver
File metadata and controls
executable file
·166 lines (155 loc) · 5.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
#!/bin/bash -e
function check_help {
case "$1" in
"--help" | "-h")
echo "************************************************************"
echo "*** HELP ***************************************************"
echo "************************************************************"
echo "*** Run the script without parameter to build and ***"
echo "*** install the driver. The build script will creates a ***"
echo "*** build directory (./tmp_build). ***"
echo "*** To specify a build directory just pass a directory ***"
echo "*** path. ***"
echo "*** ***"
echo "*** e.g.: ***"
echo "*** mkdir ./my_build_path ***"
echo "*** ./build_install_driver ./my_build_path ***"
echo "************************************************************"
exit 0
;;
*)
;;
esac
}
builddir="./tmp_build/"
if (( "$#" >= "1" )); then
check_help $1
if [ -d "${1}" ]; then
builddir=$(realpath "${1}")
else
echo "Error - Given parameter \"$1\" is not a folder or does not exist!"
exit 1
fi
else
mkdir -p "${builddir}"
fi
# check if directories contain white spaces...
invalid_path=$(pwd | { grep " " || true; } )
if [ "${invalid_path}" != "" ]; then
echo "Error - path contains spaces (\"${PWD}\")! Please use path without."
exit 1
fi
invalid_path=$(echo ${builddir} | { grep " " || true; } )
if [ "${invalid_path}" != "" ]; then
echo "Error - path contains spaces (\"${builddir}\")! Please use path without."
exit 1
fi
if [ -d "${builddir}/libcifx" ] || [ -d "${builddir}/uio_netx" ]; then
echo -e "\n********************************************************************************"
echo "NOTE: The build folder (\"${builddir}\") is not empty! Force overwrting (yes=y)?"
echo " Or pass a new build folder (./build_install_driver [my_build_folder]."
echo "********************************************************************************"
read delete_files
if [ "${delete_files}" = "y" ]; then
echo "...deleting build folder!"
rm -rf "${builddir}/libcifx"
rm -rf "${builddir}/uio_netx"
else
echo "...canceled build process!"
exit 1
fi
fi
driver_src=$(dirname $(realpath $0))
scripts_dir="${driver_src}/scripts"
cur_path=$PWD
kernelversion=""
ret=0
echo -e "\n************************************************************"
echo "**** Please type 'y'/'n' to enable/disable DMA support ***"
echo "************************************************************"
export CIFX_DMA_SUPPORT="0"
export USE_VFIO_DRIVER="0"
read dma_enable
if [ "${dma_enable}" = "y" ]; then
CIFX_DMA_SUPPORT="1"
echo -e "\n************************************************************"
echo "**** Please type 'y' if IOMMU support is enabled and not set to 'passthrough' or the driver is running on a system with \"EFI Secure Boot\" enabled."
echo "************************************************************"
echo "NOTE: This will disable support for PCI devices of the uio_netx driver. Instead vfio-pci will be used."
read iommu_enable
if [ "${iommu_enable}" = "y" ]; then
USE_VFIO_DRIVER="1"
fi
fi
install_step="uio_netx"
while [ "$install_step" != "stop" ]
do
case $install_step in
error)
echo -e "\n************************************************************"
echo "**** An error occured during the installation ***"
echo "************************************************************"
echo "Please check the error message in the previous steps."
echo "When the problem is fixed restart the installation."
install_step="stop"
ret=1
;;
uio_netx)
install_step="firmware"
mkdir -p "${builddir}/uio_netx"
echo -e "\n************************************************************"
echo "**** Start building kernel module uio_netx ***"
echo "************************************************************"
if ! "${scripts_dir}/"install_uio_netx build "${builddir}/uio_netx"; then # build module
echo "Error building kernel module!"
install_step="error"
fi
if ! "${scripts_dir}/"install_uio_netx install "${builddir}/uio_netx"; then # install module
echo "Error installing kernel module!"
install_step="error"
fi
;;
firmware)
install_step="libcifx"
echo -e "\n************************************************************"
echo "**** Installing kernel module and firmware ***"
echo "************************************************************"
install_step="libcifx"
if ! "${scripts_dir}/"install_firmware install ; then # install firmware
echo "Error installing firmware!"
install_step="error"
fi
if ! "${scripts_dir}/"install_uio_netx update ; then # load driver
echo "Error updating module dependencies!"
install_step="error"
fi
if ! "${scripts_dir}/"install_uio_netx unload ; then
echo "Error unloading driver!"
install_step="error"
fi
if [ "${USE_VFIO_DRIVER}" == "0" ]; then
# No vfio driver means uio_netx is compiled with PCI support - make sure no PCI
# device is still occupied by the vfio-pci driver before loading uio_netx.
${scripts_dir}/register_vfio_device -d
fi
if ! "${scripts_dir}/"install_uio_netx load; then
echo "Error loading driver!"
install_step="error"
fi
if [ "${USE_VFIO_DRIVER}" == "1" ]; then
# vfio driver is enabled - so register all Hilscher PCI ids to the vfio-pci driver
${scripts_dir}/register_vfio_device
fi
;;
libcifx)
echo -e "\n************************************************************"
echo "**** Building and installing user space library libcifx ***"
echo "************************************************************"
mkdir -p "${builddir}/libcifx"
"${scripts_dir}/"install_libcifx "${builddir}/libcifx"
install_step="stop"
;;
esac
done
cd ..
exit $ret