forked from u-root/u-root
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cmos.go
32 lines (26 loc) · 734 Bytes
/
cmos.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Copyright 2012-2020 the u-root Authors. All rights reserved
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// +build amd64 386
package cmos
import (
"github.com/u-root/u-root/pkg/memio"
)
const (
cmosRegPort = 0x70
cmosDataPort = 0x71
)
// Read reads a register reg from CMOS into data.
func Read(reg memio.Uint8, data memio.UintN) error {
if err := memio.Out(cmosRegPort, ®); err != nil {
return err
}
return memio.In(cmosDataPort, data)
}
// Write writes value data into CMOS register reg.
func Write(reg memio.Uint8, data memio.UintN) error {
if err := memio.Out(cmosRegPort, ®); err != nil {
return err
}
return memio.Out(cmosDataPort, data)
}