Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Lint, Build and Test

on:
push:
branches: [ "main" ]
pull_request:
types: [opened, synchronize, reopened, ready_for_review]

env:
CARGO_TERM_COLOR: always

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust (stable) with components
uses: dtolnay/rust-toolchain@stable
with:
components: clippy, rustfmt
- name: Cache cargo registry and build
uses: Swatinem/rust-cache@v2
- name: rustfmt check
run: cargo fmt --all -- --check
- name: clippy (deny warnings)
run: |
cargo clippy --all-targets --all-features -- -D warnings

build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust (stable) with components
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo registry and build
uses: Swatinem/rust-cache@v2
- name: Cargo Build
run: cargo build --verbose
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust (stable) with components
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo registry and build
uses: Swatinem/rust-cache@v2
- name: Run tests
run: cargo test --all-features --verbose
11 changes: 11 additions & 0 deletions .github/workflows/license.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: License Check

on: pull_request

jobs:
license:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: License Eye Header
uses: apache/[email protected]
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
target/
Cargo.lock
12 changes: 12 additions & 0 deletions .licenserc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
header:
license:
spdx-id: Apache-2.0
# No copyright owner until this has been clarified
# copyright-owner: OpenPRoT a Series of LF Projects, LLC
copyright-year: 2025
software-name: pldm-lib

paths:
- '**/*.rs'

comment: on-failure
14 changes: 13 additions & 1 deletion src/codec.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
// Licensed under the Apache-2.0 license
// Copyright 2025
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

use zerocopy::{FromBytes, Immutable, IntoBytes};

