mirror of
https://github.com/taigrr/gopher-os
synced 2025-01-18 04:43:13 -08:00
Implement functions for reading/writing from/to IO ports
This commit is contained in:
parent
e4879b9f8a
commit
4f3312b85d
@ -38,3 +38,21 @@ func IsIntel() bool {
|
||||
edx == 0x49656e69 && // "ineI"
|
||||
ecx == 0x6c65746e // "ntel"
|
||||
}
|
||||
|
||||
// PortWriteByte writes a uint8 value to the requested port.
|
||||
func PortWriteByte(port uint16, val uint8)
|
||||
|
||||
// PortWriteWord writes a uint16 value to the requested port.
|
||||
func PortWriteWord(port uint16, val uint16)
|
||||
|
||||
// PortWriteDword writes a uint32 value to the requested port.
|
||||
func PortWriteDword(port uint16, val uint32)
|
||||
|
||||
// PortReadByte reads a uint8 value from the requested port.
|
||||
func PortReadByte(port uint16) uint8
|
||||
|
||||
// PortReadWord reads a uint16 value from the requested port.
|
||||
func PortReadWord(port uint16) uint16
|
||||
|
||||
// PortReadDword reads a uint32 value from the requested port.
|
||||
func PortReadDword(port uint16) uint32
|
||||
|
@ -40,3 +40,41 @@ TEXT ·ID(SB),NOSPLIT,$0
|
||||
MOVL CX, ret+8(FP)
|
||||
MOVL DX, ret+12(FP)
|
||||
RET
|
||||
|
||||
TEXT ·PortWriteByte(SB),NOSPLIT,$0
|
||||
MOVW port+0(FP), DX
|
||||
MOVB val+0(FP), AX
|
||||
BYTE $0xee // out al, dx
|
||||
RET
|
||||
|
||||
TEXT ·PortWriteWord(SB),NOSPLIT,$0
|
||||
MOVW port+0(FP), DX
|
||||
MOVW val+0(FP), AX
|
||||
BYTE $0x66
|
||||
BYTE $0xef // out ax, dx
|
||||
RET
|
||||
|
||||
TEXT ·PortWriteDword(SB),NOSPLIT,$0
|
||||
MOVW port+0(FP), DX
|
||||
MOVL val+0(FP), AX
|
||||
BYTE $0xef // out eax, dx
|
||||
RET
|
||||
|
||||
TEXT ·PortReadByte(SB),NOSPLIT,$0
|
||||
MOVW port+0(FP), DX
|
||||
BYTE $0xec // in al, dx
|
||||
MOVB AX, ret+0(FP)
|
||||
RET
|
||||
|
||||
TEXT ·PortReadWord(SB),NOSPLIT,$0
|
||||
MOVW port+0(FP), DX
|
||||
BYTE $0x66
|
||||
BYTE $0xed // in ax, dx
|
||||
MOVW AX, ret+0(FP)
|
||||
RET
|
||||
|
||||
TEXT ·PortReadDword(SB),NOSPLIT,$0
|
||||
MOVW port+0(FP), DX
|
||||
BYTE $0xed // in eax, dx
|
||||
MOVL AX, ret+0(FP)
|
||||
RET
|
||||
|
Loading…
x
Reference in New Issue
Block a user