iPXE
Data Structures | Macros | Enumerations | Functions | Variables
librm.h File Reference

Go to the source code of this file.

Data Structures

struct  idtr32
 A 32-bit interrupt descriptor table register. More...
 
struct  idtr64
 A 64-bit interrupt descriptor table register. More...
 
struct  interrupt32_descriptor
 A 32-bit interrupt descriptor table entry. More...
 
struct  interrupt64_descriptor
 A 64-bit interrupt descriptor table entry. More...
 
struct  interrupt_vector
 An interrupt vector. More...
 
struct  interrupt_frame32
 32-bit interrupt wrapper stack frame More...
 
struct  interrupt_frame64
 64-bit interrupt wrapper stack frame More...
 
struct  page_table
 A page table. More...
 

Macros

#define VIRTUAL_CS   0x08
 
#define VIRTUAL_DS   0x10
 
#define PHYSICAL_CS   0x18
 
#define PHYSICAL_DS   0x20
 
#define REAL_CS   0x28
 
#define REAL_DS   0x30
 
#define P2R_DS   0x38
 
#define LONG_CS   0x40
 
#define VIRTUAL(address)   (address)
 
#define UACCESS_PREFIX_librm   __librm_
 
#define VIRT_CALL(function)
 Call C function from real-mode code. More...
 
#define __data16(variable)
 
#define __data16_array(variable, array)
 
#define __bss16(variable)
 
#define __bss16_array(variable, array)
 
#define __text16(variable)
 
#define __text16_array(variable, array)
 
#define __use_data16(variable)
 
#define __use_text16(variable)
 
#define __from_data16(pointer)
 
#define __from_text16(pointer)
 
#define rm_cs   __use_text16 ( rm_cs )
 
#define rm_ds   __use_text16 ( rm_ds )
 
#define CODE_DEFAULT   ".code32"
 
#define STACK_DEFAULT   "l"
 
#define LINE_SYMBOL   _S2 ( OBJECT ) "__line_" _S2 ( __LINE__ ) "__%=:"
 
#define TEXT16_CODE(asm_code_str)
 
#define REAL_CODE(asm_code_str)
 
#define PHYS_CODE(asm_code_str)
 
#define NUM_INT   256
 Number of interrupts. More...
 
#define IDTE_PRESENT   0x80
 Interrupt descriptor is present. More...
 
#define IDTE_TYPE_IRQ32   0x0e
 Interrupt descriptor 32-bit interrupt gate type. More...
 
#define IDTE_TYPE_IRQ64   0x0e
 Interrupt descriptor 64-bit interrupt gate type. More...
 
#define PUSH_INSN   0x50
 "push %eax" instruction More...
 
#define MOVB_INSN   0xb0
 "movb" instruction More...
 
#define JMP_INSN   0xe9
 "jmp" instruction More...
 
#define IO_PAGE_SIZE   0x200000UL
 I/O page size. More...
 
#define IO_BASE   ( ( void * ) 0x100000000ULL )
 I/O page base address. More...
 
#define sipi   __use_text16 ( sipi )
 
#define sipi_ds   __use_text16 ( sipi_ds )
 

Enumerations

enum  page_flags {
  PAGE_P = 0x01, PAGE_RW = 0x02, PAGE_US = 0x04, PAGE_PWT = 0x08,
  PAGE_PCD = 0x10, PAGE_PS = 0x80, PAGE_LAST = 0x800
}
 Page flags. More...
 

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
static __always_inline userptr_t UACCESS_INLINE (librm, phys_to_user)(unsigned long phys_addr)
 Convert physical address to user pointer. More...
 
