43#ifndef _RTEMS_SCORE_I386_H
44#define _RTEMS_SCORE_I386_H
79#if defined(__pentiumpro__)
81 #define CPU_MODEL_NAME "Pentium Pro"
83#elif defined(__i586__)
85 #if defined(__pentium__)
86 #define CPU_MODEL_NAME "Pentium"
88 #define CPU_MODEL_NAME "K6"
90 #define CPU_MODEL_NAME "i586"
93#elif defined(__i486__)
95 #define CPU_MODEL_NAME "i486dx"
97#elif defined(__i386__)
99 #define I386_HAS_BSWAP 0
100 #define CPU_MODEL_NAME "i386 with i387"
103 #error "Unknown CPU Model"
111#ifndef I386_HAS_BSWAP
112#define I386_HAS_BSWAP 1
118#define CPU_NAME "Intel i386"
127static inline uint32_t i386_swap_u32(
133#if (I386_HAS_BSWAP == 0)
134 __asm__ volatile(
"rorw $8,%%ax;"
136 "rorw $8,%%ax" :
"=a" (lout) :
"0" (value) );
138 __asm__ volatile(
"bswap %0" :
"=r" (lout) :
"0" (value));
142#define CPU_swap_u32( _value ) i386_swap_u32( _value )
144static inline uint16_t i386_swap_u16(
150 __asm__ volatile(
"rorw $8,%0" :
"=r" (sout) :
"0" (value));
153#define CPU_swap_u16( _value ) i386_swap_u16( _value )
158static inline unsigned int i386_get_cr0(
void)
160 unsigned int segment = 0;
162 __asm__ volatile (
"movl %%cr0,%0" :
"=r" (segment) :
"0" (segment) );
167static inline void i386_set_cr0(
unsigned int segment)
169 __asm__ volatile (
"movl %0,%%cr0" :
"=r" (segment) :
"0" (segment) );
172static inline unsigned int i386_get_cr2(
void)
174 unsigned int segment = 0;
176 __asm__ volatile (
"movl %%cr2,%0" :
"=r" (segment) :
"0" (segment) );
181static inline unsigned int i386_get_cr3(
void)
183 unsigned int segment = 0;
185 __asm__ volatile (
"movl %%cr3,%0" :
"=r" (segment) :
"0" (segment) );
190static inline void i386_set_cr3(
unsigned int segment)
192 __asm__ volatile (
"movl %0,%%cr3" :
"=r" (segment) :
"0" (segment) );
202void *i386_Logical_to_physical(
203 unsigned short segment,
212void *i386_Physical_to_logical(
213 unsigned short segment,
226static inline void *i386_Real_to_physical(
230 return (
void *)(((uint32_t)segment<<4)+offset);
265static __inline__
unsigned short i386_get_cs(
void)
267 unsigned short segment = 0;
269 __asm__ volatile (
"movw %%cs,%0" :
"=r" (segment) :
"0" (segment) );
274static __inline__
unsigned short i386_get_ds(
void)
276 unsigned short segment = 0;
278 __asm__ volatile (
"movw %%ds,%0" :
"=r" (segment) :
"0" (segment) );
283static __inline__
unsigned short i386_get_es(
void)
285 unsigned short segment = 0;
287 __asm__ volatile (
"movw %%es,%0" :
"=r" (segment) :
"0" (segment) );
292static __inline__
unsigned short i386_get_ss(
void)
294 unsigned short segment = 0;
296 __asm__ volatile (
"movw %%ss,%0" :
"=r" (segment) :
"0" (segment) );
301static __inline__
unsigned short i386_get_fs(
void)
303 unsigned short segment = 0;
305 __asm__ volatile (
"movw %%fs,%0" :
"=r" (segment) :
"0" (segment) );
310static __inline__
unsigned short i386_get_gs(
void)
312 unsigned short segment = 0;
314 __asm__ volatile (
"movw %%gs,%0" :
"=r" (segment) :
"0" (segment) );
323#define i386_outport_byte( _port, _value ) \
324do { unsigned short __port = _port; \
325 unsigned char __value = _value; \
327 __asm__ volatile ( "outb %0,%1" : : "a" (__value), "d" (__port) ); \
330#define i386_outport_word( _port, _value ) \
331do { unsigned short __port = _port; \
332 unsigned short __value = _value; \
334 __asm__ volatile ( "outw %0,%1" : : "a" (__value), "d" (__port) ); \
337#define i386_outport_long( _port, _value ) \
338do { unsigned short __port = _port; \
339 unsigned int __value = _value; \
341 __asm__ volatile ( "outl %0,%1" : : "a" (__value), "d" (__port) ); \
344#define i386_inport_byte( _port, _value ) \
345do { unsigned short __port = _port; \
346 unsigned char __value = 0; \
348 __asm__ volatile ( "inb %1,%0" : "=a" (__value) \
354#define i386_inport_word( _port, _value ) \
355do { unsigned short __port = _port; \
356 unsigned short __value = 0; \
358 __asm__ volatile ( "inw %1,%0" : "=a" (__value) \
364#define i386_inport_long( _port, _value ) \
365do { unsigned short __port = _port; \
366 unsigned int __value = 0; \
368 __asm__ volatile ( "inl %1,%0" : "=a" (__value) \
378typedef unsigned char rtems_vector_offset;
384 rtems_vector_offset idtIndex;
388 rtems_raw_irq_hdl hdl;
397 rtems_raw_irq_enable on;
406 rtems_raw_irq_disable off;
410 rtems_raw_irq_is_enabled isOn;
417 unsigned int idtSize;
434rtems_raw_irq_hdl get_hdl_from_vector(rtems_vector_offset);
473 unsigned int limit_15_0 : 16;
474 unsigned int base_address_15_0 : 16;
475 unsigned int base_address_23_16 : 8;
476 unsigned int type : 4;
477 unsigned int descriptor_type : 1;
478 unsigned int privilege : 2;
479 unsigned int present : 1;
480 unsigned int limit_19_16 : 4;
481 unsigned int available : 1;
482 unsigned int fixed_value_bits : 1;
483 unsigned int operation_size : 1;
484 unsigned int granularity : 1;
485 unsigned int base_address_31_24 : 8;
492extern void i386_get_info_from_GDTR (segment_descriptors** table,
498extern void i386_set_GDTR (segment_descriptors*,
514 segment_descriptors* sd);
523 segment_descriptors* sd);
534 segment_descriptors* sd);
539extern uint32_t i386_set_gdt_entry (uint16_t segment_selector,
563 segment_descriptors* struct_to_fill);
580static inline void* i386_base_gdt_entry (segment_descriptors* gdt_entry)
582 return (
void*)(gdt_entry->base_address_15_0 |
583 (gdt_entry->base_address_23_16<<16) |
584 (gdt_entry->base_address_31_24<<24));
601 unsigned int offset : 12;
602 unsigned int page : 10;
603 unsigned int directory : 10;
608 unsigned int address;
618 unsigned int present : 1;
619 unsigned int writable : 1;
620 unsigned int user : 1;
621 unsigned int write_through : 1;
622 unsigned int cache_disable : 1;
623 unsigned int accessed : 1;
624 unsigned int reserved1 : 1;
625 unsigned int page_size : 1;
626 unsigned int reserved2 : 1;
627 unsigned int available : 3;
628 unsigned int page_frame_address : 20;
633 unsigned int dir_entry;
637 unsigned int present : 1;
638 unsigned int writable : 1;
639 unsigned int user : 1;
640 unsigned int write_through : 1;
641 unsigned int cache_disable : 1;
642 unsigned int accessed : 1;
643 unsigned int dirty : 1;
644 unsigned int reserved2 : 2;
645 unsigned int available : 3;
646 unsigned int page_frame_address : 20;
651 unsigned int table_entry;
657#define PG_SIZE 0x1000
658#define MASK_OFFSET 0xFFF
659#define MAX_ENTRY (PG_SIZE/sizeof(page_dir_entry))
660#define FOUR_MB 0x400000
661#define MASK_FLAGS 0x1A
663#define PTE_PRESENT 0x01
664#define PTE_WRITABLE 0x02
666#define PTE_WRITE_THROUGH 0x08
667#define PTE_CACHE_DISABLE 0x10
678#define outport_byte( _port, _value ) i386_outport_byte( _port, _value )
679#define outport_word( _port, _value ) i386_outport_word( _port, _value )
680#define outport_long( _port, _value ) i386_outport_long( _port, _value )
681#define inport_byte( _port, _value ) i386_inport_byte( _port, _value )
682#define inport_word( _port, _value ) i386_inport_word( _port, _value )
683#define inport_long( _port, _value ) i386_inport_long( _port, _value )
register struct Per_CPU_Control *_SPARC_Per_CPU_current __asm__("g6")
The pointer to the current per-CPU control is available via register g6.
Intel CPU Constants and Definitions.
void i386_fill_segment_desc_limit(uint32_t limit, segment_descriptors *sd)
fills sd with provided limit in appropriate fields of sd
Definition: idt.c:293
void i386_fill_segment_desc_base(uint32_t base, segment_descriptors *sd)
fills sd with provided base in appropriate fields of sd
Definition: idt.c:285
int i386_Physical_to_real(void *address, uint16_t *segment, uint16_t *offset)
Retrieves real mode pointer elements {segmnet, offset} from physical address.
uint32_t i386_limit_gdt_entry(segment_descriptors *gdt_entry)
Extracts limit in bytes from GDT entry pointed to by gdt_entry.
Definition: idt.c:374
uint16_t i386_next_empty_gdt_entry(void)
Returns next empty descriptor in GDT.
Definition: idt.c:330
uint32_t i386_raw_gdt_entry(uint16_t segment_selector_index, segment_descriptors *sd)
Allows to set a GDT entry.
Definition: idt.c:243
uint16_t i386_cpy_gdt_entry(uint16_t segment_selector, segment_descriptors *struct_to_fill)
Copies GDT entry at index segment_selector to structure pointed to by struct_to_fill.
Definition: idt.c:345
segment_descriptors * i386_get_gdt_entry(uint16_t sgmnt_selector)
Returns pointer to GDT table at index given by segment_selector.
Definition: idt.c:361
Intel I386 Data Structures.
Intel I386 Interrupt Macros.
Used for passing and retrieving registers content to/from real mode interrupt call.
Definition: realmode_int.h:43
Definition: deflate.c:114