github.com/u-root/u-root@v7.0.1-0.20200915234505-ad7babab0a8e+incompatible/pkg/memio/ports_plan9.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 plan9
     6  
     7  package memio
     8  
     9  import (
    10  	"fmt"
    11  )
    12  
    13  // In reads data from the x86 port at address addr. Data must be Uint8, Uint16,
    14  // Uint32, but not Uint64.
    15  func In(addr uint16, data UintN) error {
    16  	switch data.(type) {
    17  	case *Uint32:
    18  		return pathRead("#P/iol", int64(addr), data)
    19  	case *Uint16:
    20  		return pathRead("#P/iow", int64(addr), data)
    21  	case *Uint8:
    22  		return pathRead("#P/iob", int64(addr), data)
    23  	}
    24  	return fmt.Errorf("port data must be 8, 16 or 32 bits")
    25  }
    26  
    27  // Out writes data to the x86 port at address addr. data must be Uint8, Uint16
    28  // uint32, but not Uint64.
    29  func Out(addr uint16, data UintN) error {
    30  	switch data.(type) {
    31  	case *Uint32:
    32  		return pathWrite("#P/iol", int64(addr), data)
    33  	case *Uint16:
    34  		return pathWrite("#P/iow", int64(addr), data)
    35  	case *Uint8:
    36  		return pathWrite("#P/iob", int64(addr), data)
    37  	}
    38  	return fmt.Errorf("port data must be 8, 16 or 32 bits")
    39  }