Commit fb14b47f authored by Yoshinori Sato's avatar Yoshinori Sato Committed by Linus Torvalds

[PATCH] h8300 support fix (1/2)

o build script update
o interrupt management fix
o mtd support fix
o signal handling fix
parent 4a7f0bf3
......@@ -2169,6 +2169,12 @@ W: http://www.ic.nec.co.jp/micro/uclinux/eng/
W: http://www.ee.nec.de/uclinux/
S: Supported
UCLINUX FOR RENESAS H8/300
P: Yoshinori Sato
M: ysato@users.sourceforge.jp
W: http://uclinux-h8.sourceforge.jp/
S: Supported
USB DIAMOND RIO500 DRIVER
P: Cesar Miquel
M: miquel@df.uba.ar
......
......@@ -190,6 +190,8 @@ endmenu
source "drivers/base/Kconfig"
source "drivers/mtd/Kconfig"
source "drivers/block/Kconfig"
source "drivers/ide/Kconfig"
......
......@@ -5,7 +5,7 @@
# License. See the file "COPYING" in the main directory of this archive
# for more details.
#
# (C) Copyright 2002, Yoshinori Sato <ysato@users.sourceforge.jp>
# (C) Copyright 2002,2003 Yoshinori Sato <ysato@users.sourceforge.jp>
#
ifndef include-config
-include $(TOPDIR)/.config
......@@ -37,8 +37,8 @@ CFLAGS += $(cflags-y)
CFLAGS += -mint32 -fno-builtin -Os
CFLAGS += -g
CFLAGS += -D__linux__
CFLAGS += -DUTS_SYSNAME=\"uClinux\" -DTARGET=$(BOARD)
AFLAGS += -DPLATFORM=$(PLATFORM) -DTARGET=$(BOARD) -DMODEL=$(MODEL) $(cflags-y)
CFLAGS += -DUTS_SYSNAME=\"uClinux\"
AFLAGS += -DPLATFORM=$(PLATFORM) -DMODEL=$(MODEL) $(cflags-y)
LDFLAGS += $(ldflags-y)
CROSS_COMPILE = h8300-elf-
......@@ -53,28 +53,32 @@ core-y += arch/$(ARCH)/kernel/ \
libs-y += arch/$(ARCH)/lib/ $(LIBGCC)
export MODEL
boot := arch/h8300/boot
export MODEL PLATFORM BOARD
archmrproper:
archclean:
$(call descend arch/$(ARCH), subdirclean)
$(Q)$(MAKE) $(clean)=$(boot)
prepare: include/asm-$(ARCH)/machine-depend.h include/asm-$(ARCH)/asm-offsets.h
prepare: include/asm-$(ARCH)/asm-offsets.h
include/asm-$(ARCH)/machine-depend.h: include/asm-$(ARCH)/$(BOARD)/machine-depend.h
$(Q)ln -sf $(BOARD)/machine-depend.h \
include/asm-$(ARCH)/machine-depend.h
@echo ' Create include/asm-$(ARCH)/machine-depend.h'
include/asm-$(ARCH)/asm-offsets.h: arch/$(ARCH)/kernel/asm-offsets.s \
include/asm include/linux/version.h
$(call filechk,gen-asm-offsets)
vmlinux.bin: vmlinux
$(OBJCOPY) -Obinary $< $@
vmlinux.srec: vmlinux
$(OBJCOPY) -Osrec $< $@
vmlinux.srec vmlinux.bin: vmlinux
$(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
define archhelp
echo 'vmlinux.bin - Create raw binary'
echo 'vmlinux.srec - Create srec binary'
endef
CLEAN_FILES += arch/$(ARCH)/vmlinux.bin arch/$(ARCH)/vmlinux.srec
CLEAN_FILES += include/asm-$(ARCH)/asm-offsets.h include/asm-$(ARCH)/machine-depend.h
# arch/h8300/boot/Makefile
targets := vmlinux.srec vmlinux.bin
OBJCOPYFLAGS_vmlinux.srec := -Osrec
OBJCOPYFLAGS_vmlinux.bin := -Obinary
$(obj)/vmlinux.srec $(obj)/vmlinux.bin: vmlinux FORCE
$(call if_changed,objcopy)
@echo ' Kernel: $@ is ready'
CLEAN_FILES += arch/$(ARCH)/vmlinux.bin arch/$(ARCH)/vmlinux.srec
......@@ -157,6 +157,7 @@ struct sigframe
#if defined(CONFIG_CPU_H8S)
short dummy_exr;
#endif
long dummy_pc;
char *pretcode;
unsigned char retcode[8];
unsigned long extramask[_NSIG_WORDS-1];
......@@ -170,6 +171,7 @@ struct rt_sigframe
#if defined(CONFIG_CPU_H8S)
short dummy_exr;
#endif
long dummy_pc;
char *pretcode;
unsigned char retcode[8];
struct siginfo info;
......@@ -241,7 +243,7 @@ rt_restore_ucontext(struct pt_regs *regs, struct ucontext *uc, int *pd0)
asmlinkage int do_sigreturn(unsigned long __unused,...)
{
struct pt_regs *regs = (struct pt_regs *) &__unused;
struct pt_regs *regs = (struct pt_regs *) (&__unused - 1);
unsigned long usp = rdusp();
struct sigframe *frame = (struct sigframe *)(usp - 4);
sigset_t set;
......@@ -416,7 +418,6 @@ static void setup_rt_frame (int sig, struct k_sigaction *ka, siginfo_t *info,
/* Set up to return from userspace. */
err |= __put_user(frame->retcode, &frame->pretcode);
/* moveq #,d0; notb d0; movea.l #,a5; trap #0 */
/* sub.l er0,er0; mov.b #__NR_rt_sigreturn,r0l; trapa #0 */
err != __put_user(0x1a80f800 + (__NR_rt_sigreturn & 0xff),
(long *)(frame->retcode + 0));
......
......@@ -275,14 +275,18 @@ SYMBOL_NAME_LABEL(sys_call_table)
.long SYMBOL_NAME(sys_ni_syscall) /* sys_remap_file_pages */
.long SYMBOL_NAME(sys_set_tid_address)
.long SYMBOL_NAME(sys_timer_create)
.long SYMBOL_NAME(sys_timer_settime) /* 260 */
.long SYMBOL_NAME(sys_timer_settime) /* 260 */
.long SYMBOL_NAME(sys_timer_gettime)
.long SYMBOL_NAME(sys_timer_getoverrun)
.long SYMBOL_NAME(sys_timer_delete)
.long SYMBOL_NAME(sys_clock_settime)
.long SYMBOL_NAME(sys_clock_gettime) /* 265 */
.long SYMBOL_NAME(sys_clock_gettime) /* 265 */
.long SYMBOL_NAME(sys_clock_getres)
.long SYMBOL_NAME(sys_clock_nanosleep)
.long SYMBOL_NAME(sys_statfs64)
.long SYMBOL_NAME(sys_fstatfs64)
.long SYMBOL_NAME(sys_tgkill) /* 270 */
.long SYMBOL_NAME(sys_utimes)
.rept NR_syscalls-(.-SYMBOL_NAME(sys_call_table))/4
.long SYMBOL_NAME(sys_ni_syscall)
......
......@@ -2,58 +2,62 @@
#ifdef CONFIG_H8300H_GENERIC
#ifdef CONFIG_ROMKERNEL
#include "platform/h8300h/generic/rom.ld"
#include "../platform/h8300h/generic/rom.ld"
#endif
#ifdef CONFIG_RAMKERNEL
#include "platform/h8300h/generic/ram.ld"
#include "../platform/h8300h/generic/ram.ld"
#endif
#endif
#ifdef CONFIG_H8300H_AKI3068NET
#ifdef CONFIG_ROMKERNEL
#include "platform/h8300h/aki3068net/rom.ld"
#include "../platform/h8300h/aki3068net/rom.ld"
#endif
#ifdef CONFIG_RAMKERNEL
#include "platform/h8300h/aki3068net/ram.ld"
#include "../platform/h8300h/aki3068net/ram.ld"
#endif
#endif
#ifdef CONFIG_H8300H_H8MAX
#ifdef CONFIG_ROMKERNEL
#include "platform/h8300h/h8max/rom.ld"
#include "../platform/h8300h/h8max/rom.ld"
#endif
#ifdef CONFIG_RAMKERNEL
#include "platform/h8300h/h8max/ram.ld"
#include "../platform/h8300h/h8max/ram.ld"
#endif
#endif
#ifdef CONFIG_H8300H_SIM
#ifdef CONFIG_ROMKERNEL
#include "platform/h8300h/generic/rom.ld"
#include "../platform/h8300h/generic/rom.ld"
#endif
#ifdef CONFIG_RAMKERNEL
#include "platform/h8300h/generic/ram.ld"
#include "../platform/h8300h/generic/ram.ld"
#endif
#endif
#ifdef CONFIG_H8S_SIM
#ifdef CONFIG_ROMKERNEL
#include "platform/h8s/generic/rom.ld"
#include "../platform/h8s/generic/rom.ld"
#endif
#ifdef CONFIG_RAMKERNEL
#include "platform/h8s/generic/ram.ld"
#include "../platform/h8s/generic/ram.ld"
#endif
#endif
#ifdef CONFIG_H8S_EDOSK2674
#ifdef CONFIG_ROMKERNEL
#include "platform/h8s/edosk2674/rom.ld"
#include "../platform/h8s/edosk2674/rom.ld"
#endif
#ifdef CONFIG_RAMKERNEL
#include "platform/h8s/edosk2674/ram.ld"
#include "../platform/h8s/edosk2674/ram.ld"
#endif
#endif
#if defined(CONFIG_H8300H_SIM) || defined(CONFIG_H8S_SIM)
INPUT(romfs.o)
#endif
_jiffies = _jiffies_64 + 4;
SECTIONS
......@@ -169,6 +173,10 @@ SECTIONS
__end = . ;
__ramstart = .;
} > ram
.romfs :
{
*(.romfs*)
} > ram
.dummy :
{
COMMAND_START = . - 0x200 ;
......
/* romfs move to __ebss */
#include <asm/linkage.h>
#if defined(__H8300H__)
.h8300h
#endif
#if defined(__H8300S__)
.h8300s
#endif
.text
.globl __move_romfs
_romfs_sig_len = 8
__move_romfs:
mov.l #__sbss,er0
mov.l #_romfs_sig,er1
mov.b #_romfs_sig_len,r3l
1: /* check romfs image */
mov.b @er0+,r2l
mov.b @er1+,r2h
cmp.b r2l,r2h
bne 2f
dec.b r3l
bne 1b
/* find romfs image */
mov.l @__sbss+8,er0 /* romfs length(be) */
mov.l #__sbss,er1
add.l er0,er1 /* romfs image end */
mov.l #__ebss,er2
add.l er0,er2 /* distination address */
adds #2,er0
adds #1,er0
shlr er0
shlr er0 /* transfer length */
1:
mov.l @er1,er3 /* copy image */
mov.l er3,@er2
subs #4,er1
subs #4,er2
dec.l #1,er0
bpl 1b
2:
rts
.section .rodata
_romfs_sig:
.ascii "-rom1fs-"
.end
......@@ -25,15 +25,11 @@
#define CMFA 6
extern int request_irq_boot(unsigned int,
irqreturn_t (*handler)(int, void *, struct pt_regs *),
unsigned long, const char *, void *);
void __init platform_timer_setup(irqreturn_t (*timer_int)(int, void *, struct pt_regs *))
{
outb(H8300_TIMER_COUNT_DATA,TCORA2);
outb(0x00,_8TCSR2);
request_irq_boot(40,timer_int,0,"timer",0);
request_irq(40,timer_int,0,"timer",0);
outb(0x40|0x08|0x03,_8TCR2);
}
......
......@@ -111,7 +111,7 @@ LRET = 38
mov.l er1,@(8:16,er0)
mov.l @sp+,er1
add.l #(LRET-LORIG),sp /* remove LORIG - LRET */
add.l #(LRET-LER1),sp /* remove LORIG - LRET */
mov.l sp,@SYMBOL_NAME(sw_ksp)
mov.l er0,sp
bra 8f
......@@ -255,6 +255,7 @@ SYMBOL_NAME_LABEL(ret_from_exception)
btst #TIF_NEED_RESCHED,r1l
bne @SYMBOL_NAME(reschedule):16
mov.l sp,er1
subs #4,er1 /* adjust retpc */
mov.l er2,er0
jsr @SYMBOL_NAME(do_signal)
3:
......
......@@ -44,14 +44,19 @@ SYMBOL_NAME_LABEL(_start)
/* copy .data */
#if !defined(CONFIG_H8300H_SIM)
/* copy .data */
mov.l #__begin_data,er5
mov.l #__sdata,er6
mov.l #__edata,er4
sub.l er6,er4
sub.l er6,er4
shlr.l er4
shlr.l er4
1:
eepmov.w
dec.w #1,e4
bpl 1b
mov.l @er5+,er0
mov.l er0,@er6
adds #4,er6
dec.l #1,er4
bne 1b
#endif
/* copy kernel commandline */
......
......@@ -25,15 +25,11 @@
#define CMFA 6
extern int request_irq_boot(unsigned int,
irqreturn_t (*handler)(int, void *, struct pt_regs *),
unsigned long, const char *, void *);
void __init platform_timer_setup(irqreturn_t (*timer_int)(int, void *, struct pt_regs *))
{
outb(H8300_TIMER_COUNT_DATA,TCORA2);
outb(0x00,_8TCSR2);
request_irq_boot(40,timer_int,0,"timer",0);
request_irq(40,timer_int,0,"timer",0);
outb(0x40|0x08|0x03,_8TCR2);
}
......
......@@ -52,7 +52,8 @@ typedef struct irq_handler {
const char *devname;
} irq_handler_t;
irq_handler_t *irq_list[NR_IRQS];
static irq_handler_t *irq_list[NR_IRQS];
static int use_kmalloc;
extern unsigned long *interrupt_redirect_table;
......@@ -119,20 +120,6 @@ void __init init_IRQ(void)
#endif
}
void __init request_irq_boot(unsigned int irq,
irqreturn_t (*handler)(int, void *, struct pt_regs *),
unsigned long flags, const char *devname, void *dev_id)
{
irq_handler_t *irq_handle;
irq_handle = alloc_bootmem(sizeof(irq_handler_t));
irq_handle->handler = handler;
irq_handle->flags = flags;
irq_handle->count = 0;
irq_handle->dev_id = dev_id;
irq_handle->devname = devname;
irq_list[irq] = irq_handle;
}
int request_irq(unsigned int irq,
irqreturn_t (*handler)(int, void *, struct pt_regs *),
unsigned long flags, const char *devname, void *dev_id)
......@@ -154,7 +141,14 @@ int request_irq(unsigned int irq,
return -EBUSY;
H8300_GPIO_DDR(H8300_GPIO_P9, (irq - EXT_IRQ0), 0);
}
irq_handle = (irq_handler_t *)kmalloc(sizeof(irq_handler_t), GFP_ATOMIC);
if (use_kmalloc)
irq_handle = (irq_handler_t *)kmalloc(sizeof(irq_handler_t), GFP_ATOMIC);
else {
irq_handle = alloc_bootmem(sizeof(irq_handler_t));
(unsigned long)irq_handle |= 0x80000000; /* bootmem allocater */
}
if (irq_handle == NULL)
return -ENOMEM;
......@@ -177,8 +171,10 @@ void free_irq(unsigned int irq, void *dev_id)
irq, irq_list[irq]->devname);
if (irq >= EXT_IRQ0 && irq <= EXT_IRQ5)
*(volatile unsigned char *)IER &= ~(1 << (irq - EXT_IRQ0));
kfree(irq_list[irq]);
irq_list[irq] = NULL;
if ((irq_list[irq] & 0x80000000) == 0) {
kfree(irq_list[irq]);
irq_list[irq] = NULL;
}
}
/*
......@@ -244,3 +240,9 @@ int show_interrupts(struct seq_file *p, void *v)
void init_irq_proc(void)
{
}
static void __init enable_kmalloc(void)
{
use_kmalloc = 1;
}
__initcall(enable_kmalloc);
......@@ -37,7 +37,8 @@
/* CPU Reset entry */
SYMBOL_NAME_LABEL(_start)
mov.l #RAMEND,sp
ldc #0x07,exr
ldc #0x80,ccr
ldc #0x00,exr
/* Peripheral Setup */
bclr #4,@INTCR:8 /* interrupt mode 2 */
......@@ -46,7 +47,7 @@ SYMBOL_NAME_LABEL(_start)
bset #1,@ISCRL+1:16 /* IRQ0 Positive Edge */
bclr #0,@ISCRL+1:16
#if defined(CONFIG_BLK_DEV_BLKMEM)
#if defined(CONFIG_MTD_UCLINUX)
/* move romfs image */
jsr @__move_romfs
#endif
......@@ -71,7 +72,7 @@ SYMBOL_NAME_LABEL(_start)
eepmov.w
/* uClinux kernel start */
ldc #0x10,ccr /* running kernel */
ldc #0x90,ccr /* running kernel */
mov.l #SYMBOL_NAME(init_thread_union),sp
add.l #0x2000,sp
jsr @_start_kernel
......
......@@ -26,10 +26,6 @@
#define REGS(regs) __REGS(regs)
#define __REGS(regs) #regs
extern int request_irq_boot(unsigned int,
irqreturn_t (*handler)(int, void *, struct pt_regs *),
unsigned long, const char *, void *);
int __init platform_timer_setup(irqreturn_t (*timer_int)(int, void *, struct pt_regs *))
{
unsigned char mstpcrl;
......@@ -38,7 +34,7 @@ int __init platform_timer_setup(irqreturn_t (*timer_int)(int, void *, struct pt_
outb(mstpcrl,MSTPCRL);
outb(H8300_TIMER_COUNT_DATA,_8TCORA1);
outb(0x00,_8TCSR1);
request_irq_boot(76,timer_int,0,"timer",0);
request_irq(76,timer_int,0,"timer",0);
outb(0x40|0x08|0x03,_8TCR1);
return 0;
}
......
......@@ -112,7 +112,7 @@ LRET = 40
mov.l er1,@(10:16,er0)
mov.l @sp+,er1
add.l #(LRET-LORIG),sp /* remove LORIG - LRET */
add.l #(LRET-LER1),sp /* remove LORIG - LRET */
mov.l sp,@SYMBOL_NAME(sw_ksp)
mov.l er0,sp
bra 8f
......@@ -252,6 +252,7 @@ SYMBOL_NAME_LABEL(ret_from_exception)
btst #TIF_NEED_RESCHED,r1l
bne @SYMBOL_NAME(reschedule):16
mov.l sp,er1
subs #4,er1 /* adjust retpc */
mov.l er2,er0
jsr @SYMBOL_NAME(do_signal)
3:
......
......@@ -37,13 +37,14 @@
/* CPU Reset entry */
SYMBOL_NAME_LABEL(_start)
mov.l #RAMEND,sp
ldc #0x07,exr
ldc #0x80,ccr
ldc #0x00,exr
/* Peripheral Setup */
bclr #4,@INTCR:8 /* interrupt mode 2 */
bset #5,@INTCR:8
#if defined(CONFIG_BLK_DEV_BLKMEM)
#if defined(CONFIG_MTD_UCLINUX)
/* move romfs image */
jsr @__move_romfs
#endif
......@@ -68,7 +69,7 @@ SYMBOL_NAME_LABEL(_start)
eepmov.w
/* uClinux kernel start */
ldc #0x10,ccr /* running kernel */
ldc #0x90,ccr /* running kernel */
mov.l #SYMBOL_NAME(init_thread_union),sp
add.l #0x2000,sp
jsr @_start_kernel
......
......@@ -33,36 +33,32 @@ SYMBOL_NAME_LABEL(_start)
/* Peripheral Setup */
/* .bss clear */
mov.l #__sbss,er5
mov.l er5,er6
inc.l #1,er6
mov.l #__ebss,er4
sub.l er5,er4
sub.w r0,r0
mov.b r0l,@er5
1:
eepmov.w
dec.w #1,e4
bpl 1b
/* copy .data */
#if !defined(CONFIG_H8S_SIM)
mov.l #__begin_data,er5
mov.l #__sdata,er6
mov.l #__edata,er4
sub.l er6,er4
sub.l er6,er4
shlr.l #2,er4
1:
eepmov.w
dec.w #1,e4
bpl 1b
mov.l @er5+,er0
mov.l er0,@er6
adds #4,er6
dec.l #1,er4
bne 1b
#endif
/* copy kernel commandline */
mov.l #COMMAND_START,er5
mov.l #SYMBOL_NAME(_command_line),er6
mov.w #512,r4
eepmov.w
/* .bss clear */
mov.l #__sbss,er5
mov.l #__ebss,er4
sub.l er5,er4
shlr.l #2,er4
sub.l er0,er0
1:
mov.l er0,@er5
adds #4,er5
dec.l #1,er4
bne 1b
/* linux kernel start */
ldc #0x90,ccr /* running kernel */
......
......@@ -6,6 +6,6 @@ MEMORY
vector : ORIGIN = 0x000000, LENGTH = 0x000200
rom : ORIGIN = 0x000200, LENGTH = 0x200000-0x000200
erom : ORIGIN = 0x200000, LENGTH = 0
ram : ORIGIN = 0x200000, LENGTH = 0x200000
eram : ORIGIN = 0x400000, LENGTH = 0
ram : ORIGIN = 0x200000, LENGTH = 0x400000
eram : ORIGIN = 0x600000, LENGTH = 0
}
......@@ -23,15 +23,11 @@
#include <asm/irq.h>
#include <asm/regs267x.h>
extern int request_irq_boot(unsigned int,
irqreturn_t (*handler)(int, void *, struct pt_regs *),
unsigned long, const char *, void *);
int platform_timer_setup(irqreturn_t (*timer_int)(int, void *, struct pt_regs *))
{
outb(H8300_TIMER_COUNT_DATA,_8TCORA1);
outb(0x00,_8TCSR1);
request_irq_boot(76,timer_int,0,"timer",0);
request_irq(76,timer_int,0,"timer",0);
outb(0x40|0x08|0x03,_8TCR1);
return 0;
}
......
......@@ -91,6 +91,8 @@ const static struct irq_pins irq_assign_table1[16]={
{H8300_GPIO_P2,H8300_GPIO_B6},{H8300_GPIO_P2,H8300_GPIO_B7},
};
static int use_kmalloc;
extern unsigned long *interrupt_redirect_table;
static inline unsigned long *get_vector_address(void)
......@@ -159,22 +161,6 @@ void __init init_IRQ(void)
#endif
}
/* special request_irq */
/* used bootmem allocater */
void __init request_irq_boot(unsigned int irq,
irqreturn_t (*handler)(int, void *, struct pt_regs *),
unsigned long flags, const char *devname, void *dev_id)
{
irq_handler_t *irq_handle;
irq_handle = alloc_bootmem(sizeof(irq_handler_t));
irq_handle->handler = handler;
irq_handle->flags = flags;
irq_handle->count = 0;
irq_handle->dev_id = dev_id;
irq_handle->devname = devname;
irq_list[irq] = irq_handle;
}
int request_irq(unsigned int irq,
irqreturn_t (*handler)(int, void *, struct pt_regs *),
unsigned long flags, const char *devname, void *dev_id)
......@@ -202,7 +188,14 @@ int request_irq(unsigned int irq,
H8300_GPIO_DDR(port_no, bit_no, H8300_GPIO_INPUT);
*(volatile unsigned short *)ISR &= ~ptn; /* ISR clear */
}
irq_handle = (irq_handler_t *)kmalloc(sizeof(irq_handler_t), GFP_ATOMIC);
if (use_kmalloc)
irq_handle = (irq_handler_t *)kmalloc(sizeof(irq_handler_t), GFP_ATOMIC);
else {
irq_handle = alloc_bootmem(sizeof(irq_handler_t));
(unsigned long)irq_handle |= 0x80000000; /* bootmem allocater */
}
if (irq_handle == NULL)
return -ENOMEM;
......@@ -243,8 +236,10 @@ void free_irq(unsigned int irq, void *dev_id)
}
H8300_GPIO_FREE(port_no, bit_no);
}
kfree(irq_list[irq]);
irq_list[irq] = NULL;
if (((unsigned long)irq_list[irq] & 0x80000000) == 0) {
kfree(irq_list[irq]);
irq_list[irq] = NULL;
}
}
unsigned long probe_irq_on (void)
......@@ -306,3 +301,10 @@ int show_interrupts(struct seq_file *p, void *v)
void init_irq_proc(void)
{
}
static int __init enable_kmalloc(void)
{
use_kmalloc = 1;
return 0;
}
__initcall(enable_kmalloc);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment