<commit_before>/*
 *
 * TINKER Source Code
 *
 *
 *  [2009] - [2014] <NAME>
 *  All Rights Reserved.
 */

#include "arm_vec.h"
#include "console/print_out.h"
#pragma GCC optimize ("-O0")

#define SWITCH_TO_SYSTEM_MODE \
	asm volatile("mrs r0, cpsr"); \
	asm volatile("mov r2, r0"); \
	asm volatile("mov r1, #0xFFFFFF80"); \
	asm volatile("and r0, r0, r1"); \
	asm volatile("mov r1, #0xDF"); \
	asm volatile("orr r0, r0, r1"); \
	asm volatile("msr cpsr, r0");

#define SWITCH_BACK \
	asm volatile("msr cpsr, r2");

#define FIX_STACK_ALIGNMENT \
	asm volatile("and r1, sp, #4"); \
	asm volatile("sub sp, sp, r1"); \
	asm volatile("push {r1}");

#define UNFIX_STACK_ALIGNMENT \
	asm volatile("pop {r1}"); \
	asm volatile("add sp, sp, r1");

#define EXCEPTION_START_COMMON \
	uint32_t context; \
	asm volatile("stmfd sp!,{r0-r12,lr}");				/* store all the registers */ \
	asm volatile("mrs r0, spsr"); 						/* get the spsr */ \
	asm volatile("push {r0}"); 							/* store the spsr */ \
	SWITCH_TO_SYSTEM_MODE						/* switch to system mode so we can get r13(sp), r14(lr) */ \
	asm volatile("mov r3, sp");							/* get user stack pointer */ \
	asm volatile("mov r4, lr");							/* get user link pointer */ \
	SWITCH_BACK \
	asm volatile("push {r3, r4}");						/* store sp, lr */ \
	FIX_STACK_ALIGNMENT \
	asm volatile("mov %[ps], sp" : [ps]"=r" (context)); 	/* move the sp into context var */ \

#define EXCEPTION_START_SYSCALL \
	EXCEPTION_START_COMMON

#define EXCEPTION_START_VECTOR \
	asm volatile("sub lr, lr, #4"); 						/* update return addr */ \
	EXCEPTION_START_COMMON

#define EXCEPTION_END \
	asm volatile("nop"); \
	UNFIX_STACK_ALIGNMENT \
	asm volatile("pop {r3, r4}");						/* get the sp and pc back */ \
	SWITCH_TO_SYSTEM_MODE \
	asm volatile("mov sp, r3");							/* restore the sp */ \
	asm volatile("mov lr, r4");							/* restore the sp */ \
	SWITCH_BACK \
	asm volatile("pop {r0}");							/* get the spsr back */ \
	asm volatile("msr SPSR_cxsf, r0"); 					/* restore spsr */ \
	asm volatile("ldm sp!, {r0-r12,pc}^");				/* return! */

static arm_vec_handler_t * vector_table[8];

static void __attribute__((naked,used)) arm_vector_reset()
{
	EXCEPTION_START_VECTOR;
	vector_table[VECTOR_RESET](VECTOR_RESET, context);
	EXCEPTION_END;
}

static void __attribute__((naked,used)) arm_vector_undefined()
{
	EXCEPTION_START_VECTOR;
	vector_table[VECTOR_UNDEFINED](VECTOR_UNDEFINED, context);
	EXCEPTION_END;<commit_msg>Scrap the old alignment mod<commit_after>/*
 *
 * TINKER Source Code
 *
 *
 *  [2009] - [2014] <NAME>
 *  All Rights Reserved.
 */

#include "arm_vec.h"
#include "console/print_out.h"
#pragma GCC optimize ("-O0")

#define SWITCH_TO_SYSTEM_MODE \
	asm volatile("mrs r0, cpsr"); \
	asm volatile("mov r2, r0"); \
	asm volatile("mov r1, #0xFFFFFF80"); \
	asm volatile("and r0, r0, r1"); \
	asm volatile("mov r1, #0xDF"); \
	asm volatile("orr r0, r0, r1"); \
	asm volatile("msr cpsr, r0");

#define SWITCH_BACK \
	asm volatile("msr cpsr, r2");

#define FIX_STACK_ALIGNMENT \
	asm volatile("push {r1}");

#define UNFIX_STACK_ALIGNMENT \
	asm volatile("pop {r1}");

#define EXCEPTION_START_COMMON \
	uint32_t context; \
	asm volatile("stmfd sp!,{r0-r12,lr}");				/* store all the registers */ \
	asm volatile("mrs r0, spsr"); 						/* get the spsr */ \
	asm volatile("push {r0}"); 							/* store the spsr */ \
	SWITCH_TO_SYSTEM_MODE								/* switch to system mode so we can get r13(sp), r14(lr) */ \
	asm volatile("mov r3, sp");							/* get user stack pointer */ \
	asm volatile("mov r4, lr");							/* get user link pointer */ \
	SWITCH_BACK \
	asm volatile("push {r3, r4}");						/* store sp, lr */ \
	FIX_STACK_ALIGNMENT \
	asm volatile("mov %[ps], sp" : [ps]"=r" (context)); /* move the sp into context var */ \

#define EXCEPTION_START_SYSCALL \
	EXCEPTION_START_COMMON

#define EXCEPTION_START_VECTOR \
	asm volatile("sub lr, lr, #4"); 					/* update return addr */ \
	EXCEPTION_START_COMMON

#define EXCEPTION_END \
	asm volatile("nop"); \
	UNFIX_STACK_ALIGNMENT \
	asm volatile("pop {r3, r4}");						/* get the sp and pc back */ \
	SWITCH_TO_SYSTEM_MODE \
	asm volatile("mov sp, r3");							/* restore the sp */ \
	asm volatile("mov lr, r4");							/* restore the sp */ \
	SWITCH_BACK \
	asm volatile("pop {r0}");							/* get the spsr back */ \
	asm volatile("msr SPSR_cxsf, r0"); 					/* restore spsr */ \
	asm volatile("ldm sp!, {r0-r12,pc}^");				/* return! */

static arm_vec_handler_t * vector_table[8];

static void __attribute__((naked,used)) arm_vector_reset()
{
	EXCEPTION_START_VECTOR;
	vector_table[VECTOR_RESET](VECTOR_RESET, context);
	EXCEPTION_END;
}

static void __attribute__((naked,used)) arm_vector_undefined()
{
	EXCEPTION_START_VECTOR;
	vector_table[VECTOR_UNDEFINED](VECTOR_UNDEFINED, context);
	EXCEPTION_END;
{'fraction_non_alphanumeric': 0.16012591815320043, 'fraction_numerical': 0.023504721930745015, 'mean_word_length': 3.5520534861509074, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '221481', 'n_tokens_mistral': 2016, 'n_tokens_neox': 1860, 'n_words': 458}