Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 4 commits
  • 8 files changed
  • 0 comments
  • 1 contributor
Jul 06, 2013
Lars-Peter Clausen lm32: Use free_reserved_area helpers
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
f6c70cb
Lars-Peter Clausen lm32: Put signal trampoline in static code
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
ac44f7f
Lars-Peter Clausen lm32: Directly link against libgcc
Instead of copying files from libgcc over just directly link against libgcc.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
d9b73e7
Lars-Peter Clausen milkymist-timer: Use clockevents_config_and_register()
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
69bceed
3  arch/lm32/Makefile
@@ -22,6 +22,8 @@
22 22
 # MA 02111-1307 USA
23 23
 #
24 24
 
  25
+LIBGCC 		:= $(shell $(CC) $(KBUILD_CFLAGS) -print-libgcc-file-name)
  26
+
25 27
 board-$(CONFIG_BOARD_MILKYMIST_ONE)	:= milkymist-one
26 28
 board-$(CONFIG_BOARD_MILKYMIST_SOC)	:= milkymist-soc
27 29
 BOARD := $(board-y)
@@ -41,6 +43,7 @@ head-y := arch/lm32/kernel/head.o
41 43
 core-y	+= arch/lm32/
42 44
 core-y	+= arch/lm32/platforms/
43 45
 libs-y	+= arch/lm32/lib/
  46
+libs-y	+= $(LIBGCC)
44 47
 
45 48
 boot := arch/lm32/boot
46 49
 
4  arch/lm32/kernel/entry.S
@@ -418,3 +418,7 @@ ENTRY(_switch_to)
418 418
 	lw  ba,  (r3+TI_CC_BA)
419 419
 
420 420
 	ret
  421
+
  422
+ENTRY(sigreturn_tramp)
  423
+	mvi r8, __NR_rt_sigreturn
  424
+	scall
17  arch/lm32/kernel/signal.c
@@ -60,10 +60,11 @@
60 60
 
61 61
 #define DEBUG_SIG 0
62 62
 
  63
+extern unsigned long sigreturn_tramp;
  64
+
63 65
 struct rt_sigframe {
64 66
 	struct siginfo info;
65 67
 	struct ucontext uc;
66  
-	unsigned long tramp[2]; /* signal trampoline */
67 68
 };
68 69
 
69 70
 static int restore_sigcontext(struct pt_regs *regs,
@@ -142,20 +143,8 @@ static int setup_rt_frame(struct ksignal *ksig, sigset_t *set, struct pt_regs *r
142 143
 
143 144
 	err |= __copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set));
144 145
 
145  
-	/* Set up to return from userspace. */
146  
-	/* mvi  r8, __NR_rt_sigreturn = addi  r8, r0, __NR_sigreturn */
147  
-	err |= __put_user(0x34080000 | __NR_rt_sigreturn, &frame->tramp[0]);
148  
-
149  
-	/* scall */
150  
-	err |= __put_user(0xac000007, &frame->tramp[1]);
151  
-
152  
-	if (err)
153  
-		return err;
154  
-
155  
-	flush_icache_range(&frame->tramp, &frame->tramp + 2);
156  
-
157 146
 	/* set return address for signal handler to trampoline */
158  
-	regs->ra = (unsigned long)(&frame->tramp[0]);
  147
+	regs->ra = sigreturn_tramp;
159 148
 
160 149
 	/* Set up registers for returning to signal handler */
161 150
 	/* entry point */
2  arch/lm32/lib/Makefile
@@ -2,5 +2,5 @@
2 2
 # Makefile for lm32 specific library files..
3 3
 #
4 4
 
5  
-lib-y	:= memset.o memcpy.o arithmetic.o libgcc2.o
  5
+lib-y	:= memset.o memcpy.o
6 6
 
