github.com/system-transparency/u-root@v6.0.1-0.20190919065413-ed07a650de4c+incompatible/integration/testcmd/io/uinit/io.go (about) 1 // Copyright 2018 the u-root Authors. All rights reserved 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package main 6 7 import ( 8 "fmt" 9 "log" 10 "os" 11 "os/exec" 12 13 "golang.org/x/sys/unix" 14 ) 15 16 // Prints the string "UART TEST\r\n" using IO. 17 func main() { 18 // Writing to the serial port is atomic in QEMU, so no polling or 19 // sleeping is needed between characters. 20 for _, b := range []byte("UART TEST\r\n") { 21 cmd := exec.Command("io", "outb", "0x3f8", fmt.Sprintf("%d", b)) 22 cmd.Stdout = os.Stdout 23 cmd.Stderr = os.Stderr 24 err := cmd.Run() 25 if err != nil { 26 log.Fatal(err) 27 } 28 } 29 30 unix.Reboot(unix.LINUX_REBOOT_CMD_POWER_OFF) 31 }