diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2021-06-26 17:09:37 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2021-07-12 14:53:01 +0200 |
commit | 37dd80169403bd64b926a9a0d331ba8624fc2306 (patch) | |
tree | 4ec4ccc281634a26d1a498bd260be08dcedec803 | |
parent | spec: Specify rtems_interrupt_vector_disable() (diff) | |
download | rtems-central-37dd80169403bd64b926a9a0d331ba8624fc2306.tar.bz2 |
spec: Specify rtems_interrupt_entry_install()
-rw-r--r-- | spec/rtems/intr/req/entry-install.yml | 891 |
1 files changed, 891 insertions, 0 deletions
diff --git a/spec/rtems/intr/req/entry-install.yml b/spec/rtems/intr/req/entry-install.yml new file mode 100644 index 00000000..67d20996 --- /dev/null +++ b/spec/rtems/intr/req/entry-install.yml @@ -0,0 +1,891 @@ +SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause +copyrights: +- Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de) +enabled-by: true +functional-type: action +links: +- role: interface-function + uid: ../if/entry-install +post-conditions: +- name: Status + states: + - name: Ok + test-code: | + T_rsc_success( ctx->status ); + text: | + The return status of ${../if/entry-install:/name} shall be + ${../../status/if/successful:/name}. + - name: InvAddr + test-code: | + T_rsc( ctx->status, RTEMS_INVALID_ADDRESS ); + text: | + The return status of ${../if/entry-install:/name} shall be + ${../../status/if/invalid-address:/name}. + - name: IncStat + test-code: | + T_rsc( ctx->status, RTEMS_INCORRECT_STATE ); + text: | + The return status of ${../if/entry-install:/name} shall be + ${../../status/if/incorrect-state:/name}. + - name: InvId + test-code: | + T_rsc( ctx->status, RTEMS_INVALID_ID ); + text: | + The return status of ${../if/entry-install:/name} shall be + ${../../status/if/invalid-id:/name}. + - name: InvNum + test-code: | + T_rsc( ctx->status, RTEMS_INVALID_NUMBER ); + text: | + The return status of ${../if/entry-install:/name} shall be + ${../../status/if/invalid-number:/name}. + - name: CalledFromISR + test-code: | + T_rsc( ctx->status, RTEMS_CALLED_FROM_ISR ); + text: | + The return status of ${../if/entry-install:/name} shall be + ${../../status/if/called-from-isr:/name}. + - name: InUse + test-code: | + T_rsc( ctx->status, RTEMS_RESOURCE_IN_USE ); + text: | + The return status of ${../if/entry-install:/name} shall be + ${../../status/if/resource-in-use:/name}. + - name: TooMany + test-code: | + T_rsc( ctx->status, RTEMS_TOO_MANY ); + text: | + The return status of ${../if/entry-install:/name} shall be + ${../../status/if/too-many:/name}. + test-epilogue: null + test-prologue: null +- name: IsEnabled + states: + - name: Nop + test-code: | + if ( !ctx->interrupt_occurred ) { + T_eq( ctx->enabled_before, ctx->enabled_after ); + } + text: | + The enabled status of the interrupt vector specified by + ${../if/entry-install:/params[0]/name} shall not be modified by the + ${../if/entry-install:/name} call. + - name: 'Yes' + test-code: | + T_false( ctx->enabled_before ); + T_true( ctx->enabled_after || ctx->interrupt_occurred ); + text: | + The interrupt vector specified by ${../if/entry-install:/params[0]/name} + shall be enabled. + test-epilogue: null + test-prologue: null +- name: Installed + states: + - name: 'No' + test-code: | + if ( ctx->other_installed && ctx->third_installed ) { + T_eq_u32( ctx->visited_entries, 2 ); + } else if ( ctx->other_installed ) { + T_eq_u32( ctx->visited_entries, 1 ); + } else { + T_eq_u32( ctx->visited_entries, 0 ); + } + text: | + The entry referenced by ${../if/entry-install:/params[2]/name} shall not + be installed at the interrupt vector specified by + ${../if/entry-install:/params[0]/name}. + - name: Last + test-code: | + if ( ctx->other_installed && ctx->third_installed ) { + T_eq_u32( ctx->visited_entries, 3 ); + } else if ( ctx->other_installed ) { + T_eq_u32( ctx->visited_entries, 2 ); + } else { + T_eq_u32( ctx->visited_entries, 1 ); + } + text: | + The entry referenced by ${../if/entry-install:/params[2]/name} shall be + installed as the last entry at the interrupt vector specified by + ${../if/entry-install:/params[0]/name}. + test-epilogue: null + test-prologue: | + rtems_status_code sc; + + ctx->visited_entries = 0; + sc = rtems_interrupt_handler_iterate( + ctx->valid_vector, + VisitInstalled, + ctx + ); + T_rsc_success( sc ); +pre-conditions: +- name: Vector + states: + - name: Valid + test-code: | + ctx->vector = ctx->valid_vector; + text: | + While the ${../if/entry-install:/params[0]/name} parameter is + associated with an interrupt vector. + - name: Invalid + test-code: | + ctx->vector = BSP_INTERRUPT_VECTOR_COUNT; + text: | + While the ${../if/entry-install:/params[0]/name} parameter is + not associated with an interrupt vector. + test-epilogue: null + test-prologue: null +- name: Options + states: + - name: Unique + test-code: | + ctx->options = RTEMS_INTERRUPT_UNIQUE; + text: | + While the ${../if/entry-install:/params[1]/name} indicates that an unique + entry shall be installed. + - name: Shared + test-code: | + ctx->options = RTEMS_INTERRUPT_SHARED; + text: | + While the ${../if/entry-install:/params[1]/name} indicates that a shared + entry shall be installed. + - name: Replace + test-code: | + ctx->options = RTEMS_INTERRUPT_REPLACE; + text: | + While the ${../if/entry-install:/params[1]/name} indicates that the entry + handler routine shall be replaced. + test-epilogue: null + test-prologue: null +- name: Entry + states: + - name: Obj + test-code: | + ctx->entry = &ctx->entry_obj; + text: | + While the ${../if/entry-install:/params[2]/name} parameter references an + object of type ${../if/entry:/name}. + - name: 'Null' + test-code: | + ctx->entry = NULL; + text: | + While the ${../if/entry-install:/params[2]/name} parameter is equal to + ${/c/if/null:/name}. + test-epilogue: null + test-prologue: null +- name: Routine + states: + - name: Valid + test-code: | + rtems_interrupt_entry_initialize( + &ctx->entry_obj, + EntryRoutine, + &entry_arg, + entry_info + ); + text: | + While the handler routine of the object referenced by the + ${../if/entry-install:/params[2]/name} parameter is valid. + - name: 'Null' + test-code: | + rtems_interrupt_entry_initialize( + &ctx->entry_obj, + NULL, + &entry_arg, + entry_info + ); + text: | + While the handler routine of the object referenced by the + ${../if/entry-install:/params[2]/name} parameter is equal to + ${/c/if/null:/name}. + test-epilogue: null + test-prologue: null +- name: Init + states: + - name: 'Yes' + test-code: | + ctx->initialized = true; + text: | + While the service is initialized. + - name: 'No' + test-code: | + ctx->initialized = false; + text: | + While the service is not initialized. + test-epilogue: null + test-prologue: null +- name: ISR + states: + - name: 'Yes' + test-code: | + ctx->isr = true; + text: | + While ${../if/entry-install:/name} is called from within interrupt + context. + - name: 'No' + test-code: | + ctx->isr = false; + text: | + While ${../if/entry-install:/name} is not called from within interrupt + context. + test-epilogue: null + test-prologue: null +- name: Installed + states: + - name: None + test-code: | + /* Nothing to do */ + text: | + While the no entry is installed at the interrupt vector specified by the + ${../if/entry-install:/params[0]/name} parameter. + - name: Unique + test-code: | + Install( ctx, RTEMS_INTERRUPT_UNIQUE, EntryRoutine, &entry_arg ); + text: | + While a unique entry is installed at the interrupt vector specified by + the ${../if/entry-install:/params[0]/name} parameter. + - name: Other + test-code: | + Install( ctx, RTEMS_INTERRUPT_SHARED, OtherRoutine, &other_arg ); + InstallThird( ctx ); + text: | + While at least one non-unique entry is installed at the interrupt vector + specified by the ${../if/entry-install:/params[0]/name} parameter, + while all entries installed at the interrupt vector specified by the + ${../if/entry-install:/params[0]/name} parameter have a handler routine + which is not equal to the handler routine of the object referenced by the + ${../if/entry-install:/params[2]/name} parameter, + while all entries installed at the interrupt vector specified by the + ${../if/entry-install:/params[0]/name} parameter have a handler argument + which is not equal to the handler argument of the object referenced by + the ${../if/entry-install:/params[2]/name} parameter. + - name: EqRoutine + test-code: | + Install( ctx, RTEMS_INTERRUPT_SHARED, EntryRoutine, &other_arg ); + text: | + While at least one non-unique entry is installed at the interrupt vector + specified by the ${../if/entry-install:/params[0]/name} parameter, + while at least one entry installed at the interrupt vector specified by + the ${../if/entry-install:/params[0]/name} parameter has a handler + routine which is equal to the handler routine of the object referenced by + the ${../if/entry-install:/params[2]/name} parameter, + while all entries installed at the interrupt vector specified by the + ${../if/entry-install:/params[0]/name} parameter have a handler argument + which is not equal to the handler argument of the object referenced by + the ${../if/entry-install:/params[2]/name} parameter. + - name: EqArg + test-code: | + Install( ctx, RTEMS_INTERRUPT_SHARED, OtherRoutine, &other_arg ); + text: | + While at least one non-unique entry is installed at the interrupt vector + specified by the ${../if/entry-install:/params[0]/name} parameter, + while all entries installed at the interrupt vector specified by the + ${../if/entry-install:/params[0]/name} parameter have a handler routine + which is not equal to the handler routine of the object referenced by the + ${../if/entry-install:/params[2]/name} parameter, + while at least one entry installed at the interrupt vector specified by + the ${../if/entry-install:/params[0]/name} parameter has a handler + argument which is equal to the handler argument of the object referenced + by the ${../if/entry-install:/params[2]/name} parameter. + - name: Match + test-code: | + Install( ctx, RTEMS_INTERRUPT_SHARED, EntryRoutine, &entry_arg ); + text: | + While at least one non-unique entry with a handler routine which is equal + to the handler routine of the object referenced by the + ${../if/entry-install:/params[2]/name} parameter and with a handler + argument which is equal to the handler argument of the object referenced + by the ${../if/entry-install:/params[2]/name} parameter is installed at + the interrupt vector specified by the + ${../if/entry-install:/params[0]/name} parameter. + test-epilogue: null + test-prologue: null +rationale: null +references: [] +requirement-type: functional +skip-reasons: {} +test-action: | + if ( ctx->isr ) { + CallWithinISR( Action, ctx ); + } else { + Action( ctx ); + } +test-brief: null +test-cleanup: | + rtems_status_code sc; + + if ( ctx->third_installed ) { + sc = rtems_interrupt_entry_remove( ctx->valid_vector, &ctx->third_entry ); + T_rsc_success( sc ); + } + + if ( ctx->other_installed ) { + sc = rtems_interrupt_entry_remove( ctx->valid_vector, &ctx->other_entry ); + T_rsc_success( sc ); + } + + if ( ctx->status == RTEMS_SUCCESSFUL ) { + sc = rtems_interrupt_entry_remove( ctx->valid_vector, ctx->entry ); + T_rsc_success( sc ); + } +test-context: +- brief: | + If this member is true, then the service was initialized during setup. + description: null + member: | + bool initialized_during_setup +- brief: | + If this member is true, then an interrupt occurred. + description: null + member: | + bool interrupt_occurred +- brief: | + This member provides a valid interrupt vector number. + description: null + member: | + rtems_vector_number valid_vector +- brief: | + If this member is true, then the service shall be initialized. + description: null + member: | + bool initialized +- brief: | + If this member is true, then ${../if/entry-install:/name} shall be called + from within interrupt context. + description: null + member: | + bool isr +- brief: | + This member contains the enabled status before the + ${../if/entry-install:/name} call. + description: null + member: | + bool enabled_before +- brief: | + This member contains the enabled status after the + ${../if/entry-install:/name} call. + description: null + member: | + bool enabled_after +- brief: | + This member provides the count of visited entries. + description: null + member: | + uint32_t visited_entries +- brief: | + This member provides another ${../if/entry:/name} object. + description: null + member: | + rtems_interrupt_entry other_entry +- brief: | + If this member is true, then another entry was installed. + description: null + member: | + bool other_installed +- brief: | + This member provides a third ${../if/entry:/name} object. + description: null + member: | + rtems_interrupt_entry third_entry +- brief: | + If this member is true, then the third entry was installed. + description: null + member: | + bool third_installed +- brief: | + This member provides the options used to install the other + ${../if/entry:/name} object. + description: null + member: | + rtems_option other_options +- brief: | + This member provides the ${../if/entry:/name} object. + description: null + member: | + rtems_interrupt_entry entry_obj +- brief: | + This member specifies if the ${../if/entry-install:/params[0]/name} + parameter value. + description: null + member: | + rtems_vector_number vector +- brief: | + This member specifies if the ${../if/entry-install:/params[1]/name} + parameter value. + description: null + member: | + rtems_option options +- brief: | + This member specifies if the ${../if/entry-install:/params[2]/name} + parameter value. + description: null + member: | + rtems_interrupt_entry *entry; +- brief: | + This member contains the return value of the ${../if/entry-install:/name} + call. + description: null + member: | + rtems_status_code status +test-context-support: null +test-description: null +test-header: null +test-includes: +- rtems/irq-extension.h +- bsp/irq-generic.h +test-local-includes: +- tx-support.h +test-prepare: | + ctx->interrupt_occurred = false; + ctx->other_installed = false; + ctx->third_installed = false; +test-setup: + brief: null + code: | + ctx->initialized_during_setup = bsp_interrupt_is_initialized(); + + /* Find a valid interrupt vector for this test */ + for ( + ctx->valid_vector = 0; + ctx->valid_vector < BSP_INTERRUPT_VECTOR_COUNT; + ++ctx->valid_vector + ) { + rtems_status_code sc; + rtems_interrupt_attributes attr; + + sc = rtems_interrupt_get_attributes( ctx->valid_vector, &attr ); + + if ( + sc == RTEMS_SUCCESSFUL && attr.can_enable && attr.can_disable && + attr.is_maskable && + !HasInterruptVectorEntriesInstalled( ctx->valid_vector ) + ) { + break; + } + } + description: null +test-stop: null +test-support: | + typedef RtemsIntrReqEntryInstall_Context Context; + + static char entry_arg; + + static char other_arg; + + static char third_arg; + + static const char entry_info[] = "Entry"; + + static const char other_info[] = "Other"; + + static const char third_info[] = "Third"; + + static void Install( + Context *ctx, + rtems_option options, + rtems_interrupt_handler routine, + void *arg + ) + { + rtems_status_code sc; + + ctx->other_options = options; + rtems_interrupt_entry_initialize( + &ctx->other_entry, + routine, + arg, + other_info + ); + + sc = rtems_interrupt_entry_install( + ctx->valid_vector, + options, + &ctx->other_entry + ); + T_rsc_success( sc ); + + ctx->other_installed = true; + } + + static void OtherRoutine( void *arg ) + { + Context *ctx; + rtems_status_code sc; + + (void) arg; + ctx = T_fixture_context(); + sc = rtems_interrupt_vector_disable( ctx->valid_vector ); + T_rsc_success( sc ); + + ctx->interrupt_occurred = true; + } + + static void EntryRoutine( void *arg ) + { + T_eq_ptr( arg, &entry_arg ); + OtherRoutine( NULL ); + } + + static void ThirdRoutine( void *arg ) + { + T_eq_ptr( arg, &third_arg ); + OtherRoutine( NULL ); + } + + static void InstallThird( Context *ctx ) + { + rtems_status_code sc; + + rtems_interrupt_entry_initialize( + &ctx->third_entry, + ThirdRoutine, + &third_arg, + third_info + ); + + sc = rtems_interrupt_entry_install( + ctx->valid_vector, + RTEMS_INTERRUPT_SHARED, + &ctx->third_entry + ); + T_rsc_success( sc ); + + ctx->third_installed = true; + } + + static void Action( void *arg ) + { + Context *ctx; + rtems_status_code sc; + + ctx = arg; + + sc = rtems_interrupt_vector_is_enabled( + ctx->valid_vector, + &ctx->enabled_before + ); + T_rsc_success( sc ); + + bsp_interrupt_set_handler_unique( + BSP_INTERRUPT_HANDLER_TABLE_SIZE, + ctx->initialized + ); + + ctx->status = rtems_interrupt_entry_install( + ctx->vector, + ctx->options, + ctx->entry + ); + + bsp_interrupt_set_handler_unique( + BSP_INTERRUPT_HANDLER_TABLE_SIZE, + ctx->initialized_during_setup + ); + + sc = rtems_interrupt_vector_is_enabled( + ctx->valid_vector, + &ctx->enabled_after + ); + T_rsc_success( sc ); + } + + static void VisitInstalled( + void *arg, + const char *info, + rtems_option options, + rtems_interrupt_handler handler_routine, + void *handler_arg + ) + { + Context *ctx; + uint32_t visited_entries; + + ctx = arg; + visited_entries = ctx->visited_entries; + + if ( visited_entries == 0 && ctx->other_installed ) { + T_eq_ptr( info, other_info ); + T_eq_u32( options, ctx->other_options ); + T_eq_ptr( handler_routine, ctx->other_entry.handler ); + T_eq_ptr( handler_arg, ctx->other_entry.arg ); + } else if ( visited_entries == 1 && ctx->third_installed ) { + T_eq_ptr( info, third_info ); + T_eq_u32( options, RTEMS_INTERRUPT_SHARED ); + T_eq_ptr( handler_routine, ThirdRoutine ); + T_eq_ptr( handler_arg, &third_arg ); + } else { + T_eq_ptr( info, entry_info ); + T_eq_u32( options, ctx->options ); + T_eq_ptr( handler_routine, ctx->entry_obj.handler ); + T_eq_ptr( handler_arg, ctx->entry_obj.arg ); + } + + ctx->visited_entries = visited_entries + 1; + } +test-target: testsuites/validation/tc-intr-entry-install.c +test-teardown: null +text: ${.:text-template} +transition-map: +- enabled-by: true + post-conditions: + Status: Ok + IsEnabled: 'Yes' + Installed: Last + pre-conditions: + Vector: + - Valid + Options: + - Unique + Entry: + - Obj + Routine: + - Valid + Init: + - 'Yes' + ISR: + - 'No' + Installed: + - None +- enabled-by: true + post-conditions: + Status: Ok + IsEnabled: + - if: + pre-conditions: + Installed: None + then: 'Yes' + - else: Nop + Installed: Last + pre-conditions: + Vector: + - Valid + Options: + - Shared + Entry: + - Obj + Routine: + - Valid + Init: + - 'Yes' + ISR: + - 'No' + Installed: + - None + - Other + - EqRoutine + - EqArg +- enabled-by: true + post-conditions: + Status: InvAddr + IsEnabled: Nop + Installed: N/A + pre-conditions: + Vector: + - Valid + Options: all + Entry: + - 'Null' + Routine: N/A + Init: all + ISR: all + Installed: all +- enabled-by: true + post-conditions: + Status: InvAddr + IsEnabled: N/A + Installed: N/A + pre-conditions: + Vector: + - Invalid + Options: all + Entry: + - 'Null' + Routine: N/A + Init: all + ISR: all + Installed: N/A +- enabled-by: true + post-conditions: + Status: IncStat + IsEnabled: Nop + Installed: 'No' + pre-conditions: + Vector: + - Valid + Options: all + Entry: + - Obj + Routine: all + Init: + - 'No' + ISR: all + Installed: all +- enabled-by: true + post-conditions: + Status: IncStat + IsEnabled: N/A + Installed: N/A + pre-conditions: + Vector: + - Invalid + Options: all + Entry: + - Obj + Routine: all + Init: + - 'No' + ISR: all + Installed: N/A +- enabled-by: true + post-conditions: + Status: InvAddr + IsEnabled: Nop + Installed: 'No' + pre-conditions: + Vector: + - Valid + Options: all + Entry: + - Obj + Routine: + - 'Null' + Init: + - 'Yes' + ISR: all + Installed: all +- enabled-by: true + post-conditions: + Status: InvAddr + IsEnabled: N/A + Installed: N/A + pre-conditions: + Vector: + - Invalid + Options: all + Entry: + - Obj + Routine: + - 'Null' + Init: + - 'Yes' + ISR: all + Installed: N/A +- enabled-by: true + post-conditions: + Status: InvId + IsEnabled: N/A + Installed: N/A + pre-conditions: + Vector: + - Invalid + Options: all + Entry: + - Obj + Routine: + - Valid + Init: + - 'Yes' + ISR: all + Installed: N/A +- enabled-by: true + post-conditions: + Status: CalledFromISR + IsEnabled: Nop + Installed: 'No' + pre-conditions: + Vector: + - Valid + Options: all + Entry: + - Obj + Routine: + - Valid + Init: + - 'Yes' + ISR: + - 'Yes' + Installed: all +- enabled-by: true + post-conditions: + Status: InvNum + IsEnabled: Nop + Installed: 'No' + pre-conditions: + Vector: + - Valid + Options: + - Replace + Entry: + - Obj + Routine: + - Valid + Init: + - 'Yes' + ISR: + - 'No' + Installed: all +- enabled-by: true + post-conditions: + Status: InUse + IsEnabled: Nop + Installed: 'No' + pre-conditions: + Vector: + - Valid + Options: + - Unique + Entry: + - Obj + Routine: + - Valid + Init: + - 'Yes' + ISR: + - 'No' + Installed: + - Unique + - Other + - EqRoutine + - EqArg + - Match +- enabled-by: true + post-conditions: + Status: InUse + IsEnabled: Nop + Installed: 'No' + pre-conditions: + Vector: + - Valid + Options: + - Shared + Entry: + - Obj + Routine: + - Valid + Init: + - 'Yes' + ISR: + - 'No' + Installed: + - Unique +- enabled-by: true + post-conditions: + Status: TooMany + IsEnabled: Nop + Installed: 'No' + pre-conditions: + Vector: + - Valid + Options: + - Shared + Entry: + - Obj + Routine: + - Valid + Init: + - 'Yes' + ISR: + - 'No' + Installed: + - Match +type: requirement |