Subversion Repositories freemyipod

Rev

Go to most recent revision | 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:
15 theseven 29
	mrs	r1, cpsr
30
	orr	r0, r1, #0xc0
31
	msr	cpsr_c, r0
14 theseven 32
	ldr	r0, =current_thread
33
	ldr	r0, [r0]
34
	stmia	r0!, {r0-r14}
35
	str	lr, [r0], #4
36
	str	r1, [r0]
15 theseven 37
	msr	cpsr_c, #0xd2
14 theseven 38
	adr	lr, resume_thread
15 theseven 39
	mov	r0, #-1
14 theseven 40
	b	scheduler_switch
41
.size context_switch, .-context_switch
42
 
43
.global irq_handler
44
.type irq_handler, %function
45
irq_handler:
46
	str	r12, [sp,#-4]
47
	ldr	r12, =current_thread
48
	ldr	r12, [r12]
49
	stmia	r12!, {r0-r11}
50
	ldr	r0, [sp,#-4]
51
	mrs	r5, cpsr
52
	mrs	r4, spsr
53
	orr	r6, r4, #0xc0
54
	msr	cpsr_c, r6
55
	mov	r1, sp
56
	mov	r2, lr
57
	msr	cpsr_c, r5
58
	sub	r3, lr, #4
59
	stmia	r12, {r0-r4}
60
	bl	irqhandler
61
@ fallthrough
62
 
63
.global resume_thread
64
.type resume_thread, %function
65
resume_thread:
15 theseven 66
	ldr	lr, =current_thread
67
	ldr	lr, [lr]
68
	mov	r0, lr
69
	ldr	r1, [lr,#0x40]
70
	ldr	lr, [lr,#0x3c]
71
	msr	spsr_all, r1
72
	orr	r1, r1, #0xc0
73
	msr	cpsr_c, r1
74
	ldmia	r0, {r0-r14}
14 theseven 75
	msr	cpsr_c, #0xd2
76
	movs	pc, lr
77
.size irq_handler, .-irq_handler
78
.size resume_thread, .-resume_thread
79
 
80
.global enter_critical_section
81
.type enter_critical_section, %function
82
enter_critical_section:
83
	mrs	r0, cpsr
15 theseven 84
	orr	r1, r0, #0xc0
85
	msr	cpsr_c, r1
14 theseven 86
	mov	pc, lr
87
.size enter_critical_section, .-enter_critical_section
88
 
89
.global leave_critical_section
90
.type leave_critical_section, %function
91
leave_critical_section:
92
	msr	cpsr_c, r0
93
	mov	pc, lr
94
.size leave_critical_section, .-leave_critical_section