github.com/mvdan/u-root-coreutils@v0.0.0-20230122170626-c2eef2898555/cmds/core/io/asmports.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  //go:build (linux && amd64) || (linux && 386)
     6  // +build linux,amd64 linux,386
     7  
     8  package main
     9  
    10  import (
    11  	"github.com/mvdan/u-root-coreutils/pkg/memio"
    12  )
    13  
    14  // The xin* and xout* commands use iopl, and hence
    15  // must be run by root.
    16  func init() {
    17  	usageMsg += `io (xin{b,w,l} address)...
    18  io (xout{b,w,l} address value)...
    19  `
    20  	addCmd(readCmds, "xinb", &cmd{xin, 16, 8})
    21  	addCmd(readCmds, "xinw", &cmd{xin, 16, 16})
    22  	addCmd(readCmds, "xinl", &cmd{xin, 16, 32})
    23  	addCmd(writeCmds, "xoutb", &cmd{xout, 16, 8})
    24  	addCmd(writeCmds, "xoutw", &cmd{xout, 16, 16})
    25  	addCmd(writeCmds, "xoutl", &cmd{xout, 16, 32})
    26  }
    27  
    28  func xin(addr int64, data memio.UintN) error {
    29  	return memio.ArchIn(uint16(addr), data)
    30  }
    31  
    32  func xout(addr int64, data memio.UintN) error {
    33  	return memio.ArchOut(uint16(addr), data)
    34  }