223  arch/lm32/lib/arithmetic.c
... ...
@@ -1,223 +0,0 @@
1  
-/* Arithmetic functions taken from libgcc2 for lm32 */
2  
-
3  
-/* Fixed-point arithmetic. */
4  
-
5  
-typedef unsigned long UQItype __attribute__ ((mode (QI)));
6  
-typedef	long SItype __attribute__ ((mode (SI)));
7  
-typedef unsigned long USItype __attribute__ ((mode (SI)));
8  
-
9  
-/* Prototypes */
10  
-
11  
-USItype __mulsi3 (USItype a, USItype b);
12  
-
13  
-USItype __udivmodsi4 (USItype num, USItype den, int modwanted);
14  
-SItype __divsi3 (SItype a, SItype b);
15  
-SItype __modsi3 (SItype a, SItype b);
16  
-USItype __udivsi3 (USItype a, USItype b);
17  
-USItype __umodsi3 (USItype a, USItype b);
18  
-
19  
-SItype __ashlsi3 (SItype a, SItype b);
20  
-SItype __ashrsi3 (SItype a, SItype b);
21  
-USItype __lshrsi3 (USItype a, USItype b);
22  
-
23  
-/* Multiplication */
24  
-
25  
-USItype 
26  
-__mulsi3 (USItype a, USItype b)
27  
-{
28  
-  USItype result;
29  
-    
30  
-  result = 0;
31  
-
32  
-  if (a==0)
33  
-    return 0;
34  
-
35  
-  while (b!=0)
36  
-    {
37  
-      if (b & 1)
38  
-        result += a;
39  
-      a <<= 1;
40  
-      b >>= 1;
41  
-    }
42  
-       
43  
-  return result;    
44  
-}
45  
-
46  
-/* Division */
47  
-
48  
-USItype
49  
-__udivmodsi4 (USItype num, USItype den, int modwanted)
50  
-{
51  
-  USItype bit = 1;
52  
-  USItype res = 0;
53  
-
54  
-  while (den < num && bit && !(den & (1L<<31)))
55  
-    {
56  
-      den <<=1;
57  
-      bit <<=1;
58  
-    }
59  
-  while (bit)
60  
-    {
61  
-      if (num >= den)
62  
-	{
63  
-	  num -= den;
64  
-	  res |= bit;
65  
-	}
66  
-      bit >>=1;
67  
-      den >>=1;
68  
-    }
69  
-  if (modwanted) 
70  
-    return num;
71  
-  return res;
72  
-}
73  
-
74  
-static const UQItype __divsi3_table[] = {
75  
-  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
76  
-  0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
77  
-  0, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
78  
-  0, 3, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
79  
-  0, 4, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
80  
-  0, 5, 2, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
81  
-  0, 6, 3, 2, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
82  
-  0, 7, 3, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
83  
-  0, 8, 4, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0,
84  
-  0, 9, 4, 3, 2, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0,
85  
-  0, 10, 5, 3, 2, 2, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0,
86  
-  0, 11, 5, 3, 2, 2, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0,
87  
-  0, 12, 6, 4, 3, 2, 2, 1, 1, 1, 1, 1, 1, 0, 0, 0,
88  
-  0, 13, 6, 4, 3, 2, 2, 1, 1, 1, 1, 1, 1, 1, 0, 0,
89  
-  0, 14, 7, 4, 3, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 0,
90  
-  0, 15, 7, 5, 3, 3, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1,
91  
-};
92  
-
93  
-SItype
94  
-__divsi3 (SItype a, SItype b)
95  
-{
96  
-  int neg = 0;
97  
-  SItype res;
98  
-  int cfg;
99  
-
100  
-  if (b == 0) 
101  
-    {
102  
-      /* Raise divide by zero exception */
103  
-      int eba;
104  
-      __asm__ __volatile__ ("rcsr %0, EBA" : "=r" (eba));
105  
-      eba += 32 * 5;
106  
-      __asm__ __volatile__ ("mv ea, ra");
107  
-      __asm__ __volatile__ ("b %0" : : "r" (eba)); 
108  
-    }
109  
-
110  
-  if ((a | b) < 16)
111  
-    {
112  
-      res = __divsi3_table[(a << 4) + b];
113  
-    } 
114  
-  else
115  
-    {
116  
-
117  
-      if (a < 0)
118  
-        {
119  
-          a = -a;
120  
-          neg = !neg;
121  
-        }
122  
-    
123  
-      if (b < 0)
124  
-        {
125  
-          b = -b;
126  
-          neg = !neg;
127  
-        }
128  
-    
129  
-      __asm__ ("rcsr %0, CFG" : "=r" (cfg));
130  
-      if (cfg & 2)
131  
-        __asm__ ("divu %0, %1, %2" : "=r" (res) : "r" (a), "r" (b));
132  
-      else 
133  
-        res = __udivmodsi4 (a, b, 0);
134  
-    
135  
-      if (neg)
136  
-        res = -res;
137  
-    }
138  
-
139  
-  return res;
140  
-}
141  
-
142  
-	
143  
-SItype
144  
-__modsi3 (SItype a, SItype b)
145  
-{
146  
-  int neg = 0;
147  
-  SItype res;
148  
-  int cfg;
149  
-  
150  
-  if (b == 0) 
151  
-    {
152  
-      /* Raise divide by zero exception */
153  
-      int eba;
154  
-      __asm__ __volatile__ ("rcsr %0, EBA" : "=r" (eba));
155  
-      eba += 32 * 5;
156  
-      __asm__ __volatile__ ("mv ea, ra");
157  
-      __asm__ __volatile__ ("b %0" : : "r" (eba)); 
158  
-    }
159  
-  
160  
-  if (a < 0)
161  
-    {
162  
-      a = -a;
163  
-      neg = 1;
164  
-    }
165  
-
166  
-  if (b < 0)
167  
-    b = -b;
168  
-
169  
-  __asm__ ("rcsr %0, CFG" : "=r" (cfg));
170  
-  if (cfg & 2)
171  
-    __asm__ ("modu %0, %1, %2" : "=r" (res) : "r" (a), "r" (b));
172  
-  else 
173  
-    res = __udivmodsi4 (a, b, 1);
174  
-
175  
-  if (neg)
176  
-    res = -res;
177  
-
178  
-  return res;
179  
-}
180  
-
181  
-USItype
182  
-__udivsi3 (USItype a, USItype b)
183  
-{
184  
-  return __udivmodsi4 (a, b, 0);
185  
-}
186  
-
187  
-USItype
188  
-__umodsi3 (USItype a, USItype b)
189  
-{
190  
-  return __udivmodsi4 (a, b, 1);
191  
-}
192  
-
193  
-
194  
-/* Shifts - Optimized versions implemented in assembly. Use these if code space is preferred to performance.  */
195  
-SItype 
196  
-__ashlsi3 (SItype a, SItype b)
197  
-{
198  
-  int i;
199  
-  
200  
-  for (i = (b & 0x1f); i > 0; --i)
201  
-    a += a;
202  
-  return a;
203  
-}
204  
-
205  
-SItype
206  
-__ashrsi3 (SItype a, SItype b)
207  
-{
208  
-  int i;
209  
-  
210  
-  for (i = (b & 0x1f); i > 0; --i)
211  
-    __asm__ ("sri      %0, %0, 1" : "=r" (a) : "0" (a));
212  
-  return a;
213  
-}
214  
-
215  
-USItype
216  
-__lshrsi3 (USItype a, USItype b)
217  
-{
218  
-  int i;
219  
-  
220  
-  for (i = (b & 0x1f); i > 0; --i)
221  
-    __asm__ ("srui     %0, %0, 1" : "=r" (a) : "0" (a));
222  
-  return a;
223  
-}
181  arch/lm32/lib/libgcc2.c
... ...
@@ -1,181 +0,0 @@
1  
-/* Arithmetic functions taken from libgcc2 for lm32 */
2  
-
3  
-typedef		 int QItype	__attribute__ ((mode (QI)));
4  
-typedef unsigned int UQItype	__attribute__ ((mode (QI)));
5  
-typedef		 int HItype	__attribute__ ((mode (HI)));
6  
-typedef unsigned int UHItype	__attribute__ ((mode (HI)));
7  
-typedef 	 int SItype	__attribute__ ((mode (SI)));
8  
-typedef unsigned int USItype	__attribute__ ((mode (SI)));
9  
-typedef		 int DItype	__attribute__ ((mode (DI)));
10  
-typedef unsigned int UDItype	__attribute__ ((mode (DI)));
11  
-
12  
-typedef 	float SFtype	__attribute__ ((mode (SF)));
13  
-typedef		float DFtype	__attribute__ ((mode (DF)));
14  
-
15  
-typedef int word_type __attribute__ ((mode (__word__)));
16  
-
17  
-#define BITS_PER_UNIT 8
18  
-
19  
-#define Wtype	SItype
20  
-#define UWtype	USItype
21  
-#define HWtype	SItype
22  
-#define UHWtype	USItype
23  
-#define DWtype	DItype
24  
-#define UDWtype	UDItype
25  
-
26  
-extern UDWtype __umulsidi3 (UWtype, UWtype);
27  
-extern DWtype __muldi3 (DWtype, DWtype);
28  
-extern DWtype __divdi3 (DWtype, DWtype);
29  
-extern UDWtype __udivdi3 (UDWtype, UDWtype);
30  
-extern UDWtype __umoddi3 (UDWtype, UDWtype);
31  
-extern DWtype __moddi3 (DWtype, DWtype);
32  
-extern DWtype __negdi2 (DWtype);
33  
-extern DWtype __lshrdi3 (DWtype, word_type);
34  
-extern DWtype __ashldi3 (DWtype, word_type);
35  
-extern DWtype __ashrdi3 (DWtype, word_type);
36  
-
37  
-// big endian
38  
-struct DWstruct {
39  
-	Wtype high, low;
40  
-};
41  
-
42  
-typedef union
43  
-{
44  
-  struct DWstruct s;
45  
-  DWtype ll;
46  
-} DWunion;
47  
-
48  
-DWtype
49  
-__negdi2 (DWtype u)
50  
-{
51  
-  const DWunion uu = {.ll = u};
52  
-  const DWunion w = { {.low = -uu.s.low,
53  
-		       .high = -uu.s.high - ((UWtype) -uu.s.low > 0) } };
54  
-
55  
-  return w.ll;
56  
-}
57  
-
58  
-#define W_TYPE_SIZE	32
59  
-#define __ll_B ((UWtype) 1 << (W_TYPE_SIZE / 2))
60  
-#define __ll_lowpart(t) ((UWtype) (t) & (__ll_B - 1))
61  
-#define __ll_highpart(t) ((UWtype) (t) >> (W_TYPE_SIZE / 2))
62  
-#define umul_ppmm(w1, w0, u, v)						\
63  
-  do {									\
64  
-    UWtype __x0, __x1, __x2, __x3;					\
65  
-    UHWtype __ul, __vl, __uh, __vh;					\
66  
-									\
67  
-    __ul = __ll_lowpart (u);						\
68  
-    __uh = __ll_highpart (u);						\
69  
-    __vl = __ll_lowpart (v);						\
70  
-    __vh = __ll_highpart (v);						\
71  
-									\
72  
-    __x0 = (UWtype) __ul * __vl;					\
73  
-    __x1 = (UWtype) __ul * __vh;					\
74  
-    __x2 = (UWtype) __uh * __vl;					\
75  
-    __x3 = (UWtype) __uh * __vh;					\
76  
-									\
77  
-    __x1 += __ll_highpart (__x0);/* this can't give carry */		\
78  
-    __x1 += __x2;		/* but this indeed can */		\
79  
-    if (__x1 < __x2)		/* did we get it? */			\
80  
-      __x3 += __ll_B;		/* yes, add it in the proper pos.  */	\
81  
-									\
82  
-    (w1) = __x3 + __ll_highpart (__x1);					\
83  
-    (w0) = __ll_lowpart (__x1) * __ll_B + __ll_lowpart (__x0);		\
84  
-  } while (0)
85  
-
86  
-#define __umulsidi3(u, v) \
87  
-  ({DWunion __w;							\
88  
-    umul_ppmm (__w.s.high, __w.s.low, u, v);				\
89  
-    __w.ll; })
90  
-
91  
-DWtype
92  
-__muldi3 (DWtype u, DWtype v)
93  
-{
94  
-  const DWunion uu = {.ll = u};
95  
-  const DWunion vv = {.ll = v};
96  
-  DWunion w = {.ll = __umulsidi3 (uu.s.low, vv.s.low)};
97  
-
98  
-  w.s.high += ((UWtype) uu.s.low * (UWtype) vv.s.high
99  
-	       + (UWtype) uu.s.high * (UWtype) vv.s.low);
100  
-
101  
-  return w.ll;
102  
-}
103  
-
104  
-DWtype
105  
-__lshrdi3 (DWtype u, word_type b)
106  
-{
107  
-  const DWunion uu = {.ll = u};
108  
-  const word_type bm = (sizeof (Wtype) * BITS_PER_UNIT) - b;
109  
-  DWunion w;
110  
-
111  
-  if (b == 0)
112  
-    return u;
113  
-
114  
-  if (bm <= 0)
115  
-    {
116  
-      w.s.high = 0;
117  
-      w.s.low = (UWtype) uu.s.high >> -bm;
118  
-    }
119  
-  else
120  
-    {
121  
-      const UWtype carries = (UWtype) uu.s.high << bm;
122  
-
123  
-      w.s.high = (UWtype) uu.s.high >> b;
124  
-      w.s.low = ((UWtype) uu.s.low >> b) | carries;
125  
-    }
126  
-
127  
-  return w.ll;
128  
-}
129  
-
130  
-DWtype
131  
-__ashldi3 (DWtype u, word_type b)
132  
-{
133  
-  const DWunion uu = {.ll = u};
134  
-  const word_type bm = (sizeof (Wtype) * BITS_PER_UNIT) - b;
135  
-  DWunion w;
136  
-
137  
-  if (b == 0)
138  
-    return u;
139  
-
140  
-  if (bm <= 0)
141  
-    {
142  
-      w.s.low = 0;
143  
-      w.s.high = (UWtype) uu.s.low << -bm;
144  
-    }
145  
-  else
146  
-    {
147  
-      const UWtype carries = (UWtype) uu.s.low >> bm;
148  
-
149  
-      w.s.low = (UWtype) uu.s.low << b;
150  
-      w.s.high = ((UWtype) uu.s.high << b) | carries;
151  
-    }
152  
-
153  
-  return w.ll;
154  
-}
155  
-
156  
-DWtype
157  
-__ashrdi3 (DWtype u, word_type b)
158  
-{
159  
-  const DWunion uu = {.ll = u};
160  
-  const word_type bm = (sizeof (Wtype) * BITS_PER_UNIT) - b;
161  
-  DWunion w;
162  
-
163  
-  if (b == 0)
164  
-    return u;
165  
-
166  
-  if (bm <= 0)
167  
-    {
168  
-      /* w.s.high = 1..1 or 0..0 */
169  
-      w.s.high = uu.s.high >> (sizeof (Wtype) * BITS_PER_UNIT - 1);
170  
-      w.s.low = uu.s.high >> -bm;
171  
-    }
172  
-  else
173  
-    {
174  
-      const UWtype carries = (UWtype) uu.s.high << bm;
175  
-
176  
-      w.s.high = uu.s.high >> b;
177  
-      w.s.low = ((UWtype) uu.s.low >> b) | carries;
178  
-    }
179  
-
180  
-  return w.ll;
181  
-}
25  arch/lm32/mm/init.c
@@ -121,29 +121,16 @@ void __init mem_init(void)
121 121
 	       );
