Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

We’re showing branches in this repository, but you can also compare across forks.

base fork: m-labs/linux-milkymist
base: 2c77f4259960
...
head fork: m-labs/linux-milkymist
compare: 69bceedb87bf
  • 4 commits
  • 8 files changed
  • 0 commit comments
  • 1 contributor
Commits on Jul 06, 2013
Lars-Peter Clausen larsclausen lm32: Use free_reserved_area helpers
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
f6c70cb
Lars-Peter Clausen larsclausen lm32: Put signal trampoline in static code
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
ac44f7f
Lars-Peter Clausen larsclausen 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 larsclausen milkymist-timer: Use clockevents_config_and_register()
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
69bceed
3  arch/lm32/Makefile
View
@@ -22,6 +22,8 @@
# MA 02111-1307 USA
#
+LIBGCC := $(shell $(CC) $(KBUILD_CFLAGS) -print-libgcc-file-name)
+
board-$(CONFIG_BOARD_MILKYMIST_ONE) := milkymist-one
board-$(CONFIG_BOARD_MILKYMIST_SOC) := milkymist-soc
BOARD := $(board-y)
@@ -41,6 +43,7 @@ head-y := arch/lm32/kernel/head.o
core-y += arch/lm32/
core-y += arch/lm32/platforms/
libs-y += arch/lm32/lib/
+libs-y += $(LIBGCC)
boot := arch/lm32/boot
4 arch/lm32/kernel/entry.S
View
@@ -418,3 +418,7 @@ ENTRY(_switch_to)
lw ba, (r3+TI_CC_BA)
ret
+
+ENTRY(sigreturn_tramp)
+ mvi r8, __NR_rt_sigreturn
+ scall
17 arch/lm32/kernel/signal.c
View
@@ -60,10 +60,11 @@
#define DEBUG_SIG 0
+extern unsigned long sigreturn_tramp;
+
struct rt_sigframe {
struct siginfo info;
struct ucontext uc;
- unsigned long tramp[2]; /* signal trampoline */
};
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
err |= __copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set));
- /* Set up to return from userspace. */
- /* mvi r8, __NR_rt_sigreturn = addi r8, r0, __NR_sigreturn */
- err |= __put_user(0x34080000 | __NR_rt_sigreturn, &frame->tramp[0]);
-
- /* scall */
- err |= __put_user(0xac000007, &frame->tramp[1]);
-
- if (err)
- return err;
-
- flush_icache_range(&frame->tramp, &frame->tramp + 2);
-
/* set return address for signal handler to trampoline */
- regs->ra = (unsigned long)(&frame->tramp[0]);
+ regs->ra = sigreturn_tramp;
/* Set up registers for returning to signal handler */
/* entry point */
2  arch/lm32/lib/Makefile
View
@@ -2,5 +2,5 @@
# Makefile for lm32 specific library files..
#
-lib-y := memset.o memcpy.o arithmetic.o libgcc2.o
+lib-y := memset.o memcpy.o
223 arch/lm32/lib/arithmetic.c
View
@@ -1,223 +0,0 @@
-/* Arithmetic functions taken from libgcc2 for lm32 */
-
-/* Fixed-point arithmetic. */
-
-typedef unsigned long UQItype __attribute__ ((mode (QI)));
-typedef long SItype __attribute__ ((mode (SI)));
-typedef unsigned long USItype __attribute__ ((mode (SI)));
-
-/* Prototypes */
-
-USItype __mulsi3 (USItype a, USItype b);
-
-USItype __udivmodsi4 (USItype num, USItype den, int modwanted);
-SItype __divsi3 (SItype a, SItype b);
-SItype __modsi3 (SItype a, SItype b);
-USItype __udivsi3 (USItype a, USItype b);
-USItype __umodsi3 (USItype a, USItype b);
-
-SItype __ashlsi3 (SItype a, SItype b);
-SItype __ashrsi3 (SItype a, SItype b);
-USItype __lshrsi3 (USItype a, USItype b);
-
-/* Multiplication */
-
-USItype
-__mulsi3 (USItype a, USItype b)
-{
- USItype result;
-
- result = 0;
-
- if (a==0)
- return 0;
-
- while (b!=0)
- {
- if (b & 1)
- result += a;
- a <<= 1;
- b >>= 1;
- }
-
- return result;
-}
-
-/* Division */
-
-USItype
-__udivmodsi4 (USItype num, USItype den, int modwanted)
-{
- USItype bit = 1;
- USItype res = 0;
-
- while (den < num && bit && !(den & (1L<<31)))
- {
- den <<=1;
- bit <<=1;
- }
- while (bit)
- {
- if (num >= den)
- {
- num -= den;
- res |= bit;
- }
- bit >>=1;
- den >>=1;
- }
- if (modwanted)
- return num;
- return res;
-}
-
-static const UQItype __divsi3_table[] = {
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 3, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 4, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 5, 2, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 6, 3, 2, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 7, 3, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 8, 4, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0,
- 0, 9, 4, 3, 2, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0,
- 0, 10, 5, 3, 2, 2, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0,
- 0, 11, 5, 3, 2, 2, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0,
- 0, 12, 6, 4, 3, 2, 2, 1, 1, 1, 1, 1, 1, 0, 0, 0,
- 0, 13, 6, 4, 3, 2, 2, 1, 1, 1, 1, 1, 1, 1, 0, 0,
- 0, 14, 7, 4, 3, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 0,
- 0, 15, 7, 5, 3, 3, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1,
-};
-
-SItype
-__divsi3 (SItype a, SItype b)
-{
- int neg = 0;
- SItype res;
- int cfg;
-
- if (b == 0)
- {
- /* Raise divide by zero exception */
- int eba;
- __asm__ __volatile__ ("rcsr %0, EBA" : "=r" (eba));
- eba += 32 * 5;
- __asm__ __volatile__ ("mv ea, ra");
- __asm__ __volatile__ ("b %0" : : "r" (eba));
- }
-
- if ((a | b) < 16)
- {
- res = __divsi3_table[(a << 4) + b];
- }
- else
- {
-
- if (a < 0)
- {
- a = -a;
- neg = !neg;
- }
-
- if (b < 0)
- {
- b = -b;
- neg = !neg;
- }
-
- __asm__ ("rcsr %0, CFG" : "=r" (cfg));
- if (cfg & 2)
- __asm__ ("divu %0, %1, %2" : "=r" (res) : "r" (a), "r" (b));
- else
- res = __udivmodsi4 (a, b, 0);
-
- if (neg)
- res = -res;
- }
-
- return res;
-}
-
-
-SItype
-__modsi3 (SItype a, SItype b)
-{
- int neg = 0;
- SItype res;
- int cfg;
-
- if (b == 0)
- {
- /* Raise divide by zero exception */
- int eba;
- __asm__ __volatile__ ("rcsr %0, EBA" : "=r" (eba));
- eba += 32 * 5;
- __asm__ __volatile__ ("mv ea, ra");
- __asm__ __volatile__ ("b %0" : : "r" (eba));
- }
-
- if (a < 0)
- {
- a = -a;
- neg = 1;
- }
-
- if (b < 0)
- b = -b;
-
- __asm__ ("rcsr %0, CFG" : "=r" (cfg));
- if (cfg & 2)
- __asm__ ("modu %0, %1, %2" : "=r" (res) : "r" (a), "r" (b));
- else
- res = __udivmodsi4 (a, b, 1);
-
- if (neg)
- res = -res;
-
- return res;
-}
-
-USItype
-__udivsi3 (USItype a, USItype b)
-{
- return __udivmodsi4 (a, b, 0);
-}
-
-USItype
-__umodsi3 (USItype a, USItype b)
-{
- return __udivmodsi4 (a, b, 1);
-}
-
-
-/* Shifts - Optimized versions implemented in assembly. Use these if code space is preferred to performance. */
-SItype
-__ashlsi3 (SItype a, SItype b)
-{
- int i;
-
- for (i = (b & 0x1f); i > 0; --i)
- a += a;
- return a;
-}
-
-SItype
-__ashrsi3 (SItype a, SItype b)
-{
- int i;
-
- for (i = (b & 0x1f); i > 0; --i)
- __asm__ ("sri %0, %0, 1" : "=r" (a) : "0" (a));
- return a;
-}
-
-USItype
-__lshrsi3 (USItype a, USItype b)
-{
- int i;
-
- for (i = (b & 0x1f); i > 0; --i)
- __asm__ ("srui %0, %0, 1" : "=r" (a) : "0" (a));
- return a;
-}
181 arch/lm32/lib/libgcc2.c
View
@@ -1,181 +0,0 @@
-/* Arithmetic functions taken from libgcc2 for lm32 */
-
-typedef int QItype __attribute__ ((mode (QI)));
-typedef unsigned int UQItype __attribute__ ((mode (QI)));
-typedef int HItype __attribute__ ((mode (HI)));
-typedef unsigned int UHItype __attribute__ ((mode (HI)));
-typedef int SItype __attribute__ ((mode (SI)));
-typedef unsigned int USItype __attribute__ ((mode (SI)));
-typedef int DItype __attribute__ ((mode (DI)));
-typedef unsigned int UDItype __attribute__ ((mode (DI)));
-
-typedef float SFtype __attribute__ ((mode (SF)));
-typedef float DFtype __attribute__ ((mode (DF)));
-
-typedef int word_type __attribute__ ((mode (__word__)));
-
-#define BITS_PER_UNIT 8
-
-#define Wtype SItype
-#define UWtype USItype
-#define HWtype SItype
-#define UHWtype USItype
-#define DWtype DItype
-#define UDWtype UDItype
-
-extern UDWtype __umulsidi3 (UWtype, UWtype);
-extern DWtype __muldi3 (DWtype, DWtype);
-extern DWtype __divdi3 (DWtype, DWtype);
-extern UDWtype __udivdi3 (UDWtype, UDWtype);
-extern UDWtype __umoddi3 (UDWtype, UDWtype);
-extern DWtype __moddi3 (DWtype, DWtype);
-extern DWtype __negdi2 (DWtype);
-extern DWtype __lshrdi3 (DWtype, word_type);
-extern DWtype __ashldi3 (DWtype, word_type);
-extern DWtype __ashrdi3 (DWtype, word_type);
-
-// big endian
-struct DWstruct {
- Wtype high, low;
-};
-
-typedef union
-{
- struct DWstruct s;
- DWtype ll;
-} DWunion;
-
-DWtype
-__negdi2 (DWtype u)
-{
- const DWunion uu = {.ll = u};
- const DWunion w = { {.low = -uu.s.low,
- .high = -uu.s.high - ((UWtype) -uu.s.low > 0) } };
-
- return w.ll;
-}
-
-#define W_TYPE_SIZE 32
-#define __ll_B ((UWtype) 1 << (W_TYPE_SIZE / 2))
-#define __ll_lowpart(t) ((UWtype) (t) & (__ll_B - 1))
-#define __ll_highpart(t) ((UWtype) (t) >> (W_TYPE_SIZE / 2))
-#define umul_ppmm(w1, w0, u, v) \
- do { \
- UWtype __x0, __x1, __x2, __x3; \
- UHWtype __ul, __vl, __uh, __vh; \
- \
- __ul = __ll_lowpart (u); \
- __uh = __ll_highpart (u); \
- __vl = __ll_lowpart (v); \
- __vh = __ll_highpart (v); \
- \
- __x0 = (UWtype) __ul * __vl; \
- __x1 = (UWtype) __ul * __vh; \
- __x2 = (UWtype) __uh * __vl; \
- __x3 = (UWtype) __uh * __vh; \
- \
- __x1 += __ll_highpart (__x0);/* this can't give carry */ \
- __x1 += __x2; /* but this indeed can */ \
- if (__x1 < __x2) /* did we get it? */ \
- __x3 += __ll_B; /* yes, add it in the proper pos. */ \
- \
- (w1) = __x3 + __ll_highpart (__x1); \
- (w0) = __ll_lowpart (__x1) * __ll_B + __ll_lowpart (__x0); \
- } while (0)
-
-#define __umulsidi3(u, v) \
- ({DWunion __w; \
- umul_ppmm (__w.s.high, __w.s.low, u, v); \
- __w.ll; })
-
-DWtype
-__muldi3 (DWtype u, DWtype v)
-{
- const DWunion uu = {.ll = u};
- const DWunion vv = {.ll = v};
- DWunion w = {.ll = __umulsidi3 (uu.s.low, vv.s.low)};
-
- w.s.high += ((UWtype) uu.s.low * (UWtype) vv.s.high
- + (UWtype) uu.s.high * (UWtype) vv.s.low);
-
- return w.ll;
-}
-
-DWtype
-__lshrdi3 (DWtype u, word_type b)
-{
- const DWunion uu = {.ll = u};
- const word_type bm = (sizeof (Wtype) * BITS_PER_UNIT) - b;
- DWunion w;
-
- if (b == 0)
- return u;
-
- if (bm <= 0)
- {
- w.s.high = 0;
- w.s.low = (UWtype) uu.s.high >> -bm;
- }
- else
- {
- const UWtype carries = (UWtype) uu.s.high << bm;
-
- w.s.high = (UWtype) uu.s.high >> b;
- w.s.low = ((UWtype) uu.s.low >> b) | carries;
- }
-
- return w.ll;
-}
-
-DWtype
-__ashldi3 (DWtype u, word_type b)
-{
- const DWunion uu = {.ll = u};
- const word_type bm = (sizeof (Wtype) * BITS_PER_UNIT) - b;
- DWunion w;
-
- if (b == 0)
- return u;
-
- if (bm <= 0)
- {
- w.s.low = 0;
- w.s.high = (UWtype) uu.s.low << -bm;
- }
- else
- {
- const UWtype carries = (UWtype) uu.s.low >> bm;
-
- w.s.low = (UWtype) uu.s.low << b;
- w.s.high = ((UWtype) uu.s.high << b) | carries;
- }
-
- return w.ll;
-}
-
-DWtype
-__ashrdi3 (DWtype u, word_type b)
-{
- const DWunion uu = {.ll = u};
- const word_type bm = (sizeof (Wtype) * BITS_PER_UNIT) - b;
- DWunion w;
-
- if (b == 0)
- return u;
-
- if (bm <= 0)
- {
- /* w.s.high = 1..1 or 0..0 */
- w.s.high = uu.s.high >> (sizeof (Wtype) * BITS_PER_UNIT - 1);
- w.s.low = uu.s.high >> -bm;
- }
- else
- {
- const UWtype carries = (UWtype) uu.s.high << bm;
-
- w.s.high = uu.s.high >> b;
- w.s.low = ((UWtype) uu.s.low >> b) | carries;
- }
-
- return w.ll;
-}
25 arch/lm32/mm/init.c
View
@@ -121,29 +121,16 @@ void __init mem_init(void)
);
}
-static void free_init_pages(const char *what, unsigned long start, unsigned long end)
-{
- unsigned long addr;
-
- for (addr = start; addr < end; addr += PAGE_SIZE) {
- struct page* page = virt_to_page(addr);
-
- ClearPageReserved(page);
- init_page_count(page);
- __free_page(page);
- totalram_pages++;
- }
-
- printk("Freeing %s mem: %ldk freed\n", what, (end-start) >> 10);
-}
-
void free_initmem(void)
{
- free_init_pages("unused kernel", (unsigned long)&__init_begin, (unsigned long)&__init_end);
+ free_initmem_default(0);
}
#ifdef CONFIG_BLK_DEV_INITRD
-void __init free_initrd_mem(unsigned long start, unsigned long end) {
- free_init_pages("initrd", start, end);
+
+void __init free_initrd_mem(unsigned long start, unsigned long end)
+{
+ free_reserved_area(start, end, 0, "initrd");
}
+
#endif
8 arch/lm32/platforms/milkymist/time.c
View
@@ -144,17 +144,13 @@ void __init plat_time_init(void)
milkymist_ticks_per_jiffy = DIV_ROUND_CLOSEST(CONFIG_CPU_CLOCK, HZ);
- clockevents_calc_mult_shift(&milkymist_clockevent, CONFIG_CPU_CLOCK, 5);
- milkymist_clockevent.min_delta_ns = clockevent_delta2ns(100, &milkymist_clockevent);
- milkymist_clockevent.max_delta_ns = clockevent_delta2ns(0xffff, &milkymist_clockevent);
- milkymist_clockevent.cpumask = cpumask_of(0);
-
milkymist_timer_disable(TIMER_CLOCKSOURCE);
milkymist_timer_set_compare(TIMER_CLOCKSOURCE, 0xffffffff);
milkymist_timer_set_counter(TIMER_CLOCKSOURCE, 0);
milkymist_timer_enable(TIMER_CLOCKSOURCE, true);
- clockevents_register_device(&milkymist_clockevent);
+ clockevents_config_and_register(&milkymist_clockevent, CONFIG_CPU_CLOCK,
+ 100, 0xffff);
ret = clocksource_register_hz(&milkymist_clocksource, CONFIG_CPU_CLOCK);

No commit comments for this range

Something went wrong with that request. Please try again.