<commit_before>/* thread.c - test nanokernel CPU and thread APIs */

/*
 * Copyright (c) 2012-2015 Wind River Systems, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
DESCRIPTION
This module tests the following CPU and thread related routines:
  fiber_fiber_start(), task_fiber_start(), fiber_yield(),
  sys_thread_self_get(), sys_execution_context_type_get(), nano_cpu_idle(),
  irq_lock(), irq_unlock(),
  irq_offload(), nanoCpuExcConnect(),
  irq_enable(), irq_disable(),
 */

#include <tc_util.h>
#include <nano_private.h>
#include <arch/cpu.h>
#include <irq_offload.h>

#include <util_test_common.h>

/*
 * Include board.h from platform to get IRQ number.
 * NOTE: Cortex-M3/M4 does not need IRQ numbers
 */
#if !defined(CONFIG_CPU_CORTEX_M3_M4)
  #include <board.h>
#endif

#define FIBER_STACKSIZE    384
#define FIBER_PRIORITY     4

#define THREAD_SELF_CMD    0
#define EXEC_CTX_TYPE_CMD  1

#define UNKNOWN_COMMAND    -1

/*
 * Get the timer type dependent IRQ number. If timer type
 * is not defined in platform, generate an error
 */
#if defined(CONFIG_HPET_TIMER)
  #define TICK_IRQ CONFIG_HPET_TIMER_IRQ
#elif defined(CONFIG_LOAPIC_TIMER)
  #define TICK_IRQ CONFIG_LOAPIC_TIMER_IRQ
#elif defined(CONFIG_ALTERA_AVALON_TIMER)
  #define TICK_IRQ TIMER_0_IRQ
#elif defined(CONFIG_ARCV2_TIMER)
  #define TICK_IRQ IRQ_TIMER0
#elif defined(CONFIG_CPU_CORTEX_M3_M4)
/*
 * The Cortex-M3/M4 use the SYSTICK exception for the system timer, which is
 * not considered an IRQ by the irq_enable/Disable APIs.
 */
#else
  /* generate an error */
  #error Timer type is not defined for this platform
#endif

/* Nios II doesn't have a power saving instruction, so nano_cpu_idle()
 * returns immediately
 */
#if !defined(CONFIG_NIOS2)
#define HAS_POWERSAVE_INSTRUCTION
#endif<commit_msg>test_context: use correct timer IRQ for mint valley<commit_after>/* thread.c - test nanokernel CPU and thread APIs */

/*
 * Copyright (c) 2012-2015 Wind River Systems, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
DESCRIPTION
This module tests the following CPU and thread related routines:
  fiber_fiber_start(), task_fiber_start(), fiber_yield(),
  sys_thread_self_get(), sys_execution_context_type_get(), nano_cpu_idle(),
  irq_lock(), irq_unlock(),
  irq_offload(), nanoCpuExcConnect(),
  irq_enable(), irq_disable(),
 */

#include <tc_util.h>
#include <nano_private.h>
#include <arch/cpu.h>
#include <irq_offload.h>

#include <util_test_common.h>

/*
 * Include board.h from platform to get IRQ number.
 * NOTE: Cortex-M3/M4 does not need IRQ numbers
 */
#if !defined(CONFIG_CPU_CORTEX_M3_M4)
  #include <board.h>
#endif

#define FIBER_STACKSIZE    384
#define FIBER_PRIORITY     4

#define THREAD_SELF_CMD    0
#define EXEC_CTX_TYPE_CMD  1

#define UNKNOWN_COMMAND    -1

/*
 * Get the timer type dependent IRQ number. If timer type
 * is not defined in platform, generate an error
 */
#if defined(CONFIG_HPET_TIMER)
  #define TICK_IRQ CONFIG_HPET_TIMER_IRQ
#elif defined(CONFIG_LOAPIC_TIMER)
  #if defined(CONFIG_LOAPIC)
    #define TICK_IRQ CONFIG_LOAPIC_TIMER_IRQ
  #else
    /* MVIC case */
    #define TICK_IRQ CONFIG_MVIC_TIMER_IRQ
  #endif
#elif defined(CONFIG_ALTERA_AVALON_TIMER)
  #define TICK_IRQ TIMER_0_IRQ
#elif defined(CONFIG_ARCV2_TIMER)
  #define TICK_IRQ IRQ_TIMER0
#elif defined(CONFIG_CPU_CORTEX_M3_M4)
/*
 * The Cortex-M3/M4 use the SYSTICK exception for the system timer, which is
 * not considered an IRQ by the irq_enable/Disable APIs.
 */
#else
  /* generate an error */
  #error Timer type is not defined for this platform
#endif

/* Nios II doesn't have a power saving instruction, so nano_cpu_idle()
 * returns immediately
 */
#if !defined(CONFIG_NIOS2)
#define HAS_POWERSAVE_INSTRUCTION
#endif
{'fraction_non_alphanumeric': 0.08762345030468585, 'fraction_numerical': 0.013027947047699096, 'mean_word_length': 4.502890173410405, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3299005', 'n_tokens_mistral': 1618, 'n_tokens_neox': 1579, 'n_words': 519}