Re: [PATCH v2 1/2] Add FDT support for Beaglebone Black.
Ok, thanks. Best Regards Sichen Zhao From: devel on behalf of Sebastian Huber Sent: Wednesday, July 12, 2017 2:40:28 PM To: Sichen Zhao; devel@rtems.org Cc: punitv...@gmail.com; christian.maude...@embedded-brains.de Subject: Re: [PATCH v2 1/2] Add FDT support for Beaglebone Black. I checked in a slightly modified version: http://git.rtems.org/rtems/commit/?id=f6115d7cd2d1551a05cd257ac9f00476c61e5e0d -- Sebastian Huber, embedded brains GmbH Address : Dornierstr. 4, D-82178 Puchheim, Germany Phone : +49 89 189 47 41-16 Fax : +49 89 189 47 41-09 E-Mail : sebastian.hu...@embedded-brains.de PGP : Public key available on request. Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG. ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
Re: [PATCH 5/6] Add FDT support for am335x USB driver.
Please merge with patch 4. -- Sebastian Huber, embedded brains GmbH Address : Dornierstr. 4, D-82178 Puchheim, Germany Phone : +49 89 189 47 41-16 Fax : +49 89 189 47 41-09 E-Mail : sebastian.hu...@embedded-brains.de PGP : Public key available on request. Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG. ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
Re: [PATCH 4/6] Port am335x usb driver to RTEMS.
On 11/07/17 12:53, Sichen Zhao wrote: +#ifndef __rtems__ #include +#endif /* __rtems__ */ https://github.com/RTEMS/rtems-libbsd/blob/master/CONTRIBUTING.md "In general, provide empty header files and do not guard includes." Each #if __rtems__ makes it harder to stay in synchronization with FreeBSD. Its not a problem to import unmodified FreeBSD header files to get rid of a guarded include. -- Sebastian Huber, embedded brains GmbH Address : Dornierstr. 4, D-82178 Puchheim, Germany Phone : +49 89 189 47 41-16 Fax : +49 89 189 47 41-09 E-Mail : sebastian.hu...@embedded-brains.de PGP : Public key available on request. Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG. ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
Re: [PATCH 2/6] Modify the support for multiple memory resources.
Is patch 1 and 2 still needed for the later patches? If not, then please drop them. -- Sebastian Huber, embedded brains GmbH Address : Dornierstr. 4, D-82178 Puchheim, Germany Phone : +49 89 189 47 41-16 Fax : +49 89 189 47 41-09 E-Mail : sebastian.hu...@embedded-brains.de PGP : Public key available on request. Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG. ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
Re: [PATCH 6/6] Add umass support for Beaglebone black.
Please merge with patch 5. -- Sebastian Huber, embedded brains GmbH Address : Dornierstr. 4, D-82178 Puchheim, Germany Phone : +49 89 189 47 41-16 Fax : +49 89 189 47 41-09 E-Mail : sebastian.hu...@embedded-brains.de PGP : Public key available on request. Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG. ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
Re: [PATCH v2 1/2] Add FDT support for Beaglebone Black.
I checked in a slightly modified version: http://git.rtems.org/rtems/commit/?id=f6115d7cd2d1551a05cd257ac9f00476c61e5e0d -- Sebastian Huber, embedded brains GmbH Address : Dornierstr. 4, D-82178 Puchheim, Germany Phone : +49 89 189 47 41-16 Fax : +49 89 189 47 41-09 E-Mail : sebastian.hu...@embedded-brains.de PGP : Public key available on request. Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG. ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
Re: [PATCH 3/7] Create one interrupt server per processor
On 12/07/17 08:06, Chris Johns wrote: On 12/07/2017 15:35, Sebastian Huber wrote: On 11/07/17 17:06, Gedare Bloom wrote: Is there a reason someone might have to not want one server per core when using SMP? That is, should this be configurable? Yes, this should be configurable. One option is to add an alternative initialization routine that uses a configuration table. However, this is a job for another day. Should this be recorded in a ticket? https://devel.rtems.org/ticket/3073 -- Sebastian Huber, embedded brains GmbH Address : Dornierstr. 4, D-82178 Puchheim, Germany Phone : +49 89 189 47 41-16 Fax : +49 89 189 47 41-09 E-Mail : sebastian.hu...@embedded-brains.de PGP : Public key available on request. Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG. ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
Re: [PATCH 3/7] Create one interrupt server per processor
On 12/07/2017 15:35, Sebastian Huber wrote: > On 11/07/17 17:06, Gedare Bloom wrote: > >> Is there a reason someone might have to not want one server per core >> when using SMP? That is, should this be configurable? > > Yes, this should be configurable. One option is to add an alternative > initialization routine that uses a configuration table. However, this is a job > for another day. > Should this be recorded in a ticket? Chris ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
Re: [PATCH 2/7] rtems: Add rtems_scheduler_ident_by_processor_set
On 11/07/17 16:59, Gedare Bloom wrote: +rtems_status_code rtems_scheduler_ident_by_processor_set( + size_t cpusetsize, + const cpu_set_t *cpuset, + rtems_id*id +); + Also needs doc. I wonder if "identify" or "id" may be better. "ident" seems a bit unusual. All the object identification by name operations use rtems_class_ident(). So, I made it rtems_class_ident_by_x(). -- Sebastian Huber, embedded brains GmbH Address : Dornierstr. 4, D-82178 Puchheim, Germany Phone : +49 89 189 47 41-16 Fax : +49 89 189 47 41-09 E-Mail : sebastian.hu...@embedded-brains.de PGP : Public key available on request. Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG. ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
Re: [PATCH 3/7] Create one interrupt server per processor
On 11/07/17 17:06, Gedare Bloom wrote: Is there a reason someone might have to not want one server per core when using SMP? That is, should this be configurable? Yes, this should be configurable. One option is to add an alternative initialization routine that uses a configuration table. However, this is a job for another day. -- Sebastian Huber, embedded brains GmbH Address : Dornierstr. 4, D-82178 Puchheim, Germany Phone : +49 89 189 47 41-16 Fax : +49 89 189 47 41-09 E-Mail : sebastian.hu...@embedded-brains.de PGP : Public key available on request. Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG. ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
Re: [PATCH 3/7] Create one interrupt server per processor
There should probably be a ticket for this change. Is there a reason someone might have to not want one server per core when using SMP? That is, should this be configurable? On Tue, Jul 11, 2017 at 9:41 AM, Sebastian Huber wrote: > This allows load balancing of interrupt processing in SMP > configurations. > --- > c/src/lib/libbsp/shared/src/irq-server.c | 263 > +-- > cpukit/include/rtems/irq-extension.h | 129 --- > 2 files changed, 254 insertions(+), 138 deletions(-) > > diff --git a/c/src/lib/libbsp/shared/src/irq-server.c > b/c/src/lib/libbsp/shared/src/irq-server.c > index 1f9b75ffd9..a37c9caafc 100644 > --- a/c/src/lib/libbsp/shared/src/irq-server.c > +++ b/c/src/lib/libbsp/shared/src/irq-server.c > @@ -30,47 +30,70 @@ > > #define BSP_INTERRUPT_SERVER_MANAGEMENT_VECTOR (BSP_INTERRUPT_VECTOR_MAX + 1) > > -RTEMS_INTERRUPT_LOCK_DEFINE( > - static, > - bsp_interrupt_server_lock, > - "Interrupt Server" > +typedef struct { > + RTEMS_INTERRUPT_LOCK_MEMBER(lock); > + rtems_chain_control entries; > + rtems_id server; > + unsigned errors; > +} bsp_interrupt_server_context; > + > +#if defined(RTEMS_SMP) > +static bsp_interrupt_server_context *bsp_interrupt_server_instances; > +#else > +static bsp_interrupt_server_context bsp_interrupt_server_instance; > +#endif > + > +static bsp_interrupt_server_context *bsp_interrupt_server_get_context( > + uint32_t server_index, > + rtems_status_code *sc > ) > - > -static rtems_id bsp_interrupt_server_id = RTEMS_ID_NONE; > - > -static RTEMS_CHAIN_DEFINE_EMPTY(bsp_interrupt_server_chain); > - > -static rtems_status_code bsp_interrupt_server_is_initialized(void) > { > - if (bsp_interrupt_server_id != RTEMS_ID_NONE) { > -return RTEMS_SUCCESSFUL; > - } else { > -return RTEMS_INCORRECT_STATE; > +#if defined(RTEMS_SMP) > + if (bsp_interrupt_server_instances == NULL) { > +*sc = RTEMS_INCORRECT_STATE; > +return NULL; >} > -} > +#else > + if (bsp_interrupt_server_instance.server == RTEMS_ID_NONE) { > +*sc = RTEMS_INCORRECT_STATE; > +return NULL; > + } > +#endif > > -static unsigned bsp_interrupt_server_errors; > + if (server_index >= rtems_get_processor_count()) { > +*sc = RTEMS_INVALID_ID; > +return NULL; > + } > + > + *sc = RTEMS_SUCCESSFUL; > +#if defined(RTEMS_SMP) > + return &bsp_interrupt_server_instances[server_index]; > +#else > + return &bsp_interrupt_server_instance; > +#endif > +} > > static void bsp_interrupt_server_trigger(void *arg) > { >rtems_interrupt_lock_context lock_context; >rtems_interrupt_server_entry *e = arg; > + bsp_interrupt_server_context *s = e->server; > >if (bsp_interrupt_is_valid_vector(e->vector)) { > bsp_interrupt_vector_disable(e->vector); >} > > - rtems_interrupt_lock_acquire(&bsp_interrupt_server_lock, &lock_context); > + rtems_interrupt_lock_acquire(&s->lock, &lock_context); > >if (rtems_chain_is_node_off_chain(&e->node)) { > -rtems_chain_append_unprotected(&bsp_interrupt_server_chain, &e->node); > +rtems_chain_append_unprotected(&s->entries, &e->node); >} else { > -++bsp_interrupt_server_errors; > +++s->errors; >} > > - rtems_interrupt_lock_release(&bsp_interrupt_server_lock, &lock_context); > + rtems_interrupt_lock_release(&s->lock, &lock_context); > > - rtems_event_system_send(bsp_interrupt_server_id, > RTEMS_EVENT_SYSTEM_SERVER); > + rtems_event_system_send(s->server, RTEMS_EVENT_SYSTEM_SERVER); > } > > typedef struct { > @@ -114,6 +137,7 @@ static rtems_interrupt_server_entry > *bsp_interrupt_server_query_entry( > } > > typedef struct { > + bsp_interrupt_server_context *server; >rtems_vector_number vector; >rtems_option options; >rtems_interrupt_handler handler; > @@ -146,6 +170,7 @@ static void bsp_interrupt_server_install_helper(void *arg) >if (e == NULL) { > e = calloc(1, sizeof(*e)); > if (e != NULL) { > + e->server = hd->server; >e->vector = hd->vector; >e->actions = a; > > @@ -162,6 +187,10 @@ static void bsp_interrupt_server_install_helper(void > *arg) > } else { >sc = RTEMS_NO_MEMORY; > } > +#if defined(RTEMS_SMP) > + } else if (e->server != hd->server) { > +sc = RTEMS_RESOURCE_IN_USE; > +#endif >} else if ( > RTEMS_INTERRUPT_IS_UNIQUE(hd->options) >|| RTEMS_INTERRUPT_IS_UNIQUE(trigger_options) > @@ -252,6 +281,7 @@ static void bsp_interrupt_server_remove_helper(void *arg) > } > > static rtems_status_code bsp_interrupt_server_call_helper( > + bsp_interrupt_server_context *s, >rtems_vector_number vector, >rtems_option options, >rtems_interrupt_handler handler, > @@ -260,6 +290,7 @@ static rtems_status_code bsp_interrupt_server_call_helper( > ) > { >bsp_interrupt_server_helper_data hd = { > +.server = s, > .vector = vector, > .options = options, > .handler = handler, > @@ -271,6 +302,7 @@ static rtems_status_code bsp_interrupt_server_call_he
Re: [PATCH 2/7] rtems: Add rtems_scheduler_ident_by_processor_set
On Tue, Jul 11, 2017 at 9:41 AM, Sebastian Huber wrote: > Update #3070. > --- > cpukit/rtems/Makefile.am| 1 + > cpukit/rtems/include/rtems/rtems/tasks.h| 25 +++ > cpukit/rtems/src/scheduleridentbyprocessorset.c | 60 > + > testsuites/smptests/smpscheduler02/init.c | 11 + > testsuites/sptests/spscheduler01/init.c | 19 > 5 files changed, 116 insertions(+) > create mode 100644 cpukit/rtems/src/scheduleridentbyprocessorset.c > > diff --git a/cpukit/rtems/Makefile.am b/cpukit/rtems/Makefile.am > index e9ad2deb5d..da6e302e2e 100644 > --- a/cpukit/rtems/Makefile.am > +++ b/cpukit/rtems/Makefile.am > @@ -109,6 +109,7 @@ librtems_a_SOURCES += src/scheduleraddprocessor.c > librtems_a_SOURCES += src/schedulergetprocessorset.c > librtems_a_SOURCES += src/schedulerident.c > librtems_a_SOURCES += src/scheduleridentbyprocessor.c > +librtems_a_SOURCES += src/scheduleridentbyprocessorset.c > librtems_a_SOURCES += src/schedulerremoveprocessor.c > > ## RATEMON_C_FILES > diff --git a/cpukit/rtems/include/rtems/rtems/tasks.h > b/cpukit/rtems/include/rtems/rtems/tasks.h > index e68c78989d..585f4c449c 100644 > --- a/cpukit/rtems/include/rtems/rtems/tasks.h > +++ b/cpukit/rtems/include/rtems/rtems/tasks.h > @@ -577,6 +577,31 @@ rtems_status_code rtems_scheduler_ident_by_processor( > ); > > /** > + * @brief Identifies a scheduler by a processor set. > + * > + * The scheduler is selected according to the highest numbered online > processor > + * in the specified processor set. > + * > + * @param[in] cpusetsize Size of the specified processor set buffer in > + * bytes. This value must be positive. > + * @param[out] cpuset The processor set to identify the scheduler. > + * @param[out] id The scheduler identifier associated with the processor set. > + * > + * @retval RTEMS_SUCCESSFUL Successful operation. > + * @retval RTEMS_INVALID_ADDRESS The @a id parameter is @c NULL. > + * @retval RTEMS_INVALID_SIZE Invalid processor set size. > + * @retval RTEMS_INVALID_NAME The processor set contains no online processor. > + * @retval RTEMS_INCORRECT_STATE The processor set is valid, however, the > + * highest numbered online processor in the specified processor set is not > + * owned by a scheduler. > + */ > +rtems_status_code rtems_scheduler_ident_by_processor_set( > + size_t cpusetsize, > + const cpu_set_t *cpuset, > + rtems_id*id > +); > + Also needs doc. I wonder if "identify" or "id" may be better. "ident" seems a bit unusual. > +/** > * @brief Gets the set of processors owned by the specified scheduler > instance. > * > * @param[in] scheduler_id Identifier of the scheduler instance. > diff --git a/cpukit/rtems/src/scheduleridentbyprocessorset.c > b/cpukit/rtems/src/scheduleridentbyprocessorset.c > new file mode 100644 > index 00..4988ed0fb8 > --- /dev/null > +++ b/cpukit/rtems/src/scheduleridentbyprocessorset.c > @@ -0,0 +1,60 @@ > +/* > + * Copyright (c) 2017 embedded brains GmbH. All rights reserved. > + * > + * embedded brains GmbH > + * Dornierstr. 4 > + * 82178 Puchheim > + * Germany > + * > + * > + * 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. > + */ > + > +#if HAVE_CONFIG_H > +#include "config.h" > +#endif > + > +#include > +#include > +#include > + > +rtems_status_code rtems_scheduler_ident_by_processor_set( > + size_t cpusetsize, > + const cpu_set_t *cpuset, > + rtems_id*id > +) > +{ > + Processor_mask set; > + Processor_mask_Copy_status status; > + uint32_tcpu_index; > + const Scheduler_Control*scheduler; > + > + if ( id == NULL ) { > +return RTEMS_INVALID_ADDRESS; > + } > + > + status = _Processor_mask_From_cpu_set_t( &set, cpusetsize, cpuset ); > + if ( status == PROCESSOR_MASK_COPY_INVALID_SIZE ) { > +return RTEMS_INVALID_SIZE; > + } > + > + _Processor_mask_And( &set, &set, _SMP_Get_online_processors() ); > + cpu_index = _Processor_mask_Find_last_set( &set ); > + if ( cpu_index == 0 ) { > +return RTEMS_INVALID_NAME; > + } > + > + scheduler = _Scheduler_Get_by_CPU( _Per_CPU_Get_by_index( cpu_index - 1) ); > +#if defined(RTEMS_SMP) > + if ( scheduler == NULL ) { > +return RTEMS_INCORRECT_STATE; > + } > +#else > + _Assert( scheduler != NULL ); > +#endif > + > + *id = _Scheduler_Build_id( _Scheduler_Get_index( scheduler ) ); > + return RTEMS_SUCCESSFUL; > +} > diff --git a/testsuites/smptests/smpscheduler02/init.c > b/testsuites/smptests/smpscheduler02/init.c > index 7dd60ec4c5..3975802d4a 100644 > --- a/testsuites/smptests/smpscheduler02/init.c > +++ b/testsuites/smptests/smpscheduler02/init.c > @@ -134,8 +134,10 @@ static void test_scheduler_add_remove_processors(void) >rtems_test_assert(sc == RTEMS_RESOURCE_IN_USE); > >if (rtems_get_processor_count()
Re: [PATCH 1/7] rtems: Add rtems_scheduler_ident_by_processor()
On Tue, Jul 11, 2017 at 9:41 AM, Sebastian Huber wrote: > Update #3069. > --- > cpukit/rtems/Makefile.am | 1 + > cpukit/rtems/include/rtems/rtems/tasks.h | 17 ++ > cpukit/rtems/src/scheduleridentbyprocessor.c | 49 > > testsuites/smptests/smpfatal04/init.c| 6 > testsuites/sptests/spscheduler01/init.c | 12 +++ > 5 files changed, 85 insertions(+) > create mode 100644 cpukit/rtems/src/scheduleridentbyprocessor.c > > diff --git a/cpukit/rtems/Makefile.am b/cpukit/rtems/Makefile.am > index ada1f83510..e9ad2deb5d 100644 > --- a/cpukit/rtems/Makefile.am > +++ b/cpukit/rtems/Makefile.am > @@ -108,6 +108,7 @@ librtems_a_SOURCES += src/taskwakewhen.c > librtems_a_SOURCES += src/scheduleraddprocessor.c > librtems_a_SOURCES += src/schedulergetprocessorset.c > librtems_a_SOURCES += src/schedulerident.c > +librtems_a_SOURCES += src/scheduleridentbyprocessor.c > librtems_a_SOURCES += src/schedulerremoveprocessor.c > > ## RATEMON_C_FILES > diff --git a/cpukit/rtems/include/rtems/rtems/tasks.h > b/cpukit/rtems/include/rtems/rtems/tasks.h > index 88e43556ce..e68c78989d 100644 > --- a/cpukit/rtems/include/rtems/rtems/tasks.h > +++ b/cpukit/rtems/include/rtems/rtems/tasks.h > @@ -560,6 +560,23 @@ rtems_status_code rtems_scheduler_ident( > ); > > /** > + * @brief Identifies a scheduler by a processor index. > + * > + * @param[in] cpu_index The processor index. > + * @param[out] id The scheduler identifier associated with the processor > index. > + * > + * @retval RTEMS_SUCCESSFUL Successful operation. > + * @retval RTEMS_INVALID_ADDRESS The @a id parameter is @c NULL. > + * @retval RTEMS_INVALID_NAME Invalid processor index. > + * @retval RTEMS_INCORRECT_STATE The processor index is valid, however, this > + * processor is not owned by a scheduler. > + */ > +rtems_status_code rtems_scheduler_ident_by_processor( > + uint32_t cpu_index, > + rtems_id *id > +); > + This requires an update in the associated user manual page. > +/** > * @brief Gets the set of processors owned by the specified scheduler > instance. > * > * @param[in] scheduler_id Identifier of the scheduler instance. > diff --git a/cpukit/rtems/src/scheduleridentbyprocessor.c > b/cpukit/rtems/src/scheduleridentbyprocessor.c > new file mode 100644 > index 00..2bc64d77d3 > --- /dev/null > +++ b/cpukit/rtems/src/scheduleridentbyprocessor.c > @@ -0,0 +1,49 @@ > +/* > + * Copyright (c) 2017 embedded brains GmbH. All rights reserved. > + * > + * embedded brains GmbH > + * Dornierstr. 4 > + * 82178 Puchheim > + * Germany > + * > + * > + * 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. > + */ > + > +#if HAVE_CONFIG_H > +#include "config.h" > +#endif > + > +#include > +#include > +#include > + > +rtems_status_code rtems_scheduler_ident_by_processor( > + uint32_t cpu_index, > + rtems_id *id > +) > +{ > + const Scheduler_Control *scheduler; > + > + if ( id == NULL ) { > +return RTEMS_INVALID_ADDRESS; > + } > + > + if ( cpu_index >= _SMP_Get_processor_count() ) { > +return RTEMS_INVALID_NAME; > + } > + > + scheduler = _Scheduler_Get_by_CPU( _Per_CPU_Get_by_index( cpu_index ) ); > +#if defined(RTEMS_SMP) > + if ( scheduler == NULL ) { > +return RTEMS_INCORRECT_STATE; > + } > +#else > + _Assert( scheduler != NULL ); > +#endif > + > + *id = _Scheduler_Build_id( _Scheduler_Get_index( scheduler ) ); > + return RTEMS_SUCCESSFUL; > +} > diff --git a/testsuites/smptests/smpfatal04/init.c > b/testsuites/smptests/smpfatal04/init.c > index 0215914ce8..73ef701c70 100644 > --- a/testsuites/smptests/smpfatal04/init.c > +++ b/testsuites/smptests/smpfatal04/init.c > @@ -45,6 +45,12 @@ static void fatal_extension( >&& !always_set_to_false >&& code == SMP_FATAL_BOOT_PROCESSOR_NOT_ASSIGNED_TO_SCHEDULER >) { > +rtems_status_code sc; > +rtems_id id; > + > +sc = rtems_scheduler_ident_by_processor(0, &id); > +assert(sc == RTEMS_INCORRECT_STATE); > + > TEST_END(); >} > } > diff --git a/testsuites/sptests/spscheduler01/init.c > b/testsuites/sptests/spscheduler01/init.c > index 9bdfacc8db..2415ace803 100644 > --- a/testsuites/sptests/spscheduler01/init.c > +++ b/testsuites/sptests/spscheduler01/init.c > @@ -355,6 +355,18 @@ static void test_scheduler_ident(void) >rtems_test_assert(sc == RTEMS_SUCCESSFUL); > >rtems_test_assert(scheduler_id == expected_id); > + > + sc = rtems_scheduler_ident_by_processor(1, NULL); > + rtems_test_assert(sc == RTEMS_INVALID_ADDRESS); > + > + sc = rtems_scheduler_ident_by_processor(1, &scheduler_id); > + rtems_test_assert(sc == RTEMS_INVALID_NAME); > + > + scheduler_id = 0; > + sc = rtems_scheduler_ident_by_processor(0, &scheduler_id); > + rtems_test_assert(sc == RTEMS_SUCCESSFUL); > + > + rtems_test_assert(scheduler_id == expected_id); > } > >
[PATCH 3/7] Create one interrupt server per processor
This allows load balancing of interrupt processing in SMP configurations. --- c/src/lib/libbsp/shared/src/irq-server.c | 263 +-- cpukit/include/rtems/irq-extension.h | 129 --- 2 files changed, 254 insertions(+), 138 deletions(-) diff --git a/c/src/lib/libbsp/shared/src/irq-server.c b/c/src/lib/libbsp/shared/src/irq-server.c index 1f9b75ffd9..a37c9caafc 100644 --- a/c/src/lib/libbsp/shared/src/irq-server.c +++ b/c/src/lib/libbsp/shared/src/irq-server.c @@ -30,47 +30,70 @@ #define BSP_INTERRUPT_SERVER_MANAGEMENT_VECTOR (BSP_INTERRUPT_VECTOR_MAX + 1) -RTEMS_INTERRUPT_LOCK_DEFINE( - static, - bsp_interrupt_server_lock, - "Interrupt Server" +typedef struct { + RTEMS_INTERRUPT_LOCK_MEMBER(lock); + rtems_chain_control entries; + rtems_id server; + unsigned errors; +} bsp_interrupt_server_context; + +#if defined(RTEMS_SMP) +static bsp_interrupt_server_context *bsp_interrupt_server_instances; +#else +static bsp_interrupt_server_context bsp_interrupt_server_instance; +#endif + +static bsp_interrupt_server_context *bsp_interrupt_server_get_context( + uint32_t server_index, + rtems_status_code *sc ) - -static rtems_id bsp_interrupt_server_id = RTEMS_ID_NONE; - -static RTEMS_CHAIN_DEFINE_EMPTY(bsp_interrupt_server_chain); - -static rtems_status_code bsp_interrupt_server_is_initialized(void) { - if (bsp_interrupt_server_id != RTEMS_ID_NONE) { -return RTEMS_SUCCESSFUL; - } else { -return RTEMS_INCORRECT_STATE; +#if defined(RTEMS_SMP) + if (bsp_interrupt_server_instances == NULL) { +*sc = RTEMS_INCORRECT_STATE; +return NULL; } -} +#else + if (bsp_interrupt_server_instance.server == RTEMS_ID_NONE) { +*sc = RTEMS_INCORRECT_STATE; +return NULL; + } +#endif -static unsigned bsp_interrupt_server_errors; + if (server_index >= rtems_get_processor_count()) { +*sc = RTEMS_INVALID_ID; +return NULL; + } + + *sc = RTEMS_SUCCESSFUL; +#if defined(RTEMS_SMP) + return &bsp_interrupt_server_instances[server_index]; +#else + return &bsp_interrupt_server_instance; +#endif +} static void bsp_interrupt_server_trigger(void *arg) { rtems_interrupt_lock_context lock_context; rtems_interrupt_server_entry *e = arg; + bsp_interrupt_server_context *s = e->server; if (bsp_interrupt_is_valid_vector(e->vector)) { bsp_interrupt_vector_disable(e->vector); } - rtems_interrupt_lock_acquire(&bsp_interrupt_server_lock, &lock_context); + rtems_interrupt_lock_acquire(&s->lock, &lock_context); if (rtems_chain_is_node_off_chain(&e->node)) { -rtems_chain_append_unprotected(&bsp_interrupt_server_chain, &e->node); +rtems_chain_append_unprotected(&s->entries, &e->node); } else { -++bsp_interrupt_server_errors; +++s->errors; } - rtems_interrupt_lock_release(&bsp_interrupt_server_lock, &lock_context); + rtems_interrupt_lock_release(&s->lock, &lock_context); - rtems_event_system_send(bsp_interrupt_server_id, RTEMS_EVENT_SYSTEM_SERVER); + rtems_event_system_send(s->server, RTEMS_EVENT_SYSTEM_SERVER); } typedef struct { @@ -114,6 +137,7 @@ static rtems_interrupt_server_entry *bsp_interrupt_server_query_entry( } typedef struct { + bsp_interrupt_server_context *server; rtems_vector_number vector; rtems_option options; rtems_interrupt_handler handler; @@ -146,6 +170,7 @@ static void bsp_interrupt_server_install_helper(void *arg) if (e == NULL) { e = calloc(1, sizeof(*e)); if (e != NULL) { + e->server = hd->server; e->vector = hd->vector; e->actions = a; @@ -162,6 +187,10 @@ static void bsp_interrupt_server_install_helper(void *arg) } else { sc = RTEMS_NO_MEMORY; } +#if defined(RTEMS_SMP) + } else if (e->server != hd->server) { +sc = RTEMS_RESOURCE_IN_USE; +#endif } else if ( RTEMS_INTERRUPT_IS_UNIQUE(hd->options) || RTEMS_INTERRUPT_IS_UNIQUE(trigger_options) @@ -252,6 +281,7 @@ static void bsp_interrupt_server_remove_helper(void *arg) } static rtems_status_code bsp_interrupt_server_call_helper( + bsp_interrupt_server_context *s, rtems_vector_number vector, rtems_option options, rtems_interrupt_handler handler, @@ -260,6 +290,7 @@ static rtems_status_code bsp_interrupt_server_call_helper( ) { bsp_interrupt_server_helper_data hd = { +.server = s, .vector = vector, .options = options, .handler = handler, @@ -271,6 +302,7 @@ static rtems_status_code bsp_interrupt_server_call_helper( .arg = &hd }; rtems_interrupt_server_entry e = { +.server = s, .vector = BSP_INTERRUPT_SERVER_MANAGEMENT_VECTOR, .actions = &a }; @@ -281,30 +313,32 @@ static rtems_status_code bsp_interrupt_server_call_helper( return hd.sc; } -static rtems_interrupt_server_entry *bsp_interrupt_server_get_entry(void) +static rtems_interrupt_server_entry *bsp_interrupt_server_get_entry( + bsp_interrupt_server_context *s +) { rtems_interrupt_lock_context lock_context; rtems_inter
[PATCH 6/7] Add interrupt server move
--- c/src/lib/libbsp/shared/src/irq-server.c | 75 cpukit/include/rtems/irq-extension.h | 26 +++ 2 files changed, 101 insertions(+) diff --git a/c/src/lib/libbsp/shared/src/irq-server.c b/c/src/lib/libbsp/shared/src/irq-server.c index 61d31754c2..a7b277c62c 100644 --- a/c/src/lib/libbsp/shared/src/irq-server.c +++ b/c/src/lib/libbsp/shared/src/irq-server.c @@ -694,6 +694,81 @@ rtems_status_code rtems_interrupt_server_request_initialize( return RTEMS_SUCCESSFUL; } +static void bsp_interrupt_server_handler_move_helper(void *arg) +{ + bsp_interrupt_server_helper_data *hd = arg; + bsp_interrupt_server_handler_iterate_helper_data *hihd = hd->arg; + rtems_interrupt_server_entry *e; + rtems_option trigger_options; + + bsp_interrupt_lock(); + + e = bsp_interrupt_server_query_entry(hd->vector, &trigger_options); + if (e != NULL) { +rtems_interrupt_lock_context lock_context; +bsp_interrupt_server_context *src = e->server; +bsp_interrupt_server_context *dst = hihd->arg; +bool pending; + +rtems_interrupt_lock_acquire(&src->lock, &lock_context); + +pending = !rtems_chain_is_node_off_chain(&e->node); +if (pending) { + rtems_chain_extract_unprotected(&e->node); + rtems_chain_set_off_chain(&e->node); +} + +rtems_interrupt_lock_release(&src->lock, &lock_context); + +e->server = dst; + +if (pending) { + bsp_interrupt_server_trigger(e); +} + } + + bsp_interrupt_unlock(); + + rtems_event_transient_send(hd->task); +} + +rtems_status_code rtems_interrupt_server_move( + uint32_t source_server_index, + rtems_vector_number vector, + uint32_t destination_server_index +) +{ + rtems_status_code sc; + bsp_interrupt_server_context *src; + bsp_interrupt_server_context *dst; + bsp_interrupt_server_handler_iterate_helper_data hihd; + + src = bsp_interrupt_server_get_context(source_server_index, &sc); + if (src == NULL) { +return sc; + } + + dst = bsp_interrupt_server_get_context(destination_server_index, &sc); + if (dst == NULL) { +return sc; + } + + if (!bsp_interrupt_is_valid_vector(vector)) { +return RTEMS_INVALID_ID; + } + + hihd.arg = dst; + bsp_interrupt_server_call_helper( +src, +vector, +0, +NULL, +&hihd, +bsp_interrupt_server_handler_move_helper + ); + return RTEMS_SUCCESSFUL; +} + static void bsp_interrupt_server_entry_suspend_helper(void *arg) { bsp_interrupt_server_helper_data *hd = arg; diff --git a/cpukit/include/rtems/irq-extension.h b/cpukit/include/rtems/irq-extension.h index 9cade113ad..e3fb4c5fea 100644 --- a/cpukit/include/rtems/irq-extension.h +++ b/cpukit/include/rtems/irq-extension.h @@ -362,6 +362,32 @@ rtems_status_code rtems_interrupt_server_handler_iterate( ); /** + * @brief Moves the interrupt handlers installed on the specified source + * interrupt server to the destination interrupt server. + * + * This function must be called from thread context. It may block. Calling + * this function within the context of an interrupt server is undefined + * behaviour. + * + * @param[in] source_server_index The source interrupt server index. Use + * @c RTEMS_INTERRUPT_SERVER_DEFAULT to specify the default server. + * @param[in] vector The interrupt vector number. + * @param[in] destination_server_index The destination interrupt server index. + * Use @c RTEMS_INTERRUPT_SERVER_DEFAULT to specify the default server. + * + * @retval RTEMS_SUCCESSFUL Successful operation + * @retval RTEMS_INCORRECT_STATE The interrupt servers are not initialized. + * @retval RTEMS_INVALID_ID The destination interrupt server index is invalid. + * @retval RTEMS_INVALID_ID The vector number is invalid. + * @retval RTEMS_INVALID_ID The destination interrupt server index is invalid. + */ +rtems_status_code rtems_interrupt_server_move( + uint32_tsource_server_index, + rtems_vector_number vector, + uint32_tdestination_server_index +); + +/** * @brief Suspends the specified interrupt server. * * A suspend request is sent to the specified interrupt server. This function -- 2.12.3 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[PATCH 1/7] rtems: Add rtems_scheduler_ident_by_processor()
Update #3069. --- cpukit/rtems/Makefile.am | 1 + cpukit/rtems/include/rtems/rtems/tasks.h | 17 ++ cpukit/rtems/src/scheduleridentbyprocessor.c | 49 testsuites/smptests/smpfatal04/init.c| 6 testsuites/sptests/spscheduler01/init.c | 12 +++ 5 files changed, 85 insertions(+) create mode 100644 cpukit/rtems/src/scheduleridentbyprocessor.c diff --git a/cpukit/rtems/Makefile.am b/cpukit/rtems/Makefile.am index ada1f83510..e9ad2deb5d 100644 --- a/cpukit/rtems/Makefile.am +++ b/cpukit/rtems/Makefile.am @@ -108,6 +108,7 @@ librtems_a_SOURCES += src/taskwakewhen.c librtems_a_SOURCES += src/scheduleraddprocessor.c librtems_a_SOURCES += src/schedulergetprocessorset.c librtems_a_SOURCES += src/schedulerident.c +librtems_a_SOURCES += src/scheduleridentbyprocessor.c librtems_a_SOURCES += src/schedulerremoveprocessor.c ## RATEMON_C_FILES diff --git a/cpukit/rtems/include/rtems/rtems/tasks.h b/cpukit/rtems/include/rtems/rtems/tasks.h index 88e43556ce..e68c78989d 100644 --- a/cpukit/rtems/include/rtems/rtems/tasks.h +++ b/cpukit/rtems/include/rtems/rtems/tasks.h @@ -560,6 +560,23 @@ rtems_status_code rtems_scheduler_ident( ); /** + * @brief Identifies a scheduler by a processor index. + * + * @param[in] cpu_index The processor index. + * @param[out] id The scheduler identifier associated with the processor index. + * + * @retval RTEMS_SUCCESSFUL Successful operation. + * @retval RTEMS_INVALID_ADDRESS The @a id parameter is @c NULL. + * @retval RTEMS_INVALID_NAME Invalid processor index. + * @retval RTEMS_INCORRECT_STATE The processor index is valid, however, this + * processor is not owned by a scheduler. + */ +rtems_status_code rtems_scheduler_ident_by_processor( + uint32_t cpu_index, + rtems_id *id +); + +/** * @brief Gets the set of processors owned by the specified scheduler instance. * * @param[in] scheduler_id Identifier of the scheduler instance. diff --git a/cpukit/rtems/src/scheduleridentbyprocessor.c b/cpukit/rtems/src/scheduleridentbyprocessor.c new file mode 100644 index 00..2bc64d77d3 --- /dev/null +++ b/cpukit/rtems/src/scheduleridentbyprocessor.c @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2017 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Dornierstr. 4 + * 82178 Puchheim + * Germany + * + * + * 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. + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include + +rtems_status_code rtems_scheduler_ident_by_processor( + uint32_t cpu_index, + rtems_id *id +) +{ + const Scheduler_Control *scheduler; + + if ( id == NULL ) { +return RTEMS_INVALID_ADDRESS; + } + + if ( cpu_index >= _SMP_Get_processor_count() ) { +return RTEMS_INVALID_NAME; + } + + scheduler = _Scheduler_Get_by_CPU( _Per_CPU_Get_by_index( cpu_index ) ); +#if defined(RTEMS_SMP) + if ( scheduler == NULL ) { +return RTEMS_INCORRECT_STATE; + } +#else + _Assert( scheduler != NULL ); +#endif + + *id = _Scheduler_Build_id( _Scheduler_Get_index( scheduler ) ); + return RTEMS_SUCCESSFUL; +} diff --git a/testsuites/smptests/smpfatal04/init.c b/testsuites/smptests/smpfatal04/init.c index 0215914ce8..73ef701c70 100644 --- a/testsuites/smptests/smpfatal04/init.c +++ b/testsuites/smptests/smpfatal04/init.c @@ -45,6 +45,12 @@ static void fatal_extension( && !always_set_to_false && code == SMP_FATAL_BOOT_PROCESSOR_NOT_ASSIGNED_TO_SCHEDULER ) { +rtems_status_code sc; +rtems_id id; + +sc = rtems_scheduler_ident_by_processor(0, &id); +assert(sc == RTEMS_INCORRECT_STATE); + TEST_END(); } } diff --git a/testsuites/sptests/spscheduler01/init.c b/testsuites/sptests/spscheduler01/init.c index 9bdfacc8db..2415ace803 100644 --- a/testsuites/sptests/spscheduler01/init.c +++ b/testsuites/sptests/spscheduler01/init.c @@ -355,6 +355,18 @@ static void test_scheduler_ident(void) rtems_test_assert(sc == RTEMS_SUCCESSFUL); rtems_test_assert(scheduler_id == expected_id); + + sc = rtems_scheduler_ident_by_processor(1, NULL); + rtems_test_assert(sc == RTEMS_INVALID_ADDRESS); + + sc = rtems_scheduler_ident_by_processor(1, &scheduler_id); + rtems_test_assert(sc == RTEMS_INVALID_NAME); + + scheduler_id = 0; + sc = rtems_scheduler_ident_by_processor(0, &scheduler_id); + rtems_test_assert(sc == RTEMS_SUCCESSFUL); + + rtems_test_assert(scheduler_id == expected_id); } static void test_scheduler_get_processors(void) -- 2.12.3 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[PATCH 7/7] Add interrupt vector set/get affinity
--- c/src/lib/libbsp/arm/shared/arm-gic-irq.c | 24 ++ c/src/lib/libbsp/arm/shared/include/arm-gic-irq.h | 9 +++- .../lib/libbsp/powerpc/qoriq/clock/clock-config.c | 16 +++ c/src/lib/libbsp/powerpc/qoriq/include/irq.h | 8 ++-- c/src/lib/libbsp/powerpc/qoriq/irq/irq.c | 24 -- c/src/lib/libbsp/shared/src/irq-generic.c | 53 +- c/src/lib/libbsp/sparc/erc32/include/bsp/irq.h | 20 c/src/lib/libbsp/sparc/leon3/clock/ckinit.c| 11 + c/src/lib/libbsp/sparc/leon3/include/bsp/irq.h | 10 c/src/lib/libbsp/sparc/leon3/startup/eirq.c| 41 + cpukit/include/rtems/irq-extension.h | 37 +++ cpukit/score/include/rtems/score/processormask.h | 25 ++ 12 files changed, 226 insertions(+), 52 deletions(-) diff --git a/c/src/lib/libbsp/arm/shared/arm-gic-irq.c b/c/src/lib/libbsp/arm/shared/arm-gic-irq.c index 5a4a998bfb..7d36ce0930 100644 --- a/c/src/lib/libbsp/arm/shared/arm-gic-irq.c +++ b/c/src/lib/libbsp/arm/shared/arm-gic-irq.c @@ -153,20 +153,24 @@ rtems_status_code arm_gic_irq_get_priority( return sc; } -rtems_status_code arm_gic_irq_set_affinity( +void bsp_interrupt_set_affinity( rtems_vector_number vector, - uint8_t targets + const Processor_mask *affinity ) { - rtems_status_code sc = RTEMS_SUCCESSFUL; + volatile gic_dist *dist = ARM_GIC_DIST; + uint8_t targets = (uint8_t) _Processor_mask_To_uint32_t(affinity, 0); - if (bsp_interrupt_is_valid_vector(vector)) { -volatile gic_dist *dist = ARM_GIC_DIST; + gic_id_set_targets(dist, vector, targets); +} -gic_id_set_targets(dist, vector, targets); - } else { -sc = RTEMS_INVALID_ID; - } +void bsp_interrupt_get_affinity( + rtems_vector_number vector, + Processor_mask *affinity +) +{ + volatile gic_dist *dist = ARM_GIC_DIST; + uint8_t targets = gic_id_get_targets(dist, vector); - return sc; + _Processor_mask_From_uint32_t(affinity, targets, 0); } diff --git a/c/src/lib/libbsp/arm/shared/include/arm-gic-irq.h b/c/src/lib/libbsp/arm/shared/include/arm-gic-irq.h index a8c29bb7c5..1351cfb683 100644 --- a/c/src/lib/libbsp/arm/shared/include/arm-gic-irq.h +++ b/c/src/lib/libbsp/arm/shared/include/arm-gic-irq.h @@ -58,9 +58,14 @@ rtems_status_code arm_gic_irq_get_priority( uint8_t *priority ); -rtems_status_code arm_gic_irq_set_affinity( +void bsp_interrupt_set_affinity( rtems_vector_number vector, - uint8_t targets + const Processor_mask *affinity +); + +void bsp_interrupt_get_affinity( + rtems_vector_number vector, + Processor_mask *affinity ); typedef enum { diff --git a/c/src/lib/libbsp/powerpc/qoriq/clock/clock-config.c b/c/src/lib/libbsp/powerpc/qoriq/clock/clock-config.c index 42fdfda77c..99e9f973e9 100644 --- a/c/src/lib/libbsp/powerpc/qoriq/clock/clock-config.c +++ b/c/src/lib/libbsp/powerpc/qoriq/clock/clock-config.c @@ -56,12 +56,11 @@ static void qoriq_clock_handler_install(rtems_isr_entry *old_isr) *old_isr = NULL; #if defined(RTEMS_MULTIPROCESSING) && !defined(RTEMS_SMP) - sc = qoriq_pic_set_affinity( -CLOCK_INTERRUPT, -ppc_processor_id() - ); - if (sc != RTEMS_SUCCESSFUL) { -rtems_fatal_error_occurred(0xdeadbeef); + { +Processor_mask affinity; + +_Processor_mask_From_index(&affinity, ppc_processor_id()); +bsp_interrupt_set_affinity(CLOCK_INTERRUPT, &affinity); } #endif @@ -133,10 +132,7 @@ static void qoriq_clock_cleanup(void) qoriq_clock_handler_install(&old_isr) #define Clock_driver_support_set_interrupt_affinity(online_processors) \ - qoriq_pic_set_affinities( \ -CLOCK_INTERRUPT, \ -_Processor_mask_To_uint32_t(online_processors, 0) \ - ) + bsp_interrupt_set_affinity(CLOCK_INTERRUPT, online_processors) #define Clock_driver_support_shutdown_hardware() \ qoriq_clock_cleanup() diff --git a/c/src/lib/libbsp/powerpc/qoriq/include/irq.h b/c/src/lib/libbsp/powerpc/qoriq/include/irq.h index edda658ba9..feee951794 100644 --- a/c/src/lib/libbsp/powerpc/qoriq/include/irq.h +++ b/c/src/lib/libbsp/powerpc/qoriq/include/irq.h @@ -372,14 +372,14 @@ rtems_status_code qoriq_pic_set_priority( int *old_priority ); -rtems_status_code qoriq_pic_set_affinity( +void bsp_interrupt_set_affinity( rtems_vector_number vector, - uint32_t processor_index + const Processor_mask *affinity ); -rtems_status_code qoriq_pic_set_affinities( +void bsp_interrupt_get_affinity( rtems_vector_number vector, - uint32_t processor_affinities + Processor_mask *affinity ); /** @} */ diff --git a/c/src/lib/libbsp/powerpc/qoriq/irq/irq.c b/c/src/lib/libbsp/powerpc/qoriq/irq/irq.c index ea086215fc..facb53b347 100644 --- a/c/src/lib/libbsp/powerpc/qoriq/irq/irq.c +++ b/c/src/lib/libbsp/powerpc/qoriq/irq/irq.c @@ -147,30 +147,24 @@ rtems_status_code qoriq_pic_set_priority( return sc; } -rtems_status_code qoriq_pic_set_affinities( +void bsp_interrupt_set_affinity( rtems_vector_n
[PATCH 2/7] rtems: Add rtems_scheduler_ident_by_processor_set
Update #3070. --- cpukit/rtems/Makefile.am| 1 + cpukit/rtems/include/rtems/rtems/tasks.h| 25 +++ cpukit/rtems/src/scheduleridentbyprocessorset.c | 60 + testsuites/smptests/smpscheduler02/init.c | 11 + testsuites/sptests/spscheduler01/init.c | 19 5 files changed, 116 insertions(+) create mode 100644 cpukit/rtems/src/scheduleridentbyprocessorset.c diff --git a/cpukit/rtems/Makefile.am b/cpukit/rtems/Makefile.am index e9ad2deb5d..da6e302e2e 100644 --- a/cpukit/rtems/Makefile.am +++ b/cpukit/rtems/Makefile.am @@ -109,6 +109,7 @@ librtems_a_SOURCES += src/scheduleraddprocessor.c librtems_a_SOURCES += src/schedulergetprocessorset.c librtems_a_SOURCES += src/schedulerident.c librtems_a_SOURCES += src/scheduleridentbyprocessor.c +librtems_a_SOURCES += src/scheduleridentbyprocessorset.c librtems_a_SOURCES += src/schedulerremoveprocessor.c ## RATEMON_C_FILES diff --git a/cpukit/rtems/include/rtems/rtems/tasks.h b/cpukit/rtems/include/rtems/rtems/tasks.h index e68c78989d..585f4c449c 100644 --- a/cpukit/rtems/include/rtems/rtems/tasks.h +++ b/cpukit/rtems/include/rtems/rtems/tasks.h @@ -577,6 +577,31 @@ rtems_status_code rtems_scheduler_ident_by_processor( ); /** + * @brief Identifies a scheduler by a processor set. + * + * The scheduler is selected according to the highest numbered online processor + * in the specified processor set. + * + * @param[in] cpusetsize Size of the specified processor set buffer in + * bytes. This value must be positive. + * @param[out] cpuset The processor set to identify the scheduler. + * @param[out] id The scheduler identifier associated with the processor set. + * + * @retval RTEMS_SUCCESSFUL Successful operation. + * @retval RTEMS_INVALID_ADDRESS The @a id parameter is @c NULL. + * @retval RTEMS_INVALID_SIZE Invalid processor set size. + * @retval RTEMS_INVALID_NAME The processor set contains no online processor. + * @retval RTEMS_INCORRECT_STATE The processor set is valid, however, the + * highest numbered online processor in the specified processor set is not + * owned by a scheduler. + */ +rtems_status_code rtems_scheduler_ident_by_processor_set( + size_t cpusetsize, + const cpu_set_t *cpuset, + rtems_id*id +); + +/** * @brief Gets the set of processors owned by the specified scheduler instance. * * @param[in] scheduler_id Identifier of the scheduler instance. diff --git a/cpukit/rtems/src/scheduleridentbyprocessorset.c b/cpukit/rtems/src/scheduleridentbyprocessorset.c new file mode 100644 index 00..4988ed0fb8 --- /dev/null +++ b/cpukit/rtems/src/scheduleridentbyprocessorset.c @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2017 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Dornierstr. 4 + * 82178 Puchheim + * Germany + * + * + * 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. + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include + +rtems_status_code rtems_scheduler_ident_by_processor_set( + size_t cpusetsize, + const cpu_set_t *cpuset, + rtems_id*id +) +{ + Processor_mask set; + Processor_mask_Copy_status status; + uint32_tcpu_index; + const Scheduler_Control*scheduler; + + if ( id == NULL ) { +return RTEMS_INVALID_ADDRESS; + } + + status = _Processor_mask_From_cpu_set_t( &set, cpusetsize, cpuset ); + if ( status == PROCESSOR_MASK_COPY_INVALID_SIZE ) { +return RTEMS_INVALID_SIZE; + } + + _Processor_mask_And( &set, &set, _SMP_Get_online_processors() ); + cpu_index = _Processor_mask_Find_last_set( &set ); + if ( cpu_index == 0 ) { +return RTEMS_INVALID_NAME; + } + + scheduler = _Scheduler_Get_by_CPU( _Per_CPU_Get_by_index( cpu_index - 1) ); +#if defined(RTEMS_SMP) + if ( scheduler == NULL ) { +return RTEMS_INCORRECT_STATE; + } +#else + _Assert( scheduler != NULL ); +#endif + + *id = _Scheduler_Build_id( _Scheduler_Get_index( scheduler ) ); + return RTEMS_SUCCESSFUL; +} diff --git a/testsuites/smptests/smpscheduler02/init.c b/testsuites/smptests/smpscheduler02/init.c index 7dd60ec4c5..3975802d4a 100644 --- a/testsuites/smptests/smpscheduler02/init.c +++ b/testsuites/smptests/smpscheduler02/init.c @@ -134,8 +134,10 @@ static void test_scheduler_add_remove_processors(void) rtems_test_assert(sc == RTEMS_RESOURCE_IN_USE); if (rtems_get_processor_count() > 1) { +rtems_id scheduler_id; rtems_id scheduler_b_id; rtems_id task_id; +cpu_set_t first_cpu; sc = rtems_scheduler_ident(SCHED_B, &scheduler_b_id); rtems_test_assert(sc == RTEMS_SUCCESSFUL); @@ -153,6 +155,15 @@ static void test_scheduler_add_remove_processors(void) rtems_test_assert(rtems_get_current_processor() == 1); +CPU_ZERO(&first_cpu); +CPU_SET(0, &first_cpu); +
[PATCH 5/7] Add interrupt server set affinity
--- c/src/lib/libbsp/shared/src/irq-server.c | 33 + cpukit/include/rtems/irq-extension.h | 36 2 files changed, 69 insertions(+) diff --git a/c/src/lib/libbsp/shared/src/irq-server.c b/c/src/lib/libbsp/shared/src/irq-server.c index 542276c601..61d31754c2 100644 --- a/c/src/lib/libbsp/shared/src/irq-server.c +++ b/c/src/lib/libbsp/shared/src/irq-server.c @@ -750,3 +750,36 @@ rtems_status_code rtems_interrupt_server_resume(uint32_t server_index) ); return RTEMS_SUCCESSFUL; } + +rtems_status_code rtems_interrupt_server_set_affinity( + uint32_tserver_index, + size_t affinity_size, + const cpu_set_t*affinity, + rtems_task_priority priority +) +{ + rtems_status_code sc; + bsp_interrupt_server_context *s; + rtems_id scheduler; + + s = bsp_interrupt_server_get_context(server_index, &sc); + if (s == NULL) { +return sc; + } + + sc = rtems_scheduler_ident_by_processor_set( +affinity_size, +affinity, +&scheduler + ); + if (sc != RTEMS_SUCCESSFUL) { +return sc; + } + + sc = rtems_task_set_scheduler(s->server, scheduler, priority); + if (sc != RTEMS_SUCCESSFUL) { +return sc; + } + + return rtems_task_set_affinity(s->server, affinity_size, affinity); +} diff --git a/cpukit/include/rtems/irq-extension.h b/cpukit/include/rtems/irq-extension.h index 4b49a1a078..9cade113ad 100644 --- a/cpukit/include/rtems/irq-extension.h +++ b/cpukit/include/rtems/irq-extension.h @@ -401,6 +401,42 @@ rtems_status_code rtems_interrupt_server_suspend( uint32_t server_index ); rtems_status_code rtems_interrupt_server_resume( uint32_t server_index ); /** + * @brief Sets the processor affinity of the specified interrupt server. + * + * The scheduler is set determined by the highest numbered processor in the + * specified affinity set. + * + * This operation is only reliable in case the specified interrupt was + * suspended via rtems_interrupt_server_suspend(). + * + * @param[in] server_index The interrupt server index. Use + * @c RTEMS_INTERRUPT_SERVER_DEFAULT to specify the default server. + * @param[in] affinity_size The storage size of the affinity set. + * @param[in] affinity The desired processor affinity set for the specified + * interrupt server. + * @param[in] priority The task priority with respect to the corresponding + * scheduler instance. + * + * @retval RTEMS_SUCCESSFUL Successful operation + * @retval RTEMS_INCORRECT_STATE The interrupt servers are not initialized. + * @retval RTEMS_INVALID_ID If the interrupt server index is invalid. + * @retval RTEMS_INVALID_SIZE Invalid affinity set size. + * @retval RTEMS_INVALID_NAME The affinity set contains no online processor. + * @retval RTEMS_INCORRECT_STATE The highest numbered online processor in the + * specified affinity set is not owned by a scheduler. + * @retval RTEMS_INVALID_PRIORITY Invalid priority. + * @retval RTEMS_RESOURCE_IN_USE The interrupt server owns resources which deny + * a scheduler change. + * @retval RTEMS_INVALID_NUMBER Invalid processor affinity set. + */ +rtems_status_code rtems_interrupt_server_set_affinity( + uint32_tserver_index, + size_t affinity_size, + const cpu_set_t*affinity, + rtems_task_priority priority +); + +/** * @brief Initializes the specified interrupt server entry. * * @param[in] server_index The interrupt server index. Use -- 2.12.3 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[PATCH 4/7] Add interrupt server suspend/resume
This mechanism can be used to safely move the interrupt server from one scheduler instance to another for example. --- c/src/lib/libbsp/shared/src/irq-server.c | 61 ++-- cpukit/include/rtems/irq-extension.h | 39 cpukit/rtems/include/rtems/rtems/event.h | 6 3 files changed, 104 insertions(+), 2 deletions(-) diff --git a/c/src/lib/libbsp/shared/src/irq-server.c b/c/src/lib/libbsp/shared/src/irq-server.c index a37c9caafc..542276c601 100644 --- a/c/src/lib/libbsp/shared/src/irq-server.c +++ b/c/src/lib/libbsp/shared/src/irq-server.c @@ -635,7 +635,7 @@ void rtems_interrupt_server_entry_submit( bsp_interrupt_server_trigger(entry); } -static void bsp_interrupt_server_entry_destroy_helper(void *arg) +static void bsp_interrupt_server_entry_synchronize_helper(void *arg) { bsp_interrupt_server_helper_data *hd = arg; @@ -665,7 +665,7 @@ void rtems_interrupt_server_entry_destroy( 0, NULL, NULL, -bsp_interrupt_server_entry_destroy_helper +bsp_interrupt_server_entry_synchronize_helper ); } @@ -693,3 +693,60 @@ rtems_status_code rtems_interrupt_server_request_initialize( ); return RTEMS_SUCCESSFUL; } + +static void bsp_interrupt_server_entry_suspend_helper(void *arg) +{ + bsp_interrupt_server_helper_data *hd = arg; + rtems_event_set events; + + rtems_event_transient_send(hd->task); + rtems_event_system_receive( +RTEMS_EVENT_SYSTEM_SERVER_RESUME, +RTEMS_WAIT, +RTEMS_NO_TIMEOUT, +&events + ); +} + +rtems_status_code rtems_interrupt_server_suspend(uint32_t server_index) +{ + rtems_status_code sc; + bsp_interrupt_server_context *s; + + s = bsp_interrupt_server_get_context(server_index, &sc); + if (s == NULL) { +return sc; + } + + bsp_interrupt_server_call_helper( +s, +BSP_INTERRUPT_SERVER_MANAGEMENT_VECTOR, +0, +NULL, +NULL, +bsp_interrupt_server_entry_suspend_helper + ); + return RTEMS_SUCCESSFUL; +} + +rtems_status_code rtems_interrupt_server_resume(uint32_t server_index) +{ + rtems_status_code sc; + bsp_interrupt_server_context *s; + + s = bsp_interrupt_server_get_context(server_index, &sc); + if (s == NULL) { +return sc; + } + + rtems_event_system_send(s->server, RTEMS_EVENT_SYSTEM_SERVER_RESUME); + bsp_interrupt_server_call_helper( +s, +BSP_INTERRUPT_SERVER_MANAGEMENT_VECTOR, +0, +NULL, +NULL, +bsp_interrupt_server_entry_synchronize_helper + ); + return RTEMS_SUCCESSFUL; +} diff --git a/cpukit/include/rtems/irq-extension.h b/cpukit/include/rtems/irq-extension.h index 0c72b6e086..4b49a1a078 100644 --- a/cpukit/include/rtems/irq-extension.h +++ b/cpukit/include/rtems/irq-extension.h @@ -362,6 +362,45 @@ rtems_status_code rtems_interrupt_server_handler_iterate( ); /** + * @brief Suspends the specified interrupt server. + * + * A suspend request is sent to the specified interrupt server. This function + * waits for an acknowledgment from the specified interrupt server. + * + * This function must be called from thread context. It may block. Calling + * this function within the context of an interrupt server is undefined + * behaviour. + * + * @param[in] server_index The interrupt server index. Use + * @c RTEMS_INTERRUPT_SERVER_DEFAULT to specify the default server. + * + * @see rtems_interrupt_server_resume(). + * + * @retval RTEMS_SUCCESSFUL Successful operation + * @retval RTEMS_INCORRECT_STATE The interrupt servers are not initialized. + * @retval RTEMS_INVALID_ID If the interrupt server index is invalid. + */ +rtems_status_code rtems_interrupt_server_suspend( uint32_t server_index ); + +/** + * @brief Resumes the specified interrupt server. + * + * This function must be called from thread context. It may block. Calling + * this function within the context of an interrupt server is undefined + * behaviour. + * + * @param[in] server_index The interrupt server index. Use + * @c RTEMS_INTERRUPT_SERVER_DEFAULT to specify the default server. + * + * @see rtems_interrupt_server_suspend(). + * + * @retval RTEMS_SUCCESSFUL Successful operation + * @retval RTEMS_INCORRECT_STATE The interrupt servers are not initialized. + * @retval RTEMS_INVALID_ID If the interrupt server index is invalid. + */ +rtems_status_code rtems_interrupt_server_resume( uint32_t server_index ); + +/** * @brief Initializes the specified interrupt server entry. * * @param[in] server_index The interrupt server index. Use diff --git a/cpukit/rtems/include/rtems/rtems/event.h b/cpukit/rtems/include/rtems/rtems/event.h index 4263a4b881..1cd64c0cfa 100644 --- a/cpukit/rtems/include/rtems/rtems/event.h +++ b/cpukit/rtems/include/rtems/rtems/event.h @@ -319,6 +319,12 @@ rtems_status_code rtems_event_receive ( #define RTEMS_EVENT_SYSTEM_NETWORK_CLOSE RTEMS_EVENT_26 /** + * @brief Reserved system event to resume server threads, e.g timer or + * interrupt server. + */ +#define RTEMS_EVENT_SYSTEM_SERVER_RESUME RTEMS_EVENT_29 + +/** * @b
[PATCH 5/6] Add FDT support for am335x USB driver.
Now RTEMS can detect and mount USB device. --- rtemsbsd/include/bsp/nexus-devices.h | 13 + 1 file changed, 13 insertions(+) diff --git a/rtemsbsd/include/bsp/nexus-devices.h b/rtemsbsd/include/bsp/nexus-devices.h index 1fbf756..2d5694e 100644 --- a/rtemsbsd/include/bsp/nexus-devices.h +++ b/rtemsbsd/include/bsp/nexus-devices.h @@ -46,6 +46,19 @@ RTEMS_BSD_DRIVER_SMC0(0x4e00, RVPBXA9_IRQ_ETHERNET); +#elif defined(LIBBSP_ARM_BEAGLE_BSP_H) + +#include + +RTEMS_BSD_DEFINE_NEXUS_DEVICE(ofwbus, 0, 0, NULL); +SYSINIT_DRIVER_REFERENCE(simplebus, ofwbus); +SYSINIT_DRIVER_REFERENCE(ti_scm, simplebus); +SYSINIT_DRIVER_REFERENCE(am335x_prcm, simplebus); +SYSINIT_DRIVER_REFERENCE(usbss, simplebus); +SYSINIT_DRIVER_REFERENCE(musbotg, usbss); + +RTEMS_BSD_DRIVER_USB; + #elif defined(LIBBSP_ARM_LPC32XX_BSP_H) #include -- 2.7.4 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[PATCH 6/6] Add umass support for Beaglebone black.
Now RTEMS can mount and open USB disk. --- rtemsbsd/include/bsp/nexus-devices.h | 1 + 1 file changed, 1 insertion(+) diff --git a/rtemsbsd/include/bsp/nexus-devices.h b/rtemsbsd/include/bsp/nexus-devices.h index 2d5694e..09a4cc3 100644 --- a/rtemsbsd/include/bsp/nexus-devices.h +++ b/rtemsbsd/include/bsp/nexus-devices.h @@ -58,6 +58,7 @@ SYSINIT_DRIVER_REFERENCE(usbss, simplebus); SYSINIT_DRIVER_REFERENCE(musbotg, usbss); RTEMS_BSD_DRIVER_USB; +RTEMS_BSD_DRIVER_USB_MASS; #elif defined(LIBBSP_ARM_LPC32XX_BSP_H) -- 2.7.4 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[PATCH 4/6] Port am335x usb driver to RTEMS.
--- freebsd/sys/arm/ti/am335x/am335x_prcm.c | 8 freebsd/sys/arm/ti/ti_cpuid.h | 19 +++ freebsd/sys/arm/ti/ti_prcm.c| 2 ++ freebsd/sys/arm/ti/ti_scm.c | 2 ++ libbsd.py | 30 ++ libbsd_waf.py | 6 ++ 6 files changed, 67 insertions(+) diff --git a/freebsd/sys/arm/ti/am335x/am335x_prcm.c b/freebsd/sys/arm/ti/am335x/am335x_prcm.c index 1d10f7f..5494e86 100644 --- a/freebsd/sys/arm/ti/am335x/am335x_prcm.c +++ b/freebsd/sys/arm/ti/am335x/am335x_prcm.c @@ -36,12 +36,18 @@ __FBSDID("$FreeBSD$"); #include #include #include +#ifndef __rtems__ #include +#endif /* __rtems__ */ #include +#ifndef __rtems__ #include +#endif /* __rtems__ */ #include #include +#ifndef __rtems__ #include +#endif /* __rtems__ */ #include #include @@ -438,7 +444,9 @@ am335x_prcm_attach(device_t dev) sc->bsh = rman_get_bushandle(sc->res[0]); am335x_prcm_sc = sc; +#ifndef __rtems__ ti_cpu_reset = am335x_prcm_reset; +#endif /* __rtems__ */ if (am335x_clk_get_sysclk_freq(NULL, &sysclk) != 0) sysclk = 0; diff --git a/freebsd/sys/arm/ti/ti_cpuid.h b/freebsd/sys/arm/ti/ti_cpuid.h index 715f080..213714b 100644 --- a/freebsd/sys/arm/ti/ti_cpuid.h +++ b/freebsd/sys/arm/ti/ti_cpuid.h @@ -29,6 +29,9 @@ #ifndef _TI_CPUID_H_ #define_TI_CPUID_H_ +#ifdef __rtems__ +#include +#endif /* __rtems__ */ #defineOMAP_MAKEREV(d, a, b, c) \ (uint32_t)(((d) << 16) | (((a) & 0xf) << 8) | (((b) & 0xf) << 4) | ((c) & 0xf)) @@ -70,7 +73,23 @@ #defineCHIP_OMAP_4 0 #defineCHIP_AM335X 1 +#ifdef __rtems__ +#ifdef IS_AM335X +#define SOC_TI_AM335X +#else +#warning Unknown SOC. +#endif + +#if defined(SOC_TI_AM335X) +#define _ti_chip CHIP_AM335X +#elif defined(SOC_OMAP4) +#define _ti_chip CHIP_OMAP_4 +#else +#define _ti_chip -1 +#endif +#else /* __rtems__ */ extern int _ti_chip; +#endif /* __rtems__ */ static __inline int ti_chip(void) { diff --git a/freebsd/sys/arm/ti/ti_prcm.c b/freebsd/sys/arm/ti/ti_prcm.c index b4dd03f..04b1b6b 100644 --- a/freebsd/sys/arm/ti/ti_prcm.c +++ b/freebsd/sys/arm/ti/ti_prcm.c @@ -55,7 +55,9 @@ __FBSDID("$FreeBSD$"); #include #include +#ifndef __rtems__ #include +#endif /* __rtems__ */ #include #include diff --git a/freebsd/sys/arm/ti/ti_scm.c b/freebsd/sys/arm/ti/ti_scm.c index 2e54262..d3cbb4f 100644 --- a/freebsd/sys/arm/ti/ti_scm.c +++ b/freebsd/sys/arm/ti/ti_scm.c @@ -66,7 +66,9 @@ __FBSDID("$FreeBSD$"); #include #include #include +#ifndef __rtems__ #include +#endif /* __rtems__ */ #include "ti_scm.h" diff --git a/libbsd.py b/libbsd.py index e171a9d..c53d5a00 100644 --- a/libbsd.py +++ b/libbsd.py @@ -890,6 +890,35 @@ def dev_usb_storage_add_on(mm): return mod # +# BBB USB +# +def dev_usb_controller_bbb(mm): +mod = builder.Module('dev_usb_controller_bbb') +mod.addDependency(mm['dev_usb']) +mod.addKernelSpaceHeaderFiles( +[ +'sys/arm/ti/ti_cpuid.h', +'sys/arm/ti/ti_prcm.h', +'sys/arm/ti/ti_scm.h', +'sys/arm/ti/tivar.h', +'sys/arm/ti/am335x/am335x_scm.h', +'sys/dev/usb/controller/musb_otg.h', +] +) +mod.addKernelSpaceSourceFiles( +[ +'sys/arm/ti/ti_scm.c', +'sys/arm/ti/am335x/am335x_prcm.c', +'sys/arm/ti/am335x/am335x_usbss.c', +'sys/arm/ti/ti_prcm.c', +'sys/arm/ti/am335x/am335x_musb.c', +'sys/dev/usb/controller/musb_otg.c', +], +mm.generator['source']() +) +return mod + +# # USB Template # def dev_usb_template(mm): @@ -3195,6 +3224,7 @@ def sources(mm): mm.addModule(cam(mm)) mm.addModule(dev_usb_storage(mm)) #mm.addModule(dev_usb_storage_add_on(mm)) +mm.addModule(dev_usb_controller_bbb(mm)) #mm.addModule(dev_usb_template(mm)) diff --git a/libbsd_waf.py b/libbsd_waf.py index 30765de..5d0d5d0 100644 --- a/libbsd_waf.py +++ b/libbsd_waf.py @@ -731,6 +731,11 @@ def build(bld): source = ['freebsd/sys/arm/lpc/if_lpe.c', 'freebsd/sys/arm/lpc/lpc_pwr.c', + 'freebsd/sys/arm/ti/am335x/am335x_musb.c', + 'freebsd/sys/arm/ti/am335x/am335x_prcm.c', + 'freebsd/sys/arm/ti/am335x/am335x_usbss.c', + 'freebsd/sys/arm/ti/ti_prcm.c', + 'freebsd/sys/arm/ti/ti_scm.c', 'freebsd/sys/arm/xilinx/zy7_slcr.c', 'freebsd/sys/cam/cam.c', 'freebsd/sys/cam/scsi/scsi_all.c', @@ -896,6 +901,7 @@ def build(bld): 'freebsd/sys/dev/tsec/if_tsec_fdt.c', 'freebsd/sys/dev/usb/controller/dwc_otg.c', 'freebsd/sys/dev/usb/controller/ehci.c', + 'freebsd/sys/dev/usb/controller/musb_otg.c', 'freebsd/sys/dev/usb/controller/ohci.
[PATCH 2/6] Modify the support for multiple memory resources.
rtems-libbsd only support single resource for a device. But some usb control need two resources, such as musb. So modify support for multiple device resources allocation. --- rtemsbsd/rtems/rtems-kernel-nexus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rtemsbsd/rtems/rtems-kernel-nexus.c b/rtemsbsd/rtems/rtems-kernel-nexus.c index 1a5a9ef..35e56ee 100644 --- a/rtemsbsd/rtems/rtems-kernel-nexus.c +++ b/rtemsbsd/rtems/rtems-kernel-nexus.c @@ -139,7 +139,7 @@ nexus_get_start(const rtems_bsd_device *nd, int type, int rid, rman_res_t *start for (i = 0; i < nd->resource_count; ++i) { const rtems_bsd_device_resource *dr = &nd->resources[i]; - if (dr->type == type && dr->start_request == sr) { + if (dr->type == type && dr->start_request >= sr) { if(rid--) continue; *start = dr->start_actual; -- 2.7.4 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[PATCH 1/6] Add support for multiple memory resources.
From: Hans Petter Selasky --- rtemsbsd/rtems/rtems-kernel-nexus.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/rtemsbsd/rtems/rtems-kernel-nexus.c b/rtemsbsd/rtems/rtems-kernel-nexus.c index 008e4b2..1a5a9ef 100644 --- a/rtemsbsd/rtems/rtems-kernel-nexus.c +++ b/rtemsbsd/rtems/rtems-kernel-nexus.c @@ -131,7 +131,7 @@ nexus_probe(device_t dev) } static bool -nexus_get_start(const rtems_bsd_device *nd, int type, rman_res_t *start) +nexus_get_start(const rtems_bsd_device *nd, int type, int rid, rman_res_t *start) { u_long sr = (u_long)*start; size_t i; @@ -140,6 +140,8 @@ nexus_get_start(const rtems_bsd_device *nd, int type, rman_res_t *start) const rtems_bsd_device_resource *dr = &nd->resources[i]; if (dr->type == type && dr->start_request == sr) { + if(rid--) + continue; *start = dr->start_actual; return (true); @@ -176,7 +178,7 @@ nexus_alloc_resource(device_t bus, device_t child, int type, int *rid, SET_FOREACH(nd, nexus) { if (strcmp(device_get_name(child), nd->name) == 0 && device_get_unit(child) == nd->unit) { - if (nexus_get_start(nd, type, &start)) { + if (nexus_get_start(nd, type, *rid, &start)) { res = rman_reserve_resource(rm, start, end, count, flags, child); if (res != NULL) { -- 2.7.4 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[PATCH v2 1/2] Add FDT support for Beaglebone Black.
--- c/src/lib/libbsp/arm/beagle/Makefile.am| 1 + c/src/lib/libbsp/arm/beagle/configure.ac | 9 + c/src/lib/libbsp/arm/beagle/include/bsp.h | 6 +- c/src/lib/libbsp/arm/beagle/startup/bspstart.c | 5 + c/src/lib/libbsp/arm/shared/start/start.S | 5 + 5 files changed, 25 insertions(+), 1 deletion(-) diff --git a/c/src/lib/libbsp/arm/beagle/Makefile.am b/c/src/lib/libbsp/arm/beagle/Makefile.am index 8e10ee2..e7c44a1 100644 --- a/c/src/lib/libbsp/arm/beagle/Makefile.am +++ b/c/src/lib/libbsp/arm/beagle/Makefile.am @@ -76,6 +76,7 @@ libbsp_a_LIBADD = # Shared libbsp_a_SOURCES += ../../shared/bootcard.c +libbsp_a_SOURCES += ../../shared/src/bsp-fdt.c libbsp_a_SOURCES += ../../shared/bspclean.c libbsp_a_SOURCES += ../../shared/bspgetworkarea.c libbsp_a_SOURCES += ../../shared/bsppredriverhook.c diff --git a/c/src/lib/libbsp/arm/beagle/configure.ac b/c/src/lib/libbsp/arm/beagle/configure.ac index b0c99a3..ad09a62 100644 --- a/c/src/lib/libbsp/arm/beagle/configure.ac +++ b/c/src/lib/libbsp/arm/beagle/configure.ac @@ -18,6 +18,15 @@ RTEMS_PROG_CC_FOR_TARGET RTEMS_CANONICALIZE_TOOLS RTEMS_PROG_CCAS +RTEMS_BSPOPTS_SET([BSP_START_COPY_FROM_U_BOOT],[beaglebone*],[1]) +RTEMS_BSPOPTS_HELP([BSP_START_COPY_FROM_U_BOOT],[enables U-Boot support using FDT]) + +RTEMS_BSPOPTS_SET([BSP_FDT_BLOB_SIZE_MAX],[beaglebone*],[262144]) +RTEMS_BSPOPTS_HELP([BSP_FDT_BLOB_SIZE_MAX],[maximum size of the FDT blob in bytes]) + +RTEMS_BSPOPTS_SET([BSP_FDT_BLOB_READ_ONLY],[beaglebone*],[1]) +RTEMS_BSPOPTS_HELP([BSP_FDT_BLOB_READ_ONLY],[place the FDT blob into the read-only data area]) + RTEMS_BSPOPTS_SET([IS_DM3730],[beagleboard*],[1]) RTEMS_BSPOPTS_HELP([IS_DM3730],[true if SOC is DM3730]) diff --git a/c/src/lib/libbsp/arm/beagle/include/bsp.h b/c/src/lib/libbsp/arm/beagle/include/bsp.h index d9fd2ae..8a45480 100644 --- a/c/src/lib/libbsp/arm/beagle/include/bsp.h +++ b/c/src/lib/libbsp/arm/beagle/include/bsp.h @@ -187,6 +187,10 @@ static inline void flush_data_cache(void) #define BSP_GPIO_PINS_PER_BANK 32 #endif +#if BSP_START_COPY_FROM_U_BOOT +#define BSP_FDT_IS_SUPPORTED +#endif + /* i2c stuff */ typedef struct { uint32_t rx_or_tx; @@ -357,4 +361,4 @@ static inline void write_ttbr0(uint32_t bar) */ BSP_START_TEXT_SECTION void beagle_setup_mmu_and_cache(void); -#endif /* LIBBSP_ARM_BEAGLE_BSP_H */ \ No newline at end of file +#endif /* LIBBSP_ARM_BEAGLE_BSP_H */ diff --git a/c/src/lib/libbsp/arm/beagle/startup/bspstart.c b/c/src/lib/libbsp/arm/beagle/startup/bspstart.c index b156564..c527ea0 100644 --- a/c/src/lib/libbsp/arm/beagle/startup/bspstart.c +++ b/c/src/lib/libbsp/arm/beagle/startup/bspstart.c @@ -27,3 +27,8 @@ void bsp_start(void) bsp_interrupt_initialize(); printk("\nRTEMS Beagleboard: %s\n", type); } + +uint32_t bsp_fdt_map_intr(uint32_t intr) +{ + return intr; +} diff --git a/c/src/lib/libbsp/arm/shared/start/start.S b/c/src/lib/libbsp/arm/shared/start/start.S index c5263ec..a2fc671 100755 --- a/c/src/lib/libbsp/arm/shared/start/start.S +++ b/c/src/lib/libbsp/arm/shared/start/start.S @@ -183,6 +183,11 @@ _start: bl bsp_start_init_registers_core #endif +#ifdef BSP_START_COPY_FROM_U_BOOT + mov r0, r6 + bl bsp_fdt_copy +#endif + #ifdef RTEMS_SMP /* Read MPIDR and get current processor index */ mrc p15, 0, r0, c0, c0, 5 -- 2.7.4 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[PATCH v2 2/2] Add dts file to generate dtb binary file for Beaglebone black.
These dts files import from FreeBSD, git link: https://github.com/freebsd/freebsd/tree/master/sys/gnu/dts The license for these files in beagle/simscripts --- c/src/lib/libbsp/arm/beagle/README | 11 + c/src/lib/libbsp/arm/beagle/simscripts/LICENSE |2 + .../arm/beagle/simscripts/am335x-bone-common.dtsi | 417 .../beagle/simscripts/am335x-boneblack-common.dtsi | 163 .../arm/beagle/simscripts/am335x-boneblack.dts | 28 + .../arm/beagle/simscripts/am33xx-clocks.dtsi | 646 + c/src/lib/libbsp/arm/beagle/simscripts/am33xx.dtsi | 1011 .../simscripts/dt-bindings/display/tda998x.h |7 + .../arm/beagle/simscripts/dt-bindings/gpio/gpio.h | 31 + .../beagle/simscripts/dt-bindings/pinctrl/am33xx.h | 43 + .../beagle/simscripts/dt-bindings/pinctrl/omap.h | 90 ++ c/src/lib/libbsp/arm/beagle/simscripts/sdcard.sh | 10 +- .../lib/libbsp/arm/beagle/simscripts/tps65217.dtsi | 68 ++ 13 files changed, 2525 insertions(+), 2 deletions(-) create mode 100644 c/src/lib/libbsp/arm/beagle/simscripts/LICENSE create mode 100644 c/src/lib/libbsp/arm/beagle/simscripts/am335x-bone-common.dtsi create mode 100644 c/src/lib/libbsp/arm/beagle/simscripts/am335x-boneblack-common.dtsi create mode 100644 c/src/lib/libbsp/arm/beagle/simscripts/am335x-boneblack.dts create mode 100644 c/src/lib/libbsp/arm/beagle/simscripts/am33xx-clocks.dtsi create mode 100644 c/src/lib/libbsp/arm/beagle/simscripts/am33xx.dtsi create mode 100644 c/src/lib/libbsp/arm/beagle/simscripts/dt-bindings/display/tda998x.h create mode 100644 c/src/lib/libbsp/arm/beagle/simscripts/dt-bindings/gpio/gpio.h create mode 100644 c/src/lib/libbsp/arm/beagle/simscripts/dt-bindings/pinctrl/am33xx.h create mode 100644 c/src/lib/libbsp/arm/beagle/simscripts/dt-bindings/pinctrl/omap.h create mode 100644 c/src/lib/libbsp/arm/beagle/simscripts/tps65217.dtsi diff --git a/c/src/lib/libbsp/arm/beagle/README b/c/src/lib/libbsp/arm/beagle/README index e558287..2ed9393 100644 --- a/c/src/lib/libbsp/arm/beagle/README +++ b/c/src/lib/libbsp/arm/beagle/README @@ -93,6 +93,17 @@ uboot# bootm 0x8080 There is a script here that automatically writes an SD card for any of the beagle targets. +Before using the script, you need DTC(device tree compiler) tool to +compile dts to dtb file. So you need add this tool in RSB bset file. + +These dts and dtsi files are licensed under the terms of the GNU +General Public License * version 2. + +For example, to add dtc tool in rtems-arm.bset, you need include +dtc.bset in rtems-arm.bset. + +%include devel/dtc.bset + Let's write one for the Beaglebone Black. Assuming your source tree is at $HOME/development/rtems/rtems-src and your bsp is built and linked with examples and installed at $HOME/development/rtems/4.11. diff --git a/c/src/lib/libbsp/arm/beagle/simscripts/LICENSE b/c/src/lib/libbsp/arm/beagle/simscripts/LICENSE new file mode 100644 index 000..587a3dd --- /dev/null +++ b/c/src/lib/libbsp/arm/beagle/simscripts/LICENSE @@ -0,0 +1,2 @@ +These files are imported from FreeBSD. +These files is licensed under the terms of the GNU General Public License * version 2. diff --git a/c/src/lib/libbsp/arm/beagle/simscripts/am335x-bone-common.dtsi b/c/src/lib/libbsp/arm/beagle/simscripts/am335x-bone-common.dtsi new file mode 100644 index 000..bf6b26a --- /dev/null +++ b/c/src/lib/libbsp/arm/beagle/simscripts/am335x-bone-common.dtsi @@ -0,0 +1,417 @@ +/* + * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +/ { + cpus { + cpu@0 { + cpu0-supply = <&dcdc2_reg>; + }; + }; + + memory@8000 { + device_type = "memory"; + reg = <0x8000 0x1000>; /* 256 MB */ + }; + + chosen { + stdout-path = &uart0; + }; + + leds { + pinctrl-names = "default"; + pinctrl-0 = <&user_leds_s0>; + + compatible = "gpio-leds"; + + led2 { + label = "beaglebone:green:heartbeat"; + gpios = <&gpio1 21 GPIO_ACTIVE_HIGH>; + linux,default-trigger = "heartbeat"; + default-state = "off"; + }; + + led3 { + label = "beaglebone:green:mmc0"; + gpios = <&gpio1 22 GPIO_ACTIVE_HIGH>; + linux,default-trigger = "mmc0"; + default-state = "off"; + }; + + led4 { + label = "beaglebone:green:usr2"; + gpios = <&gpio1 23 GPIO_ACTIVE_HIGH>; + linux,default-tri