Main Page   Modules   Alphabetical List   Data Structures   File List   Data Fields   Globals   Related Pages  

i386.h File Reference

Generic (IA-32) routines and headers. More...

#include <const.h>

Go to the source code of this file.

Data Structures

struct  atomic
 The atomic variable structure. More...


Defines

#define rdtsc(low, high)   __asm__ __volatile__( "rdtsc" : "=a"(low), "=d"(high) )
 Read the timestamp counter from the model-specific register and put it into two 32-bit registers.

#define rdtscll(val)   __asm__ __volatile__( "rdtsc" : "=A"(val) )
 Read the timestamp counter from the model-specific register and put it into eax:edx registers. This is a 64-bit value.

#define wmb()   mb()
 A macro equivalent to the function mb().

#define get_eip()   ({ void *eip; __asm__("movl $1f,%0\n1:" : "=g" (eip)); eip; })
 A macro that returns current instruction pointer.

#define in   inportb
 A macro equivalent to the inportb(word port) function.

#define in16   inportw
 A macro equivalent to the inportw(word port) function.

#define in32   inportl
 A macro equivalent to the inportl(word port) function.

#define out   outportb
 A macro equivalent to the outportb(word port, byte val) function.

#define out16   outportw
 A macro equivalent to the outportw(word port, word val) function.

#define out32   outportl
 A macro equivalent to the outportl(word port, dword val) function.

#define inportbm   insb
 A macro equivalent to the insb(unsigned short port, void * addr, unsigned long count) function.

#define inportwm   insw
 A macro equivalent to the insw(unsigned short port, void * addr, unsigned long count) function.

#define inportlm   insl
 A macro equivalent to the insl(unsigned short port, void * addr, unsigned long count) function.

#define outportbm   outsb
 A macro equivalent to the outsb(unsigned short port, void * addr, unsigned long count) function.

#define outportwm   outsw
 A macro equivalent to the outsw(unsigned short port, void * addr, unsigned long count) function.

#define outportlm   outsl
 A macro equivalent to the outsl(unsigned short port, void * addr, unsigned long count) function.

#define atomic_set(v, i)   (((v)->counter) = (i))
 Set the atomic value of v to i (guaranteed only 24 bits)
Parameters:
v  The atomic variable.
i  The value to assign.


#define atomic_read(v)   ((v)->counter)
 Read the atomic value of v (guaranteed only 24 bits)
Parameters:
v  The atomic variable.



Typedefs

typedef atomic atomic_t
 The atomic variable structure.


Functions

__inline__ void mb ()
 Force strict CPU ordering (required for all out-of-order Intel CPUs to preserve the order of execution).

__inline__ void enable ()
 Enable all interrupts.

__inline__ void disable ()
 Disable all interrupts.

__inline__ dword GET_IF ()
 Get the IF (interrupt enable flag) value from the EFLAGS register.
Returns:
The interrupt enable flag (IF).


__inline__ void SET_IF (dword IF)
 Set the IF (interrupt enable flag) value into the EFLAGS register.
Parameters:
IF  The interrupt flag:
  • 1 = ON
  • 0 = OFF.


__inline__ byte inportb (word port)
 Get a byte from an I/O port.
Parameters:
port  The I/O port.
Returns:
The value of the byte.


__inline__ word inportw (word port)
 Get a word from an I/O port.
Parameters:
port  The I/O port.
Returns:
The value of the word.


__inline__ dword inportl (word port)
 Get a dword from an I/O port.
Parameters:
port  The I/O port.
Returns:
The value of the double word.


__inline__ void outportb (word port, byte val)
 Put a byte to an I/O port.
Parameters:
port  The I/O port.
val  The value you want to put.


__inline__ void outportw (word port, word val)
 Put a word to an I/O port.
Parameters:
port  The I/O port.
val  The value you want to put.


__inline__ void outportl (word port, dword val)
 Put a dword to an I/O port.
Parameters:
port  The I/O port.
val  The value you want to put.


void insb (unsigned short port, void *addr, unsigned long count)
 The string version of in().
Parameters:
port  The I/O port.
addr  A memory buffer where the values will be copied.
count  How many bytes we want to read from the port.


void insw (unsigned short port, void *addr, unsigned long count)
 The string version of in16().
Parameters:
port  The I/O port.
addr  A memory buffer where the values will be copied.
count  How many words we want to read from the port.


void insl (unsigned short port, void *addr, unsigned long count)
 The string version of in32().
Parameters:
port  The I/O port.
addr  A memory buffer where the values will be copied.
count  How many double words we want to read from the port.


void outsb (unsigned short port, void *addr, unsigned long count)
 The string version of out().
Parameters:
port  The I/O port.
addr  A memory buffer that contains the values to be copied.
count  How many bytes we want to write to the port.


void outsw (unsigned short port, void *addr, unsigned long count)
 The string version of out16().
Parameters:
port  The I/O port.
addr  A memory buffer that contains the values to be copied.
count  How many words we want to write to the port.


void outsl (unsigned short port, void *addr, unsigned long count)
 The string version of out32().
Parameters:
port  The I/O port.
addr  A memory buffer that contains the values to be copied.
count  How many double words we want to write to the port.


__inline__ void cpuid (int op, int *eax, int *ebx, int *ecx, int *edx)
 Get the CPUID information.
Parameters:
op  The operation code to perform.
eax  EAX register value after the CPUID execution.
ebx  EBX register value after the CPUID execution.
ecx  ECX register value after the CPUID execution.
edx  EDX register value after the CPUID execution.
Warning:
Not all the Intel CPUs support the CPUID instruction!!! Only some Intel486 family and subsequent Intel processors provide this method for determinig the architecture flags. Execution of CPUID on a processor that does not support this instruction will result in an invalid opcode exception.

To determine if it is possible to use this instruction we can use bit 21 of the EFLAGS register. If software can change the value of this flag, the CPUID instruction is executable.


__inline__ void atomic_inc (atomic_t *v)
 Perform an atomic increment.
Parameters:
v  The atomic value to increment.
Warning:
Guaranteed only 24 bits.


__inline__ void atomic_dec (atomic_t *v)
 Perform an atomic decrement.
Parameters:
v  The atomic value to decrement.
Warning:
Guaranteed only 24 bits.


__inline__ void halt ()
 Halt the system by disabling the CPU.
Warning:
This is truly the end. You have to reboot the system after this...


__inline__ void breakpoint ()
 Perform a breakpoint exeception.


Detailed Description

Generic (IA-32) routines and headers.

Author:
Andrea Righi <drizzt@inwind.it>
Date:
Last update: 2004-02-19
Note:
Copyright (©) 2003 Andrea Righi
This file contains the definition of a lot useful function for the x86 architecture. The greater part of them are in assembler...

Definition in file i386.h.


Generated on Fri Feb 20 15:32:18 2004 for Minirighi by doxygen1.2.18