-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
156 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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 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 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,82 @@ | ||
package main | ||
|
||
import ( | ||
"flag" | ||
"fmt" | ||
"os" | ||
) | ||
|
||
var ( | ||
flagDevObjName string | ||
flagDevicePriority int | ||
flagDevicePolicy int | ||
flagMsiSupported int | ||
flagMessageNumberLimit int | ||
flagCPU string | ||
flagRestart bool | ||
flagHelp bool | ||
|
||
CLIMode bool | ||
) | ||
|
||
func init() { | ||
flag.StringVar(&flagDevObjName, "devobj", "", "\\Device\\00000123") | ||
flag.StringVar(&flagCPU, "cpu", "", "e.g. 0,1,2,4") | ||
flag.IntVar(&flagDevicePriority, "priority", -1, "0=Undefined, 1=Low, 2=Normal, 3=High") | ||
flag.IntVar(&flagDevicePolicy, "policy", -1, "0=Default, 1=All Close Proc, 2=One Close Proc, 3=All Proc in Machine, 4=Specified Proc, 5=Spread Messages Across All Proc") | ||
flag.IntVar(&flagMsiSupported, "msisupported", -1, "0=Off, 1=On") | ||
flag.IntVar(&flagMessageNumberLimit, "msilimit", -1, "Message Signaled Interrupt Limit") | ||
flag.BoolVar(&flagRestart, "restart", false, "Restart target device") | ||
flag.BoolVar(&flagHelp, "help", false, "Print Defaults") | ||
|
||
flag.Parse() | ||
if flagHelp { | ||
fmt.Printf("Usage: %s [OPTIONS] argument ...\n", os.Args[0]) | ||
flag.PrintDefaults() | ||
os.Exit(0) | ||
} | ||
|
||
if flagDevObjName != "" || flagDevicePriority != -1 || flagDevicePolicy != -1 || flagMsiSupported != -1 || flagMessageNumberLimit != -1 || flagRestart { | ||
CLIMode = true | ||
} | ||
|
||
if flagDevObjName != "" { | ||
fmt.Println("DevObjName:", flagDevObjName) | ||
} | ||
if flagDevicePriority != -1 { | ||
var prio string | ||
switch flagDevicePriority { | ||
case 0: | ||
prio = "Undefined" | ||
case 1: | ||
prio = "Low" | ||
case 2: | ||
prio = "Normal" | ||
case 3: | ||
prio = "High" | ||
default: | ||
prio = fmt.Sprintf("%d", flagDevicePriority) | ||
} | ||
fmt.Println("DevicePriority:", prio) | ||
} | ||
if flagDevicePolicy != -1 { | ||
var policy string | ||
switch flagDevicePolicy { | ||
case IrqPolicyMachineDefault: // 0x00 | ||
policy = "Default" | ||
case IrqPolicyAllCloseProcessors: // 0x01 | ||
policy = "All Close Proc" | ||
case IrqPolicyOneCloseProcessor: // 0x02 | ||
policy = "One Close Proc" | ||
case IrqPolicyAllProcessorsInMachine: // 0x03 | ||
policy = "All Proc in Machine" | ||
case IrqPolicySpecifiedProcessors: // 0x04 | ||
policy = "Specified Proc" | ||
case IrqPolicySpreadMessagesAcrossAllProcessors: // 0x05 | ||
policy = "Spread Messages Across All Proc" | ||
default: | ||
policy = fmt.Sprintf("%d", flagDevicePolicy) | ||
} | ||
fmt.Println("DevicePolicy:", policy) | ||
} | ||
} |
This file contains 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 |
---|---|---|
@@ -1,10 +1,13 @@ | ||
module github.com/spddl/go-interruptPolicy | ||
|
||
go 1.16 | ||
go 1.19 | ||
|
||
require ( | ||
github.com/lxn/walk v0.0.0-20210112085537-c389da54e794 | ||
golang.org/x/sys v0.3.0 | ||
) | ||
|
||
require ( | ||
github.com/lxn/win v0.0.0-20210218163916-a377121e959e // indirect | ||
golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac | ||
gopkg.in/Knetic/govaluate.v3 v3.0.0 // indirect | ||
) |
This file contains 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 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