Jump to content

DevHlp_PortIO

From EDM2

Perform IO to a specified port.

This function is used to perform input/output operations to a specified local port.

Parameters

Pointer to a PORT_IO structure.

Structures
    typedef struct port_io_s{
       ulong_t port;   (Input)
       ulong_t data;   (Input/Output)
       ulong_t flags;  (Input)
    } PORT_IO;
port
indicates which port to read to, or write from.
data
contains the data read from a read request, or the data to write if a write request.
flags
indicate what operation to perform.
IO_READ_BYTE
Read a byte from the port
IO_READ_WORD
Read a word from the port
IO_READ_DWORD
Read a dword from the port
IO_WRITE_BYTE
Write a byte to the port
IO_WRITE_WORD
Write a word to the port
IO_WRITE_DWORD
Write a dword to the port

Return code

Exit

Example Code

Assembly language
     ;       dh_Port_IO - Perform I/O to a specified port ;
     ;       This devhlp is called by device drivers to do
     ;       I/O to a specified local port.
     ;
     ;       ENTRY:  ES:DI = pointer to port_io structure
     ;
     ;       EXIT:   port_io.data filled in if I/O read
     ;
     ;       USES:   EAX, Flags
     ;

     port_io_s         STRUC
     port_io_port        DD   ?
     port_io_data        DD   ?
     port_io_flags       DD   ?
     port_io_s         ENDS

     IO_READ_BYTE      EQU  0000H
     IO_READ_WORD      EQU  0001H
     IO_READ_DWORD     EQU  0002H
     IO_WRITE_BYTE     EQU  0003H
     IO_WRITE_WORD     EQU  0004H
     IO_WRITE_DWORD    EQU  0005H
     IO_FLAGMASK       EQU  0007H

     MOV     PORT_IO.port_io_port,21h
     MOV     PORT_IO.port_io_data,08h
     MOV     PORT_IO.port_io_flags,IO_WRITE_BYTE

     LES     SI,PORT_IO
     MOV     DL,dh_Port_IO
     CALL    DevHlp
     JC      Error

     ;       EXIT:   port_io_struc.data filled in if I/O read