4
4
5
5
### Bindgen
6
6
The bindings are currently generated using
7
- [ bindgen] ( https://crates.io/crates/bindgen ) version 0.59.1 :
7
+ [ bindgen] ( https://crates.io/crates/bindgen ) version 0.64.0 :
8
8
``` bash
9
- cargo install bindgen --vers 0.59.1
9
+ cargo install bindgen-cli --vers 0.64.0
10
10
```
11
11
12
12
### Linux Kernel
@@ -17,48 +17,50 @@ repository on your machine:
17
17
git clone https://github.com/torvalds/linux.git
18
18
```
19
19
20
- ## Add a new architecture
20
+ ## Updating bindings / adding a new architecture
21
+
21
22
When adding a new architecture, the bindings must be generated for all existing
22
23
versions for consistency reasons.
23
24
24
- ### Example for arm64 and version 5.13
25
+ ### Example for arm64 and kernel version 6.2
25
26
26
27
For this example we assume that you have both linux and kvm-bindings
27
28
repositories in your root.
28
29
29
30
``` bash
30
- # Step 1: Create a new module using the name of the architecture in src/
31
- cd kvm-bindings
31
+ # Step 1 (if adding a new architecture) : Create a new module using the name of the architecture in src/
32
+ pushd kvm-bindings
32
33
mkdir src/arm64
33
- cd ~
34
+ popd
34
35
35
36
# linux is the repository that you cloned at the previous step.
36
- cd linux
37
+ pushd linux
37
38
# Step 2: Checkout the version you want to generate the bindings for.
38
- git checkout v5.13
39
+ git checkout v6.2
39
40
40
41
# Step 3: Generate the bindings.
41
42
# This will generate the headers for the targeted architecture and place them
42
- # in the user specified directory. In this case, we generate them in the
43
- # arm64_v5_13_headers directory.
44
- make headers_install ARCH=arm64 INSTALL_HDR_PATH=arm64_v5_13_headers
45
- cd arm64_v5_13_headers
46
- bindgen include/linux/kvm.h -o bindings_v5_13_0.rs \
47
- --with-derive-default \
48
- --with-derive-partialeq \
49
- -- -Iinclude
50
- cd ~
43
+ # in the user specified directory
44
+
45
+ export ARCH=arm64
46
+ make headers_install ARCH=$ARCH INSTALL_HDR_PATH=" $ARCH " _headers
47
+ pushd " $ARCH " _headers
48
+ bindgen include/linux/kvm.h -o bindings.rs \
49
+ --impl-debug --with-derive-default \
50
+ --with-derive-partialeq --impl-partialeq \
51
+ -- -Iinclude
52
+ popd
51
53
52
54
# Step 4: Copy the generated file to the arm64 module.
53
- cp linux/arm64_v5_13_headers/bindings_v5_13_0.rs
55
+ popd
56
+ cp linux/" $ARCH " _headers/bindings.rs src/arm64
57
+
54
58
```
55
59
56
- Steps 2, 3 and 4 must be repeated for each of the existing KVM versions. Don't
57
- forget to change the name of the bindings file using the appropriate version.
60
+ Steps 2, 3 and 4 must be repeated for all existing architectures.
58
61
59
- Now that we have the bindings generated, we can copy the module file from
60
- one of the existing modules as this is only changed when a new version is
61
- added.
62
+ Now that we have the bindings generated, for a new architecture we can copy the
63
+ module file from one of the existing modules.
62
64
63
65
``` bash
64
66
cp arm/mod.rs arm64/
0 commit comments