[PATCH 1/8] i386/pc386: configurable size of descriptor tables

Jan Dolezal dolezj21 at fel.cvut.cz
Thu Nov 20 14:00:26 UTC 2014


---
 c/src/lib/libbsp/i386/pc386/Makefile.am        |  1 +
 c/src/lib/libbsp/i386/pc386/configure.ac       |  5 +++++
 c/src/lib/libbsp/i386/pc386/include/bsp.h      |  6 ++----
 c/src/lib/libbsp/i386/pc386/include/tblsizes.h | 25 +++++++++++++++++++++++++
 c/src/lib/libbsp/i386/pc386/preinstall.am      |  4 ++++
 c/src/lib/libbsp/i386/pc386/startup/ldsegs.S   | 18 ++++++++++++++----
 6 files changed, 51 insertions(+), 8 deletions(-)
 create mode 100644 c/src/lib/libbsp/i386/pc386/include/tblsizes.h

diff --git a/c/src/lib/libbsp/i386/pc386/Makefile.am b/c/src/lib/libbsp/i386/pc386/Makefile.am
index 22ba5e9..23a46da 100644
--- a/c/src/lib/libbsp/i386/pc386/Makefile.am
+++ b/c/src/lib/libbsp/i386/pc386/Makefile.am
@@ -32,6 +32,7 @@ include_bsp_HEADERS += ../../shared/include/irq-generic.h
 include_bsp_HEADERS += ../../shared/include/irq-info.h
 include_bsp_HEADERS += console/rtd316.h
 include_bsp_HEADERS += console/exar17d15x.h
+include_bsp_HEADERS += include/tblsizes.h
 
 if HAS_SMP
 include_bsp_HEADERS += ../../i386/shared/irq/apic.h
diff --git a/c/src/lib/libbsp/i386/pc386/configure.ac b/c/src/lib/libbsp/i386/pc386/configure.ac
index 1125c7c..ecec056 100644
--- a/c/src/lib/libbsp/i386/pc386/configure.ac
+++ b/c/src/lib/libbsp/i386/pc386/configure.ac
@@ -82,6 +82,11 @@ RTEMS_BSPOPTS_HELP([USE_CIRRUS_GD5446],
  NOTE: This has only been tested on Qemu.])
 AM_CONDITIONAL(USE_CIRRUS_GD5446,test "$USE_CIRRUS_GD5446" = "1")
 
+RTEMS_BSPOPTS_SET([NUM_APP_DRV_GDT_DESCRIPTORS],[*],[0])
+RTEMS_BSPOPTS_HELP([NUM_APP_DRV_GDT_DESCRIPTORS],
+[Defines how many descriptors in GDT may be allocated for application or
+ driver usage.])
+
 if test X${CLOCK_DRIVER_USE_TSC} = X1 -a X${CLOCK_DRIVER_USE_8254} = X1 ; then
   AC_MSG_ERROR([pc386 both TSC and 8254 specified for clock driver])
 fi
diff --git a/c/src/lib/libbsp/i386/pc386/include/bsp.h b/c/src/lib/libbsp/i386/pc386/include/bsp.h
index 21aa054..26d4fa4 100644
--- a/c/src/lib/libbsp/i386/pc386/include/bsp.h
+++ b/c/src/lib/libbsp/i386/pc386/include/bsp.h
@@ -51,6 +51,7 @@
 
 #include <bspopts.h>
 #include <bsp/default-initial-extension.h>
+#include <bsp/tblsizes.h>
 
 #include <rtems.h>
 #include <rtems/iosupp.h>
@@ -166,11 +167,8 @@ extern int rtems_3c509_driver_attach(struct rtems_bsdnet_ifconfig *config);
 /*-------------------------------------------------------------------------+
 | External Variables.
 +--------------------------------------------------------------------------*/
-#define IDT_SIZE 256
-#define GDT_SIZE 3
-
 extern interrupt_gate_descriptor Interrupt_descriptor_table[IDT_SIZE];
