iPXE
Defines | Typedefs | Functions | Variables
libkir.h File Reference
#include "realmode.h"

Go to the source code of this file.

Defines

#define __data16(variable)   variable
#define __data16_array(variable, array)   variable array
#define __bss16(variable)   variable
#define __bss16_array(variable, array)   variable array
#define __text16(variable)   variable
#define __text16_array(variable, array)   variable array
#define __use_data16(variable)   variable
#define __use_text16(variable)   variable
#define __from_data16(pointer)   pointer
#define __from_text16(pointer)   pointer
#define rm_cs   ( _rm_cs() )
#define rm_ds   ( _rm_ds() )
#define copy_to_real   copy_to_real_libkir
#define copy_from_real   copy_from_real_libkir
#define put_real_kir_const_off(var, seg, off)
#define put_real_kir_nonconst_off(var, seg, off)
#define put_real_kir(var, seg, off)
#define get_real_kir_const_off(var, seg, off)
#define get_real_kir_nonconst_off(var, seg, off)
#define get_real_kir(var, seg, off)
#define put_real   put_real_kir
#define get_real   get_real_kir
#define TEXT16_CODE(asm_code_str)
#define REAL_CODE(asm_code_str)

Typedefs

typedef uint32_t userptr_t
 A pointer to a user buffer.

Functions

static __attribute__ ((always_inline)) void copy_to_user(userptr_t buffer
 Copy data to user buffer.
static void copy_to_real_libkir (unsigned int dest_seg, unsigned int dest_off, const void *src, size_t n)
static void copy_from_real_libkir (void *dest, unsigned int src_seg, unsigned int src_off, size_t n)

Variables

static off_t offset
static off_t const void * src

Define Documentation

#define __data16 (   variable)    variable

Definition at line 14 of file libkir.h.

#define __data16_array (   variable,
  array 
)    variable array

Definition at line 15 of file libkir.h.

#define __bss16 (   variable)    variable

Definition at line 16 of file libkir.h.

#define __bss16_array (   variable,
  array 
)    variable array

Definition at line 17 of file libkir.h.

#define __text16 (   variable)    variable

Definition at line 18 of file libkir.h.

#define __text16_array (   variable,
  array 
)    variable array

Definition at line 19 of file libkir.h.

#define __use_data16 (   variable)    variable

Definition at line 20 of file libkir.h.

#define __use_text16 (   variable)    variable

Definition at line 21 of file libkir.h.

#define __from_data16 (   pointer)    pointer
#define __from_text16 (   pointer)    pointer

Definition at line 23 of file libkir.h.

Referenced by int22(), pxe_activate(), pxe_start_nbp(), and undi_loader().

#define rm_cs   ( _rm_cs() )
#define rm_ds   ( _rm_ds() )
#define put_real_kir_const_off (   var,
  seg,
  off 
)
Value:
__asm__ ( "movw %w1, %%es\n\t"                                       \
                  "mov %0, %%es:%c2\n\t"                                     \
                  "pushw %%ds\n\t" /* restore %es */                         \
                  "popw %%es\n\t"                                            \
                  :                                                          \
                  : "r,r" ( var ), "rm,rm" ( seg ), "i,!r" ( off )           \
                  )

Definition at line 98 of file libkir.h.

#define put_real_kir_nonconst_off (   var,
  seg,
  off 
)
Value:
__asm__ ( "movw %w1, %%es\n\t"                                       \
                  "mov %0, %%es:(%2)\n\t"                                    \
                  "pushw %%ds\n\t" /* restore %es */                         \
                  "popw %%es\n\t"                                            \
                  :                                                          \
                  : "r" ( var ), "rm" ( seg ), "r" ( off )                   \
                  )

Definition at line 107 of file libkir.h.

#define put_real_kir (   var,
  seg,
  off 
)
Value:
do {                                                                 \
          if ( __builtin_constant_p ( off ) )                                \
                  put_real_kir_const_off ( var, seg, off );                  \
	  else								     \
		  put_real_kir_nonconst_off ( var, seg, off );                     \
        } while ( 0 )

Definition at line 116 of file libkir.h.

