Skip to content
This repository was archived by the owner on Nov 6, 2024. It is now read-only.

Commit 891fcdf

Browse files
rbradfordandreeaflorescu
authored andcommitted
docs: Updating CONTRIBUTING.md
* Update for newer bindgen * Update to reflect that there are not multiple versions of bindings any more Signed-off-by: Rob Bradford <rbradford@rivosinc.com>
1 parent a688677 commit 891fcdf

File tree

1 file changed

+26
-24
lines changed

1 file changed

+26
-24
lines changed

CONTRIBUTING.md

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
### Bindgen
66
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:
88
```bash
9-
cargo install bindgen --vers 0.59.1
9+
cargo install bindgen-cli --vers 0.64.0
1010
```
1111

1212
### Linux Kernel
@@ -17,48 +17,50 @@ repository on your machine:
1717
git clone https://github.com/torvalds/linux.git
1818
```
1919

20-
## Add a new architecture
20+
## Updating bindings / adding a new architecture
21+
2122
When adding a new architecture, the bindings must be generated for all existing
2223
versions for consistency reasons.
2324

24-
### Example for arm64 and version 5.13
25+
### Example for arm64 and kernel version 6.2
2526

2627
For this example we assume that you have both linux and kvm-bindings
2728
repositories in your root.
2829

2930
```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
3233
mkdir src/arm64
33-
cd ~
34+
popd
3435

3536
# linux is the repository that you cloned at the previous step.
36-
cd linux
37+
pushd linux
3738
# Step 2: Checkout the version you want to generate the bindings for.
38-
git checkout v5.13
39+
git checkout v6.2
3940

4041
# Step 3: Generate the bindings.
4142
# 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
5153

5254
# 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+
5458
```
5559

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.
5861

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.
6264

6365
```bash
6466
cp arm/mod.rs arm64/

0 commit comments

Comments
 (0)