-extern segment_descriptors Global_descriptor_table   [GDT_SIZE];
+extern segment_descriptors _Global_descriptor_table   [GDT_SIZE];
 
 /*-------------------------------------------------------------------------+
 | Function Prototypes.
diff --git a/c/src/lib/libbsp/i386/pc386/include/tblsizes.h b/c/src/lib/libbsp/i386/pc386/include/tblsizes.h
new file mode 100644
index 0000000..ef51ae7
--- /dev/null
+++ b/c/src/lib/libbsp/i386/pc386/include/tblsizes.h
@@ -0,0 +1,25 @@
+/**
+ * @file
+ *
+ * @ingroup i386_pc386
+ *
+ * @brief Sizes of Global and Interrupt descriptor tables.
+ */
+
+/*
+ * Definitions related to the PC386 BSP.
+ * This header file is also used in assembler modules.
+ *
+ * Copyright (C) 2014  Jan Doležal (dolezj21 at fel.cvut.cz)
+ *                     CTU in Prague.
+ *
+ *  The license and distribution terms for this file may be
+ *  found in the file LICENSE in this distribution or at
+ *  http://www.rtems.org/license/LICENSE.
+ */
+
+#include <bspopts.h>
+
+#define IDT_SIZE (256)
+#define GDT_SIZE (3 + NUM_APP_DRV_GDT_DESCRIPTORS)
+
diff --git a/c/src/lib/libbsp/i386/pc386/preinstall.am b/c/src/lib/libbsp/i386/pc386/preinstall.am
index 182f564..825023a 100644
--- a/c/src/lib/libbsp/i386/pc386/preinstall.am
+++ b/c/src/lib/libbsp/i386/pc386/preinstall.am
@@ -81,6 +81,10 @@ $(PROJECT_INCLUDE)/bsp/exar17d15x.h: console/exar17d15x.h $(PROJECT_INCLUDE)/bsp
 	$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/exar17d15x.h
 PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/exar17d15x.h
 
+$(PROJECT_INCLUDE)/bsp/tblsizes.h: include/tblsizes.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
+	$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/tblsizes.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/tblsizes.h
+
 if HAS_SMP
 $(PROJECT_INCLUDE)/bsp/apic.h: ../../i386/shared/irq/apic.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
 	$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/apic.h
diff --git a/c/src/lib/libbsp/i386/pc386/startup/ldsegs.S b/c/src/lib/libbsp/i386/pc386/startup/ldsegs.S
index 495d68a..14cbb95 100644
--- a/c/src/lib/libbsp/i386/pc386/startup/ldsegs.S
+++ b/c/src/lib/libbsp/i386/pc386/startup/ldsegs.S
@@ -34,6 +34,7 @@
 +--------------------------------------------------------------------------*/
 
 #include <rtems/asm.h>
+#include <bsp/tblsizes.h> /* contains sizes of GDT and IDT */
 
 /*----------------------------------------------------------------------------+
 | CODE section
@@ -167,6 +168,9 @@ next_step:
 /*---------------------------------------------------------------------------+
 | GDT itself
 +--------------------------------------------------------------------------*/
+#if GDT_SIZE < 3
+#error "GDT_SIZE must be at least 3"
+#endif
 
 BEGIN_DATA
 	.p2align 4
@@ -186,11 +190,17 @@ SYM (_Global_descriptor_table):
 	.word 0xffff, 0
 	.byte 0, 0x92, 0xcf, 0
 
+        /* allocated space for user segments */
+        .rept (GDT_SIZE - 3)
+        .word 0,0,0,0
+        .endr
+
 /*---------------------------------------------------------------------------+
 | Descriptor of GDT
 +--------------------------------------------------------------------------*/
-SYM (gdtdesc):
-	.word (3*8 - 1)
+        PUBLIC(gdtdesc)
+SYM(gdtdesc):
+	.word (GDT_SIZE*8 - 1)
 	.long SYM (_Global_descriptor_table)
 
 /*---------------------------------------------------------------------------+
@@ -200,7 +210,7 @@ SYM (gdtdesc):
 
 	PUBLIC(Interrupt_descriptor_table)
 SYM(Interrupt_descriptor_table):
-	.rept 256
+	.rept IDT_SIZE
 	.word 0,0,0,0
 	.endr
 
@@ -211,7 +221,7 @@ SYM(Interrupt_descriptor_table):
 	.p2align 4
 	PUBLIC(IDT_Descriptor)
 SYM(IDT_Descriptor):
-	.word  (256*8 - 1)
+	.word  (IDT_SIZE*8 - 1)
 	.long  SYM (Interrupt_descriptor_table)
 
 END_DATA
-- 
1.9.1




More information about the devel mailing list