Subversion Repositories freemyipod

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
14 theseven 1
@
2
@
3
@    Copyright 2010 TheSeven
4
@
5
@
6
@    This file is part of emBIOS.
7
@
8
@    emBIOS is free software: you can redistribute it and/or
9
@    modify it under the terms of the GNU General Public License as
10
@    published by the Free Software Foundation, either version 2 of the
11
@    License, or (at your option) any later version.
12
@
13
@    emBIOS is distributed in the hope that it will be useful,
14
@    but WITHOUT ANY WARRANTY; without even the implied warranty of
15
@    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16
@    See the GNU General Public License for more details.
17
@
18
@    You should have received a copy of the GNU General Public License
19
@    along with emBIOS.  If not, see <http://www.gnu.org/licenses/>.
20
@
21
@
22
 
23
 
24
.section .icode.contextswitch, "ax", %progbits
25
.align 2
26
.global context_switch
27
.type context_switch, %function
28
context_switch:
29
	ldr	r0, =current_thread
30
	ldr	r0, [r0]
31
	stmia	r0!, {r0-r14}
32
	str	lr, [r0], #4
33
	mrs	r1, cpsr
34
	str	r1, [r0]
35
	adr	lr, resume_thread
36
	b	scheduler_switch
37
.size context_switch, .-context_switch
38
 
39
.global irq_handler
40
.type irq_handler, %function
41
irq_handler:
42
	str	r12, [sp,#-4]
43
	ldr	r12, =current_thread
44
	ldr	r12, [r12]
45
	stmia	r12!, {r0-r11}
46
	ldr	r0, [sp,#-4]
47
	mrs	r5, cpsr
48
	mrs	r4, spsr
49
	orr	r6, r4, #0xc0
50
	msr	cpsr_c, r6
51
	mov	r1, sp
52
	mov	r2, lr
53
	msr	cpsr_c, r5
54
	sub	r3, lr, #4
55
	stmia	r12, {r0-r4}
56
	bl	irqhandler
57
@ fallthrough
58
 
59
.global resume_thread
60
.type resume_thread, %function
61
resume_thread:
62
	ldr	r0, =current_thread
63
	ldr	r0, [r0]
64
	ldr	r1, [r0,#0x40]
65
	orr	r2, r1, #0xc0
66
	msr	cpsr_c, r2
67
	ldr	sp, [r0,#0x34]
68
	ldr	lr, [r0,#0x38]
69
	msr	cpsr_c, #0xd2
70
	msr	spsr_all, r1
71
	ldr	lr, [r0,#0x3c]
72
	ldmia	r0, {r0-r12}
73
	movs	pc, lr
74
.size irq_handler, .-irq_handler
75
.size resume_thread, .-resume_thread
76
 
77
.global enter_critical_section
78
.type enter_critical_section, %function
79
enter_critical_section:
80
	mrs	r0, cpsr
81
	msr	cpsr_c, #0xd3
82
	mov	pc, lr
83
.size enter_critical_section, .-enter_critical_section
84
 
85
.global leave_critical_section
86
.type leave_critical_section, %function
87
leave_critical_section:
88
	msr	cpsr_c, r0
89
	mov	pc, lr
90
.size leave_critical_section, .-leave_critical_section