forked from xt-sys/exectos
		
	Import XT kernel mode library
This commit is contained in:
		
							
								
								
									
										56
									
								
								sdk/xtklib/hl/amd64/cpufunc.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										56
									
								
								sdk/xtklib/hl/amd64/cpufunc.c
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,56 @@
 | 
			
		||||
/**
 | 
			
		||||
 * PROJECT:         ExectOS
 | 
			
		||||
 * COPYRIGHT:       See COPYING.md in the top level directory
 | 
			
		||||
 * FILE:            sdk/xtklib/hl/cpufunc.c
 | 
			
		||||
 * DESCRIPTION:     Routines to provide access to special AMD64 CPU instructions
 | 
			
		||||
 * DEVELOPERS:      Rafal Kupiec <belliash@codingworkshop.eu.org>
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include "xtkmapi.h"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Reads the data from the specified I/O port.
 | 
			
		||||
 *
 | 
			
		||||
 * @param Port
 | 
			
		||||
 *        Specifies the port number in the range of 0-0xFFFF.
 | 
			
		||||
 *
 | 
			
		||||
 * @return The value read from the port.
 | 
			
		||||
 *
 | 
			
		||||
 * @since XT 1.0
 | 
			
		||||
 */
 | 
			
		||||
UCHAR
 | 
			
		||||
XTAPI
 | 
			
		||||
HlIoPortInByte(IN USHORT Port)
 | 
			
		||||
{
 | 
			
		||||
    UCHAR Value;
 | 
			
		||||
    asm volatile("inb %1, %0"
 | 
			
		||||
                 : "=a"(Value)
 | 
			
		||||
                 : "Nd"(Port));
 | 
			
		||||
    return Value;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Writes the data to the specified I/O port.
 | 
			
		||||
 *
 | 
			
		||||
 * @param Port
 | 
			
		||||
 *        Specifies the port number in the range of 0-0xFFFF.
 | 
			
		||||
 *
 | 
			
		||||
 * @param Value
 | 
			
		||||
 *        Supplies the value to write.
 | 
			
		||||
 *
 | 
			
		||||
 * @return This routine does not return any value.
 | 
			
		||||
 *
 | 
			
		||||
 * @since XT 1.0
 | 
			
		||||
 */
 | 
			
		||||
VOID
 | 
			
		||||
XTAPI
 | 
			
		||||
HlIoPortOutByte(IN USHORT Port,
 | 
			
		||||
                IN UCHAR Value)
 | 
			
		||||
{
 | 
			
		||||
    asm volatile("outb %0, %1"
 | 
			
		||||
                 :
 | 
			
		||||
                 :
 | 
			
		||||
                 "a"(Value),
 | 
			
		||||
                 "Nd"(Port));
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user