#define get_real_kir_const_off (   var,
  seg,
  off 
)
Value:
__asm__ ( "movw %w1, %%es\n\t"                                       \
                  "mov %%es:%c2, %0\n\t"                                     \
                  "pushw %%ds\n\t" /* restore %es */                         \
                  "popw %%es\n\t"                                            \
                  : "=r,r" ( var )                                           \
                  : "rm,rm" ( seg ), "i,!r" ( off )                          \
                  )

Definition at line 124 of file libkir.h.

#define get_real_kir_nonconst_off (   var,
  seg,
  off 
)
Value:
__asm__ ( "movw %w1, %%es\n\t"                                       \
                  "mov %%es:(%2), %0\n\t"                                    \
                  "pushw %%ds\n\t" /* restore %es */                         \
                  "popw %%es\n\t"                                            \
                  : "=r" ( var )                                             \
                  : "rm" ( seg ), "r" ( off )                                \
                  )

Definition at line 133 of file libkir.h.

#define get_real_kir (   var,
  seg,
  off 
)
Value:
do {                                                                 \
          if ( __builtin_constant_p ( off ) )                                \
                  get_real_kir_const_off ( var, seg, off );                  \
	  else								     \
		  get_real_kir_nonconst_off ( var, seg, off );                     \
        } while ( 0 )

Definition at line 142 of file libkir.h.

#define put_real   put_real_kir
#define get_real   get_real_kir
#define TEXT16_CODE (   asm_code_str)
Value:
".section \".text16\", \"ax\", @progbits\n\t"   \
        ".code16\n\t"                                   \
        ".arch i386\n\t"                                \
        asm_code_str "\n\t"                             \
        ".code16gcc\n\t"                                \
        ".previous\n\t"

Referenced by _dump_regs(), bios_inject_startup(), fake_e820(), hook_comboot_interrupts(), int13_hook_vector(), and rtc_hook_isr().

#define REAL_CODE (   asm_code_str)

Typedef Documentation

A pointer to a user buffer.

This is actually a struct segoff, but encoded as a uint32_t to ensure that gcc passes it around efficiently.

Definition at line 159 of file libkir.h.


Function Documentation

static __attribute__ ( (always_inline)  ) [inline, static]

Copy data to user buffer.

Parameters:
bufferUser buffer
offsetOffset within user buffer
srcSource
lenLength

Definition at line 26 of file libkir.h.

References __asm__(), and cs.

                                                                             {
        uint16_t cs;
        __asm__ __volatile__ ( "movw %%cs, %w0" : "=r" ( cs ) );
        return cs;
}
static void copy_to_real_libkir ( unsigned int  dest_seg,
unsigned int  dest_off,
const void *  src,
size_t  n 
) [inline, static]

Definition at line 43 of file libkir.h.

References __asm__().

                                                                     {
        unsigned int discard_D, discard_S, discard_c;

        __asm__ __volatile__ ( "pushw %%es\n\t"
                               "movw %3, %%es\n\t"
                               "rep movsb\n\t"
                               "popw %%es\n\t"
                               : "=D" ( discard_D ), "=S" ( discard_S ),
                                 "=c" ( discard_c )
                               : "r" ( dest_seg ), "D" ( dest_off ),
                                 "S" ( src ),
                                 "c" ( n )
                               : "memory" );
}
static void copy_from_real_libkir ( void *  dest,
unsigned int  src_seg,
unsigned int  src_off,
size_t  n 
) [inline, static]

Definition at line 60 of file libkir.h.

References __asm__().

                                                      {
        unsigned int discard_D, discard_S, discard_c;

        __asm__ __volatile__ ( "pushw %%ds\n\t"
                               "movw %4, %%ds\n\t"
                               "rep movsb\n\t"
                               "popw %%ds\n\t"
                               : "=D" ( discard_D ), "=S" ( discard_S ),
                                 "=c" ( discard_c )
                               : "D" ( dest ),
                                 "r" ( src_seg ), "S" ( src_off ),
                                 "c" ( n )
                               : "memory" );
}

Variable Documentation

Definition at line 170 of file libkir.h.

off_t const void* src

Definition at line 170 of file libkir.h.