diff options
Diffstat (limited to 'arch/m32r')
-rw-r--r-- | arch/m32r/Kconfig | 3 | ||||
-rw-r--r-- | arch/m32r/boot/compressed/Makefile | 18 | ||||
-rw-r--r-- | arch/m32r/boot/compressed/misc.c | 143 | ||||
-rw-r--r-- | arch/m32r/kernel/smp.c | 2 | ||||
-rw-r--r-- | arch/m32r/kernel/time.c | 6 | ||||
-rw-r--r-- | arch/m32r/kernel/vmlinux.lds.S | 2 |
6 files changed, 49 insertions, 125 deletions
diff --git a/arch/m32r/Kconfig b/arch/m32r/Kconfig index c41234f1b825..3a9319f93e89 100644 --- a/arch/m32r/Kconfig +++ b/arch/m32r/Kconfig | |||
@@ -11,6 +11,9 @@ config M32R | |||
11 | select HAVE_IDE | 11 | select HAVE_IDE |
12 | select HAVE_OPROFILE | 12 | select HAVE_OPROFILE |
13 | select INIT_ALL_POSSIBLE | 13 | select INIT_ALL_POSSIBLE |
14 | select HAVE_KERNEL_GZIP | ||
15 | select HAVE_KERNEL_BZIP2 | ||
16 | select HAVE_KERNEL_LZMA | ||
14 | 17 | ||
15 | config SBUS | 18 | config SBUS |
16 | bool | 19 | bool |
diff --git a/arch/m32r/boot/compressed/Makefile b/arch/m32r/boot/compressed/Makefile index 560484ae35ec..177716b1d613 100644 --- a/arch/m32r/boot/compressed/Makefile +++ b/arch/m32r/boot/compressed/Makefile | |||
@@ -1,11 +1,11 @@ | |||
1 | # | 1 | # |
2 | # linux/arch/sh/boot/compressed/Makefile | 2 | # linux/arch/m32r/boot/compressed/Makefile |
3 | # | 3 | # |
4 | # create a compressed vmlinux image from the original vmlinux | 4 | # create a compressed vmlinux image from the original vmlinux |
5 | # | 5 | # |
6 | 6 | ||
7 | targets := vmlinux vmlinux.bin vmlinux.bin.gz head.o misc.o \ | 7 | targets := vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 \ |
8 | piggy.o vmlinux.lds | 8 | vmlinux.bin.lzma head.o misc.o piggy.o vmlinux.lds |
9 | 9 | ||
10 | OBJECTS = $(obj)/head.o $(obj)/misc.o | 10 | OBJECTS = $(obj)/head.o $(obj)/misc.o |
11 | 11 | ||
@@ -27,6 +27,12 @@ $(obj)/vmlinux.bin: vmlinux FORCE | |||
27 | $(obj)/vmlinux.bin.gz: $(obj)/vmlinux.bin FORCE | 27 | $(obj)/vmlinux.bin.gz: $(obj)/vmlinux.bin FORCE |
28 | $(call if_changed,gzip) | 28 | $(call if_changed,gzip) |
29 | 29 | ||
30 | $(obj)/vmlinux.bin.bz2: $(obj)/vmlinux.bin FORCE | ||
31 | $(call if_changed,bzip2) | ||
32 | |||
33 | $(obj)/vmlinux.bin.lzma: $(obj)/vmlinux.bin FORCE | ||
34 | $(call if_changed,lzma) | ||
35 | |||
30 | CFLAGS_misc.o += -fpic | 36 | CFLAGS_misc.o += -fpic |
31 | 37 | ||
32 | ifdef CONFIG_MMU | 38 | ifdef CONFIG_MMU |
@@ -37,5 +43,9 @@ endif | |||
37 | 43 | ||
38 | OBJCOPYFLAGS += -R .empty_zero_page | 44 | OBJCOPYFLAGS += -R .empty_zero_page |
39 | 45 | ||
40 | $(obj)/piggy.o: $(obj)/vmlinux.scr $(obj)/vmlinux.bin.gz FORCE | 46 | suffix_$(CONFIG_KERNEL_GZIP) = gz |
47 | suffix_$(CONFIG_KERNEL_BZIP2) = bz2 | ||
48 | suffix_$(CONFIG_KERNEL_LZMA) = lzma | ||
49 | |||
50 | $(obj)/piggy.o: $(obj)/vmlinux.scr $(obj)/vmlinux.bin.$(suffix-y) FORCE | ||
41 | $(call if_changed,ld) | 51 | $(call if_changed,ld) |
diff --git a/arch/m32r/boot/compressed/misc.c b/arch/m32r/boot/compressed/misc.c index d394292498c0..370d60881977 100644 --- a/arch/m32r/boot/compressed/misc.c +++ b/arch/m32r/boot/compressed/misc.c | |||
@@ -9,140 +9,49 @@ | |||
9 | * Adapted for SH by Stuart Menefy, Aug 1999 | 9 | * Adapted for SH by Stuart Menefy, Aug 1999 |
10 | * | 10 | * |
11 | * 2003-02-12: Support M32R by Takeo Takahashi | 11 | * 2003-02-12: Support M32R by Takeo Takahashi |
12 | * This is based on arch/sh/boot/compressed/misc.c. | ||
13 | */ | 12 | */ |
14 | 13 | ||
15 | #include <linux/string.h> | ||
16 | |||
17 | /* | 14 | /* |
18 | * gzip declarations | 15 | * gzip declarations |
19 | */ | 16 | */ |
20 | |||
21 | #define OF(args) args | ||
22 | #define STATIC static | 17 | #define STATIC static |
23 | 18 | ||
24 | #undef memset | 19 | #undef memset |
25 | #undef memcpy | 20 | #undef memcpy |
26 | #define memzero(s, n) memset ((s), 0, (n)) | 21 | #define memzero(s, n) memset ((s), 0, (n)) |
27 | 22 | ||
28 | typedef unsigned char uch; | ||
29 | typedef unsigned short ush; | ||
30 | typedef unsigned long ulg; | ||
31 | |||
32 | #define WSIZE 0x8000 /* Window size must be at least 32k, */ | ||
33 | /* and a power of two */ | ||
34 | |||
35 | static uch *inbuf; /* input buffer */ | ||
36 | static uch window[WSIZE]; /* Sliding window buffer */ | ||
37 | |||
38 | static unsigned insize = 0; /* valid bytes in inbuf */ | ||
39 | static unsigned inptr = 0; /* index of next byte to be processed in inbuf */ | ||
40 | static unsigned outcnt = 0; /* bytes in output buffer */ | ||
41 | |||
42 | /* gzip flag byte */ | ||
43 | #define ASCII_FLAG 0x01 /* bit 0 set: file probably ASCII text */ | ||
44 | #define CONTINUATION 0x02 /* bit 1 set: continuation of multi-part gzip file */ | ||
45 | #define EXTRA_FIELD 0x04 /* bit 2 set: extra field present */ | ||
46 | #define ORIG_NAME 0x08 /* bit 3 set: original file name present */ | ||
47 | #define COMMENT 0x10 /* bit 4 set: file comment present */ | ||
48 | #define ENCRYPTED 0x20 /* bit 5 set: file is encrypted */ | ||
49 | #define RESERVED 0xC0 /* bit 6,7: reserved */ | ||
50 | |||
51 | #define get_byte() (inptr < insize ? inbuf[inptr++] : fill_inbuf()) | ||
52 | |||
53 | /* Diagnostic functions */ | ||
54 | #ifdef DEBUG | ||
55 | # define Assert(cond,msg) {if(!(cond)) error(msg);} | ||
56 | # define Trace(x) fprintf x | ||
57 | # define Tracev(x) {if (verbose) fprintf x ;} | ||
58 | # define Tracevv(x) {if (verbose>1) fprintf x ;} | ||
59 | # define Tracec(c,x) {if (verbose && (c)) fprintf x ;} | ||
60 | # define Tracecv(c,x) {if (verbose>1 && (c)) fprintf x ;} | ||
61 | #else | ||
62 | # define Assert(cond,msg) | ||
63 | # define Trace(x) | ||
64 | # define Tracev(x) | ||
65 | # define Tracevv(x) | ||
66 | # define Tracec(c,x) | ||
67 | # define Tracecv(c,x) | ||
68 | #endif | ||
69 | |||
70 | static int fill_inbuf(void); | ||
71 | static void flush_window(void); | ||
72 | static void error(char *m); | 23 | static void error(char *m); |
73 | 24 | ||
74 | static unsigned char *input_data; | ||
75 | static int input_len; | ||
76 | |||
77 | static long bytes_out = 0; | ||
78 | static uch *output_data; | ||
79 | static unsigned long output_ptr = 0; | ||
80 | |||
81 | #include "m32r_sio.c" | 25 | #include "m32r_sio.c" |
82 | 26 | ||
83 | static unsigned long free_mem_ptr; | 27 | static unsigned long free_mem_ptr; |
84 | static unsigned long free_mem_end_ptr; | 28 | static unsigned long free_mem_end_ptr; |
85 | 29 | ||
86 | #define HEAP_SIZE 0x10000 | 30 | #ifdef CONFIG_KERNEL_BZIP2 |
87 | 31 | static void *memset(void *s, int c, size_t n) | |
88 | #include "../../../../lib/inflate.c" | ||
89 | |||
90 | void* memset(void* s, int c, size_t n) | ||
91 | { | 32 | { |
92 | int i; | 33 | char *ss = s; |
93 | char *ss = (char*)s; | ||
94 | 34 | ||
95 | for (i=0;i<n;i++) ss[i] = c; | 35 | while (n--) |
36 | *ss++ = c; | ||
96 | return s; | 37 | return s; |
97 | } | 38 | } |
39 | #endif | ||
98 | 40 | ||
99 | void* memcpy(void* __dest, __const void* __src, | 41 | #ifdef CONFIG_KERNEL_GZIP |
100 | size_t __n) | 42 | #define BOOT_HEAP_SIZE 0x10000 |
101 | { | 43 | #include "../../../../lib/decompress_inflate.c" |
102 | int i; | 44 | #endif |
103 | char *d = (char *)__dest, *s = (char *)__src; | ||
104 | |||
105 | for (i=0;i<__n;i++) d[i] = s[i]; | ||
106 | return __dest; | ||
107 | } | ||
108 | |||
109 | /* =========================================================================== | ||
110 | * Fill the input buffer. This is called only when the buffer is empty | ||
111 | * and at least one byte is really needed. | ||
112 | */ | ||
113 | static int fill_inbuf(void) | ||
114 | { | ||
115 | if (insize != 0) { | ||
116 | error("ran out of input data"); | ||
117 | } | ||
118 | |||
119 | inbuf = input_data; | ||
120 | insize = input_len; | ||
121 | inptr = 1; | ||
122 | return inbuf[0]; | ||
123 | } | ||
124 | 45 | ||
125 | /* =========================================================================== | 46 | #ifdef CONFIG_KERNEL_BZIP2 |
126 | * Write the output window window[0..outcnt-1] and update crc and bytes_out. | 47 | #define BOOT_HEAP_SIZE 0x400000 |
127 | * (Used for the decompressed data only.) | 48 | #include "../../../../lib/decompress_bunzip2.c" |
128 | */ | 49 | #endif |
129 | static void flush_window(void) | ||
130 | { | ||
131 | ulg c = crc; /* temporary variable */ | ||
132 | unsigned n; | ||
133 | uch *in, *out, ch; | ||
134 | 50 | ||
135 | in = window; | 51 | #ifdef CONFIG_KERNEL_LZMA |
136 | out = &output_data[output_ptr]; | 52 | #define BOOT_HEAP_SIZE 0x10000 |
137 | for (n = 0; n < outcnt; n++) { | 53 | #include "../../../../lib/decompress_unlzma.c" |
138 | ch = *out++ = *in++; | 54 | #endif |
139 | c = crc_32_tab[((int)c ^ ch) & 0xff] ^ (c >> 8); | ||
140 | } | ||
141 | crc = c; | ||
142 | bytes_out += (ulg)outcnt; | ||
143 | output_ptr += (ulg)outcnt; | ||
144 | outcnt = 0; | ||
145 | } | ||
146 | 55 | ||
147 | static void error(char *x) | 56 | static void error(char *x) |
148 | { | 57 | { |
@@ -153,20 +62,20 @@ static void error(char *x) | |||
153 | while(1); /* Halt */ | 62 | while(1); /* Halt */ |
154 | } | 63 | } |
155 | 64 | ||
156 | /* return decompressed size */ | ||
157 | void | 65 | void |
158 | decompress_kernel(int mmu_on, unsigned char *zimage_data, | 66 | decompress_kernel(int mmu_on, unsigned char *zimage_data, |
159 | unsigned int zimage_len, unsigned long heap) | 67 | unsigned int zimage_len, unsigned long heap) |
160 | { | 68 | { |
69 | unsigned char *input_data = zimage_data; | ||
70 | int input_len = zimage_len; | ||
71 | unsigned char *output_data; | ||
72 | |||
161 | output_data = (unsigned char *)CONFIG_MEMORY_START + 0x2000 | 73 | output_data = (unsigned char *)CONFIG_MEMORY_START + 0x2000 |
162 | + (mmu_on ? 0x80000000 : 0); | 74 | + (mmu_on ? 0x80000000 : 0); |
163 | free_mem_ptr = heap; | 75 | free_mem_ptr = heap; |
164 | free_mem_end_ptr = free_mem_ptr + HEAP_SIZE; | 76 | free_mem_end_ptr = free_mem_ptr + BOOT_HEAP_SIZE; |
165 | input_data = zimage_data; | ||
166 | input_len = zimage_len; | ||
167 | 77 | ||
168 | makecrc(); | 78 | puts("\nDecompressing Linux... "); |
169 | puts("Uncompressing Linux... "); | 79 | decompress(input_data, input_len, NULL, NULL, output_data, NULL, error); |
170 | gunzip(); | 80 | puts("done.\nBooting the kernel.\n"); |
171 | puts("Ok, booting the kernel.\n"); | ||
172 | } | 81 | } |
diff --git a/arch/m32r/kernel/smp.c b/arch/m32r/kernel/smp.c index 8a88f1f0a3e2..31cef20b2996 100644 --- a/arch/m32r/kernel/smp.c +++ b/arch/m32r/kernel/smp.c | |||
@@ -806,7 +806,7 @@ unsigned long send_IPI_mask_phys(cpumask_t physid_mask, int ipi_num, | |||
806 | 806 | ||
807 | if (mask & ~physids_coerce(phys_cpu_present_map)) | 807 | if (mask & ~physids_coerce(phys_cpu_present_map)) |
808 | BUG(); | 808 | BUG(); |
809 | if (ipi_num >= NR_IPIS) | 809 | if (ipi_num >= NR_IPIS || ipi_num < 0) |
810 | BUG(); | 810 | BUG(); |
811 | 811 | ||
812 | mask <<= IPI_SHIFT; | 812 | mask <<= IPI_SHIFT; |
diff --git a/arch/m32r/kernel/time.c b/arch/m32r/kernel/time.c index e7fee0f198d5..9cedcef11575 100644 --- a/arch/m32r/kernel/time.c +++ b/arch/m32r/kernel/time.c | |||
@@ -75,7 +75,7 @@ u32 arch_gettimeoffset(void) | |||
75 | count = 0; | 75 | count = 0; |
76 | 76 | ||
77 | count = (latch - count) * TICK_SIZE; | 77 | count = (latch - count) * TICK_SIZE; |
78 | elapsed_time = (count + latch / 2) / latch; | 78 | elapsed_time = DIV_ROUND_CLOSEST(count, latch); |
79 | /* NOTE: LATCH is equal to the "interval" value (= reload count). */ | 79 | /* NOTE: LATCH is equal to the "interval" value (= reload count). */ |
80 | 80 | ||
81 | #else /* CONFIG_SMP */ | 81 | #else /* CONFIG_SMP */ |
@@ -93,7 +93,7 @@ u32 arch_gettimeoffset(void) | |||
93 | p_count = count; | 93 | p_count = count; |
94 | 94 | ||
95 | count = (latch - count) * TICK_SIZE; | 95 | count = (latch - count) * TICK_SIZE; |
96 | elapsed_time = (count + latch / 2) / latch; | 96 | elapsed_time = DIV_ROUND_CLOSEST(count, latch); |
97 | /* NOTE: LATCH is equal to the "interval" value (= reload count). */ | 97 | /* NOTE: LATCH is equal to the "interval" value (= reload count). */ |
98 | #endif /* CONFIG_SMP */ | 98 | #endif /* CONFIG_SMP */ |
99 | #elif defined(CONFIG_CHIP_M32310) | 99 | #elif defined(CONFIG_CHIP_M32310) |
@@ -211,7 +211,7 @@ void __init time_init(void) | |||
211 | 211 | ||
212 | bus_clock = boot_cpu_data.bus_clock; | 212 | bus_clock = boot_cpu_data.bus_clock; |
213 | divide = boot_cpu_data.timer_divide; | 213 | divide = boot_cpu_data.timer_divide; |
214 | latch = (bus_clock/divide + HZ / 2) / HZ; | 214 | latch = DIV_ROUND_CLOSEST(bus_clock/divide, HZ); |
215 | 215 | ||
216 | printk("Timer start : latch = %ld\n", latch); | 216 | printk("Timer start : latch = %ld\n", latch); |
217 | 217 | ||
diff --git a/arch/m32r/kernel/vmlinux.lds.S b/arch/m32r/kernel/vmlinux.lds.S index 8ceb6181d805..7da94eaa082b 100644 --- a/arch/m32r/kernel/vmlinux.lds.S +++ b/arch/m32r/kernel/vmlinux.lds.S | |||
@@ -42,6 +42,8 @@ SECTIONS | |||
42 | _etext = .; /* End of text section */ | 42 | _etext = .; /* End of text section */ |
43 | 43 | ||
44 | EXCEPTION_TABLE(16) | 44 | EXCEPTION_TABLE(16) |
45 | NOTES | ||
46 | |||
45 | RODATA | 47 | RODATA |
46 | RW_DATA_SECTION(32, PAGE_SIZE, THREAD_SIZE) | 48 | RW_DATA_SECTION(32, PAGE_SIZE, THREAD_SIZE) |
47 | _edata = .; /* End of data section */ | 49 | _edata = .; /* End of data section */ |