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

Jan Dolezal dolezj21 at fel.cvut.cz
Tue Nov 18 15:46:25 UTC 2014


Hello Gedare,
thank you very much for fast and valuable response.

I made most of the changes you suggested.


On 12.11.2014 16:20, Gedare Bloom wrote:
> On Wed, Nov 12, 2014 at 10:07 AM, Jan Dolezal <dolezj21 at fel.cvut.cz>wrote:
>> ---
>>   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/bsptblsizes.h | 25 ++++++++++++++++++++++
>>   c/src/lib/libbsp/i386/pc386/preinstall.am         |  4 ++++
>>   c/src/lib/libbsp/i386/pc386/startup/ldsegs.S      | 26 +++++++++++++++++++----
>>   6 files changed, 59 insertions(+), 8 deletions(-)
>>   create mode 100644 c/src/lib/libbsp/i386/pc386/include/bsptblsizes.h
>>
>> diff --git a/c/src/lib/libbsp/i386/pc386/Makefile.am  b/c/src/lib/libbsp/i386/pc386/Makefile.am
>> index 22ba5e9..9c901df 100644
>> --- a/c/src/lib/libbsp/i386/pc386/Makefile.am
>> +++ b/c/src/lib/libbsp/i386/pc386/Makefile.am
>> @@ -15,6 +15,7 @@ include_bspdir = $(includedir)/bsp
>>   dist_project_lib_DATA = bsp_specs
>>
>>   include_HEADERS = include/bsp.h
>> +include_HEADERS += include/bsptblsizes.h
> This header should probably be nested under bsp at least.
changed to
include/bsp/tblsizes.h

>
>>   include_HEADERS += include/tm27.h
>>
>>   nodist_include_HEADERS = include/bspopts.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..3425a6d 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 <bsptblsizes.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
>> -
> Why not just update these #defines with the new  ones you have in
bsptblsizes.h?
It seemed to me that it is not necessary. I thought it is enough to have
them in bsp/tblsizes.h and then use them here and in asm modules.

Could you please post an example? I don't understand how should such an
update look like.

>
>>   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/bsptblsizes.h
b/c/src/lib/libbsp/i386/pc386/include/bsptblsizes.h
>> new file mode 100644
>> index 0000000..ef51ae7
>> --- /dev/null
>> +++ b/c/src/lib/libbsp/i386/pc386/include/bsptblsizes.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..aff01dc 100644
>> --- a/c/src/lib/libbsp/i386/pc386/preinstall.am
>> +++ b/c/src/lib/libbsp/i386/pc386/preinstall.am
>> @@ -41,6 +41,10 @@ $(PROJECT_INCLUDE)/bsp.h: include/bsp.h
$(PROJECT_INCLUDE)/$(dirstamp)
>>          $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp.h
>>   PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp.h
>>
>> +$(PROJECT_INCLUDE)/bsptblsizes.h: include/bsptblsizes.h
$(PROJECT_INCLUDE)/$(dirstamp)
>> +       $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsptblsizes.h
>> +PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsptblsizes.h
>> +
>>   $(PROJECT_INCLUDE)/tm27.h: include/tm27.h
$(PROJECT_INCLUDE)/$(dirstamp)
>>          $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/tm27.h
>>   PREINSTALL_FILES += $(PROJECT_INCLUDE)/tm27.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..8f2220d 100644
>> --- a/c/src/lib/libbsp/i386/pc386/startup/ldsegs.S
>> +++ b/c/src/lib/libbsp/i386/pc386/startup/ldsegs.S
>> @@ -34,6 +34,15 @@
>>
+--------------------------------------------------------------------------*/
>>
>>   #include <rtems/asm.h>
>> +#include <bsptblsizes.h> /* contains sizes of GDT and IDT */
>> +
>> +#ifndef GDT_SIZE
>> +#define GDT_SIZE (3)
>> +#endif
>> +
>> +#ifndef IDT_SIZE
>> +#define IDT_SIZE (256)
>> +#endif
>>
> Adding ifndef here is redundant since they are unconditionally defined
> in bsptblsizes.h
removed

>
>>
/*----------------------------------------------------------------------------+
>>   | CODE section
>> @@ -167,6 +176,9 @@ next_step:
>>
/*---------------------------------------------------------------------------+
>>   | GDT itself
>>
+--------------------------------------------------------------------------*/
>> +#if GDT_SIZE < 3
>> +#error "GDT_SIZE must be at least 3"
>> +#endif
>>
> Is there a way to use assert() type function in assembly or
> preprocessor code? I'm just curious. This #if and #error is a good
> thing to do at least, and I'm glad to see that you have it!
I'm sorry, but I'm not aware of that possibility.

>
>>   BEGIN_DATA
>>          .p2align 4
>> @@ -186,11 +198,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 +218,7 @@ SYM (gdtdesc):
>>
>>          PUBLIC(Interrupt_descriptor_table)
>>   SYM(Interrupt_descriptor_table):
>> -       .rept 256
>> +       .rept IDT_SIZE
>>          .word 0,0,0,0
>>          .endr
>>
>> @@ -211,7 +229,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
>>
>> _______________________________________________
>> devel mailing list
>> devel at rtems.org
>> http://lists.rtems.org/mailman/listinfo/devel



More information about the devel mailing list