1
###############################################################################
3
# MN10300 Context switch operation
5
# Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
6
# Written by David Howells (dhowells@redhat.com)
8
# This program is free software; you can redistribute it and/or
9
# modify it under the terms of the GNU General Public Licence
10
# as published by the Free Software Foundation; either version
11
# 2 of the Licence, or (at your option) any later version.
13
###############################################################################
14
#include <linux/sys.h>
15
#include <linux/linkage.h>
16
#include <asm/thread_info.h>
17
#include <asm/cpu-regs.h>
19
#include <proc/smp-regs.h>
20
#endif /* CONFIG_SMP */
24
###############################################################################
26
# struct task_struct *__switch_to(struct thread_struct *prev,
27
# struct thread_struct *next,
28
# struct task_struct *prev_task)
30
###############################################################################
32
movm [d2,d3,a2,a3,exreg1],(sp)
47
btst 0xff,(kgdb_single_step)
48
bne __switch_to__lift_sstep_bp
49
__switch_to__continue:
64
#ifdef CONFIG_MN10300_CURRENT_IN_E2
69
mov d2,d0 # for ret_from_fork
70
mov d0,a0 # for __switch_to
76
ret [d2,d3,a2,a3,exreg1],32
79
###############################################################################
81
# Lift the single-step breakpoints when the task being traced is switched out
85
###############################################################################
86
__switch_to__lift_sstep_bp:
91
# Clear the single-step flag to prevent us coming this way until we get
93
bclr 0xff,(kgdb_single_step)
95
# Remove first breakpoint
96
mov (kgdb_sstep_bp_addr),a2
99
movbu (kgdb_sstep_bp),d0
101
#if defined(CONFIG_MN10300_CACHE_FLUSH_ICACHE) || defined(CONFIG_MN10300_CACHE_INV_ICACHE)
105
calls flush_icache_range
109
# Remove second breakpoint
110
mov (kgdb_sstep_bp_addr+4),a2
113
movbu (kgdb_sstep_bp+1),d0
115
#if defined(CONFIG_MN10300_CACHE_FLUSH_ICACHE) || defined(CONFIG_MN10300_CACHE_INV_ICACHE)
119
calls flush_icache_range
123
# Change the resumption address and return
124
mov __switch_back__reinstall_sstep_bp,d0
128
bra __switch_to__continue
130
###############################################################################
132
# Reinstall the single-step breakpoints when the task being traced is switched
133
# back in (A1 points to the new thread_struct).
135
###############################################################################
136
__switch_back__reinstall_sstep_bp:
138
mov a0,e4 # save the return value
141
# Reinstall first breakpoint
142
mov (kgdb_sstep_bp_addr),a2
146
movbu d0,(kgdb_sstep_bp)
148
#if defined(CONFIG_MN10300_CACHE_FLUSH_ICACHE) || defined(CONFIG_MN10300_CACHE_INV_ICACHE)
152
calls flush_icache_range
156
# Reinstall second breakpoint
157
mov (kgdb_sstep_bp_addr+4),a2
161
movbu d0,(kgdb_sstep_bp+1)
163
#if defined(CONFIG_MN10300_CACHE_FLUSH_ICACHE) || defined(CONFIG_MN10300_CACHE_INV_ICACHE)
167
calls flush_icache_range
171
mov d3,(kgdb_single_step)
173
# Restore the return value (the previous thread_struct pointer)
179
#endif /* CONFIG_KGDB */