Expand Down
14 changes: 13 additions & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
// Licensed under the Apache-2.0 license
// Copyright 2025
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#[derive(Debug, Clone, PartialEq)]
pub enum PldmError {
Expand Down
14 changes: 13 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
// Licensed under the Apache-2.0 license
// Copyright 2025
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#![cfg_attr(target_arch = "riscv32", no_std)]

Expand Down
18 changes: 15 additions & 3 deletions src/message/control.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
// Licensed under the Apache-2.0 license
// Copyright 2025
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

use crate::error::PldmError;
use crate::protocol::base::{
InstanceId, PldmControlCmd, PldmMsgHeader, PldmMsgType, PldmSupportedType,
TransferOperationFlag, TransferRespFlag, PLDM_MSG_HEADER_LEN,
InstanceId, PLDM_MSG_HEADER_LEN, PldmControlCmd, PldmMsgHeader, PldmMsgType, PldmSupportedType,
TransferOperationFlag, TransferRespFlag,
};
use crate::protocol::version::{PldmVersion, ProtocolVersionStr, Ver32};
use zerocopy::{FromBytes, Immutable, IntoBytes};
Expand Down
16 changes: 14 additions & 2 deletions src/message/firmware_update/activate_fw.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
// Licensed under the Apache-2.0 license
// Copyright 2025
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

use crate::protocol::base::{
InstanceId, PldmMsgHeader, PldmMsgType, PldmSupportedType, PLDM_MSG_HEADER_LEN,
InstanceId, PLDM_MSG_HEADER_LEN, PldmMsgHeader, PldmMsgType, PldmSupportedType,
};
use crate::protocol::firmware_update::FwUpdateCmd;
use zerocopy::{FromBytes, Immutable, IntoBytes};
Expand Down
16 changes: 14 additions & 2 deletions src/message/firmware_update/apply_complete.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
// Licensed under the Apache-2.0 license
// Copyright 2025
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

use crate::error::PldmError;
use crate::protocol::base::{
InstanceId, PldmMsgHeader, PldmMsgType, PldmSupportedType, PLDM_MSG_HEADER_LEN,
InstanceId, PLDM_MSG_HEADER_LEN, PldmMsgHeader, PldmMsgType, PldmSupportedType,
};
use crate::protocol::firmware_update::{ComponentActivationMethods, FwUpdateCmd};
use zerocopy::{FromBytes, Immutable, IntoBytes};
Expand Down
20 changes: 16 additions & 4 deletions src/message/firmware_update/get_fw_params.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
// Licensed under the Apache-2.0 license
// Copyright 2025
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

use crate::codec::{PldmCodec, PldmCodecError};
use crate::protocol::base::{
InstanceId, PldmMsgHeader, PldmMsgType, PldmSupportedType, PLDM_MSG_HEADER_LEN,
InstanceId, PLDM_MSG_HEADER_LEN, PldmMsgHeader, PldmMsgType, PldmSupportedType,
};
use crate::protocol::firmware_update::{
ComponentParameterEntry, FirmwareDeviceCapability, FwUpdateCmd, PldmFirmwareString,
MAX_COMPONENT_COUNT, PLDM_FWUP_IMAGE_SET_VER_STR_MAX_LEN,
ComponentParameterEntry, FirmwareDeviceCapability, FwUpdateCmd, MAX_COMPONENT_COUNT,
PLDM_FWUP_IMAGE_SET_VER_STR_MAX_LEN, PldmFirmwareString,
};
use zerocopy::{FromBytes, Immutable, IntoBytes};

Expand Down
16 changes: 14 additions & 2 deletions src/message/firmware_update/get_status.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
// Licensed under the Apache-2.0 license
// Copyright 2025
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

use crate::error::PldmError;
use crate::protocol::base::{
InstanceId, PldmMsgHeader, PldmMsgType, PldmSupportedType, PLDM_MSG_HEADER_LEN,
InstanceId, PLDM_MSG_HEADER_LEN, PldmMsgHeader, PldmMsgType, PldmSupportedType,
};
use crate::protocol::firmware_update::{FirmwareDeviceState, FwUpdateCmd, UpdateOptionFlags};
use zerocopy::{FromBytes, Immutable, IntoBytes};
Expand Down
14 changes: 13 additions & 1 deletion src/message/firmware_update/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
// Licensed under the Apache-2.0 license
// Copyright 2025
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

pub mod activate_fw;
pub mod apply_complete;
Expand Down
20 changes: 16 additions & 4 deletions src/message/firmware_update/pass_component.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@
// Licensed under the Apache-2.0 license
// Copyright 2025
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

use crate::codec::{PldmCodec, PldmCodecError};
use crate::protocol::base::{
InstanceId, PldmMsgHeader, PldmMsgType, PldmSupportedType, TransferRespFlag,
PLDM_MSG_HEADER_LEN,
InstanceId, PLDM_MSG_HEADER_LEN, PldmMsgHeader, PldmMsgType, PldmSupportedType,
TransferRespFlag,
};
use crate::protocol::firmware_update::{
ComponentClassification, ComponentResponse, ComponentResponseCode, FwUpdateCmd,
PldmFirmwareString, PLDM_FWUP_IMAGE_SET_VER_STR_MAX_LEN,
PLDM_FWUP_IMAGE_SET_VER_STR_MAX_LEN, PldmFirmwareString,
};
use zerocopy::{FromBytes, Immutable, IntoBytes};

Expand Down
16 changes: 14 additions & 2 deletions src/message/firmware_update/query_devid.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
// Licensed under the Apache-2.0 license
// Copyright 2025
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

use crate::codec::{PldmCodec, PldmCodecError};
use crate::error::PldmError;
use crate::protocol::base::{
InstanceId, PldmMsgHeader, PldmMsgType, PldmSupportedType, PLDM_MSG_HEADER_LEN,
InstanceId, PLDM_MSG_HEADER_LEN, PldmMsgHeader, PldmMsgType, PldmSupportedType,
};
use crate::protocol::firmware_update::{Descriptor, FwUpdateCmd};
use zerocopy::{FromBytes, Immutable, IntoBytes};
Expand Down
16 changes: 14 additions & 2 deletions src/message/firmware_update/request_cancel.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
// Licensed under the Apache-2.0 license
// Copyright 2025
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

use crate::error::PldmError;
use crate::protocol::base::{
InstanceId, PldmMsgHeader, PldmMsgType, PldmSupportedType, PLDM_MSG_HEADER_LEN,
InstanceId, PLDM_MSG_HEADER_LEN, PldmMsgHeader, PldmMsgType, PldmSupportedType,
};
use crate::protocol::firmware_update::FwUpdateCmd;
use zerocopy::{FromBytes, Immutable, IntoBytes};
Expand Down
20 changes: 16 additions & 4 deletions src/message/firmware_update/request_fw_data.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
// Licensed under the Apache-2.0 license
// Copyright 2025
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

use crate::codec::{PldmCodec, PldmCodecError};
use crate::protocol::base::{
InstanceId, PldmMsgHeader, PldmMsgType, PldmSupportedType, PLDM_MSG_HEADER_LEN,
InstanceId, PLDM_MSG_HEADER_LEN, PldmMsgHeader, PldmMsgType, PldmSupportedType,
};
use crate::protocol::firmware_update::FwUpdateCmd;
use zerocopy::{FromBytes, Immutable, IntoBytes};
Expand Down Expand Up @@ -56,8 +68,8 @@ impl RequestFirmwareDataResponse<'_> {
pub fn new(
instance_id: InstanceId,
completion_code: u8,
data: &[u8],
) -> RequestFirmwareDataResponse {
data: &'_ [u8],
) -> RequestFirmwareDataResponse<'_> {
let fixed = RequestFirmwareDataResponseFixed {
hdr: PldmMsgHeader::new(
instance_id,
Expand Down
Loading