-
Notifications
You must be signed in to change notification settings - Fork 31
[system] Add centralized status and POC for hello #240
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
esnguyen
wants to merge
1
commit into
google:main
Choose a base branch
from
esnguyen:esnguyen/status_phase1
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
|
|
||
| // Copyright 2022 Google LLC | ||
| // | ||
| // 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. | ||
|
|
||
| #ifndef LIBHOTH_INCLUDE_LIBHOTH_STATUS_H_ | ||
| #define LIBHOTH_INCLUDE_LIBHOTH_STATUS_H_ | ||
|
|
||
| #include <stdint.h> | ||
|
|
||
| // Represents success | ||
| #define HOTH_SUCCESS 0x0ULL | ||
|
|
||
| // Typedef for the error code | ||
| typedef uint64_t libhoth_error; | ||
|
|
||
| #define LIBHOTH_ERR_CONSTRUCT(ctx, space, code) \ | ||
| (((uint64_t)(ctx) << 32) | ((uint64_t)(space) << 16) | (uint64_t)(code)) | ||
|
|
||
| // HothContextId: High 32 bits of the error code. | ||
| // Uniquely identifies the libhoth operation or subsystem. | ||
| enum HothContextId { | ||
| HOTH_CTX_NONE = 0, | ||
|
|
||
| // Initialization / General | ||
| HOTH_CTX_INIT = 1, | ||
|
|
||
| // Transport layers | ||
| HOTH_CTX_USB = 10, | ||
| HOTH_CTX_SPI = 20, | ||
|
|
||
| // Command Execution | ||
| HOTH_CTX_CMD_EXEC = 30, | ||
| }; | ||
|
|
||
| // HothHostSpace: Top 16 bits of the low 32-bit Base Error Code. | ||
| // Indicates the domain of host-side errors. | ||
| enum HothHostSpace { | ||
| HOTH_HOST_SPACE_FW = 0x0000, // Firmware errors directly | ||
| HOTH_HOST_SPACE_POSIX = 0x0001, // errno values | ||
| HOTH_HOST_SPACE_LIBUSB = 0x0002, // libusb_error values | ||
| HOTH_HOST_SPACE_LIBHOTH = 0x0005, // libhoth internal errors | ||
| }; | ||
|
|
||
| #ifndef __packed | ||
| #define __packed __attribute__((packed)) | ||
| #endif | ||
|
|
||
| // Firmware Error | ||
| enum hoth_fw_error_status { | ||
| HOTH_RES_SUCCESS = 0, | ||
| HOTH_RES_INVALID_COMMAND = 1, | ||
| HOTH_RES_ERROR = 2, | ||
| HOTH_RES_INVALID_PARAM = 3, | ||
| HOTH_RES_ACCESS_DENIED = 4, | ||
| HOTH_RES_INVALID_RESPONSE = 5, | ||
| HOTH_RES_INVALID_VERSION = 6, | ||
| HOTH_RES_INVALID_CHECKSUM = 7, | ||
| HOTH_RES_IN_PROGRESS = 8, | ||
| HOTH_RES_UNAVAILABLE = 9, | ||
| HOTH_RES_TIMEOUT = 10, | ||
| HOTH_RES_OVERFLOW = 11, | ||
| HOTH_RES_INVALID_HEADER = 12, | ||
| HOTH_RES_REQUEST_TRUNCATED = 13, | ||
| HOTH_RES_RESPONSE_TOO_BIG = 14, | ||
| HOTH_RES_BUS_ERROR = 15, | ||
| HOTH_RES_BUSY = 16, | ||
| HOTH_RES_INVALID_HEADER_VERSION = 17, | ||
| HOTH_RES_INVALID_HEADER_CRC = 18, | ||
| HOTH_RES_INVALID_DATA_CRC = 19, | ||
| HOTH_RES_DUP_UNAVAILABLE = 20, | ||
| HOTH_RES_MAX = UINT16_MAX | ||
| } __packed; | ||
|
|
||
| #endif // LIBHOTH_INCLUDE_LIBHOTH_STATUS_H_ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Would it be a good idea to mask (at least)
spaceandcode? or maybe add astatic_assertto ensure that they are not more than 16 bits in size?Otherwise misuse of this macro can cause confusion (since the macro does not mention what type to use for each parameter). Eg:
Output:
0x667788bbbbddeeffThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
making this an inline function is also an option. That way the type of parameters is more clear, and the compiler can handle truncation