RTEMS: cpukit/score/cpu/i386/include/rtems/score/i386.h File Reference

| RTEMS 5.4-rc2

Loading...
Searching...
No Matches
Data Structures | Macros | Typedefs | Functions
i386.h File Reference

Intel I386 CPU Dependent Source. More...

`#include <rtems/score/interrupts.h>`
`#include <rtems/score/registers.h>`
`#include <rtems/score/idtr.h>`

Go to the source code of this file.

## Data Structures
struct | __rtems_raw_irq_connect_data__
struct | rtems_raw_irq_global_settings
struct | RTEMS_PACKED
| Used for passing and retrieving registers content to/from real mode interrupt call. More...
struct | la_bits
union | linear_address
struct | page_dir_bits
union | page_dir_entry
struct | page_table_bits
union | page_table_entry
struct | page_directory
struct | page_table

## Macros
#define | I386_HAS_FPU 1
#define | I386_HAS_BSWAP 1
#define | CPU_NAME "Intel i386"
#define | CPU_swap_u32(_value) i386_swap_u32( _value )
#define | CPU_swap_u16(_value) i386_swap_u16( _value )
#define | i386_outport_byte(_port, _value)
#define | i386_outport_word(_port, _value)
#define | i386_outport_long(_port, _value)
#define | i386_inport_byte(_port, _value)
#define | i386_inport_word(_port, _value)
#define | i386_inport_long(_port, _value)
#define | PG_SIZE 0x1000
#define | MASK_OFFSET 0xFFF
#define | MAX_ENTRY (PG_SIZE/sizeof(page_dir_entry))
#define | FOUR_MB 0x400000
#define | MASK_FLAGS 0x1A
#define | PTE_PRESENT 0x01
#define | PTE_WRITABLE 0x02
#define | PTE_USER 0x04
#define | PTE_WRITE_THROUGH 0x08
#define | PTE_CACHE_DISABLE 0x10
#define | outport_byte(_port, _value) i386_outport_byte( _port, _value )
#define | outport_word(_port, _value) i386_outport_word( _port, _value )
#define | outport_long(_port, _value) i386_outport_long( _port, _value )
#define | inport_byte(_port, _value) i386_inport_byte( _port, _value )
#define | inport_word(_port, _value) i386_inport_word( _port, _value )
#define | inport_long(_port, _value) i386_inport_long( _port, _value )

## Typedefs
typedef unsigned char | rtems_vector_offset
typedef struct __rtems_raw_irq_connect_data__ | rtems_raw_irq_connect_data

## Functions
void * | i386_Logical_to_physical (unsigned short segment, void *address)
void * | i386_Physical_to_logical (unsigned short segment, void *address)
RTEMS_INLINE_ROUTINE void * | i386_Real_to_physical (uint16_t segment, uint16_t offset)
| Converts real mode pointer {segment, offset} to physical address.
int | i386_Physical_to_real (void *address, uint16_t *segment, uint16_t *offset)
| Retrieves real mode pointer elements {segmnet, offset} from physical address.
rtems_raw_irq_hdl | get_hdl_from_vector (rtems_vector_offset)
int | i386_set_idt_entry (const rtems_raw_irq_connect_data *)
int | i386_get_current_idt_entry (rtems_raw_irq_connect_data *)
int | i386_delete_idt_entry (const rtems_raw_irq_connect_data *)
int | i386_init_idt (rtems_raw_irq_global_settings *config)
int | i386_get_idt_config (rtems_raw_irq_global_settings **config)
void | i386_get_info_from_GDTR (segment_descriptors **table, uint16_t *limit)
void | i386_set_GDTR (segment_descriptors *, uint16_t limit)
uint32_t | i386_raw_gdt_entry (uint16_t segment_selector_index, segment_descriptors *sd)
| Allows to set a GDT entry.
void | i386_fill_segment_desc_base (uint32_t base, segment_descriptors *sd)
| fills `sd` with provided `base` in appropriate fields of `sd`
void | i386_fill_segment_desc_limit (uint32_t limit, segment_descriptors *sd)
| fills `sd` with provided `limit` in appropriate fields of `sd`
uint32_t | i386_set_gdt_entry (uint16_t segment_selector, uint32_t base, uint32_t limit)
uint16_t | i386_next_empty_gdt_entry (void)
| Returns next empty descriptor in GDT.
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`.
segment_descriptors * | i386_get_gdt_entry (uint16_t sgmnt_selector)
| Returns pointer to GDT table at index given by `segment_selector`.
RTEMS_INLINE_ROUTINE void * | i386_base_gdt_entry (segment_descriptors *gdt_entry)
| Extracts base address from GDT entry pointed to by `gdt_entry`.
uint32_t | i386_limit_gdt_entry (segment_descriptors *gdt_entry)
| Extracts limit in bytes from GDT entry pointed to by `gdt_entry`.

## Detailed Description

Intel I386 CPU Dependent Source.

## Macro Definition Documentation

## ◆ i386_inport_byte

#define i386_inport_byte | ( |  | _port,
|  |  | _value
| ) |  |

Value:
do { unsigned short __port = _port; \
unsigned char __value = 0; \
\
__asm__ volatile ( "inb %1,%0" : "=a" (__value) \
: "d" (__port) \
); \
_value = __value; \
} while (0)

## ◆ i386_inport_long

#define i386_inport_long | ( |  | _port,
|  |  | _value
| ) |  |

Value:
do { unsigned short __port = _port; \
unsigned int __value = 0; \
\
__asm__ volatile ( "inl %1,%0" : "=a" (__value) \
: "d" (__port) \
); \
_value = __value; \
} while (0)

## ◆ i386_inport_word

#define i386_inport_word | ( |  | _port,
|  |  | _value
| ) |  |

Value:
do { unsigned short __port = _port; \
unsigned short __value = 0; \
\
__asm__ volatile ( "inw %1,%0" : "=a" (__value) \
: "d" (__port) \
); \
_value = __value; \
} while (0)

## ◆ i386_outport_byte

#define i386_outport_byte | ( |  | _port,
|  |  | _value
| ) |  |

Value:
do { unsigned short __port = _port; \
unsigned char __value = _value; \
\
__asm__ volatile ( "outb %0,%1" : : "a" (__value), "d" (__port) ); \
} while (0)

## ◆ i386_outport_long

#define i386_outport_long | ( |  | _port,
|  |  | _value
| ) |  |

Value:
do { unsigned short __port = _port; \
unsigned int __value = _value; \
\
__asm__ volatile ( "outl %0,%1" : : "a" (__value), "d" (__port) ); \
} while (0)

## ◆ i386_outport_word

#define i386_outport_word | ( |  | _port,
|  |  | _value
| ) |  |

Value:
do { unsigned short __port = _port; \
unsigned short __value = _value; \
\
__asm__ volatile ( "outw %0,%1" : : "a" (__value), "d" (__port) ); \
} while (0)

## Function Documentation

## ◆ i386_base_gdt_entry()

RTEMS_INLINE_ROUTINE void * i386_base_gdt_entry | ( | segment_descriptors * | gdt_entry | ) |

Extracts base address from GDT entry pointed to by `gdt_entry`.

Parameters

  [in] | gdt_entry | pointer to entry from which base should be retrieved

Return values

  base | address from GDT entry

## ◆ i386_cpy_gdt_entry()

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`.

