24 #ifndef _RTEMS_SCORE_I386_H 25 #define _RTEMS_SCORE_I386_H 58 #define I386_HAS_FPU 1 60 #if defined(__pentiumpro__) 62 #define CPU_MODEL_NAME "Pentium Pro" 64 #elif defined(__i586__) 66 #if defined(__pentium__) 67 #define CPU_MODEL_NAME "Pentium" 69 #define CPU_MODEL_NAME "K6" 71 #define CPU_MODEL_NAME "i586" 74 #elif defined(__i486__) 76 #define CPU_MODEL_NAME "i486dx" 78 #elif defined(__i386__) 80 #define I386_HAS_BSWAP 0 81 #define CPU_MODEL_NAME "i386 with i387" 84 #error "Unknown CPU Model" 92 #ifndef I386_HAS_BSWAP 93 #define I386_HAS_BSWAP 1 99 #define CPU_NAME "Intel i386" 108 static inline uint32_t i386_swap_u32(
114 #if (I386_HAS_BSWAP == 0) 115 __asm__ volatile(
"rorw $8,%%ax;" 117 "rorw $8,%%ax" :
"=a" (lout) :
"0" (value) );
119 __asm__ volatile(
"bswap %0" :
"=r" (lout) :
"0" (value));
123 #define CPU_swap_u32( _value ) i386_swap_u32( _value ) 125 static inline uint16_t i386_swap_u16(
131 __asm__ volatile(
"rorw $8,%0" :
"=r" (sout) :
"0" (value));
134 #define CPU_swap_u16( _value ) i386_swap_u16( _value ) 139 static inline unsigned int i386_get_cr0(
void)
141 unsigned int segment = 0;
143 __asm__ volatile (
"movl %%cr0,%0" :
"=r" (segment) :
"0" (segment) );
148 static inline void i386_set_cr0(
unsigned int segment)
150 __asm__ volatile (
"movl %0,%%cr0" :
"=r" (segment) :
"0" (segment) );
153 static inline unsigned int i386_get_cr2(
void)
155 unsigned int segment = 0;
157 __asm__ volatile (
"movl %%cr2,%0" :
"=r" (segment) :
"0" (segment) );
162 static inline unsigned int i386_get_cr3(
void)
164 unsigned int segment = 0;
166 __asm__ volatile (
"movl %%cr3,%0" :
"=r" (segment) :
"0" (segment) );
171 static inline void i386_set_cr3(
unsigned int segment)
173 __asm__ volatile (
"movl %0,%%cr3" :
"=r" (segment) :
"0" (segment) );
183 void *i386_Logical_to_physical(
184 unsigned short segment,
193 void *i386_Physical_to_logical(
194 unsigned short segment,
211 return (
void *)(((uint32_t)segment<<4)+offset);
246 static __inline__
unsigned short i386_get_cs(
void)
248 unsigned short segment = 0;
250 __asm__ volatile (
"movw %%cs,%0" :
"=r" (segment) :
"0" (segment) );
255 static __inline__
unsigned short i386_get_ds(
void)
257 unsigned short segment = 0;
259 __asm__ volatile (
"movw %%ds,%0" :
"=r" (segment) :
"0" (segment) );
264 static __inline__
unsigned short i386_get_es(
void)
266 unsigned short segment = 0;
268 __asm__ volatile (
"movw %%es,%0" :
"=r" (segment) :
"0" (segment) );
273 static __inline__
unsigned short i386_get_ss(
void)
275 unsigned short segment = 0;
277 __asm__ volatile (
"movw %%ss,%0" :
"=r" (segment) :
"0" (segment) );
282 static __inline__
unsigned short i386_get_fs(
void)
284 unsigned short segment = 0;
286 __asm__ volatile (
"movw %%fs,%0" :
"=r" (segment) :
"0" (segment) );
291 static __inline__
unsigned short i386_get_gs(
void)
293 unsigned short segment = 0;
295 __asm__ volatile (
"movw %%gs,%0" :
"=r" (segment) :
"0" (segment) );
304 #define i386_outport_byte( _port, _value ) \ 305 do { unsigned short __port = _port; \ 306 unsigned char __value = _value; \ 308 __asm__ volatile ( "outb %0,%1" : : "a" (__value), "d" (__port) ); \ 311 #define i386_outport_word( _port, _value ) \ 312 do { unsigned short __port = _port; \ 313 unsigned short __value = _value; \ 315 __asm__ volatile ( "outw %0,%1" : : "a" (__value), "d" (__port) ); \ 318 #define i386_outport_long( _port, _value ) \ 319 do { unsigned short __port = _port; \ 320 unsigned int __value = _value; \ 322 __asm__ volatile ( "outl %0,%1" : : "a" (__value), "d" (__port) ); \ 325 #define i386_inport_byte( _port, _value ) \ 326 do { unsigned short __port = _port; \ 327 unsigned char __value = 0; \ 329 __asm__ volatile ( "inb %1,%0" : "=a" (__value) \ 335 #define i386_inport_word( _port, _value ) \ 336 do { unsigned short __port = _port; \ 337 unsigned short __value = 0; \ 339 __asm__ volatile ( "inw %1,%0" : "=a" (__value) \ 345 #define i386_inport_long( _port, _value ) \ 346 do { unsigned short __port = _port; \ 347 unsigned int __value = 0; \ 349 __asm__ volatile ( "inl %1,%0" : "=a" (__value) \ 359 typedef unsigned char rtems_vector_offset;
365 rtems_vector_offset idtIndex;
369 rtems_raw_irq_hdl hdl;
378 rtems_raw_irq_enable on;
387 rtems_raw_irq_disable off;
391 rtems_raw_irq_is_enabled isOn;
398 unsigned int idtSize;
415 rtems_raw_irq_hdl get_hdl_from_vector(rtems_vector_offset);
454 unsigned int limit_15_0 : 16;
455 unsigned int base_address_15_0 : 16;
456 unsigned int base_address_23_16 : 8;
457 unsigned int type : 4;
458 unsigned int descriptor_type : 1;
459 unsigned int privilege : 2;
460 unsigned int present : 1;
461 unsigned int limit_19_16 : 4;
462 unsigned int available : 1;
463 unsigned int fixed_value_bits : 1;
464 unsigned int operation_size : 1;
465 unsigned int granularity : 1;
466 unsigned int base_address_31_24 : 8;
473 extern void i386_get_info_from_GDTR (segment_descriptors** table,
479 extern void i386_set_GDTR (segment_descriptors*,
495 segment_descriptors* sd);
504 segment_descriptors* sd);
515 segment_descriptors* sd);
520 extern uint32_t i386_set_gdt_entry (uint16_t segment_selector,
544 segment_descriptors* struct_to_fill);
563 return (
void*)(gdt_entry->base_address_15_0 |
564 (gdt_entry->base_address_23_16<<16) |
565 (gdt_entry->base_address_31_24<<24));
582 unsigned int offset : 12;
583 unsigned int page : 10;
584 unsigned int directory : 10;
589 unsigned int address;
599 unsigned int present : 1;
600 unsigned int writable : 1;
601 unsigned int user : 1;
602 unsigned int write_through : 1;
603 unsigned int cache_disable : 1;
604 unsigned int accessed : 1;
605 unsigned int reserved1 : 1;
606 unsigned int page_size : 1;
607 unsigned int reserved2 : 1;
608 unsigned int available : 3;
609 unsigned int page_frame_address : 20;
614 unsigned int dir_entry;
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 dirty : 1;
625 unsigned int reserved2 : 2;
626 unsigned int available : 3;
627 unsigned int page_frame_address : 20;
632 unsigned int table_entry;
638 #define PG_SIZE 0x1000 639 #define MASK_OFFSET 0xFFF 640 #define MAX_ENTRY (PG_SIZE/sizeof(page_dir_entry)) 641 #define FOUR_MB 0x400000 642 #define MASK_FLAGS 0x1A 644 #define PTE_PRESENT 0x01 645 #define PTE_WRITABLE 0x02 646 #define PTE_USER 0x04 647 #define PTE_WRITE_THROUGH 0x08 648 #define PTE_CACHE_DISABLE 0x10 659 #define outport_byte( _port, _value ) i386_outport_byte( _port, _value ) 660 #define outport_word( _port, _value ) i386_outport_word( _port, _value ) 661 #define outport_long( _port, _value ) i386_outport_long( _port, _value ) 662 #define inport_byte( _port, _value ) i386_inport_byte( _port, _value ) 663 #define inport_word( _port, _value ) i386_inport_word( _port, _value ) 664 #define inport_long( _port, _value ) i386_inport_long( _port, _value ) Definition: deflate.c:115
Intel I386 Data Structures.
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
uint16_t i386_next_empty_gdt_entry(void)
Returns next empty descriptor in GDT.
Definition: idt.c:330
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
Intel CPU Constants and Definitions.
Intel I386 Interrupt Macros.
Used for passing and retrieving registers content to/from real mode interrupt call.
Definition: realmode_int.h:43
register struct Per_CPU_Control *_SPARC_Per_CPU_current __asm__("g6")
The pointer to the current per-CPU control is available via register g6.
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
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
RTEMS_INLINE_ROUTINE void * i386_base_gdt_entry(segment_descriptors *gdt_entry)
Extracts base address from GDT entry pointed to by gdt_entry.
Definition: i386.h:561
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
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_raw_gdt_entry(uint16_t segment_selector_index, segment_descriptors *sd)
Allows to set a GDT entry.
Definition: idt.c:243
RTEMS_INLINE_ROUTINE void * i386_Real_to_physical(uint16_t segment, uint16_t offset)
Converts real mode pointer {segment, offset} to physical address.
Definition: i386.h:207
#define RTEMS_INLINE_ROUTINE
Definition: basedefs.h:66