Delete functions that no product code calls, and fold "simple plus WithOptions" pairs into the one signature callers actually use. Rename the live macOS lifecycle functions that were labelled Legacy. The architecture tests now share one source loader and reject functions without a product caller and catalog messages nobody reads. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
59 lines
2.1 KiB
Go
59 lines
2.1 KiB
Go
package macosdriver
|
|
|
|
import (
|
|
"context"
|
|
"strings"
|
|
|
|
"github.com/Nwflower/reims-go/internal/host"
|
|
)
|
|
|
|
// DriverOptimizations returns only macOS/WHPX recommendations. The host adds
|
|
// its driver-independent facts once; startup uses the same runtime capabilities.
|
|
func DriverOptimizations(rep host.Report, runtimePatches []string) []host.Optimization {
|
|
hasPatch := func(substr string) bool {
|
|
for _, p := range runtimePatches {
|
|
if strings.Contains(strings.ToLower(p), strings.ToLower(substr)) {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|
|
var out []host.Optimization
|
|
switch {
|
|
case rep.WHPX != host.WHPXReady || !rep.WHPXCaps.KernelIrqchipAvailable:
|
|
out = append(out, host.Optimization{ID: "kernel_irqchip", Status: "unavailable", Supported: false})
|
|
case !rep.NeedsColdRebootWorkaround:
|
|
if rep.WHPXCaps.NestedVirtProperty || hasPatch("nested-virt-nonfatal") {
|
|
detail := ""
|
|
if !rep.WHPXCaps.NestedVirtProperty {
|
|
detail = "win11-nested-virt-nonfatal"
|
|
}
|
|
out = append(out, host.Optimization{ID: "kernel_irqchip", Status: "recommended", Supported: true, Recommended: true, Detail: detail})
|
|
} else {
|
|
out = append(out, host.Optimization{ID: "kernel_irqchip", Status: "unavailable", Supported: false, Detail: rep.WHPXCaps.NestedVirtProbeError})
|
|
}
|
|
default:
|
|
if hasPatch("startup-ipis") {
|
|
out = append(out, host.Optimization{ID: "kernel_irqchip", Status: "experimental", Supported: true, Detail: "win10-startup-ipis"})
|
|
} else {
|
|
out = append(out, host.Optimization{ID: "kernel_irqchip", Status: "unavailable", Supported: false, Detail: "win10-needs-patch"})
|
|
}
|
|
}
|
|
if rep.NeedsColdRebootWorkaround {
|
|
out = append(out, host.Optimization{ID: "cold_reboot", Status: "auto", Supported: true, Recommended: true})
|
|
} else {
|
|
out = append(out, host.Optimization{ID: "cold_reboot", Status: "unavailable", Supported: false})
|
|
}
|
|
return out
|
|
}
|
|
|
|
func (d *ReimsMacOSDriver) EvaluateOptimizations(_ context.Context, rep host.Report) []host.Optimization {
|
|
var patches []string
|
|
if _, active, err := d.startClient(); err == nil {
|
|
for _, p := range active.Manifest.Patches {
|
|
patches = append(patches, p.Name)
|
|
}
|
|
}
|
|
return DriverOptimizations(rep, patches)
|
|
}
|