aboutsummaryrefslogtreecommitdiffstats
path: root/arch/h8300
diff options
context:
space:
mode:
Diffstat (limited to 'arch/h8300')
-rw-r--r--arch/h8300/Kconfig8
-rw-r--r--arch/h8300/Makefile2
-rw-r--r--arch/h8300/boot/Makefile12
-rw-r--r--arch/h8300/boot/compressed/Makefile37
-rw-r--r--arch/h8300/boot/compressed/head.S47
-rw-r--r--arch/h8300/boot/compressed/misc.c219
-rw-r--r--arch/h8300/kernel/Makefile6
-rw-r--r--arch/h8300/kernel/irq.c211
-rw-r--r--arch/h8300/kernel/setup.c3
-rw-r--r--arch/h8300/kernel/time.c54
-rw-r--r--arch/h8300/mm/kmap.c4
-rw-r--r--arch/h8300/platform/h8300h/Makefile2
-rw-r--r--arch/h8300/platform/h8300h/entry.S4
-rw-r--r--arch/h8300/platform/h8300h/generic/Makefile2
-rw-r--r--arch/h8300/platform/h8300h/ints_h8300h.c85
-rw-r--r--arch/h8300/platform/h8s/entry.S17
16 files changed, 553 insertions, 160 deletions
diff --git a/arch/h8300/Kconfig b/arch/h8300/Kconfig
index 1734d96422c6..618dbad696f6 100644
--- a/arch/h8300/Kconfig
+++ b/arch/h8300/Kconfig
@@ -49,10 +49,18 @@ config GENERIC_HWEIGHT
49 bool 49 bool
50 default y 50 default y
51 51
52config GENERIC_HARDIRQS
53 bool
54 default y
55
52config GENERIC_CALIBRATE_DELAY 56config GENERIC_CALIBRATE_DELAY
53 bool 57 bool
54 default y 58 default y
55 59
60config GENERIC_TIME
61 bool
62 default y
63
56config TIME_LOW_RES 64config TIME_LOW_RES
57 bool 65 bool
58 default y 66 default y
diff --git a/arch/h8300/Makefile b/arch/h8300/Makefile
index 40b3f56f3666..b2d896a7e598 100644
--- a/arch/h8300/Makefile
+++ b/arch/h8300/Makefile
@@ -41,7 +41,7 @@ LDFLAGS += $(ldflags-y)
41CROSS_COMPILE = h8300-elf- 41CROSS_COMPILE = h8300-elf-
42LIBGCC := $(shell $(CROSS-COMPILE)$(CC) $(CFLAGS) -print-libgcc-file-name) 42LIBGCC := $(shell $(CROSS-COMPILE)$(CC) $(CFLAGS) -print-libgcc-file-name)
43 43
44head-y := arch/$(ARCH)/platform/$(platform-y)/$(board-y)/crt0_$(model-y).o 44head-y := arch/$(ARCH)/platform/$(PLATFORM)/$(BOARD)/crt0_$(MODEL).o
45 45
46core-y += arch/$(ARCH)/kernel/ \ 46core-y += arch/$(ARCH)/kernel/ \
47 arch/$(ARCH)/mm/ 47 arch/$(ARCH)/mm/
diff --git a/arch/h8300/boot/Makefile b/arch/h8300/boot/Makefile
index 65086d925ca7..0bb62e064eea 100644
--- a/arch/h8300/boot/Makefile
+++ b/arch/h8300/boot/Makefile
@@ -1,12 +1,22 @@
1# arch/h8300/boot/Makefile 1# arch/h8300/boot/Makefile
2 2
3targets := vmlinux.srec vmlinux.bin 3targets := vmlinux.srec vmlinux.bin zImage
4subdir- := compressed
4 5
5OBJCOPYFLAGS_vmlinux.srec := -Osrec 6OBJCOPYFLAGS_vmlinux.srec := -Osrec
6OBJCOPYFLAGS_vmlinux.bin := -Obinary 7OBJCOPYFLAGS_vmlinux.bin := -Obinary
8OBJCOPYFLAGS_zImage := -O binary -R .note -R .comment -R .stab -R .stabstr -S
7 9
8$(obj)/vmlinux.srec $(obj)/vmlinux.bin: vmlinux FORCE 10$(obj)/vmlinux.srec $(obj)/vmlinux.bin: vmlinux FORCE
9 $(call if_changed,objcopy) 11 $(call if_changed,objcopy)
10 @echo ' Kernel: $@ is ready' 12 @echo ' Kernel: $@ is ready'
11 13
14$(obj)/zImage: $(obj)/compressed/vmlinux FORCE
15 $(call if_changed,objcopy)
16 @echo 'Kernel: $@ is ready'
17
18$(obj)/compressed/vmlinux: FORCE
19 $(Q)$(MAKE) $(build)=$(obj)/compressed $@
20
12CLEAN_FILES += arch/$(ARCH)/vmlinux.bin arch/$(ARCH)/vmlinux.srec 21CLEAN_FILES += arch/$(ARCH)/vmlinux.bin arch/$(ARCH)/vmlinux.srec
22
diff --git a/arch/h8300/boot/compressed/Makefile b/arch/h8300/boot/compressed/Makefile
new file mode 100644
index 000000000000..71aac82a8ae0
--- /dev/null
+++ b/arch/h8300/boot/compressed/Makefile
@@ -0,0 +1,37 @@
1#
2# linux/arch/sh/boot/compressed/Makefile
3#
4# create a compressed vmlinux image from the original vmlinux
5#
6
7targets := vmlinux vmlinux.bin vmlinux.bin.gz head.o misc.o piggy.o
8EXTRA_AFLAGS := -traditional
9
10OBJECTS = $(obj)/head.o $(obj)/misc.o
11
12#
13# IMAGE_OFFSET is the load offset of the compression loader
14# Assign dummy values if these 2 variables are not defined,
15# in order to suppress error message.
16#
17CONFIG_MEMORY_START ?= 0x00400000
18CONFIG_BOOT_LINK_OFFSET ?= 0x00400000
19IMAGE_OFFSET := $(shell printf "0x%08x" $$[$(CONFIG_MEMORY_START)+$(CONFIG_BOOT_LINK_OFFSET)])
20
21LDFLAGS_vmlinux := -T $(obj)/vmlinux.lds
22
23$(obj)/vmlinux: $(OBJECTS) $(obj)/piggy.o FORCE
24 $(call if_changed,ld)
25 @:
26
27$(obj)/vmlinux.bin: vmlinux FORCE
28 $(call if_changed,objcopy)
29
30$(obj)/vmlinux.bin.gz: $(obj)/vmlinux.bin FORCE
31 $(call if_changed,gzip)
32
33LDFLAGS_piggy.o := -r --format binary --oformat elf32-h8300 -T
34OBJCOPYFLAGS := -O binary
35
36$(obj)/piggy.o: $(obj)/vmlinux.scr $(obj)/vmlinux.bin.gz FORCE
37 $(call if_changed,ld)
diff --git a/arch/h8300/boot/compressed/head.S b/arch/h8300/boot/compressed/head.S
new file mode 100644
index 000000000000..b8e90d12d19e
--- /dev/null
+++ b/arch/h8300/boot/compressed/head.S
@@ -0,0 +1,47 @@
1/*
2 * linux/arch/h8300/boot/compressed/head.S
3 *
4 * Copyright (C) 2006 Yoshinori Sato
5 */
6
7.h8300h
8#include <linux/linkage.h>
9
10#define SRAM_START 0xff4000
11
12 .section .text.startup
13 .global startup
14startup:
15 mov.l #SRAM_START+0x8000, sp
16 mov.l #__sbss, er0
17 mov.l #__ebss, er1
18 sub.l er0, er1
19 shlr er1
20 shlr er1
21 sub.l er2, er2
221:
23 mov.l er2, @er0
24 adds #4, er0
25 dec.l #1, er1
26 bne 1b
27 jsr @_decompress_kernel
28 jmp @0x400000
29
30 .align 9
31fake_headers_as_bzImage:
32 .word 0
33 .ascii "HdrS" ; header signature
34 .word 0x0202 ; header version number (>= 0x0105)
35 ; or else old loadlin-1.5 will fail)
36 .word 0 ; default_switch
37 .word 0 ; SETUPSEG
38 .word 0x1000
39 .word 0 ; pointing to kernel version string
40 .byte 0 ; = 0, old one (LILO, Loadlin,
41 ; 0xTV: T=0 for LILO
42 ; V = version
43 .byte 1 ; Load flags bzImage=1
44 .word 0x8000 ; size to move, when setup is not
45 .long 0x100000 ; 0x100000 = default for big kernel
46 .long 0 ; address of loaded ramdisk image
47 .long 0 ; its size in bytes
diff --git a/arch/h8300/boot/compressed/misc.c b/arch/h8300/boot/compressed/misc.c
new file mode 100644
index 000000000000..845074588af0
--- /dev/null
+++ b/arch/h8300/boot/compressed/misc.c
@@ -0,0 +1,219 @@
1/*
2 * arch/h8300/boot/compressed/misc.c
3 *
4 * This is a collection of several routines from gzip-1.0.3
5 * adapted for Linux.
6 *
7 * malloc by Hannu Savolainen 1993 and Matthias Urlichs 1994
8 *
9 * Adapted for h8300 by Yoshinori Sato 2006
10 */
11
12#include <asm/uaccess.h>
13
14/*
15 * gzip declarations
16 */
17
18#define OF(args) args
19#define STATIC static
20
21#undef memset
22#undef memcpy
23#define memzero(s, n) memset ((s), 0, (n))
24
25typedef unsigned char uch;
26typedef unsigned short ush;
27typedef unsigned long ulg;
28
29#define WSIZE 0x8000 /* Window size must be at least 32k, */
30 /* and a power of two */
31
32static uch *inbuf; /* input buffer */
33static uch window[WSIZE]; /* Sliding window buffer */
34
35static unsigned insize = 0; /* valid bytes in inbuf */
36static unsigned inptr = 0; /* index of next byte to be processed in inbuf */
37static unsigned outcnt = 0; /* bytes in output buffer */
38
39/* gzip flag byte */
40#define ASCII_FLAG 0x01 /* bit 0 set: file probably ASCII text */
41#define CONTINUATION 0x02 /* bit 1 set: continuation of multi-part gzip file */
42#define EXTRA_FIELD 0x04 /* bit 2 set: extra field present */
43#define ORIG_NAME 0x08 /* bit 3 set: original file name present */
44#define COMMENT 0x10 /* bit 4 set: file comment present */
45#define ENCRYPTED 0x20 /* bit 5 set: file is encrypted */
46#define RESERVED 0xC0 /* bit 6,7: reserved */
47
48#define get_byte() (inptr < insize ? inbuf[inptr++] : fill_inbuf())
49
50/* Diagnostic functions */
51#ifdef DEBUG
52# define Assert(cond,msg) {if(!(cond)) error(msg);}
53# define Trace(x) fprintf x
54# define Tracev(x) {if (verbose) fprintf x ;}
55# define Tracevv(x) {if (verbose>1) fprintf x ;}
56# define Tracec(c,x) {if (verbose && (c)) fprintf x ;}
57# define Tracecv(c,x) {if (verbose>1 && (c)) fprintf x ;}
58#else
59# define Assert(cond,msg)
60# define Trace(x)
61# define Tracev(x)
62# define Tracevv(x)
63# define Tracec(c,x)
64# define Tracecv(c,x)
65#endif
66
67static int fill_inbuf(void);
68static void flush_window(void);
69static void error(char *m);
70static void gzip_mark(void **);
71static void gzip_release(void **);
72
73extern char input_data[];
74extern int input_len;
75
76static long bytes_out = 0;
77static uch *output_data;
78static unsigned long output_ptr = 0;
79
80static void *malloc(int size);
81static void free(void *where);
82static void error(char *m);
83static void gzip_mark(void **);
84static void gzip_release(void **);
85
86int puts(const char *);
87
88extern int _text; /* Defined in vmlinux.lds.S */
89extern int _end;
90static unsigned long free_mem_ptr;
91static unsigned long free_mem_end_ptr;
92
93#define HEAP_SIZE 0x10000
94
95#include "../../../../lib/inflate.c"
96
97#define SCR *((volatile unsigned char *)0xffff8a)
98#define TDR *((volatile unsigned char *)0xffff8b)
99#define SSR *((volatile unsigned char *)0xffff8c)
100
101static void *malloc(int size)
102{
103 void *p;
104
105 if (size <0) error("Malloc error");
106 if (free_mem_ptr == 0) error("Memory error");
107
108 free_mem_ptr = (free_mem_ptr + 3) & ~3; /* Align */
109
110 p = (void *)free_mem_ptr;
111 free_mem_ptr += size;
112
113 if (free_mem_ptr >= free_mem_end_ptr)
114 error("Out of memory");
115
116 return p;
117}
118
119static void free(void *where)
120{ /* Don't care */
121}
122
123static void gzip_mark(void **ptr)
124{
125 *ptr = (void *) free_mem_ptr;
126}
127
128static void gzip_release(void **ptr)
129{
130 free_mem_ptr = (long) *ptr;
131}
132
133int puts(const char *s)
134{
135 return 0;
136}
137
138void* memset(void* s, int c, size_t n)
139{
140 int i;
141 char *ss = (char*)s;
142
143 for (i=0;i<n;i++) ss[i] = c;
144 return s;
145}
146
147void* memcpy(void* __dest, __const void* __src,
148 size_t __n)
149{
150 int i;
151 char *d = (char *)__dest, *s = (char *)__src;
152
153 for (i=0;i<__n;i++) d[i] = s[i];
154 return __dest;
155}
156
157/* ===========================================================================
158 * Fill the input buffer. This is called only when the buffer is empty
159 * and at least one byte is really needed.
160 */
161static int fill_inbuf(void)
162{
163 if (insize != 0) {
164 error("ran out of input data");
165 }
166
167 inbuf = input_data;
168 insize = input_len;
169 inptr = 1;
170 return inbuf[0];
171}
172
173/* ===========================================================================
174 * Write the output window window[0..outcnt-1] and update crc and bytes_out.
175 * (Used for the decompressed data only.)
176 */
177static void flush_window(void)
178{
179 ulg c = crc; /* temporary variable */
180 unsigned n;
181 uch *in, *out, ch;
182
183 in = window;
184 out = &output_data[output_ptr];
185 for (n = 0; n < outcnt; n++) {
186 ch = *out++ = *in++;
187 c = crc_32_tab[((int)c ^ ch) & 0xff] ^ (c >> 8);
188 }
189 crc = c;
190 bytes_out += (ulg)outcnt;
191 output_ptr += (ulg)outcnt;
192 outcnt = 0;
193}
194
195static void error(char *x)
196{
197 puts("\n\n");
198 puts(x);
199 puts("\n\n -- System halted");
200
201 while(1); /* Halt */
202}
203
204#define STACK_SIZE (4096)
205long user_stack [STACK_SIZE];
206long* stack_start = &user_stack[STACK_SIZE];
207
208void decompress_kernel(void)
209{
210 output_data = 0;
211 output_ptr = (unsigned long)0x400000;
212 free_mem_ptr = (unsigned long)&_end;
213 free_mem_end_ptr = free_mem_ptr + HEAP_SIZE;
214
215 makecrc();
216 puts("Uncompressing Linux... ");
217 gunzip();
218 puts("Ok, booting the kernel.\n");
219}
diff --git a/arch/h8300/kernel/Makefile b/arch/h8300/kernel/Makefile
index 4edbc2ef6ca2..ccc1a7fbf94b 100644
--- a/arch/h8300/kernel/Makefile
+++ b/arch/h8300/kernel/Makefile
@@ -4,10 +4,8 @@
4 4
5extra-y := vmlinux.lds 5extra-y := vmlinux.lds
6 6
7obj-y := process.o traps.o ptrace.o ints.o \ 7obj-y := process.o traps.o ptrace.o irq.o \
8 sys_h8300.o time.o semaphore.o signal.o \ 8 sys_h8300.o time.o semaphore.o signal.o \
9 setup.o gpio.o init_task.o syscalls.o devres.o 9 setup.o gpio.o init_task.o syscalls.o
10
11devres-y = ../../../kernel/irq/devres.o
12 10
13obj-$(CONFIG_MODULES) += module.o h8300_ksyms.o 11obj-$(CONFIG_MODULES) += module.o h8300_ksyms.o
diff --git a/arch/h8300/kernel/irq.c b/arch/h8300/kernel/irq.c
new file mode 100644
index 000000000000..43d21e93f41f
--- /dev/null
+++ b/arch/h8300/kernel/irq.c
@@ -0,0 +1,211 @@
1/*
2 * linux/arch/h8300/kernel/irq.c
3 *
4 * Copyright 2007 Yoshinori Sato <ysato@users.sourceforge.jp>
5 */
6
7#include <linux/module.h>
8#include <linux/types.h>
9#include <linux/kernel.h>
10#include <linux/sched.h>
11#include <linux/kernel_stat.h>
12#include <linux/seq_file.h>
13#include <linux/init.h>
14#include <linux/random.h>
15#include <linux/bootmem.h>
16#include <linux/irq.h>
17
18#include <asm/system.h>
19#include <asm/traps.h>
20#include <asm/io.h>
21#include <asm/setup.h>
22#include <asm/errno.h>
23
24/*#define DEBUG*/
25
26extern unsigned long *interrupt_redirect_table;
27extern const int h8300_saved_vectors[];
28extern const unsigned long h8300_trap_table[];
29int h8300_enable_irq_pin(unsigned int irq);
30void h8300_disable_irq_pin(unsigned int irq);
31
32#define CPU_VECTOR ((unsigned long *)0x000000)
33#define ADDR_MASK (0xffffff)
34
35static inline int is_ext_irq(unsigned int irq)
36{
37 return (irq >= EXT_IRQ0 && irq <= (EXT_IRQ0 + EXT_IRQS));
38}
39
40static void h8300_enable_irq(unsigned int irq)
41{
42 if (is_ext_irq(irq))
43 IER_REGS |= 1 << (irq - EXT_IRQ0);
44}
45
46static void h8300_disable_irq(unsigned int irq)
47{
48 if (is_ext_irq(irq))
49 IER_REGS &= ~(1 << (irq - EXT_IRQ0));
50}
51
52static void h8300_end_irq(unsigned int irq)
53{
54}
55
56static unsigned int h8300_startup_irq(unsigned int irq)
57{
58 if (is_ext_irq(irq))
59 return h8300_enable_irq_pin(irq);
60 else
61 return 0;
62}
63
64static void h8300_shutdown_irq(unsigned int irq)
65{
66 if (is_ext_irq(irq))
67 h8300_disable_irq_pin(irq);
68}
69
70/*
71 * h8300 interrupt controler implementation
72 */
73struct irq_chip h8300irq_chip = {
74 .name = "H8300-INTC",
75 .startup = h8300_startup_irq,
76 .shutdown = h8300_shutdown_irq,
77 .enable = h8300_enable_irq,
78 .disable = h8300_disable_irq,
79 .ack = NULL,
80 .end = h8300_end_irq,
81};
82
83void ack_bad_irq(unsigned int irq)
84{
85 printk("unexpected IRQ trap at vector %02x\n", irq);
86}
87
88#if defined(CONFIG_RAMKERNEL)
89static unsigned long __init *get_vector_address(void)
90{
91 unsigned long *rom_vector = CPU_VECTOR;
92 unsigned long base,tmp;
93 int vec_no;
94
95 base = rom_vector[EXT_IRQ0] & ADDR_MASK;
96
97 /* check romvector format */
98 for (vec_no = EXT_IRQ1; vec_no <= EXT_IRQ0+EXT_IRQS; vec_no++) {
99 if ((base+(vec_no - EXT_IRQ0)*4) != (rom_vector[vec_no] & ADDR_MASK))
100 return NULL;
101 }
102
103 /* ramvector base address */
104 base -= EXT_IRQ0*4;
105
106 /* writerble check */
107 tmp = ~(*(volatile unsigned long *)base);
108 (*(volatile unsigned long *)base) = tmp;
109 if ((*(volatile unsigned long *)base) != tmp)
110 return NULL;
111 return (unsigned long *)base;
112}
113
114static void __init setup_vector(void)
115{
116 int i;
117 unsigned long *ramvec,*ramvec_p;
118 const unsigned long *trap_entry;
119 const int *saved_vector;
120
121 ramvec = get_vector_address();
122 if (ramvec == NULL)
123 panic("interrupt vector serup failed.");
124 else
125 printk(KERN_INFO "virtual vector at 0x%08lx\n",(unsigned long)ramvec);
126
127 /* create redirect table */
128 ramvec_p = ramvec;
129 trap_entry = h8300_trap_table;
130 saved_vector = h8300_saved_vectors;
131 for ( i = 0; i < NR_IRQS; i++) {
132 if (i == *saved_vector) {
133 ramvec_p++;
134 saved_vector++;
135 } else {
136 if ( i < NR_TRAPS ) {
137 if (*trap_entry)
138 *ramvec_p = VECTOR(*trap_entry);
139 ramvec_p++;
140 trap_entry++;
141 } else
142 *ramvec_p++ = REDIRECT(interrupt_entry);
143 }
144 }
145 interrupt_redirect_table = ramvec;
146#ifdef DEBUG
147 ramvec_p = ramvec;
148 for (i = 0; i < NR_IRQS; i++) {
149 if ((i % 8) == 0)
150 printk(KERN_DEBUG "\n%p: ",ramvec_p);
151 printk(KERN_DEBUG "%p ",*ramvec_p);
152 ramvec_p++;
153 }
154 printk(KERN_DEBUG "\n");
155#endif
156}
157#else
158#define setup_vector() do { } while(0)
159#endif
160
161void __init init_IRQ(void)
162{
163 int c;
164
165 setup_vector();
166
167 for (c = 0; c < NR_IRQS; c++) {
168 irq_desc[c].status = IRQ_DISABLED;
169 irq_desc[c].action = NULL;
170 irq_desc[c].depth = 1;
171 irq_desc[c].chip = &h8300irq_chip;
172 }
173}
174
175asmlinkage void do_IRQ(int irq)
176{
177 irq_enter();
178 __do_IRQ(irq);
179 irq_exit();
180}
181
182#if defined(CONFIG_PROC_FS)
183int show_interrupts(struct seq_file *p, void *v)
184{
185 int i = *(loff_t *) v, j;
186 struct irqaction * action;
187 unsigned long flags;
188
189 if (i == 0)
190 seq_puts(p, " CPU0");
191
192 if (i < NR_IRQS) {
193 spin_lock_irqsave(&irq_desc[i].lock, flags);
194 action = irq_desc[i].action;
195 if (!action)
196 goto unlock;
197 seq_printf(p, "%3d: ",i);
198 seq_printf(p, "%10u ", kstat_cpu(j).irqs[i]);
199 seq_printf(p, " %14s", irq_desc[i].chip->name);
200 seq_printf(p, "-%-8s", irq_desc[i].name);
201 seq_printf(p, " %s", action->name);
202
203 for (action=action->next; action; action = action->next)
204 seq_printf(p, ", %s", action->name);
205 seq_putc(p, '\n');
206unlock:
207 spin_unlock_irqrestore(&irq_desc[i].lock, flags);
208 }
209 return 0;
210}
211#endif
diff --git a/arch/h8300/kernel/setup.c b/arch/h8300/kernel/setup.c
index 313cd8081044..b2e86d0255e6 100644
--- a/arch/h8300/kernel/setup.c
+++ b/arch/h8300/kernel/setup.c
@@ -33,10 +33,7 @@
33 33
34#include <asm/setup.h> 34#include <asm/setup.h>
35#include <asm/irq.h> 35#include <asm/irq.h>
36
37#ifdef CONFIG_BLK_DEV_INITRD
38#include <asm/pgtable.h> 36#include <asm/pgtable.h>
39#endif
40 37
41#if defined(__H8300H__) 38#if defined(__H8300H__)
42#define CPU "H8/300H" 39#define CPU "H8/300H"
diff --git a/arch/h8300/kernel/time.c b/arch/h8300/kernel/time.c
index d1ef615ba895..330638220a2e 100644
--- a/arch/h8300/kernel/time.c
+++ b/arch/h8300/kernel/time.c
@@ -44,7 +44,7 @@ static void timer_interrupt(int irq, void *dummy, struct pt_regs * regs)
44#ifndef CONFIG_SMP 44#ifndef CONFIG_SMP
45 update_process_times(user_mode(regs)); 45 update_process_times(user_mode(regs));
46#endif 46#endif
47 profile_tick(CPU_PROFILING, regs); 47 profile_tick(CPU_PROFILING);
48} 48}
49 49
50void time_init(void) 50void time_init(void)
@@ -66,55 +66,3 @@ void time_init(void)
66 66
67 platform_timer_setup(timer_interrupt); 67 platform_timer_setup(timer_interrupt);
68} 68}
69
70/*
71 * This version of gettimeofday has near microsecond resolution.
72 */
73void do_gettimeofday(struct timeval *tv)
74{
75 unsigned long flags;
76 unsigned long usec, sec;
77
78 read_lock_irqsave(&xtime_lock, flags);
79 usec = 0;
80 sec = xtime.tv_sec;
81 usec += (xtime.tv_nsec / 1000);
82 read_unlock_irqrestore(&xtime_lock, flags);
83
84 while (usec >= 1000000) {
85 usec -= 1000000;
86 sec++;
87 }
88
89 tv->tv_sec = sec;
90 tv->tv_usec = usec;
91}
92
93EXPORT_SYMBOL(do_gettimeofday);
94
95int do_settimeofday(struct timespec *tv)
96{
97 if ((unsigned long)tv->tv_nsec >= NSEC_PER_SEC)
98 return -EINVAL;
99
100 write_lock_irq(&xtime_lock);
101 /* This is revolting. We need to set the xtime.tv_usec
102 * correctly. However, the value in this location is
103 * is value at the last tick.
104 * Discover what correction gettimeofday
105 * would have done, and then undo it!
106 */
107 while (tv->tv_nsec < 0) {
108 tv->tv_nsec += NSEC_PER_SEC;
109 tv->tv_sec--;
110 }
111
112 xtime.tv_sec = tv->tv_sec;
113 xtime.tv_nsec = tv->tv_nsec;
114 ntp_clear();
115 write_sequnlock_irq(&xtime_lock);
116 clock_was_set();
117 return 0;
118}
119
120EXPORT_SYMBOL(do_settimeofday);
diff --git a/arch/h8300/mm/kmap.c b/arch/h8300/mm/kmap.c
index 26ab17286a53..5c7af09ae8d1 100644
--- a/arch/h8300/mm/kmap.c
+++ b/arch/h8300/mm/kmap.c
@@ -24,12 +24,14 @@
24 24
25#undef DEBUG 25#undef DEBUG
26 26
27#define VIRT_OFFSET (0x01000000)
28
27/* 29/*
28 * Map some physical address range into the kernel address space. 30 * Map some physical address range into the kernel address space.
29 */ 31 */
30void *__ioremap(unsigned long physaddr, unsigned long size, int cacheflag) 32void *__ioremap(unsigned long physaddr, unsigned long size, int cacheflag)
31{ 33{
32 return (void *)physaddr; 34 return (void *)(physaddr + VIRT_OFFSET);
33} 35}
34 36
35/* 37/*
diff --git a/arch/h8300/platform/h8300h/Makefile b/arch/h8300/platform/h8300h/Makefile
index 5d42c772f75a..b24ea08aa0a7 100644
--- a/arch/h8300/platform/h8300h/Makefile
+++ b/arch/h8300/platform/h8300h/Makefile
@@ -4,4 +4,4 @@
4# Reuse any files we can from the H8/300H 4# Reuse any files we can from the H8/300H
5# 5#
6 6
7obj-y := entry.o ints_h8300h.o ptrace_h8300h.o 7obj-y := entry.o irq_pin.o ptrace_h8300h.o
diff --git a/arch/h8300/platform/h8300h/entry.S b/arch/h8300/platform/h8300h/entry.S
index d2dea2432fb2..f86ac3b5d4de 100644
--- a/arch/h8300/platform/h8300h/entry.S
+++ b/arch/h8300/platform/h8300h/entry.S
@@ -30,12 +30,12 @@
30 mov.l er0,@-sp 30 mov.l er0,@-sp
31 31
32 stc ccr,r0l /* check kernel mode */ 32 stc ccr,r0l /* check kernel mode */
33 orc #0x10,ccr
34 btst #4,r0l 33 btst #4,r0l
35 bne 5f 34 bne 5f
36 35
37 mov.l sp,@SYMBOL_NAME(sw_usp) /* user mode */ 36 mov.l sp,@SYMBOL_NAME(sw_usp) /* user mode */
38 mov.l @sp,er0 37 mov.l @sp,er0
38 orc #0x10,ccr
39 mov.l @SYMBOL_NAME(sw_ksp),sp 39 mov.l @SYMBOL_NAME(sw_ksp),sp
40 sub.l #(LRET-LORIG),sp /* allocate LORIG - LRET */ 40 sub.l #(LRET-LORIG),sp /* allocate LORIG - LRET */
41 mov.l er0,@-sp 41 mov.l er0,@-sp
@@ -165,7 +165,7 @@ SYMBOL_NAME_LABEL(interrupt_entry)
165 dec.l #1,er0 165 dec.l #1,er0
166 mov.l sp,er1 166 mov.l sp,er1
167 subs #4,er1 /* adjust ret_pc */ 167 subs #4,er1 /* adjust ret_pc */
168 jsr @SYMBOL_NAME(process_int) 168 jsr @SYMBOL_NAME(do_IRQ)
169 mov.l @SYMBOL_NAME(irq_stat)+CPUSTAT_SOFTIRQ_PENDING,er0 169 mov.l @SYMBOL_NAME(irq_stat)+CPUSTAT_SOFTIRQ_PENDING,er0
170 beq 1f 170 beq 1f
171 jsr @SYMBOL_NAME(do_softirq) 171 jsr @SYMBOL_NAME(do_softirq)
diff --git a/arch/h8300/platform/h8300h/generic/Makefile b/arch/h8300/platform/h8300h/generic/Makefile
index b6ea7688a616..32b964a9010e 100644
--- a/arch/h8300/platform/h8300h/generic/Makefile
+++ b/arch/h8300/platform/h8300h/generic/Makefile
@@ -2,5 +2,5 @@
2# Makefile for the linux kernel. 2# Makefile for the linux kernel.
3# 3#
4 4
5extra-y := crt0_$(MODEL).o
5obj-y := timer.o 6obj-y := timer.o
6extra-y = crt0_$(MODEL).o
diff --git a/arch/h8300/platform/h8300h/ints_h8300h.c b/arch/h8300/platform/h8300h/ints_h8300h.c
deleted file mode 100644
index f1777119b871..000000000000
--- a/arch/h8300/platform/h8300h/ints_h8300h.c
+++ /dev/null
@@ -1,85 +0,0 @@
1/*
2 * linux/arch/h8300/platform/h8300h/ints_h8300h.c
3 * Interrupt handling CPU variants
4 *
5 * Yoshinori Sato <ysato@users.sourceforge.jp>
6 *
7 */
8
9#include <linux/init.h>
10#include <linux/errno.h>
11
12#include <asm/ptrace.h>
13#include <asm/traps.h>
14#include <asm/irq.h>
15#include <asm/io.h>
16#include <asm/gpio.h>
17#include <asm/regs306x.h>
18
19/* saved vector list */
20const int __initdata h8300_saved_vectors[]={
21#if defined(CONFIG_GDB_DEBUG)
22 TRAP3_VEC,
23#endif
24 -1
25};
26
27/* trap entry table */
28const unsigned long __initdata h8300_trap_table[NR_TRAPS]={
29 0,0,0,0,0,0,0,0,
30 (unsigned long)system_call, /* TRAPA #0 */
31 0,0,
32 (unsigned long)trace_break, /* TRAPA #3 */
33};
34
35int h8300_enable_irq_pin(unsigned int irq)
36{
37 int bitmask;
38 if (irq < EXT_IRQ0 || irq > EXT_IRQ5)
39 return 0;
40
41 /* initialize IRQ pin */
42 bitmask = 1 << (irq - EXT_IRQ0);
43 switch(irq) {
44 case EXT_IRQ0:
45 case EXT_IRQ1:
46 case EXT_IRQ2:
47 case EXT_IRQ3:
48 if (H8300_GPIO_RESERVE(H8300_GPIO_P8, bitmask) == 0)
49 return -EBUSY;
50 H8300_GPIO_DDR(H8300_GPIO_P8, bitmask, H8300_GPIO_INPUT);
51 break;
52 case EXT_IRQ4:
53 case EXT_IRQ5:
54 if (H8300_GPIO_RESERVE(H8300_GPIO_P9, bitmask) == 0)
55 return -EBUSY;
56 H8300_GPIO_DDR(H8300_GPIO_P9, bitmask, H8300_GPIO_INPUT);
57 break;
58 }
59
60 return 0;
61}
62
63void h8300_disable_irq_pin(unsigned int irq)
64{
65 int bitmask;
66 if (irq < EXT_IRQ0 || irq > EXT_IRQ5)
67 return;
68
69 /* disable interrupt & release IRQ pin */
70 bitmask = 1 << (irq - EXT_IRQ0);
71 switch(irq) {
72 case EXT_IRQ0:
73 case EXT_IRQ1:
74 case EXT_IRQ2:
75 case EXT_IRQ3:
76 *(volatile unsigned char *)IER &= ~bitmask;
77 H8300_GPIO_FREE(H8300_GPIO_P8, bitmask);
78 break ;
79 case EXT_IRQ4:
80 case EXT_IRQ5:
81 *(volatile unsigned char *)IER &= ~bitmask;
82 H8300_GPIO_FREE(H8300_GPIO_P9, bitmask);
83 break;
84 }
85}
diff --git a/arch/h8300/platform/h8s/entry.S b/arch/h8300/platform/h8s/entry.S
index aeb2e9faa9b2..f3d6b8e8f959 100644
--- a/arch/h8300/platform/h8s/entry.S
+++ b/arch/h8300/platform/h8s/entry.S
@@ -31,12 +31,13 @@
31 mov.l er0,@-sp 31 mov.l er0,@-sp
32 32
33 stc ccr,r0l /* check kernel mode */ 33 stc ccr,r0l /* check kernel mode */
34 orc #0x10,ccr
35 btst #4,r0l 34 btst #4,r0l
36 bne 5f 35 bne 5f
37 36
38 mov.l sp,@SYMBOL_NAME(sw_usp) /* user mode */ 37 /* user mode */
39 mov.l @sp,er0 38 mov.l sp,@SYMBOL_NAME(sw_usp)
39 mov.l @sp,er0 /* restore saved er0 */
40 orc #0x10,ccr /* switch kernel stack */
40 mov.l @SYMBOL_NAME(sw_ksp),sp 41 mov.l @SYMBOL_NAME(sw_ksp),sp
41 sub.l #(LRET-LORIG),sp /* allocate LORIG - LRET */ 42 sub.l #(LRET-LORIG),sp /* allocate LORIG - LRET */
42 stm.l er0-er3,@-sp 43 stm.l er0-er3,@-sp
@@ -55,8 +56,9 @@
55 mov.l er0,@(LER0-LER3:16,sp) /* copy ER0 */ 56 mov.l er0,@(LER0-LER3:16,sp) /* copy ER0 */
56 bra 6f 57 bra 6f
575: 585:
58 mov.l @sp,er0 /* kernel mode */ 59 /* kernel mode */
59 subs #2,sp /* dummy ccr */ 60 mov.l @sp,er0 /* restore saved er0 */
61 subs #2,sp /* set dummy ccr */
60 stm.l er0-er3,@-sp 62 stm.l er0-er3,@-sp
61 mov.w @(LRET-LER3:16,sp),r1 /* copy old ccr */ 63 mov.w @(LRET-LER3:16,sp),r1 /* copy old ccr */
62 mov.b r1h,r1l 64 mov.b r1h,r1l
@@ -94,6 +96,7 @@
94 mov.l @sp+,er1 96 mov.l @sp+,er1
95 add.l #(LRET-LER1),sp /* remove LORIG - LRET */ 97 add.l #(LRET-LER1),sp /* remove LORIG - LRET */
96 mov.l sp,@SYMBOL_NAME(sw_ksp) 98 mov.l sp,@SYMBOL_NAME(sw_ksp)
99 andc #0xef,ccr /* switch to user mode */
97 mov.l er0,sp 100 mov.l er0,sp
98 bra 8f 101 bra 8f
997: 1027:
@@ -173,9 +176,6 @@ SYMBOL_NAME_LABEL(interrupt_entry)
173SYMBOL_NAME_LABEL(system_call) 176SYMBOL_NAME_LABEL(system_call)
174 subs #4,sp /* dummy LVEC */ 177 subs #4,sp /* dummy LVEC */
175 SAVE_ALL 178 SAVE_ALL
176 mov.w @(LCCR:16,sp),r1
177 bset #4,r1l
178 ldc r1l,ccr /* restore ccr */
179 mov.l er0,er4 179 mov.l er0,er4
180 mov.l #-ENOSYS,er0 180 mov.l #-ENOSYS,er0
181 mov.l er0,@(LER0:16,sp) 181 mov.l er0,@(LER0:16,sp)
@@ -198,6 +198,7 @@ SYMBOL_NAME_LABEL(system_call)
198 mov.l @(LER1:16,sp),er0 198 mov.l @(LER1:16,sp),er0
199 mov.l @(LER2:16,sp),er1 199 mov.l @(LER2:16,sp),er1
200 mov.l @(LER3:16,sp),er2 200 mov.l @(LER3:16,sp),er2
201 andc #0x7f,ccr
201 jsr @er4 202 jsr @er4
202 mov.l er0,@(LER0:16,sp) /* save the return value */ 203 mov.l er0,@(LER0:16,sp) /* save the return value */
203#if defined(CONFIG_SYSCALL_PRINT) 204#if defined(CONFIG_SYSCALL_PRINT)