static __always_inline unsigned long UACCESS_INLINE (librm, user_to_phys)(userptr_t userptr
 Convert user buffer to physical address. More...
 
 if ((sizeof(physaddr_t) > sizeof(uint32_t)) &&(addr<=0xffffffffUL)) return addr
 
 return (addr+virt_offset)
 
static __always_inline userptr_t UACCESS_INLINE (librm, virt_to_user)(volatile const void *addr)
 
static __always_inline void * UACCESS_INLINE (librm, user_to_virt)(userptr_t userptr
 
static __always_inline userptr_t UACCESS_INLINE (librm, userptr_add)(userptr_t userptr
 
static __always_inline off_t UACCESS_INLINE (librm, userptr_sub)(userptr_t userptr
 
static __always_inline void UACCESS_INLINE (librm, memcpy_user)(userptr_t dest
 
static __always_inline void UACCESS_INLINE (librm, memmove_user)(userptr_t dest
 
static __always_inline int UACCESS_INLINE (librm, memcmp_user)(userptr_t first
 
static __always_inline void UACCESS_INLINE (librm, memset_user)(userptr_t buffer
 
static __always_inline size_t UACCESS_INLINE (librm, strlen_user)(userptr_t buffer
 
static __always_inline off_t UACCESS_INLINE (librm, memchr_user)(userptr_t buffer
 
const uint16_t __text16 (rm_cs)
 
const uint16_t __text16 (rm_ds)
 
uint16_t copy_user_to_rm_stack (userptr_t data, size_t size)
 Allocate space on the real-mode stack and copy data there from a user buffer. More...
 
void remove_user_from_rm_stack (userptr_t data, size_t size)
 Deallocate space on the real-mode stack, optionally copying back data to a user buffer. More...
 
struct idtr32 __attribute__ ((packed))
 
void set_interrupt_vector (unsigned int intr, void *vector)
 Set interrupt vector. More...
 
char __text16_array (sipi, [])
 Startup IPI real-mode handler. More...
 
uint16_t __text16 (sipi_ds)
 Startup IPI real-mode handler copy of real-mode data segment. More...
 
void setup_sipi (unsigned int vector, uint32_t handler, struct i386_regs *regs)
 Set up startup IPI handler. More...
 

Variables

const unsigned long virt_offset
 
static __always_inline unsigned long off_t offset
 Interrupt wrapper address offset. More...
 
static __always_inline off_t userptr_t subtrahend
 
static __always_inline void off_t dest_off
 
static __always_inline void off_t userptr_t src
 
static __always_inline void off_t userptr_t off_t src_off
 
static __always_inline void off_t userptr_t off_t size_t len
 
static __always_inline int off_t first_off
 
static __always_inline int off_t userptr_t second
 
static __always_inline int off_t userptr_t off_t second_off
 
static __always_inline void off_t int c
 
char *const data16
 
char *const text16
 
uint16_t rm_sp
 
uint16_t rm_ss
 
uint16_t limit
 Limit. More...
 
uint32_t base
 Base. More...
 
uint16_t low
 Low 16 bits of address. More...
 
uint16_t segment
 Code segment. More...
 
uint8_t unused
 Unused. More...
 
uint8_t attr
 Type and attributes. More...
 
uint16_t high
 High 16 bits of address. More...
 
uint16_t mid
 Middle 16 bits of address. More...
 
uint32_t reserved
 Reserved. More...
 
uint8_t push
 "push" instruction More...
 
uint8_t movb
 "movb" instruction More...
 
uint8_t intr
 Interrupt number. More...
 
uint8_t jmp
 "jmp" instruction More...
 
uint8_t next [0]
 Next instruction after jump. More...
 
uint32_t esp
 
uint32_t ss
 
uint32_t gs
 
uint32_t fs
 
uint32_t es
 
uint32_t ds
 
uint32_t ebp
 
uint32_t edi
 
uint32_t esi
 
uint32_t edx
 
uint32_t ecx
 
uint32_t ebx
 
uint32_t eax
 
uint32_t eip
 
uint32_t cs
 
uint32_t eflags
 
uint64_t r15
 
uint64_t r14
 
uint64_t r13
 
uint64_t r12
 
uint64_t r11
 
uint64_t r10
 
uint64_t r9
 
uint64_t r8
 
uint64_t rbp
 
uint64_t rdi
 
uint64_t rsi
 
uint64_t rdx
 
uint64_t rcx
 
uint64_t rbx
 
uint64_t rax
 
uint64_t rip
 
uint64_t rflags
 
uint64_t rsp
 
struct page_table __attribute__
 
struct page_table io_pages
 The I/O space page table. More...
 
char sipi_len []
 Length of startup IPI real-mode handler. More...
 
uint32_t sipi_handler
 Startup IPI protected-mode handler (physical address) More...
 
struct i386_regs sipi_regs
 Startup IPI register state. More...
 

Macro Definition Documentation

◆ VIRTUAL_CS

#define VIRTUAL_CS   0x08

Definition at line 10 of file librm.h.

◆ VIRTUAL_DS

#define VIRTUAL_DS   0x10

Definition at line 11 of file librm.h.

◆ PHYSICAL_CS

#define PHYSICAL_CS   0x18

Definition at line 12 of file librm.h.

◆ PHYSICAL_DS

#define PHYSICAL_DS   0x20

Definition at line 13 of file librm.h.

◆ REAL_CS

#define REAL_CS   0x28

Definition at line 14 of file librm.h.

◆ REAL_DS

#define REAL_DS   0x30

Definition at line 15 of file librm.h.

◆ P2R_DS

#define P2R_DS   0x38

Definition at line 16 of file librm.h.

◆ LONG_CS

#define LONG_CS   0x40

Definition at line 17 of file librm.h.

◆ VIRTUAL

#define VIRTUAL (   address)    (address)

Definition at line 50 of file librm.h.

◆ UACCESS_PREFIX_librm

#define UACCESS_PREFIX_librm   __librm_

Definition at line 70 of file librm.h.

◆ VIRT_CALL

#define VIRT_CALL (   function)
Value:
"pushl $( " _S2 ( VIRTUAL ( function ) ) " )\n\t" \
"call virt_call\n\t"
#define _S2(x)
Stringify expanded argument.
Definition: compiler.h:53
#define VIRTUAL(address)
Definition: librm.h:50

Call C function from real-mode code.

Parameters
functionC function

Definition at line 78 of file librm.h.

◆ __data16

#define __data16 (   variable)
Value:
__attribute__ (( section ( ".data16" ) )) \
_data16_ ## variable __asm__ ( #variable )
struct netvsc_rx_buffer_section section[1]
Section descriptors.
Definition: netvsc.h:18
struct page_table __attribute__
__asm__(".section \".rodata\", \"a\", " PROGBITS "\n\t" "\nprivate_key_data:\n\t" ".size private_key_data, ( . - private_key_data )\n\t" ".equ private_key_len, ( . - private_key_data )\n\t" ".previous\n\t")

Definition at line 199 of file librm.h.

◆ __data16_array

#define __data16_array (   variable,
  array 
)
Value:
__attribute__ (( section ( ".data16" ) )) \
_data16_ ## variable array __asm__ ( #variable )
struct netvsc_rx_buffer_section section[1]
Section descriptors.
Definition: netvsc.h:18
uint32_t array
Array number.
Definition: edd.h:30
struct page_table __attribute__
__asm__(".section \".rodata\", \"a\", " PROGBITS "\n\t" "\nprivate_key_data:\n\t" ".size private_key_data, ( . - private_key_data )\n\t" ".equ private_key_len, ( . - private_key_data )\n\t" ".previous\n\t")

Definition at line 203 of file librm.h.

◆ __bss16

#define __bss16 (   variable)
Value:
__attribute__ (( section ( ".bss16" ) )) \
_data16_ ## variable __asm__ ( #variable )
struct netvsc_rx_buffer_section section[1]
Section descriptors.
Definition: netvsc.h:18
struct page_table __attribute__
__asm__(".section \".rodata\", \"a\", " PROGBITS "\n\t" "\nprivate_key_data:\n\t" ".size private_key_data, ( . - private_key_data )\n\t" ".equ private_key_len, ( . - private_key_data )\n\t" ".previous\n\t")

Definition at line 207 of file librm.h.

◆ __bss16_array

#define __bss16_array (   variable,
  array 
)
Value:
__attribute__ (( section ( ".bss16" ) )) \
_data16_ ## variable array __asm__ ( #variable )
struct netvsc_rx_buffer_section section[1]
Section descriptors.
Definition: netvsc.h:18
uint32_t array
Array number.
Definition: edd.h:30
struct page_table __attribute__
__asm__(".section \".rodata\", \"a\", " PROGBITS "\n\t" "\nprivate_key_data:\n\t" ".size private_key_data, ( . - private_key_data )\n\t" ".equ private_key_len, ( . - private_key_data )\n\t" ".previous\n\t")

Definition at line 211 of file librm.h.

◆ __text16

#define __text16 (   variable)
Value:
__attribute__ (( section ( ".text16.data" ) )) \
_text16_ ## variable __asm__ ( #variable )
struct netvsc_rx_buffer_section section[1]
Section descriptors.
Definition: netvsc.h:18
struct page_table __attribute__
__asm__(".section \".rodata\", \"a\", " PROGBITS "\n\t" "\nprivate_key_data:\n\t" ".size private_key_data, ( . - private_key_data )\n\t" ".equ private_key_len, ( . - private_key_data )\n\t" ".previous\n\t")

Definition at line 215 of file librm.h.

◆ __text16_array

#define __text16_array (   variable,
  array 
)
Value:
__attribute__ (( section ( ".text16.data" ) )) \
_text16_ ## variable array __asm__ ( #variable )
struct netvsc_rx_buffer_section section[1]
Section descriptors.
Definition: netvsc.h:18
uint32_t array
Array number.
Definition: edd.h:30
struct page_table __attribute__
__asm__(".section \".rodata\", \"a\", " PROGBITS "\n\t" "\nprivate_key_data:\n\t" ".size private_key_data, ( . - private_key_data )\n\t" ".equ private_key_len, ( . - private_key_data )\n\t" ".previous\n\t")

Definition at line 219 of file librm.h.

◆ __use_data16

#define __use_data16 (   variable)
Value:
( * ( ( typeof ( _data16_ ## variable ) * ) \
& ( data16 [ ( size_t ) & ( _data16_ ## variable ) ] ) ) )
char *const data16
Definition: ib_mad.h:19
typeof(acpi_finder=acpi_find)
ACPI table finder.
Definition: acpi.c:45

Definition at line 223 of file librm.h.

◆ __use_text16

#define __use_text16 (   variable)
Value:
( * ( ( typeof ( _text16_ ## variable ) * ) \
& ( text16 [ ( size_t ) & ( _text16_ ## variable ) ] ) ) )
char *const text16
typeof(acpi_finder=acpi_find)
ACPI table finder.
Definition: acpi.c:45

Definition at line 227 of file librm.h.

◆ __from_data16

#define __from_data16 (   pointer)
Value:
( ( unsigned int ) \
( ( ( void * ) (pointer) ) - ( ( void * ) data16 ) ) )
char *const data16
Definition: ib_mad.h:19

Definition at line 231 of file librm.h.

◆ __from_text16

#define __from_text16 (   pointer)
Value:
( ( unsigned int ) \
( ( ( void * ) (pointer) ) - ( ( void * ) text16 ) ) )
char *const text16

Definition at line 235 of file librm.h.

◆ rm_cs

#define rm_cs   __use_text16 ( rm_cs )

Definition at line 243 of file librm.h.

◆ rm_ds

#define rm_ds   __use_text16 ( rm_ds )

Definition at line 245 of file librm.h.

◆ CODE_DEFAULT

#define CODE_DEFAULT   ".code32"

Definition at line 255 of file librm.h.

◆ STACK_DEFAULT

#define STACK_DEFAULT   "l"

Definition at line 256 of file librm.h.

◆ LINE_SYMBOL

#define LINE_SYMBOL   _S2 ( OBJECT ) "__line_" _S2 ( __LINE__ ) "__%=:"

Definition at line 260 of file librm.h.

◆ TEXT16_CODE

#define TEXT16_CODE (   asm_code_str)
Value:
".section \".text16\", \"ax\", @progbits\n\t" \
"\n" LINE_SYMBOL "\n\t" \
".code16\n\t" \
asm_code_str "\n\t" \
CODE_DEFAULT "\n\t" \
".previous\n\t"
#define LINE_SYMBOL
Definition: librm.h:260

Definition at line 263 of file librm.h.

◆ REAL_CODE

#define REAL_CODE (   asm_code_str)
Value:
"push" STACK_DEFAULT " $1f\n\t" \
"call real_call\n\t" \
TEXT16_CODE ( "\n1:\n\t" \
asm_code_str \
"\n\t" \
"ret\n\t" )
#define STACK_DEFAULT
Definition: librm.h:256

Definition at line 272 of file librm.h.

◆ PHYS_CODE

#define PHYS_CODE (   asm_code_str)
Value:
"push" STACK_DEFAULT " $1f\n\t" \
"call phys_call\n\t" \
".section \".text.phys\", \"ax\", @progbits\n\t"\
"\n" LINE_SYMBOL "\n\t" \
".code32\n\t" \
"\n1:\n\t" \
asm_code_str \
"\n\t" \
"ret\n\t" \
CODE_DEFAULT "\n\t" \
".previous\n\t"
#define STACK_DEFAULT
Definition: librm.h:256
#define LINE_SYMBOL
Definition: librm.h:260

Definition at line 281 of file librm.h.

◆ NUM_INT

#define NUM_INT   256

Number of interrupts.

Definition at line 295 of file librm.h.

◆ IDTE_PRESENT

#define IDTE_PRESENT   0x80

Interrupt descriptor is present.

Definition at line 346 of file librm.h.

◆ IDTE_TYPE_IRQ32

#define IDTE_TYPE_IRQ32   0x0e

Interrupt descriptor 32-bit interrupt gate type.

Definition at line 349 of file librm.h.

◆ IDTE_TYPE_IRQ64

#define IDTE_TYPE_IRQ64   0x0e

Interrupt descriptor 64-bit interrupt gate type.

Definition at line 352 of file librm.h.

◆ PUSH_INSN

#define PUSH_INSN   0x50

"push %eax" instruction

Definition at line 378 of file librm.h.

◆ MOVB_INSN

#define MOVB_INSN   0xb0

"movb" instruction

Definition at line 381 of file librm.h.

◆ JMP_INSN

#define JMP_INSN   0xe9

"jmp" instruction

Definition at line 384 of file librm.h.

◆ IO_PAGE_SIZE

#define IO_PAGE_SIZE   0x200000UL

I/O page size.

We choose to use 2MB pages for I/O space, to minimise the number of page table entries required.

Definition at line 468 of file librm.h.

◆ IO_BASE

#define IO_BASE   ( ( void * ) 0x100000000ULL )

I/O page base address.

We choose to place I/O space immediately above the identity-mapped 32-bit address space.

Definition at line 475 of file librm.h.

◆ sipi

#define sipi   __use_text16 ( sipi )

Definition at line 479 of file librm.h.

◆ sipi_ds

#define sipi_ds   __use_text16 ( sipi_ds )

Definition at line 486 of file librm.h.

Enumeration Type Documentation

◆ page_flags

enum page_flags

Page flags.

Enumerator
PAGE_P 

Page is present.

PAGE_RW 

Page is writable.

PAGE_US 

Page is accessible by user code.

PAGE_PWT 

Page-level write-through.

PAGE_PCD 

Page-level cache disable.

PAGE_PS 

Page is a large page.

PAGE_LAST 

Page is the last page in an allocation.

   This bit is ignored by the hardware.  We use it to track
   the size of allocations made by ioremap().

Definition at line 439 of file librm.h.

439  {
440  /** Page is present */
441  PAGE_P = 0x01,
442  /** Page is writable */
443  PAGE_RW = 0x02,
444  /** Page is accessible by user code */
445  PAGE_US = 0x04,
446  /** Page-level write-through */
447  PAGE_PWT = 0x08,
448  /** Page-level cache disable */
449  PAGE_PCD = 0x10,
450  /** Page is a large page */
451  PAGE_PS = 0x80,
452  /** Page is the last page in an allocation
453  *
454  * This bit is ignored by the hardware. We use it to track
455  * the size of allocations made by ioremap().
456  */
457  PAGE_LAST = 0x800,
458 };
Page-level write-through.
Definition: librm.h:447
Page-level cache disable.
Definition: librm.h:449
Page is the last page in an allocation.
Definition: librm.h:457
Page is a large page.
Definition: librm.h:451
Page is writable.
Definition: librm.h:443
Page is accessible by user code.
Definition: librm.h:445
Page is present.
Definition: librm.h:441

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ UACCESS_INLINE() [1/12]

static __always_inline userptr_t UACCESS_INLINE ( librm  ,
phys_to_user   
)
inlinestatic

Convert physical address to user pointer.

Parameters
phys_addrPhysical address
Return values
userptrUser pointer

Definition at line 92 of file librm.h.

92  {
93 
94  /* In a 64-bit build, any valid physical address is directly
95  * usable as a virtual address, since the low 4GB is
96  * identity-mapped.
97  */
98  if ( sizeof ( physaddr_t ) > sizeof ( uint32_t ) )
99  return phys_addr;
100 
101  /* In a 32-bit build, subtract virt_offset */
102  return ( phys_addr - virt_offset );
103 }
unsigned int uint32_t
Definition: stdint.h:12
unsigned long physaddr_t
Definition: stdint.h:20
const unsigned long virt_offset

References virt_offset.

◆ UACCESS_INLINE() [2/12]

static __always_inline unsigned long UACCESS_INLINE ( librm  ,
user_to_phys   
)
inlinestatic

Convert user buffer to physical address.

Parameters
userptrUser pointer
offsetOffset from user pointer
Return values
phys_addrPhysical address

◆ if()

if ( (sizeof(physaddr_t) > sizeof(uint32_t)) &&(addr<=0xffffffffUL)  )

◆ return()

return ( addr virt_offset)

◆ UACCESS_INLINE() [3/12]

static __always_inline userptr_t UACCESS_INLINE ( librm  ,
virt_to_user   
) const volatile
inlinestatic

Definition at line 131 of file librm.h.

131  {
132  return trivial_virt_to_user ( addr );
133 }
u32 addr
Definition: sky2.h:8
static __always_inline userptr_t trivial_virt_to_user(volatile const void *addr)
Convert virtual address to user pointer.
Definition: uaccess.h:55

References addr, and trivial_virt_to_user().

◆ UACCESS_INLINE() [4/12]

static __always_inline void* UACCESS_INLINE ( librm  ,
user_to_virt   
)
inlinestatic

◆ UACCESS_INLINE() [5/12]

static __always_inline userptr_t UACCESS_INLINE ( librm  ,
userptr_add   
)
inlinestatic

◆ UACCESS_INLINE() [6/12]

static __always_inline off_t UACCESS_INLINE ( librm  ,
userptr_sub   
)
inlinestatic

◆ UACCESS_INLINE() [7/12]

static __always_inline void UACCESS_INLINE ( librm  ,
memcpy_user   
)
inlinestatic

◆ UACCESS_INLINE() [8/12]

static __always_inline void UACCESS_INLINE ( librm  ,
memmove_user   
)
inlinestatic

◆ UACCESS_INLINE() [9/12]

static __always_inline int UACCESS_INLINE ( librm  ,
memcmp_user   
)
inlinestatic

◆ UACCESS_INLINE() [10/12]

static __always_inline void UACCESS_INLINE ( librm  ,
memset_user   
)
inlinestatic

◆ UACCESS_INLINE() [11/12]

static __always_inline size_t UACCESS_INLINE ( librm  ,
strlen_user   
)
inlinestatic

◆ UACCESS_INLINE() [12/12]

static __always_inline off_t UACCESS_INLINE ( librm  ,
memchr_user   
)
inlinestatic

◆ __text16() [1/3]

const uint16_t __text16 ( rm_cs  )

◆ __text16() [2/3]

const uint16_t __text16 ( rm_ds  )

◆ copy_user_to_rm_stack()

uint16_t copy_user_to_rm_stack ( userptr_t  data,
size_t  size 
)

Allocate space on the real-mode stack and copy data there from a user buffer.

Parameters
dataUser buffer
sizeSize of stack data
Return values
spNew value of real-mode stack pointer

Definition at line 68 of file librm_mgmt.c.

68  {
69  userptr_t rm_stack;
70  rm_sp -= size;
71  rm_stack = real_to_user ( rm_ss, rm_sp );
72  memcpy_user ( rm_stack, 0, data, 0, size );
73  return rm_sp;
74 };
uint16_t rm_ss
uint8_t size
Entry size (in 32-bit words)
Definition: ena.h:16
uint8_t data[48]
Additional event data.
Definition: ena.h:22
uint16_t rm_sp
static __always_inline userptr_t real_to_user(unsigned int segment, unsigned int offset)
Convert segment:offset address to user buffer.
Definition: realmode.h:75
void memcpy_user(userptr_t dest, off_t dest_off, userptr_t src, off_t src_off, size_t len)
Copy data between user buffers.
unsigned long userptr_t
A pointer to a user buffer.
Definition: uaccess.h:33

References data, memcpy_user(), real_to_user(), rm_sp, rm_ss, and size.

Referenced by com32_cfarcall().

◆ remove_user_from_rm_stack()

void remove_user_from_rm_stack ( userptr_t  data,
size_t  size 
)

Deallocate space on the real-mode stack, optionally copying back data to a user buffer.

Parameters
dataUser buffer
sizeSize of stack data

Definition at line 83 of file librm_mgmt.c.

83  {
84  if ( data ) {
85  userptr_t rm_stack = real_to_user ( rm_ss, rm_sp );
86  memcpy_user ( rm_stack, 0, data, 0, size );
87  }
88  rm_sp += size;
89 };
uint16_t rm_ss
uint8_t size
Entry size (in 32-bit words)
Definition: ena.h:16
uint8_t data[48]
Additional event data.
Definition: ena.h:22
uint16_t rm_sp
static __always_inline userptr_t real_to_user(unsigned int segment, unsigned int offset)
Convert segment:offset address to user buffer.
Definition: realmode.h:75
void memcpy_user(userptr_t dest, off_t dest_off, userptr_t src, off_t src_off, size_t len)
Copy data between user buffers.
unsigned long userptr_t
A pointer to a user buffer.
Definition: uaccess.h:33

References data, memcpy_user(), real_to_user(), rm_sp, rm_ss, and size.

Referenced by com32_cfarcall().

◆ __attribute__()

struct idtr32 __attribute__ ( (packed)  )

◆ set_interrupt_vector()

void set_interrupt_vector ( unsigned int  intr,
void *  vector 
)

Set interrupt vector.

Parameters
intrInterrupt number
vectorInterrupt vector, or NULL to disable

Definition at line 97 of file librm_mgmt.c.

97  {
98  struct interrupt32_descriptor *idte32;
99  struct interrupt64_descriptor *idte64;
100  intptr_t addr = ( ( intptr_t ) vector );
101 
102  /* Populate 32-bit interrupt descriptor */
103  idte32 = &idt32[intr];
104  idte32->segment = VIRTUAL_CS;
105  idte32->attr = ( vector ? ( IDTE_PRESENT | IDTE_TYPE_IRQ32 ) : 0 );
106  idte32->low = ( addr >> 0 );
107  idte32->high = ( addr >> 16 );
108 
109  /* Populate 64-bit interrupt descriptor, if applicable */
110  if ( sizeof ( physaddr_t ) > sizeof ( uint32_t ) ) {
111  idte64 = &idt64[intr];
112  idte64->segment = LONG_CS;
113  idte64->attr = ( vector ?
114  ( IDTE_PRESENT | IDTE_TYPE_IRQ64 ) : 0 );
115  idte64->low = ( addr >> 0 );
116  idte64->mid = ( addr >> 16 );
117  idte64->high = ( ( ( uint64_t ) addr ) >> 32 );
118  }
119 }
uint16_t mid
Middle 16 bits of address.
Definition: librm.h:338
uint32_t vector
MSI-X vector.
Definition: ena.h:20
#define IDTE_TYPE_IRQ32
Interrupt descriptor 32-bit interrupt gate type.
Definition: librm.h:349
uint16_t high
High 16 bits of address.
Definition: librm.h:324
#define LONG_CS
Definition: librm.h:17
uint8_t attr
Type and attributes.
Definition: librm.h:322
unsigned long long uint64_t
Definition: stdint.h:13
unsigned long intptr_t
Definition: stdint.h:21
uint32_t high
High 32 bits of address.
Definition: librm.h:340
#define IDTE_TYPE_IRQ64
Interrupt descriptor 64-bit interrupt gate type.
Definition: librm.h:352
A 32-bit interrupt descriptor table entry.
Definition: librm.h:314
uint8_t intr
Interrupts enabled.
Definition: ena.h:14
uint16_t low
Low 16 bits of address.
Definition: librm.h:316
#define VIRTUAL_CS
Definition: librm.h:10
u32 addr
Definition: sky2.h:8
uint16_t low
Low 16 bits of address.
Definition: librm.h:330
unsigned int uint32_t
Definition: stdint.h:12
A 64-bit interrupt descriptor table entry.
Definition: librm.h:328
unsigned long physaddr_t
Definition: stdint.h:20
#define IDTE_PRESENT
Interrupt descriptor is present.
Definition: librm.h:346
uint16_t segment
Code segment.
Definition: librm.h:332
static struct interrupt64_descriptor idt64[NUM_INT]
The 64-bit interrupt descriptor table.
Definition: librm_mgmt.c:40
uint8_t attr
Type and attributes.
Definition: librm.h:336
uint16_t segment
Code segment.
Definition: librm.h:318
static struct interrupt32_descriptor idt32[NUM_INT]
The 32-bit interrupt descriptor table.
Definition: librm_mgmt.c:31

References addr, interrupt32_descriptor::attr, interrupt64_descriptor::attr, interrupt32_descriptor::high, interrupt64_descriptor::high, idt32, idt64, IDTE_PRESENT, IDTE_TYPE_IRQ32, IDTE_TYPE_IRQ64, intr, LONG_CS, interrupt32_descriptor::low, interrupt64_descriptor::low, interrupt64_descriptor::mid, interrupt32_descriptor::segment, interrupt64_descriptor::segment, vector, and VIRTUAL_CS.

Referenced by gdbmach_init(), and init_idt().

◆ __text16_array()

char __text16_array ( sipi  )

Startup IPI real-mode handler.

◆ __text16() [3/3]

uint16_t __text16 ( sipi_ds  )

Startup IPI real-mode handler copy of real-mode data segment.

◆ setup_sipi()

void setup_sipi ( unsigned int  vector,
uint32_t  handler,
struct i386_regs regs 
)

Set up startup IPI handler.

Parameters
vectorStartup IPI vector
handlerProtected-mode startup IPI handler physical address
regsInitial register state

Definition at line 415 of file librm_mgmt.c.

416  {
417 
418  /* Record protected-mode handler */
419  sipi_handler = handler;
420 
421  /* Update copy of rm_ds */
422  sipi_ds = rm_ds;
423 
424  /* Save register state */
425  memcpy ( &sipi_regs, regs, sizeof ( sipi_regs ) );
426 
427  /* Copy real-mode handler */
428  copy_to_real ( ( vector << 8 ), 0, sipi, ( ( size_t ) sipi_len ) );
429 }
uint32_t vector
MSI-X vector.
Definition: ena.h:20
uint32_t sipi_handler
Startup IPI protected-mode handler (physical address)
struct i386_regs sipi_regs
Startup IPI register state.
Definition: librm_mgmt.c:49
#define sipi_ds
Definition: librm.h:486
#define rm_ds
Definition: libkir.h:39
void * memcpy(void *dest, const void *src, size_t len) __nonnull
#define copy_to_real
Definition: libkir.h:78
char sipi_len[]
Length of startup IPI real-mode handler.
struct i386_regs regs
Definition: registers.h:15
#define sipi
Definition: librm.h:479

References copy_to_real, memcpy(), regs, rm_ds, sipi, sipi_ds, sipi_handler, sipi_len, sipi_regs, and vector.

Referenced by bios_mp_start_all().

Variable Documentation

◆ virt_offset

const unsigned long virt_offset

Referenced by UACCESS_INLINE().

◆ offset

uint32_t offset
Initial value:
{
unsigned long addr = ( userptr + offset )
u32 addr
Definition: sky2.h:8
static __always_inline unsigned long off_t offset
Interrupt wrapper address offset.
Definition: librm.h:113

Interrupt wrapper address offset.

Definition at line 113 of file librm.h.

◆ subtrahend

Initial value:
{
return trivial_userptr_sub ( userptr, subtrahend )
static __always_inline off_t trivial_userptr_sub(userptr_t userptr, userptr_t subtrahend)
Subtract user pointers.
Definition: uaccess.h:93
static __always_inline off_t userptr_t subtrahend
Definition: librm.h:147

Definition at line 147 of file librm.h.

◆ dest_off

__always_inline void off_t dest_off

Definition at line 152 of file librm.h.

◆ src

Definition at line 152 of file librm.h.

◆ src_off

Definition at line 152 of file librm.h.

◆ len

Initial value:
{
static __always_inline void off_t dest_off
Definition: librm.h:152
static __always_inline void off_t userptr_t off_t size_t len
Definition: librm.h:154
static __always_inline void off_t userptr_t off_t src_off
Definition: librm.h:152
static void * dest
Definition: strings.h:176
static __always_inline void off_t userptr_t src
Definition: librm.h:152
static __always_inline void trivial_memcpy_user(userptr_t dest, off_t dest_off, userptr_t src, off_t src_off, size_t len)
Copy data between user buffers.
Definition: uaccess.h:107

Definition at line 154 of file librm.h.

◆ first_off

__always_inline int off_t first_off

Definition at line 166 of file librm.h.

◆ second

Definition at line 166 of file librm.h.

◆ second_off

Definition at line 166 of file librm.h.

◆ c

Definition at line 173 of file librm.h.

◆ data16

char* const data16

Definition at line 19 of file ib_mad.h.

◆ text16

char* const text16

◆ rm_sp

uint16_t rm_sp

◆ rm_ss

uint16_t rm_ss

◆ limit

uint16_t limit

◆ base

uint64_t base

Base.

Definition at line 252 of file librm.h.

◆ low

uint16_t low

Low 16 bits of address.

Definition at line 250 of file librm.h.

◆ segment

uint16_t segment

◆ unused

uint8_t unused

Unused.

Definition at line 254 of file librm.h.

◆ attr

uint8_t attr

◆ high

uint32_t high

High 16 bits of address.

High 32 bits of address.

Definition at line 258 of file librm.h.

◆ mid

uint16_t mid

Middle 16 bits of address.

Definition at line 258 of file librm.h.

Referenced by peerblk_raw_rx(), and prep_segment().

◆ reserved

uint32_t reserved

Reserved.

Definition at line 262 of file librm.h.

◆ push

uint8_t push

"push" instruction

Definition at line 250 of file librm.h.

◆ movb

uint8_t movb

"movb" instruction

Definition at line 252 of file librm.h.

◆ intr

uint8_t intr

Interrupt number.

Definition at line 254 of file librm.h.

◆ jmp

uint8_t jmp

"jmp" instruction

Definition at line 256 of file librm.h.

Referenced by pxe_start_nbp().

◆ next

uint8_t next[0]

Next instruction after jump.

Definition at line 260 of file librm.h.

◆ esp

uint32_t esp

Definition at line 249 of file librm.h.

Referenced by interrupt_dump().

◆ ss

Definition at line 250 of file librm.h.

Referenced by ath9k_hw_get_gain_boundaries_pdadcs(), and memsetw().

◆ gs

Definition at line 251 of file librm.h.

◆ fs

Definition at line 252 of file librm.h.

Referenced by efi_autoexec_filesystem(), efi_block_root(), and efi_local_open_root().

◆ es

Definition at line 253 of file librm.h.

◆ ds

◆ ebp

uint32_t ebp

Definition at line 255 of file librm.h.

◆ edi

uint32_t edi

Definition at line 256 of file librm.h.

◆ esi

uint32_t esi

Definition at line 257 of file librm.h.

◆ edx

uint32_t edx

Definition at line 258 of file librm.h.

◆ ecx

uint32_t ecx

Definition at line 259 of file librm.h.

◆ ebx

uint32_t ebx

Definition at line 260 of file librm.h.

◆ eax

uint32_t eax

Definition at line 261 of file librm.h.

◆ eip

uint32_t eip

Definition at line 262 of file librm.h.

◆ cs

Definition at line 263 of file librm.h.

Referenced by __attribute__(), linda_ib_epb_mod_reg(), and strpbrk().

◆ eflags

uint32_t eflags

Definition at line 264 of file librm.h.

◆ r15

uint64_t r15

Definition at line 249 of file librm.h.

◆ r14

uint64_t r14

Definition at line 250 of file librm.h.

◆ r13

uint64_t r13

Definition at line 251 of file librm.h.

◆ r12

uint64_t r12

Definition at line 252 of file librm.h.

◆ r11

uint64_t r11

Definition at line 253 of file librm.h.

◆ r10

uint64_t r10

Definition at line 254 of file librm.h.

◆ r9

Definition at line 255 of file librm.h.

◆ r8

Definition at line 256 of file librm.h.

◆ rbp

uint64_t rbp

Definition at line 257 of file librm.h.

◆ rdi

uint64_t rdi

Definition at line 258 of file librm.h.

◆ rsi

uint64_t rsi

Definition at line 259 of file librm.h.

◆ rdx

uint64_t rdx

Definition at line 260 of file librm.h.

◆ rcx

uint64_t rcx

Definition at line 261 of file librm.h.

◆ rbx

uint64_t rbx

Definition at line 262 of file librm.h.

◆ rax

uint64_t rax

Definition at line 263 of file librm.h.

◆ rip

uint64_t rip

Definition at line 264 of file librm.h.

◆ rflags

uint64_t rflags

Definition at line 266 of file librm.h.

◆ rsp

uint64_t rsp

◆ __attribute__

◆ io_pages

struct page_table io_pages

The I/O space page table.

Referenced by ioremap_pages(), and iounmap_pages().

◆ sipi_len

char sipi_len[]

Length of startup IPI real-mode handler.

Referenced by setup_sipi().

◆ sipi_handler

uint32_t sipi_handler

Startup IPI protected-mode handler (physical address)

Referenced by setup_sipi().

◆ sipi_regs

struct i386_regs sipi_regs

Startup IPI register state.

Definition at line 49 of file librm_mgmt.c.

Referenced by setup_sipi().