github.com/u-root/u-root@v7.0.1-0.20200915234505-ad7babab0a8e+incompatible/pkg/memio/ports_linux.go (about) 1 // Copyright 2012-2020 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 // +build linux,amd64 linux,386 6 7 package memio 8 9 import ( 10 "fmt" 11 ) 12 13 const portPath = "/dev/port" 14 15 // In reads data from the x86 port at address addr. Data must be Uint8, Uint16, 16 // Uint32, but not Uint64. 17 func In(addr uint16, data UintN) error { 18 if _, ok := data.(*Uint64); ok { 19 return fmt.Errorf("port data must be 8, 16 or 32 bits") 20 } 21 return pathRead(portPath, int64(addr), data) 22 } 23 24 // Out writes data to the x86 port at address addr. data must be Uint8, Uint16 25 // uint32, but not Uint64. 26 func Out(addr uint16, data UintN) error { 27 if _, ok := data.(*Uint64); ok { 28 return fmt.Errorf("port data must be 8, 16 or 32 bits") 29 } 30 return pathWrite(portPath, int64(addr), data) 31 }