-
Notifications
You must be signed in to change notification settings - Fork 288
Add Windows Arm64 support #291
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
Conversation
To add Windows Arm64 support was added detection of features via Windows API function IsProcessorFeaturePresent. Added _M_ARM64 to detect CPU_FEATURES_AARCH64 macro on Windows. Added initial code for Windows Arm64 testing and provided test for Raspberry PI 4. We can't use "define_introspection_and_hwcaps.inl" as a common file for all operating systems due to msvc compiler error C2099: initializer is not a constant, so as a workaround for Windows I used separate "define_introspection.inl" See also: google#268, google#284, google#186
|
Need to change Lines 80 to 85 in 4590768
|
src/impl_aarch64_windows.c
Outdated
|
|
||
| // A note on Windows AArch64 implementation: | ||
| // ----------------------------------------------------------- | ||
| // Since getting of cpu info via EL1 system registers is not possible. |
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.
"Getting cpu info via EL1 system registers is not possible, so we delegate it to the Windows API (i.e., IsProcessorFeaturePresent and GetNativeSystemInfo)."
src/impl_aarch64_windows.c
Outdated
| // Hence, we delegate detection to info via Windows API methods such | ||
| // as `IsProcessorFeaturePresent` and `GetNativeSystemInfo`. The fields of | ||
| // `Aarch64Info` struct such as `implementer`, `variant` and `part` are not | ||
| // used, so they will always be 0. To get `revision` we use `wProcessorRevision` |
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.
"The implementer, variant and part fields of the Aarch64Info struct are not used, so they are set to 0."
Also you may want to document this behaviour in include/cpuinfo_aarch64.h.
test/cpuinfo_aarch64_test.cc
Outdated
| void SetWindowsNativeSystemInfoProcessorRevision(WORD wProcessorRevision) { | ||
| processor_revision_ = wProcessorRevision; | ||
| } | ||
| #endif // CPU_FEATURES_OS_WINDOWS |
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.
No need to close the #endif here to open it up again a few lines below.
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.
I was focused to leave space for the osx implementation 😄 (https://github.com/arkivm/cpu_features/blob/aarch64-darwin-support/test/cpuinfo_aarch64_test.cc#L50). Will update
include/cpuinfo_aarch64.h
Outdated
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| // A note on Windows AArch64 implementation: |
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.
Can you add a comment on the fields themselves so it's clear when we use the API?
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.
Do yo mean like this:
typedef struct {
Aarch64Features features;
int implementer; // We set 0 for Windows.
int variant; // We set 0 for Windows.
int part; // We set 0 for Windows.
int revision; // We use GetNativeSystemInfo to get processor revision for
// Windows.
} Aarch64Info;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.
Yes this. Can you update the PR?
|
LGTM @toor1245 . Thx a lot for the PR ! |
|
Actually the comments on the struct fields in include/cpuinfo_aarch64.h is missing, but apart from that I think it's good to go. |
Added comments to specify that implementer, part and variant we set 0 for Windows, since Win API does not provide a way to get information. For revision added comment that we use GetNativeSystemInfo
|
Should the table in the readme be updated with this? |
|
@MichalPetryka We would like to have a CI up and running before claiming we support Windows / Arm64. |
To add Windows Arm64 support was added detection of features via Windows API function IsProcessorFeaturePresent. Added _M_ARM64 to detect CPU_FEATURES_AARCH64 macro on Windows. Added initial code for Windows Arm64 testing and provided test for Raspberry PI 4. We can't use "define_introspection_and_hwcaps.inl" as a common file for all operating systems due to msvc compiler error C2099: initializer is not a constant, so as a workaround for Windows I used separate "define_introspection.inl"
Refs to review:
https://developer.arm.com/documentation/ddi0487/latest
https://sourceware.org/binutils/docs/as/AArch64-Extensions.html
https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-isprocessorfeaturepresent
Note: MicrosoftDocs/sdk-api#1409 created PR to update ms docs arm64 features and fix value for
PF_ARM_V83_LRCPC_INSTRUCTIONS_AVAILABLE