summaryrefslogtreecommitdiffstats
path: root/target/linux/realtek/patches-2.6.30/005-tls-support.diff
blob: 2b3ce831dbb615f8e01e493077ef2afeb0344145 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
Index: linux-2.6.30.9/arch/rlx/kernel/traps.c
===================================================================
--- linux-2.6.30.9.orig/arch/rlx/kernel/traps.c	2011-12-04 15:31:07.000000000 +0000
+++ linux-2.6.30.9/arch/rlx/kernel/traps.c	2011-12-04 15:31:39.000000000 +0000
@@ -451,6 +451,55 @@
 }
 #endif
 
+
+/*
+ * Simulate trapping 'rdhwr' instructions to provide user accessible
+ * registers not implemented in hardware.
+ */
+static int simulate_rdhwr(struct pt_regs *regs, unsigned int opcode)
+{
+	struct thread_info *ti = task_thread_info(current);
+
+	if ((opcode & OPCODE) == SPEC3 && (opcode & FUNC) == RDHWR) {
+		int rd = (opcode & RD) >> 11;
+		int rt = (opcode & RT) >> 16;
+		switch (rd) {
+		case 0:		/* CPU number */
+			regs->regs[rt] = smp_processor_id();
+			return 0;
+		case 1:		/* SYNCI length */
+			regs->regs[rt] = min(current_cpu_data.dcache.linesz,
+					     current_cpu_data.icache.linesz);
+			return 0;
+		case 2:		/* Read count register */
+			regs->regs[rt] = read_c0_count();
+			return 0;
+		case 3:		/* Count register resolution */
+			switch (current_cpu_data.cputype) {
+#if 0
+			case CPU_20KC:
+			case CPU_25KF:
+				regs->regs[rt] = 1;
+				break;
+#endif
+			default:
+				regs->regs[rt] = 2;
+			}
+			return 0;
+		case 29:
+			regs->regs[rt] = ti->tp_value;
+			return 0;
+		default:
+			return -1;
+		}
+	}
+
+	/* Not ours.  */
+	return -1;
+}
+
+
+
 #ifndef CONFIG_CPU_HAS_SYNC
 static int simulate_sync(struct pt_regs *regs, unsigned int opcode)
 {
@@ -567,7 +616,7 @@
 		status = simulate_llsc(regs, opcode);
 #endif
 
-#if 0
+#if 1
 	if (status < 0)
 		status = simulate_rdhwr(regs, opcode);
 #endif
@@ -616,7 +665,7 @@
 			status = simulate_llsc(regs, opcode);
 #endif
 
-#if 0
+#if 1
 		if (status < 0)
 			status = simulate_rdhwr(regs, opcode);
 #endif