i386: Support thread-local storage (TLS)

Update #2468.
This commit is contained in:
Sebastian Huber
2017-06-09 15:42:36 +02:00
parent cb0d9a0747
commit 7b0c74ffb0
7 changed files with 73 additions and 16 deletions

View File

@@ -20,4 +20,5 @@
#include <bspopts.h>
#define IDT_SIZE (256)
#define GDT_SIZE (3 + NUM_APP_DRV_GDT_DESCRIPTORS)
#define NUM_SYSTEM_GDT_DESCRIPTORS 4
#define GDT_SIZE (NUM_SYSTEM_GDT_DESCRIPTORS + NUM_APP_DRV_GDT_DESCRIPTORS)

View File

@@ -171,8 +171,8 @@ next_step:
/*---------------------------------------------------------------------------+
| GDT itself
+--------------------------------------------------------------------------*/
#if GDT_SIZE < 3
#error "GDT_SIZE must be at least 3"
#if GDT_SIZE < NUM_SYSTEM_GDT_DESCRIPTORS
#error "GDT_SIZE must be at least NUM_SYSTEM_GDT_DESCRIPTORS"
#endif
BEGIN_DATA
@@ -193,8 +193,12 @@ SYM (_Global_descriptor_table):
.word 0xffff, 0
.byte 0, 0x92, 0xcf, 0
/* gs segment */
.word 0xffff, 0
.byte 0, 0x92, 0xcf, 0
/* allocated space for user segments */
.rept (GDT_SIZE - 3)
.rept (GDT_SIZE - NUM_SYSTEM_GDT_DESCRIPTORS)
.word 0,0,0,0
.endr

View File

@@ -18,6 +18,7 @@
#include <rtems/score/cpu.h>
#include <bsp/irq.h>
#include <bsp/tblsizes.h>
/*
* This locking is not enough if IDT is changed at runtime
@@ -331,7 +332,7 @@ uint16_t i386_next_empty_gdt_entry ()
uint16_t gdt_limit;
segment_descriptors* gdt_entry_tbl;
/* initial amount of filled descriptors */
static uint16_t segment_selector_index = 2;
static uint16_t segment_selector_index = NUM_SYSTEM_GDT_DESCRIPTORS - 1;
segment_selector_index += 1;
i386_get_info_from_GDTR (&gdt_entry_tbl, &gdt_limit);