Skip to content

Commit 8c8d06f

Browse files
authored
Merge pull request #3 from yenqileo/release/24.3.1-1
Release/24.3.1-1
2 parents e986f6d + 40bb611 commit 8c8d06f

File tree

2,190 files changed

+185555
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,190 files changed

+185555
-0
lines changed

.gitignore

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
######################
2+
# Project Specific
3+
######################
4+
*_.java
5+
*/build/**
6+
*/**/build/**
7+
*/out/**
8+
*/**/out/**
9+
*/log/**
10+
*/**/log/**
11+
*/src/main/generated/**
12+
*/**/.bdsignore.all
13+
*/**/verifier_core.sqlite
14+
15+
######################
16+
# Node
17+
######################
18+
/node/
19+
node_tmp/
20+
node_modules/
21+
npm-debug.log.*
22+
/.awcache/*
23+
/.cache-loader/*
24+
25+
######################
26+
# SASS
27+
######################
28+
.sass-cache/
29+
30+
######################
31+
# Eclipse
32+
######################
33+
*.pydevproject
34+
.project
35+
.metadata
36+
tmp/
37+
tmp/**/*
38+
*.tmp
39+
*.bak
40+
*.swp
41+
*~.nib
42+
local.properties
43+
.classpath
44+
.settings/
45+
.loadpath
46+
.factorypath
47+
/src/main/resources/rebel.xml
48+
49+
# External tool builders
50+
.externalToolBuilders/**
51+
52+
# Locally stored "Eclipse launch configurations"
53+
*.launch
54+
55+
# CDT-specific
56+
.cproject
57+
58+
# PDT-specific
59+
.buildpath
60+
61+
######################
62+
# Intellij
63+
######################
64+
.idea/
65+
*.iml
66+
*.iws
67+
*.ipr
68+
*.ids
69+
*.orig
70+
classes/
71+
out/
72+
73+
######################
74+
# Visual Studio Code
75+
######################
76+
.vscode/
77+
78+
######################
79+
# Maven
80+
######################
81+
/log/
82+
*/target/
83+
84+
######################
85+
# Gradle
86+
######################
87+
.gradle/
88+
/build/
89+
90+
######################
91+
# Package Files
92+
######################
93+
*.war
94+
*.ear
95+
*.db
96+
97+
######################
98+
# Windows
99+
######################
100+
# Windows image file caches
101+
Thumbs.db
102+
103+
# Folder config file
104+
Desktop.ini
105+
106+
######################
107+
# Mac OSX
108+
######################
109+
.DS_Store
110+
.svn
111+
112+
# Thumbnails
113+
._*
114+
115+
# Files that might appear on external disk
116+
.Spotlight-V100
117+
.Trashes
118+
119+
######################
120+
# Directories
121+
######################
122+
/bin/
123+
/deploy/
124+
125+
######################
126+
# Logs
127+
######################
128+
*.log*
129+
130+
######################
131+
# Others
132+
######################
133+
*.class
134+
*.*~
135+
*~
136+
.merge_file*
137+
138+
######################
139+
# Gradle Wrapper
140+
######################
141+
!gradle/wrapper/gradle-wrapper.jar
142+
143+
######################
144+
# Maven Wrapper
145+
######################
146+
!.mvn/wrapper/maven-wrapper.jar
147+
148+
######################
149+
# ESLint
150+
######################
151+
.eslintcache
152+
153+
######################
154+
# Docker Security Providers
155+
######################
156+
!*.jar
157+
!*.deb