122 122
 }
123 123
 
124  
-static void free_init_pages(const char *what, unsigned long start, unsigned long end)
125  
-{
126  
-	unsigned long addr;
127  
-
128  
-	for (addr = start; addr < end; addr += PAGE_SIZE) {
129  
-		struct page* page = virt_to_page(addr);
130  
-
131  
-		ClearPageReserved(page);
132  
-		init_page_count(page);
133  
-		__free_page(page);
134  
-		totalram_pages++;
135  
-	}
136  
-
137  
-	printk("Freeing %s mem: %ldk freed\n", what, (end-start) >> 10);
138  
-}
139  
-
140 124
 void free_initmem(void)
141 125
 {
142  
-	free_init_pages("unused kernel", (unsigned long)&__init_begin, (unsigned long)&__init_end);
  126
+	free_initmem_default(0);
143 127
 }
144 128
 
145 129
 #ifdef CONFIG_BLK_DEV_INITRD
146  
-void __init free_initrd_mem(unsigned long start, unsigned long end) {
147  
-	free_init_pages("initrd", start, end);
  130
+
  131
+void __init free_initrd_mem(unsigned long start, unsigned long end)
  132
+{
  133
+	free_reserved_area(start, end, 0, "initrd");
148 134
 }
  135
+
149 136
 #endif
8  arch/lm32/platforms/milkymist/time.c
@@ -144,17 +144,13 @@ void __init plat_time_init(void)
144 144
 
145 145
 	milkymist_ticks_per_jiffy = DIV_ROUND_CLOSEST(CONFIG_CPU_CLOCK, HZ);
146 146
 
147  
-	clockevents_calc_mult_shift(&milkymist_clockevent, CONFIG_CPU_CLOCK, 5);
148  
-	milkymist_clockevent.min_delta_ns = clockevent_delta2ns(100, &milkymist_clockevent);
149  
-	milkymist_clockevent.max_delta_ns = clockevent_delta2ns(0xffff, &milkymist_clockevent);
150  
-	milkymist_clockevent.cpumask = cpumask_of(0);
151  
-
152 147
 	milkymist_timer_disable(TIMER_CLOCKSOURCE);
153 148
 	milkymist_timer_set_compare(TIMER_CLOCKSOURCE, 0xffffffff);
154 149
 	milkymist_timer_set_counter(TIMER_CLOCKSOURCE, 0);
155 150
 	milkymist_timer_enable(TIMER_CLOCKSOURCE, true);
156 151
 
157  
-	clockevents_register_device(&milkymist_clockevent);
  152
+	clockevents_config_and_register(&milkymist_clockevent, CONFIG_CPU_CLOCK,
  153
+			100, 0xffff);
158 154
 
159 155
 	ret = clocksource_register_hz(&milkymist_clocksource, CONFIG_CPU_CLOCK);
160 156
 

No commit comments for this range

Something went wrong with that request. Please try again.