From b033a787b88a9ae0ebe6e8291b17afe2b2235a07 Mon Sep 17 00:00:00 2001 From: HikariKnight <2557889+HikariKnight@users.noreply.github.com> Date: Fri, 27 Oct 2023 19:42:17 +0200 Subject: [PATCH] add vbios extration page --- internal/pages/02_select_gpu.go | 3 +- internal/pages/03_vbios_extract.go | 50 +++++++++++++++++++ ...select_usbctrl.go => 04_select_usbctrl.go} | 0 pkg/menu/ok.go | 16 ++++++ 4 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 internal/pages/03_vbios_extract.go rename internal/pages/{03_select_usbctrl.go => 04_select_usbctrl.go} (100%) create mode 100644 pkg/menu/ok.go diff --git a/internal/pages/02_select_gpu.go b/internal/pages/02_select_gpu.go index 6742e54..4a1b8ed 100644 --- a/internal/pages/02_select_gpu.go +++ b/internal/pages/02_select_gpu.go @@ -86,6 +86,7 @@ func viewGPU(id string, ext ...int) { case "y": // Go to the select a usb controller - selectUSB() + //selectUSB() + genVBIOS_dumper(id) } } diff --git a/internal/pages/03_vbios_extract.go b/internal/pages/03_vbios_extract.go new file mode 100644 index 0000000..2551dde --- /dev/null +++ b/internal/pages/03_vbios_extract.go @@ -0,0 +1,50 @@ +package pages + +import ( + "fmt" + "os" + "path/filepath" + "strings" + + "github.com/HikariKnight/quickpassthrough/pkg/command" + "github.com/HikariKnight/quickpassthrough/pkg/menu" +) + +func genVBIOS_dumper(id string) { + // Clear the scren + command.Clear() + + // Get the program directory + exe, _ := os.Executable() + scriptdir := filepath.Dir(exe) + + // If we are using go run use the working directory instead + if strings.Contains(scriptdir, "/tmp/go-build") { + scriptdir, _ = os.Getwd() + } + + // Get the vbios path + //vbios_path := lsiommu.GetIOMMU("-g", "-i", id, "--rom")[0] + + // Tell users about the VBIOS dumper script + fmt.Print( + "For some GPUs, you will need to dump the VBIOS and pass the\n", + "rom to the VM along with the card in order to get a functional passthrough.\n", + "In many cases you can find your vbios at https://www.techpowerup.com/vgabios/\n", + "\n", + "You can also attempt to dump your own vbios using the script in\n", + fmt.Sprintf("%s/utils/dump_vbios.sh\n", scriptdir), + "\n", + ) + + // Get the OK press + choice := menu.Ok("Make sure you run the script with the display-manager stopped using ssh or tty!") + + // If OK is pressed + if choice == "next" { + selectUSB() + } else { + fmt.Println("") + os.Exit(0) + } +} diff --git a/internal/pages/03_select_usbctrl.go b/internal/pages/04_select_usbctrl.go similarity index 100% rename from internal/pages/03_select_usbctrl.go rename to internal/pages/04_select_usbctrl.go diff --git a/pkg/menu/ok.go b/pkg/menu/ok.go new file mode 100644 index 0000000..fd750ac --- /dev/null +++ b/pkg/menu/ok.go @@ -0,0 +1,16 @@ +package menu + +import "github.com/nexidian/gocliselect" + +// Make a YesNo menu +func Ok(msg string) string { + // Make the menu + menu := gocliselect.NewMenu(msg) + menu.AddItem("OK", "next") + + // Display the menu + choice := menu.Display() + + // Return the value selected + return choice +}