gitee.com/mirrors_u-root/u-root@v7.0.0+incompatible/pkg/cmos/cmos.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 amd64 386 6 7 package cmos 8 9 import ( 10 "github.com/u-root/u-root/pkg/memio" 11 ) 12 13 const ( 14 cmosRegPort = 0x70 15 cmosDataPort = 0x71 16 ) 17 18 // Read reads a register reg from CMOS into data. 19 func Read(reg memio.Uint8, data memio.UintN) error { 20 if err := memio.Out(cmosRegPort, ®); err != nil { 21 return err 22 } 23 return memio.In(cmosDataPort, data) 24 } 25 26 // Write writes value data into CMOS register reg. 27 func Write(reg memio.Uint8, data memio.UintN) error { 28 if err := memio.Out(cmosRegPort, ®); err != nil { 29 return err 30 } 31 return memio.Out(cmosDataPort, data) 32 }