10#define VIRTUAL_CS 0x08
11#define VIRTUAL_DS 0x10
12#define PHYSICAL_CS 0x18
13#define PHYSICAL_DS 0x20
48#define VIRTUAL(address) ( (address) - 0xffffffff00000000 )
50#define VIRTUAL(address) (address)
72#define VIRT_CALL( function ) \
73 "pushl $( " _S2 ( VIRTUAL ( function ) ) " )\n\t" \
85#define __data16( variable ) \
86 __attribute__ (( section ( ".data16" ) )) \
87 _data16_ ## variable __asm__ ( #variable )
89#define __data16_array( variable, array ) \
90 __attribute__ (( section ( ".data16" ) )) \
91 _data16_ ## variable array __asm__ ( #variable )
93#define __bss16( variable ) \
94 __attribute__ (( section ( ".bss16" ) )) \
95 _data16_ ## variable __asm__ ( #variable )
97#define __bss16_array( variable, array ) \
98 __attribute__ (( section ( ".bss16" ) )) \
99 _data16_ ## variable array __asm__ ( #variable )
101#define __text16( variable ) \
102 __attribute__ (( section ( ".text16.data" ) )) \
103 _text16_ ## variable __asm__ ( #variable )
105#define __text16_array( variable, array ) \
106 __attribute__ (( section ( ".text16.data" ) )) \
107 _text16_ ## variable array __asm__ ( #variable )
109#define __use_data16( variable ) \
110 ( * ( ( typeof ( _data16_ ## variable ) * ) \
111 & ( data16 [ ( size_t ) & ( _data16_ ## variable ) ] ) ) )
113#define __use_text16( variable ) \
114 ( * ( ( typeof ( _text16_ ## variable ) * ) \
115 & ( text16 [ ( size_t ) & ( _text16_ ## variable ) ] ) ) )
117#define __from_data16( pointer ) \
119 ( ( ( void * ) (pointer) ) - ( ( void * ) data16 ) ) )
121#define __from_text16( pointer ) \
123 ( ( ( void * ) (pointer) ) - ( ( void * ) text16 ) ) )
129#define rm_cs __use_text16 ( rm_cs )
131#define rm_ds __use_text16 ( rm_ds )
138#define CODE_DEFAULT ".code64"
139#define STACK_DEFAULT "q"
141#define CODE_DEFAULT ".code32"
142#define STACK_DEFAULT "l"
146#define LINE_SYMBOL _S2 ( OBJECT ) "__line_" _S2 ( __LINE__ ) "__%=:"
149#define TEXT16_CODE( asm_code_str ) \
150 ".section \".text16\", \"ax\", @progbits\n\t" \
151 "\n" LINE_SYMBOL "\n\t" \
153 asm_code_str "\n\t" \
154 CODE_DEFAULT "\n\t" \
158#define REAL_CODE( asm_code_str ) \
159 "push" STACK_DEFAULT " $1f\n\t" \
160 "call real_call\n\t" \
161 TEXT16_CODE ( "\n1:\n\t" \
167#define PHYS_CODE( asm_code_str ) \
168 "push" STACK_DEFAULT " $1f\n\t" \
169 "call phys_call\n\t" \
170 ".section \".text.phys\", \"ax\", @progbits\n\t"\
171 "\n" LINE_SYMBOL "\n\t" \
177 CODE_DEFAULT "\n\t" \
232#define IDTE_PRESENT 0x80
235#define IDTE_TYPE_IRQ32 0x0e
238#define IDTE_TYPE_IRQ64 0x0e
264#define PUSH_INSN 0x50
267#define MOVB_INSN 0xb0
350#define IO_PAGE_COUNT \
351 ( sizeof ( io_pages.page ) / sizeof ( io_pages.page[0] ) )
358#define IO_PAGE_SIZE 0x200000UL
365#define IO_BASE ( ( void * ) 0x100000000ULL )
369#define sipi __use_text16 ( sipi )
373#define sipi_len ABS_VALUE ( sipi_len )
377#define sipi_ds __use_text16 ( sipi_ds )
unsigned long long uint64_t
uint8_t function
Function.
uint8_t data[48]
Additional event data.
uint32_t vector
MSI-X vector.
uint8_t intr
Interrupts enabled.
#define ABS_SYMBOL(name)
Declare an absolute symbol (e.g.
uint16_t size
Buffer size.
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
struct page_table __attribute__
uint16_t copy_to_rm_stack(const void *data, size_t size)
Allocate space on the real-mode stack and copy data there.
void set_interrupt_vector(unsigned int intr, void *vector)
Set interrupt vector.
uint32_t sipi_handler
Startup IPI protected-mode handler (physical address)
void remove_from_rm_stack(void *data, size_t size)
Deallocate space on the real-mode stack, optionally copying back data.
#define __text16_array(variable, array)
@ PAGE_RW
Page is writable.
@ PAGE_PWT
Page-level write-through.
@ PAGE_US
Page is accessible by user code.
@ PAGE_LAST
Page is the last page in an allocation.
@ PAGE_PCD
Page-level cache disable.
@ PAGE_PS
Page is a large page.
#define __text16(variable)
struct page_table io_pages
The I/O space page table.
void setup_sipi(unsigned int vector, uint32_t handler, struct i386_regs *regs)
Set up startup IPI handler.
struct i386_regs sipi_regs
Startup IPI register state.
A 32-bit general register dump.
A 32-bit interrupt descriptor table register.
A 64-bit interrupt descriptor table register.
A 32-bit interrupt descriptor table entry.
uint16_t low
Low 16 bits of address.
uint16_t segment
Code segment.
uint8_t attr
Type and attributes.
uint16_t high
High 16 bits of address.
A 64-bit interrupt descriptor table entry.
uint8_t attr
Type and attributes.
uint16_t segment
Code segment.
uint32_t reserved
Reserved.
uint32_t high
High 32 bits of address.
uint16_t mid
Middle 16 bits of address.
uint16_t low
Low 16 bits of address.
32-bit interrupt wrapper stack frame
64-bit interrupt wrapper stack frame
uint8_t push
"push" instruction
uint32_t offset
Interrupt wrapper address offset.
uint8_t jmp
"jmp" instruction
uint8_t movb
"movb" instruction
uint8_t intr
Interrupt number.
uint8_t next[0]
Next instruction after jump.
uint64_t page[512]
Page address and flags.