1/* 2** Copyright 2001, Travis Geiselbrecht. All rights reserved. 3** Distributed under the terms of the NewOS License. 4*/ 5#ifndef KERNEL_ARCH_ARM_THREAD_TYPES_H 6#define KERNEL_ARCH_ARM_THREAD_TYPES_H 7 8#include <kernel.h> 9 10 11/* raw exception frames */ 12struct iframe { 13 uint32 spsr; 14 uint32 r0; 15 uint32 r1; 16 uint32 r2; 17 uint32 r3; 18 uint32 r4; 19 uint32 r5; 20 uint32 r6; 21 uint32 r7; 22 uint32 r8; 23 uint32 r9; 24 uint32 r10; 25 uint32 r11; 26 uint32 r12; 27 uint32 usr_sp; 28 uint32 usr_lr; 29 uint32 svc_sp; 30 uint32 svc_lr; 31 uint32 pc; 32} _PACKED; 33 34#define IFRAME_TRACE_DEPTH 4 35 36struct iframe_stack { 37 struct iframe *frames[IFRAME_TRACE_DEPTH]; 38 int32 index; 39}; 40 41struct arch_fpu_context { 42 uint64_t fp_regs[32]; 43 uint32_t fpscr; 44}; 45 46// architecture specific thread info 47struct arch_thread { 48 void *sp; // stack pointer 49 struct arch_fpu_context fpuContext; 50 51 // used to track interrupts on this thread 52 struct iframe_stack iframes; 53 54 struct iframe* userFrame; 55 uint32 oldR0; 56}; 57 58struct arch_team { 59 // gcc treats empty structures as zero-length in C, but as if they contain 60 // a char in C++. So we have to put a dummy in to be able to use the struct 61 // from both in a consistent way. 62 char dummy; 63}; 64 65struct arch_fork_arg { 66 struct iframe frame; 67}; 68 69 70#ifdef __cplusplus 71extern "C" { 72#endif 73 74void arch_return_to_userland(struct iframe *); 75void arm_context_switch(struct arch_thread* from, struct arch_thread* to); 76void arm_save_fpu(struct arch_fpu_context* context); 77void arm_restore_fpu(struct arch_fpu_context* context); 78 79#ifdef __cplusplus 80} 81#endif 82 83#endif /* KERNEL_ARCH_ARM_THREAD_TYPES_H */ 84