跳到主要内容

Claude Cage · 面向 Claude 的隔离开发环境,支持桌面工作台、多账号、远程部署与移动端连接。上游 Lee-xeo/Claude-Cage 完整源码镜像,非灵栈原创;主许可 MIT,第三方组件遵循各自许可。来源:https://github.com/Lee-xeo/Claude-Cage 。手动同步,不附带 Release 安装包。

浏览文件

cpu_windows_amd64.go

50 行 · 1.4 KB历史下载
1// SPDX-FileCopyrightText: Copyright The Lima Authors
2// SPDX-License-Identifier: Apache-2.0
3
4package qemu
5
6import (
7 "unsafe"
8
9 "github.com/sirupsen/logrus"
10 "golang.org/x/sys/windows"
11)
12
13func whpxQEMU64() string {
14 // Query the processor features available to Windows Hypervisor Platform
15 // guests. A nested hypervisor may expose a subset of the host's CPUID.
16 query := windows.NewLazySystemDLL("WinHvPlatform.dll").NewProc("WHvGetCapability")
17 if err := query.Find(); err != nil {
18 logrus.WithError(err).Warn("Cannot query WHPX processor features; using qemu64 defaults")
19 return "qemu64"
20 }
21 const processorFeatures = 0x1001 // WHvCapabilityCodeProcessorFeatures
22 var bits uint64
23 var written uint32
24 status, _, _ := query.Call(processorFeatures, uintptr(unsafe.Pointer(&bits)),
25 unsafe.Sizeof(bits), uintptr(unsafe.Pointer(&written)))
26 if int32(status) < 0 || uintptr(written) != unsafe.Sizeof(bits) {
27 logrus.Warnf("Cannot query WHPX processor features (HRESULT %#x, %d bytes); using qemu64 defaults", uint32(status), written)
28 return "qemu64"
29 }
30 return whpxQEMU64Model(bits)
31}
32
33// Bit positions are from the Windows SDK's WHV_X64_PROCESSOR_FEATURES.
34func whpxQEMU64Model(bits uint64) string {
35 model := "qemu64"
36 for _, feature := range []struct {
37 mask uint64
38 flag string
39 }{
40 {1 << 2, "+ssse3"},
41 {1 << 3, "+sse4.1"},
42 {1 << 4, "+sse4.2"},
43 {1 << 7, "+popcnt"},
44 } {
45 if bits&feature.mask != 0 {
46 model += "," + feature.flag
47 }
48 }
49 return model
50}