#undef memset
#undef memcpy
-#define memzero(s, n) memset ((s), 0, (n))
+#define memzero(s, n) memset((s), (0), (n))
extern int _end;
static unsigned long free_mem_ptr;
#include "../../../../lib/decompress_inflate.c"
-void* memset(void* s, int c, size_t n)
+void *memset(void *s, int c, size_t n)
{
int i;
- char *ss = (char*)s;
+ char *ss = (char *)s;
- for (i=0;i<n;i++) ss[i] = c;
+ for (i = 0; i < n; i++)
+ ss[i] = c;
return s;
}
-void* memcpy(void* __dest, __const void* __src,
- size_t __n)
+void *memcpy(void *dest, const void *src, size_t n)
{
int i;
- char *d = (char *)__dest, *s = (char *)__src;
+ char *d = (char *)dest, *s = (char *)src;
- for (i=0;i<__n;i++) d[i] = s[i];
- return __dest;
+ for (i = 0; i < n; i++)
+ d[i] = s[i];
+ return dest;
}
static void error(char *x)
{
- while(1); /* Halt */
+ while (1)
+ ; /* Halt */
}
#define STACK_SIZE (4096)
-long user_stack [STACK_SIZE];
-long* stack_start = &user_stack[STACK_SIZE];
+long user_stack[STACK_SIZE];
+long *stack_start = &user_stack[STACK_SIZE];
void decompress_kernel(void)
{
#if defined(CONFIG_CPU_H8300H)
#define NR_IRQS 64
-#define IRQ_CHIP &(h8300h_irq_chip)
+#define IRQ_CHIP h8300h_irq_chip
#define EXT_IRQ0 12
#define EXT_IRQS 6
#elif defined(CONFIG_CPU_H8S)
#define NR_IRQS 128
-#define IRQ_CHIP &(h8s_irq_chip)
+#define IRQ_CHIP h8s_irq_chip
#define EXT_IRQ0 16
#define EXT_IRQS 16
#endif
#define signal_pt_regs() ((struct pt_regs *)current->thread.esp0)
#define current_user_stack_pointer() rdusp()
#define task_pt_regs(task) \
- ((struct pt_regs *) (task_stack_page(task) + THREAD_SIZE) - 1)
+ ((struct pt_regs *) (task_stack_page(task) + THREAD_SIZE) - 1)
#endif /* __ASSEMBLY__ */
#endif /* _H8300_PTRACE_H */
#include <asm/page.h>
#define __HAVE_ARCH_MEMSET
-extern void * memset(void *s, int c, size_t count);
+extern void *memset(void *s, int c, size_t count);
#define __HAVE_ARCH_MEMCPY
-extern void * memcpy(void *d, const void *s, size_t count);
+extern void *memcpy(void *d, const void *s, size_t count);
#endif /* KERNEL */
"g" (prev) \
: "cc", "er0", "er1", "er2", "er3"); \
(last) = _last; \
-} while(0)
+} while (0)
#endif /* _H8300_SWITCH_TO_H */
* on our cache or tlb entries.
*/
-struct exception_table_entry
-{
+struct exception_table_entry {
unsigned long insn, fixup;
};
typeof(*(ptr)) __pu_val = (x); \
switch (sizeof(*(ptr))) { \
case 1: \
+ /* failthrough */ \
case 2: \
+ /* failthrough */ \
case 4: \
*(ptr) = x; \
break; \
#define get_user(x, ptr) \
({ \
- unsigned long long __gu_val; \
+ typeof(*(ptr)) __gu_val; \
int __gu_err = 0; \
switch (sizeof(*(ptr))) { \
case 1: \
- __gu_val = *((u8 *)(ptr)); \
+ *(u8 *)&__gu_val = *((u8 *)(ptr)); \
break; \
case 2: \
- __gu_val = *((u16 *)ptr); \
+ *(u16 *)&__gu_val = *((u16 *)ptr); \
break; \
case 4: \
- __gu_val = *((u32 *)ptr); \
+ *(u32 *)&__gu_val = *((u32 *)ptr); \
break; \
case 8: \
memcpy((void *)&__gu_val, ptr, sizeof(*(ptr))); \
__gu_err = __get_user_bad(); \
break; \
} \
- *(unsigned long *)&(x) = __gu_val; \
+ (x) = (typeof(*(ptr)))__gu_val; \
__gu_err; \
})
#define __get_user(x, ptr) get_user(x, ptr)
extern void __umoddi3(void);
extern void __umodsi3(void);
- /* gcc lib functions */
+ /* gcc lib functions */
EXPORT_SYMBOL(__gcc_bcmp);
EXPORT_SYMBOL(__ashldi3);
EXPORT_SYMBOL(__ashrdi3);
h8300_init_ipr();
for (c = 0; c < NR_IRQS; c++)
- irq_set_chip_and_handler(c, IRQ_CHIP, handle_simple_irq);
+ irq_set_chip_and_handler(c, &IRQ_CHIP, handle_simple_irq);
}
asmlinkage void do_IRQ(int irq)
static void h8300h_disable_irq(struct irq_data *data)
{
int bit;
- unsigned int addr;
int irq = data->irq - 12;
bit = ipr_bit[irq];
if (bit >= 0) {
- addr = IPR + (irq >> 3);
- ctrl_bclr(bit & 7, addr);
+ if (bit < 8)
+ ctrl_bclr(bit & 7, IPR);
+ else
+ ctrl_bclr(bit & 7, (IPR+1));
}
}
static void h8300h_enable_irq(struct irq_data *data)
{
int bit;
- unsigned int addr;
int irq = data->irq - 12;
bit = ipr_bit[irq];
if (bit >= 0) {
- addr = IPR + (irq >> 3);
- ctrl_bset(bit & 7, addr);
+ if (bit < 8)
+ ctrl_bset(bit & 7, IPR);
+ else
+ ctrl_bset(bit & 7, (IPR+1));
}
}
{
local_irq_disable();
__asm__("sleep");
- for (;;);
+ for (;;)
+ ;
}
void machine_power_off(void)
{
local_irq_disable();
__asm__("sleep");
- for (;;);
+ for (;;)
+ ;
}
void show_regs(struct pt_regs *regs)
unsigned long usp, unsigned long topstk,
struct task_struct *p)
{
- struct pt_regs * childregs;
+ struct pt_regs *childregs;
childregs = (struct pt_regs *) (THREAD_SIZE + task_stack_page(p)) - 1;
switch (request) {
/* read the word at location addr in the USER area. */
- case PTRACE_PEEKUSR: {
- unsigned long tmp = 0;
+ case PTRACE_PEEKUSR: {
+ unsigned long tmp = 0;
- if ((addr & 3) || addr >= sizeof(struct user)) {
- ret = -EIO;
- break;
- }
-
- ret = 0; /* Default return condition */
-
- if (regno < H8300_REGS_NO)
- tmp = h8300_get_reg(child, regno);
- else {
- switch (regno) {
- case 49:
- tmp = child->mm->start_code;
- break;
- case 50:
- tmp = child->mm->start_data;
- break;
- case 51:
- tmp = child->mm->end_code;
- break;
- case 52:
- tmp = child->mm->end_data;
- break;
- default:
- ret = -EIO;
- }
- }
- if (!ret)
- ret = put_user(tmp, datap);
- break ;
+ if ((addr & 3) || addr >= sizeof(struct user)) {
+ ret = -EIO;
+ break;
}
- /* when I and D space are separate, this will have to be fixed. */
- case PTRACE_POKEUSR: /* write the word at location addr
- in the USER area */
- if ((addr & 3) || addr >= sizeof(struct user)) {
- ret = -EIO;
+ ret = 0; /* Default return condition */
+
+ if (regno < H8300_REGS_NO)
+ tmp = h8300_get_reg(child, regno);
+ else {
+ switch (regno) {
+ case 49:
+ tmp = child->mm->start_code;
break;
- }
-
- if (regno == PT_ORIG_ER0) {
- ret = -EIO;
+ case 50:
+ tmp = child->mm->start_data;
break;
- }
- if (regno < H8300_REGS_NO) {
- ret = h8300_put_reg(child, regno, data);
+ case 51:
+ tmp = child->mm->end_code;
+ break;
+ case 52:
+ tmp = child->mm->end_data;
break;
+ default:
+ ret = -EIO;
}
+ }
+ if (!ret)
+ ret = put_user(tmp, datap);
+ break ;
+ }
+
+ /* when I and D space are separate, this will have to be fixed. */
+ case PTRACE_POKEUSR: /* write the word at location addr
+ in the USER area */
+ if ((addr & 3) || addr >= sizeof(struct user)) {
ret = -EIO;
break;
+ }
- case PTRACE_GETREGS: { /* Get all gp regs from the child. */
- int i;
- unsigned long tmp;
-
- for (i = 0; i < H8300_REGS_NO; i++) {
- tmp = h8300_get_reg(child, i);
- if (put_user(tmp, datap)) {
- ret = -EFAULT;
- break;
- }
- datap++;
- }
- ret = 0;
+ if (regno == PT_ORIG_ER0) {
+ ret = -EIO;
+ break;
+ }
+ if (regno < H8300_REGS_NO) {
+ ret = h8300_put_reg(child, regno, data);
break;
}
+ ret = -EIO;
+ break;
+
+ case PTRACE_GETREGS: { /* Get all gp regs from the child. */
+ int i;
+ unsigned long tmp;
- case PTRACE_SETREGS: { /* Set all gp regs in the child. */
- int i;
- unsigned long tmp;
-
- for (i = 0; i < H8300_REGS_NO; i++) {
- if (get_user(tmp, datap)) {
- ret = -EFAULT;
- break;
- }
- h8300_put_reg(child, i, tmp);
- datap++;
+ for (i = 0; i < H8300_REGS_NO; i++) {
+ tmp = h8300_get_reg(child, i);
+ if (put_user(tmp, datap)) {
+ ret = -EFAULT;
+ break;
}
- ret = 0;
- break;
+ datap++;
}
+ ret = 0;
+ break;
+ }
- default:
- ret = ptrace_request(child, request, addr, data);
- break;
+ case PTRACE_SETREGS: { /* Set all gp regs in the child. */
+ int i;
+ unsigned long tmp;
+
+ for (i = 0; i < H8300_REGS_NO; i++) {
+ if (get_user(tmp, datap)) {
+ ret = -EFAULT;
+ break;
+ }
+ h8300_put_reg(child, i, tmp);
+ datap++;
+ }
+ ret = 0;
+ break;
+ }
+
+ default:
+ ret = ptrace_request(child, request, addr, data);
+ break;
}
return ret;
}
unsigned char bitmask;
signed char length;
signed char type;
-} __packed, __aligned(1);
+} __packed __aligned(1);
#define OPTABLE(ptn, msk, len, jmp) \
- { \
+ { \
.bitpattern = ptn, \
.bitmask = msk, \
.length = len, \
- .type = jmp, \
+ .type = jmp, \
}
static const struct optable optable_0[] = {
OPTABLE(0x20, 0xe0, 1, none), /* 0x20-0x3f */
OPTABLE(0x40, 0xf0, 1, relb), /* 0x40-0x4f */
OPTABLE(0x50, 0xfc, 1, none), /* 0x50-0x53 */
- OPTABLE(0x54, 0xfd, 1, ret ), /* 0x54/0x56 */
+ OPTABLE(0x54, 0xfd, 1, ret), /* 0x54/0x56 */
OPTABLE(0x55, 0xff, 1, relb), /* 0x55 */
OPTABLE(0x57, 0xff, 1, none), /* 0x57 */
OPTABLE(0x58, 0xfb, 2, relw), /* 0x58/0x5c */
- OPTABLE(0x59, 0xfb, 1, reg ), /* 0x59/0x5b */
+ OPTABLE(0x59, 0xfb, 1, reg), /* 0x59/0x5b */
OPTABLE(0x5a, 0xfb, 2, jabs), /* 0x5a/0x5e */
- OPTABLE(0x5b, 0xfb, 2, ind ), /* 0x5b/0x5f */
+ OPTABLE(0x5b, 0xfb, 2, ind), /* 0x5b/0x5f */
OPTABLE(0x60, 0xe8, 1, none), /* 0x60-0x67/0x70-0x77 */
OPTABLE(0x68, 0xfa, 1, none), /* 0x68-0x69/0x6c-0x6d */
OPTABLE(0x6a, 0xfe, -2, none), /* 0x6a-0x6b */
OPTABLE(0x79, 0xff, 2, none), /* 0x79 */
OPTABLE(0x7a, 0xff, 3, none), /* 0x7a */
OPTABLE(0x7b, 0xff, 2, none), /* 0x7b */
- OPTABLE(0x7c, 0xfc, 2 ,none), /* 0x7c-0x7f */
+ OPTABLE(0x7c, 0xfc, 2, none), /* 0x7c-0x7f */
OPTABLE(0x80, 0x80, 1, none), /* 0x80-0xff */
};
0x0100698?/0x01006d8?/0140698?/0x01406d8? */
OPTABLE(0x00, 0x78, 3, none),
/* 0x0100692?/0x01006d2?/0140692?/0x01406d2?/
- 0x010069a?/0x01006da?/014069a?/0x01406da? */
+ 0x010069a?/0x01006da?/014069a?/0x01406da? */
OPTABLE(0x20, 0x78, 4, none),
};
int size;
} optables[] = {
#define OPTABLES(no) \
- { \
+ { \
.ptr = optable_##no, \
.size = sizeof(optable_##no) / sizeof(struct optable), \
}
0x00, 0x40, 0x01, 0x04, 0x02, 0x08, 0x10, 0x20
};
-static int isbranch(struct task_struct *task,int reson)
+static int isbranch(struct task_struct *task, int reson)
{
unsigned char cond = h8300_get_reg(task, PT_CCR);
+
/* encode complex conditions */
/* B4: N^V
B5: Z|(N^V)
"bld #2,%w0\n\t"
"bor #0,%w0\n\t"
"bst #6,%w0\n\t"
- : "=&r"(cond) :: "cc");
+ : "=&r"(cond) : : "cc");
cond &= condmask[reson >> 1];
if (!(reson & 1))
return cond == 0;
return cond != 0;
}
-static unsigned short *decode(struct task_struct *child, struct optable op,
- char *fetch_p, unsigned int *pc)
+static unsigned short *decode(struct task_struct *child, const struct optable *op,
+ char *fetch_p, unsigned short *pc,
+ unsigned char inst)
{
+ unsigned long addr;
+ unsigned long *sp;
+ int regno;
+
switch (op->type) {
case none:
- return pc + op->length;
+ return (unsigned short *)pc + op->length;
case jabs:
addr = *(unsigned long *)pc;
return (unsigned short *)(addr & 0x00ffffff);
pc = (unsigned short *)((unsigned long)pc +
((signed short)(*(pc+1))));
return pc+2; /* skip myself */
+ default:
+ return NULL;
}
}
{
const struct optable *op;
unsigned char *fetch_p;
+ int op_len;
unsigned char inst;
- unsigned long addr;
- unsigned long *sp;
- int op_len, regno;
op = optables[0].ptr;
op_len = optables[0].size;
op_len = optables[-op->length].size + 1;
inst = *fetch_p++;
} else
- return decode(child, op, fetch_p, pc);
+ return decode(child, op, fetch_p, pc, inst);
} else
op++;
- } while(--op_len > 0);
+ } while (--op_len > 0);
return NULL;
}
err |= __put_user(0, &frame->uc.uc_link);
err |= __save_altstack(&frame->uc.uc_stack, rdusp());
err |= setup_sigcontext(&frame->uc.uc_mcontext, regs, set->sig[0]);
- err |= copy_to_user (&frame->uc.uc_sigmask, set, sizeof(*set));
+ err |= copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set));
if (err)
goto give_sigsegv;
static void
handle_restart(struct pt_regs *regs, struct k_sigaction *ka)
{
- switch(regs->er0) {
+ switch (regs->er0) {
case -ERESTARTNOHAND:
if (!ka)
goto do_restart;
}
/* fallthrough */
case -ERESTARTNOINTR:
- do_restart:
+do_restart:
regs->er0 = regs->orig_er0;
regs->pc -= 2;
break;
- }
+ }
}
/*
/* sys_cacheflush -- no support. */
asmlinkage int
-sys_cacheflush (unsigned long addr, int scope, int cache, unsigned long len)
+sys_cacheflush(unsigned long addr, int scope, int cache, unsigned long len)
{
return -EINVAL;
}
return IRQ_HANDLED;
}
-
+
static inline struct timer8_priv *cs_to_priv(struct clocksource *cs)
{
return container_of(cs, struct timer8_priv, clk.cs);
p->mode = cfg->mode;
p->div = cfg->div;
- switch(p->mode) {
+ switch (p->mode) {
case H8300_TMR8_CLKSRC:
p->clk.cs.name = pdev->name;
p->clk.cs.rating = cfg->rating;
"failed to request irq %d\n", irq[OVI]);
return ret;
}
- clocksource_register_hz(&p->clk.cs,
+ clocksource_register_hz(&p->clk.cs,
get_cpu_clock() / div_rate[p->div]);
break;
case H8300_TMR8_CLKEVTDEV:
p = kmalloc(sizeof(*p), GFP_KERNEL);
if (p == NULL) {
- dev_err(&pdev->dev, "failed to allocate driver data"
- " out of memory\n");
+ dev_err(&pdev->dev, "failed to allocate driver data.\n");
return -ENOMEM;
}
static inline unsigned long read_tcnt32(struct tpu_priv *p)
{
unsigned long tcnt;
+
tcnt = ctrl_inw(p->mapbase1 + TCNT) << 16;
tcnt |= ctrl_inw(p->mapbase2 + TCNT);
return tcnt;
}
pr_info("\n");
if (STACK_MAGIC != *(unsigned long *)((unsigned long)current+PAGE_SIZE))
- pr_info("(Possibly corrupted stack page??)\n");
+ pr_info("(Possibly corrupted stack page??)\n");
pr_info("\n\n");
}
if (((unsigned long)stack & (THREAD_SIZE - 1)) == 0)
break;
if (i % 8 == 0)
- printk("\n ");
+ pr_info("\n ");
pr_info(" %08lx", *stack++);
}
SECTIONS
{
#if defined(CONFIG_ROMKERNEL)
- . = ROMTOP;
+ . = ROMTOP;
.vectors :
{
_vector = . ;
_ramstart = .;
.data : AT(ROMEND)
#else
- .data :
+ .data :
#endif
{
_sdata = . ;
# Makefile for H8/300-specific library files..
#
-lib-y = ashrdi3.o checksum.o memcpy.o memset.o abs.o strncpy.o
+lib-y = checksum.o memcpy.o memset.o abs.o strncpy.o
+++ /dev/null
-/* ashrdi3.c extracted from gcc-2.7.2/libgcc2.c which is: */
-/* Copyright (C) 1989, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
-
-This file is part of GNU CC.
-
-GNU CC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU CC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-*/
-
-#define BITS_PER_UNIT 8
-
-typedef int SItype __attribute__ ((mode (SI)));
-typedef unsigned int USItype __attribute__ ((mode (SI)));
-typedef int DItype __attribute__ ((mode (DI)));
-typedef int word_type __attribute__ ((mode (__word__)));
-
-struct DIstruct {SItype high, low;};
-
-typedef union
-{
- struct DIstruct s;
- DItype ll;
-} DIunion;
-
-DItype
-__ashrdi3 (DItype u, word_type b)
-{
- DIunion w;
- word_type bm;
- DIunion uu;
-
- if (b == 0)
- return u;
-
- uu.ll = u;
-
- bm = (sizeof (SItype) * BITS_PER_UNIT) - b;
- if (bm <= 0)
- {
- /* w.s.high = 1..1 or 0..0 */
- w.s.high = uu.s.high >> (sizeof (SItype) * BITS_PER_UNIT - 1);
- w.s.low = uu.s.high >> -bm;
- }
- else
- {
- USItype carries = (USItype)uu.s.high << bm;
- w.s.high = uu.s.high >> b;
- w.s.low = ((USItype)uu.s.low >> b) | carries;
- }
-
- return w.ll;
-}