forked from Imagelibrary/rtems
i386: global descriptor table manipulation functions
This commit is contained in:
committed by
Gedare Bloom
parent
b2db1f5c76
commit
74d2d94041
@@ -28,7 +28,7 @@
|
||||
*/
|
||||
#include <rtems/score/interrupts.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <rtems/score/basedefs.h>
|
||||
|
||||
/*
|
||||
* Segment Access Routines
|
||||
@@ -256,7 +256,7 @@ typedef struct {
|
||||
unsigned int operation_size : 1;
|
||||
unsigned int granularity : 1;
|
||||
unsigned int base_address_31_24 : 8;
|
||||
}segment_descriptors;
|
||||
} RTEMS_COMPILER_PACKED_ATTRIBUTE segment_descriptors;
|
||||
|
||||
/*
|
||||
* C callable function enabling to get easilly usable info from
|
||||
@@ -271,11 +271,94 @@ extern void i386_get_info_from_GDTR (segment_descriptors** table,
|
||||
extern void i386_set_GDTR (segment_descriptors*,
|
||||
uint16_t limit);
|
||||
|
||||
/**
|
||||
* C callable function:
|
||||
* Puts global descriptor @sd to the global descriptor table on index
|
||||
* @segment_selector_index
|
||||
*
|
||||
* @retval 0 FAILED out of GDT range or index is 0, which is not valid
|
||||
* index in GDT
|
||||
* 1 SUCCESS
|
||||
*/
|
||||
extern uint32_t i386_raw_gdt_entry (uint16_t segment_selector_index,
|
||||
segment_descriptors* sd);
|
||||
|
||||
/**
|
||||
* C callable function
|
||||
* fills @sd with provided @base in appropriate fields of @sd
|
||||
*
|
||||
* @param base 32-bit address to be set as descriptor's base
|
||||
* @param sd descriptor being filled with @base
|
||||
*/
|
||||
extern void i386_fill_segment_desc_base (uint32_t base,
|
||||
segment_descriptors* sd);
|
||||
|
||||
/**
|
||||
* C callable function
|
||||
* fills @sd with provided @limit in appropriate fields of @sd
|
||||
* also influences granularity bit
|
||||
*
|
||||
* @param limit 32-bit value representing number of limit bytes
|
||||
* @param sd descriptor being filled with @limit
|
||||
*/
|
||||
extern void i386_fill_segment_desc_limit (uint32_t limit,
|
||||
segment_descriptors* sd);
|
||||
|
||||
/*
|
||||
* C callable function enabling to set up one raw interrupt handler
|
||||
*/
|
||||
extern int i386_set_gdt_entry (unsigned short segment_selector, unsigned base,
|
||||
unsigned limit);
|
||||
extern uint32_t i386_set_gdt_entry (uint16_t segment_selector,
|
||||
uint32_t base,
|
||||
uint32_t limit);
|
||||
|
||||
/**
|
||||
* C callable function returns next empty descriptor in GDT.
|
||||
*
|
||||
* @retval 0 FAILED GDT is full
|
||||
* <1;65535> segment_selector number as index to GDT
|
||||
*/
|
||||
extern uint16_t i386_next_empty_gdt_entry (void);
|
||||
|
||||
/**
|
||||
* Copies GDT entry at index @segment_selector to structure
|
||||
* pointed to by @struct_to_fill
|
||||
*
|
||||
* @param segment_selector index to GDT table for specifying descriptor to copy
|
||||
* @retval 0 FAILED segment_selector out of GDT range
|
||||
* <1;65535> retrieved segment_selector
|
||||
*/
|
||||
extern uint16_t i386_cpy_gdt_entry (uint16_t segment_selector,
|
||||
segment_descriptors* struct_to_fill);
|
||||
|
||||
/**
|
||||
* Returns pointer to GDT table at index given by @segment_selector
|
||||
*
|
||||
* @param segment_selector index to GDT table for specifying descriptor to get
|
||||
* @retval NULL FAILED segment_selector out of GDT range
|
||||
* pointer to GDT table at @segment_selector
|
||||
*/
|
||||
extern segment_descriptors* i386_get_gdt_entry (uint16_t sgmnt_selector);
|
||||
|
||||
/**
|
||||
* Extracts base address from GDT entry pointed to by @gdt_entry
|
||||
*
|
||||
* @param gdt_entry pointer to entry from which base should be retrieved
|
||||
* @retval base address from GDT entry
|
||||
*/
|
||||
RTEMS_INLINE_ROUTINE void* i386_base_gdt_entry (segment_descriptors* gdt_entry)
|
||||
{
|
||||
return (void*)(gdt_entry->base_address_15_0 |
|
||||
(gdt_entry->base_address_23_16<<16) |
|
||||
(gdt_entry->base_address_31_24<<24));
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts limit in bytes from GDT entry pointed to by @gdt_entry
|
||||
*
|
||||
* @param gdt_entry pointer to entry from which limit should be retrieved
|
||||
* @retval limit value in bytes from GDT entry
|
||||
*/
|
||||
extern uint32_t i386_limit_gdt_entry (segment_descriptors* gdt_entry);
|
||||
|
||||
/*
|
||||
* See page 11.18 Figure 11-12.
|
||||
|
||||
Reference in New Issue
Block a user