CommandCore/build.gradle

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
/*
2+
* This project is licensed as below.
3+
*
4+
* **************************************************************************
5+
*
6+
* Copyright 2020-2024 Intel Corporation. All Rights Reserved.
7+
*
8+
* Redistribution and use in source and binary forms, with or without
9+
* modification, are permitted provided that the following conditions are met:
10+
*
11+
* 1. Redistributions of source code must retain the above copyright notice,
12+
* this list of conditions and the following disclaimer.
13+
*
14+
* 2. Redistributions in binary form must reproduce the above copyright
15+
* notice, this list of conditions and the following disclaimer in the
16+
* documentation and/or other materials provided with the distribution.
17+
*
18+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
21+
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER
22+
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23+
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24+
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25+
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26+
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27+
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28+
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29+
*
30+
* **************************************************************************
31+
*
32+
*/
33+
34+
buildscript {
35+
repositories {
36+
mavenLocal()
37+
mavenCentral()
38+
gradlePluginPortal()
39+
}
40+
}
41+
42+
plugins {
43+
alias(libs.plugins.lombok)
44+
alias(libs.plugins.gradle.versions)
45+
alias(libs.plugins.modernizer)
46+
id 'maven-publish'
47+
id 'java-library'
48+
id 'idea'
49+
}
50+
51+
apply from: rootProject.file('gradle/common.gradle')
52+
53+
def buildVersion = ext.getBuildVersion()
54+
55+
jar {
56+
archiveBaseName.set('CommandCore')
57+
archiveVersion.set(buildVersion)
58+
manifest {
59+
attributes(
60+
'Sealed': 'true',
61+
'Implementation-Title': 'Intel Command Core library',
62+
'Implementation-Version': buildVersion
63+
)
64+
}
65+
}
66+
67+
sourceCompatibility = JavaVersion.VERSION_17
68+
targetCompatibility = JavaVersion.VERSION_17
69+
70+
group = 'com.intel.bkp.command'
71+
version = buildVersion
72+
73+
74+
test {
75+
useJUnitPlatform()
76+
}
77+
78+
repositories {
79+
mavenLocal()
80+
mavenCentral()
81+
}
82+
83+
dependencies {
84+
implementation project(":Utils")
85+
implementation project(":CryptoCore")
86+
implementation project(":ServiceCore")
87+
88+
implementation libs.slf4j.api
89+
90+
testImplementation project(':TestLibrary')
91+
testImplementation platform(libs.junit.bom)
92+
testImplementation libs.junit.jupiter
93+
testImplementation libs.bundles.mockito
94+
}
95+
96+
publishing {
97+
publications {
98+
mavenJava(MavenPublication) {
99+
from components.java
100+
}
101+
}
102+
}
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
/*
2+
* This project is licensed as below.
3+
*
4+
* **************************************************************************
5+
*
6+
* Copyright 2020-2024 Intel Corporation. All Rights Reserved.
7+
*
8+
* Redistribution and use in source and binary forms, with or without
9+
* modification, are permitted provided that the following conditions are met:
10+
*
11+
* 1. Redistributions of source code must retain the above copyright notice,
12+
* this list of conditions and the following disclaimer.
13+
*
14+
* 2. Redistributions in binary form must reproduce the above copyright
15+
* notice, this list of conditions and the following disclaimer in the
16+
* documentation and/or other materials provided with the distribution.
17+
*
18+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
21+
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER
22+
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23+
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24+
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25+
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26+
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27+
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28+
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29+
*
30+
* **************************************************************************
31+
*/
32+
33+
package com.intel.bkp.command;
34+
35+
import com.intel.bkp.command.header.CommandHeader;
36+
import com.intel.bkp.command.header.CommandHeaderManager;
37+
import com.intel.bkp.command.model.CommandIdentifier;
38+
import com.intel.bkp.command.model.CommandLayer;
39+
import com.intel.bkp.utils.ByteBufferSafe;
40+
import com.intel.bkp.utils.interfaces.BytesConvertible;
41+
import lombok.extern.slf4j.Slf4j;
42+
43+
import java.nio.ByteBuffer;
44+
45+
import static com.intel.bkp.utils.HexConverter.toHex;
46+
47+
@Slf4j
48+
public class MailboxCommandLayer implements CommandLayer {
49+
50+
private static final int COMMAND_HEADER_LEN = 4;
51+
private static final int CLIENT_IDENTIFIER = 1;
52+
private static final int WORD_SIZE = Integer.BYTES;
53+
54+
@Override
55+
public byte[] create(BytesConvertible data, CommandIdentifier command) {
56+
final int commandCode = command.getCommandCode();
57+
final byte[] dataBytes = data.array();
58+
final int argumentsLen = getArgumentsLen(dataBytes);
59+
final byte[] header = buildCommandHeader(commandCode, argumentsLen, 0, CLIENT_IDENTIFIER);
60+
final byte[] rawData = withAppendedHeaderAndPadding(argumentsLen, dataBytes, header);
61+
log.trace("Sending raw data for command {}: {}", command.name(), toHex(rawData));
62+
return rawData;
63+
}
64+
65+
@Override
66+
public byte[] retrieve(byte[] data, CommandIdentifier command) {
67+
log.trace("Received raw data for response {}: {}", command.name(), toHex(data));
68+
CommandHeaderManager.validateCommandHeaderCode(data, command.name());
69+
return ByteBufferSafe.wrap(data).skip(COMMAND_HEADER_LEN).getRemaining();
70+
}
71+
72+
protected int getArgumentsLen(byte[] dataBytes) {
73+
return (int) Math.ceil((double) dataBytes.length / WORD_SIZE);
74+
}
75+
76+
protected byte[] buildCommandHeader(int commandCode, int argumentsLength, int id, int client) {
77+
return CommandHeaderManager.buildForFw(new CommandHeader(commandCode, argumentsLength, id, client));
78+
}
79+
80+
protected byte[] withAppendedHeaderAndPadding(int argumentsLen, byte[] data, byte[] header) {
81+
return ByteBuffer.allocate(header.length + argumentsLen * WORD_SIZE)
82+
.put(header)
83+
.put(data)
84+
.array();
85+
}
86+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* This project is licensed as below.
3+
*
4+
* **************************************************************************
5+
*
6+
* Copyright 2020-2024 Intel Corporation. All Rights Reserved.
7+
*
8+
* Redistribution and use in source and binary forms, with or without
9+
* modification, are permitted provided that the following conditions are met:
10+
*
11+
* 1. Redistributions of source code must retain the above copyright notice,
12+
* this list of conditions and the following disclaimer.
13+
*
14+
* 2. Redistributions in binary form must reproduce the above copyright
15+
* notice, this list of conditions and the following disclaimer in the
16+
* documentation and/or other materials provided with the distribution.
17+
*
18+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
21+
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER
22+
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23+
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24+
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25+
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26+
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27+
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28+
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29+
*
30+
* **************************************************************************
31+
*/
32+
33+
package com.intel.bkp.command.exception;
34+
35+
public class CommandHeaderValidationException extends Exception {
36+
public CommandHeaderValidationException(String internalMessage) {
37+
super(internalMessage);
38+
}
39+
}

0 commit comments

Comments
 (0)