<commit_before>/**
 * ARM architecture common support functions
 *
 * Copyright (C) 2008, 2009  <NAME> <hwill@inf.fu-berlin.de>
 * Copyright (C) 2009 <NAME> <<EMAIL>>
 *
 * This file is subject to the terms and conditions of the GNU Lesser
 * General Public License v2.1. See the file LICENSE in the top level
 * directory for more details.
 *
 * @ingroup cpu_arm7_common
 * @{
 * @file
 * @author <NAME> <<EMAIL>>
 * @author <NAME> <heiko.will@fu-berlin.de>
 * @}
 */

#include <stdio.h>
#include "arm_cpu.h"
#include "thread.h"

#define STACK_MARKER    (0x77777777)
#define REGISTER_CNT    (12)

void thread_yield_higher(void)
{
    __asm__("svc 0\n");
}

/*----------------------------------------------------------------------------
 * Processor specific routine - here for ARM7
 * sizeof(void*) = sizeof(int)
 *--------------------------------------------------------------------------*/
char *thread_stack_init(thread_task_func_t task_func, void *arg, void *stack_start, int stack_size)
{
    unsigned int *stk;
    int i;
    stk = (unsigned int *)((uintptr_t)stack_start + stack_size);
    stk--;

    *stk = STACK_MARKER;

    /* set the return address (LR) */
    stk--;<commit_msg>cpu/arm7_common: Fix thread_yield_higher in ISR<commit_after>/**
 * ARM architecture common support functions
 *
 * Copyright (C) 2008, 2009  <NAME> <hwill@inf.fu-berlin.de>
 * Copyright (C) 2009 <NAME> <<EMAIL>>
 *
 * This file is subject to the terms and conditions of the GNU Lesser
 * General Public License v2.1. See the file LICENSE in the top level
 * directory for more details.
 *
 * @ingroup cpu_arm7_common
 * @{
 * @file
 * @author <NAME> <<EMAIL>>
 * @author <NAME> <<EMAIL>>
 * @}
 */

#include <stdio.h>
#include "arm_cpu.h"
#include "irq.h"
#include "sched.h"
#include "thread.h"

#define STACK_MARKER    (0x77777777)
#define REGISTER_CNT    (12)

void thread_yield_higher(void)
{
    if (irq_is_in()) {
        sched_context_switch_request = 1;
    }
    else {
        __asm__("svc 0\n");
    }
}

/*----------------------------------------------------------------------------
 * Processor specific routine - here for ARM7
 * sizeof(void*) = sizeof(int)
 *--------------------------------------------------------------------------*/
char *thread_stack_init(thread_task_func_t task_func, void *arg, void *stack_start, int stack_size)
{
    unsigned int *stk;
    int i;
    stk = (unsigned int *)((uintptr_t)stack_start + stack_size);
    stk--;

    *stk = STACK_MARKER;

    /* set the return address (LR) */
    stk--;
{'fraction_non_alphanumeric': 0.24110671936758893, 'fraction_numerical': 0.02292490118577075, 'mean_word_length': 2.167709637046308, 'pattern_counts': {'":': 0, '<': 26, '<?xml version=': 0, '>': 26, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 3, 'substrings_counts': 2, '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': '4520854', 'n_tokens_mistral': 866, 'n_tokens_neox': 811, 'n_words': 226}