Parameters

  [in] | segment_selector | index to GDT table specifying descriptor to copy
  [out] | struct_to_fill | pointer to memory where will be descriptor coppied

Return values

  0 | FAILED segment_selector out of GDT range
  <1;65535> | retrieved segment_selector

## ◆ i386_fill_segment_desc_base()

void i386_fill_segment_desc_base | ( | uint32_t | base,
|  | segment_descriptors * | sd
| ) |  |

fills `sd` with provided `base` in appropriate fields of `sd`

Parameters

  [in] | base | 32-bit address to be set as descriptor's base
  [out] | sd | descriptor being filled with `base`

## ◆ i386_fill_segment_desc_limit()

void i386_fill_segment_desc_limit | ( | uint32_t | limit,
|  | segment_descriptors * | sd
| ) |  |

fills `sd` with provided `limit` in appropriate fields of `sd`

sets granularity bit if necessary

Parameters

  [in] | limit | 32-bit value representing number of limit bytes
  [out] | sd | descriptor being filled with `limit`

## ◆ i386_get_gdt_entry()

segment_descriptors * i386_get_gdt_entry | ( | uint16_t | sgmnt_selector | ) |

Returns pointer to GDT table at index given by `segment_selector`.

Parameters

  [in] | sgmnt_selector | index to GDT table for specifying descriptor to get

Return values

  NULL | FAILED segment_selector out of GDT range
  pointer | to GDT table at `segment_selector`

## ◆ i386_limit_gdt_entry()

uint32_t i386_limit_gdt_entry | ( | segment_descriptors * | gdt_entry | ) |

Extracts limit in bytes from GDT entry pointed to by `gdt_entry`.

Parameters

  [in] | gdt_entry | pointer to entry from which limit should be retrieved

Return values

  limit | value in bytes from GDT entry

## ◆ i386_next_empty_gdt_entry()

uint16_t i386_next_empty_gdt_entry | ( | void |  | ) |

Returns next empty descriptor in GDT.

Number of descriptors that can be returned depends on GDT_SIZE

Return values

  0 | FAILED GDT is full
  <1;65535> | segment_selector number as index to GDT

## ◆ i386_Physical_to_real()

int i386_Physical_to_real | ( | void * | address,
|  | uint16_t * | segment,
|  | uint16_t * | offset
| ) |  |

Retrieves real mode pointer elements {segmnet, offset} from physical address.

i386_Physical_to_real Function returns the highest segment (base) address possible. Example: input address - 0x4B3A2 output segment - 0x4B3A offset - 0x2 input address - 0x10F12E output segment - 0xFFFF offset - 0xF13E

Parameters

  [in] | address | address to be converted, must be less than 0x10FFEF
  [out] | segment | segment computed from `address`
  [out] | offset | offset computed from `address`

Return values

  0 | address not convertible
  1 | segment and offset extracted

## ◆ i386_raw_gdt_entry()

uint32_t i386_raw_gdt_entry | ( | uint16_t | segment_selector_index,
|  | segment_descriptors * | sd
| ) |  |

Allows to set a GDT entry.

Puts global descriptor `sd` to the global descriptor table on index `segment_selector_index`

Parameters

  [in] | segment_selector_index | index to GDT entry
  [in] | sd | structure to be coppied to given `segment_selector` in GDT

Return values

  0 | FAILED out of GDT range or index is 0, which is not valid index in GDT
  1 | SUCCESS

## ◆ i386_Real_to_physical()

RTEMS_INLINE_ROUTINE void * i386_Real_to_physical | ( | uint16_t | segment,
|  | uint16_t | offset
| ) |  |

Converts real mode pointer {segment, offset} to physical address.

i386_Real_to_physical

Parameters

  [in] | segment | used with `offset` to compute physical address
  [in] | offset | used with `segment` to compute physical address

Return values

  physical | address