diff options
author | Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> | 2006-06-26 07:57:53 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-06-26 13:48:18 -0400 |
commit | b79c4df714ff190f7149d3d5a86278bdc25a90ec (patch) | |
tree | e7fae9732a1d36a6e8399cdbe528e7fb1834f043 /arch | |
parent | 83f4fcce7fdd213bd570b899862c3838871f8cf7 (diff) |
[PATCH] i386/x86-64: Consolidate arch/{i386,x86_64}/boot/compressed/misc.c
Clean up arch/{i386,x86_64}/boot/compressed/misc.c a bit to reduce their
differences. Should have zero effect on code generation.
Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Signed-off-by: Andi Kleen <ak@suse.de>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/i386/boot/compressed/misc.c | 32 | ||||
-rw-r--r-- | arch/x86_64/boot/compressed/misc.c | 46 |
2 files changed, 35 insertions, 43 deletions
diff --git a/arch/i386/boot/compressed/misc.c b/arch/i386/boot/compressed/misc.c index f19f3a7492a5..b2ccd543410d 100644 --- a/arch/i386/boot/compressed/misc.c +++ b/arch/i386/boot/compressed/misc.c | |||
@@ -24,14 +24,6 @@ | |||
24 | 24 | ||
25 | #undef memset | 25 | #undef memset |
26 | #undef memcpy | 26 | #undef memcpy |
27 | |||
28 | /* | ||
29 | * Why do we do this? Don't ask me.. | ||
30 | * | ||
31 | * Incomprehensible are the ways of bootloaders. | ||
32 | */ | ||
33 | static void* memset(void *, int, size_t); | ||
34 | static void* memcpy(void *, __const void *, size_t); | ||
35 | #define memzero(s, n) memset ((s), 0, (n)) | 27 | #define memzero(s, n) memset ((s), 0, (n)) |
36 | 28 | ||
37 | typedef unsigned char uch; | 29 | typedef unsigned char uch; |
@@ -93,7 +85,7 @@ static unsigned char *real_mode; /* Pointer to real-mode data */ | |||
93 | #endif | 85 | #endif |
94 | #define RM_SCREEN_INFO (*(struct screen_info *)(real_mode+0)) | 86 | #define RM_SCREEN_INFO (*(struct screen_info *)(real_mode+0)) |
95 | 87 | ||
96 | extern char input_data[]; | 88 | extern unsigned char input_data[]; |
97 | extern int input_len; | 89 | extern int input_len; |
98 | 90 | ||
99 | static long bytes_out = 0; | 91 | static long bytes_out = 0; |
@@ -103,6 +95,9 @@ static unsigned long output_ptr = 0; | |||
103 | static void *malloc(int size); | 95 | static void *malloc(int size); |
104 | static void free(void *where); | 96 | static void free(void *where); |
105 | 97 | ||
98 | static void *memset(void *s, int c, unsigned n); | ||
99 | static void *memcpy(void *dest, const void *src, unsigned n); | ||
100 | |||
106 | static void putstr(const char *); | 101 | static void putstr(const char *); |
107 | 102 | ||
108 | extern int end; | 103 | extern int end; |
@@ -205,7 +200,7 @@ static void putstr(const char *s) | |||
205 | outb_p(0xff & (pos >> 1), vidport+1); | 200 | outb_p(0xff & (pos >> 1), vidport+1); |
206 | } | 201 | } |
207 | 202 | ||
208 | static void* memset(void* s, int c, size_t n) | 203 | static void* memset(void* s, int c, unsigned n) |
209 | { | 204 | { |
210 | int i; | 205 | int i; |
211 | char *ss = (char*)s; | 206 | char *ss = (char*)s; |
@@ -214,14 +209,13 @@ static void* memset(void* s, int c, size_t n) | |||
214 | return s; | 209 | return s; |
215 | } | 210 | } |
216 | 211 | ||
217 | static void* memcpy(void* __dest, __const void* __src, | 212 | static void* memcpy(void* dest, const void* src, unsigned n) |
218 | size_t __n) | ||
219 | { | 213 | { |
220 | int i; | 214 | int i; |
221 | char *d = (char *)__dest, *s = (char *)__src; | 215 | char *d = (char *)dest, *s = (char *)src; |
222 | 216 | ||
223 | for (i=0;i<__n;i++) d[i] = s[i]; | 217 | for (i=0;i<n;i++) d[i] = s[i]; |
224 | return __dest; | 218 | return dest; |
225 | } | 219 | } |
226 | 220 | ||
227 | /* =========================================================================== | 221 | /* =========================================================================== |
@@ -309,7 +303,7 @@ static void setup_normal_output_buffer(void) | |||
309 | #else | 303 | #else |
310 | if ((RM_ALT_MEM_K > RM_EXT_MEM_K ? RM_ALT_MEM_K : RM_EXT_MEM_K) < 1024) error("Less than 2MB of memory"); | 304 | if ((RM_ALT_MEM_K > RM_EXT_MEM_K ? RM_ALT_MEM_K : RM_EXT_MEM_K) < 1024) error("Less than 2MB of memory"); |
311 | #endif | 305 | #endif |
312 | output_data = (char *)__PHYSICAL_START; /* Normally Points to 1M */ | 306 | output_data = (unsigned char *)__PHYSICAL_START; /* Normally Points to 1M */ |
313 | free_mem_end_ptr = (long)real_mode; | 307 | free_mem_end_ptr = (long)real_mode; |
314 | } | 308 | } |
315 | 309 | ||
@@ -324,11 +318,9 @@ static void setup_output_buffer_if_we_run_high(struct moveparams *mv) | |||
324 | #ifdef STANDARD_MEMORY_BIOS_CALL | 318 | #ifdef STANDARD_MEMORY_BIOS_CALL |
325 | if (RM_EXT_MEM_K < (3*1024)) error("Less than 4MB of memory"); | 319 | if (RM_EXT_MEM_K < (3*1024)) error("Less than 4MB of memory"); |
326 | #else | 320 | #else |
327 | if ((RM_ALT_MEM_K > RM_EXT_MEM_K ? RM_ALT_MEM_K : RM_EXT_MEM_K) < | 321 | if ((RM_ALT_MEM_K > RM_EXT_MEM_K ? RM_ALT_MEM_K : RM_EXT_MEM_K) < (3*1024)) error("Less than 4MB of memory"); |
328 | (3*1024)) | ||
329 | error("Less than 4MB of memory"); | ||
330 | #endif | 322 | #endif |
331 | mv->low_buffer_start = output_data = (char *)LOW_BUFFER_START; | 323 | mv->low_buffer_start = output_data = (unsigned char *)LOW_BUFFER_START; |
332 | low_buffer_end = ((unsigned int)real_mode > LOW_BUFFER_MAX | 324 | low_buffer_end = ((unsigned int)real_mode > LOW_BUFFER_MAX |
333 | ? LOW_BUFFER_MAX : (unsigned int)real_mode) & ~0xfff; | 325 | ? LOW_BUFFER_MAX : (unsigned int)real_mode) & ~0xfff; |
334 | low_buffer_size = low_buffer_end - LOW_BUFFER_START; | 326 | low_buffer_size = low_buffer_end - LOW_BUFFER_START; |
diff --git a/arch/x86_64/boot/compressed/misc.c b/arch/x86_64/boot/compressed/misc.c index cf4b88c416dc..3755b2e394d0 100644 --- a/arch/x86_64/boot/compressed/misc.c +++ b/arch/x86_64/boot/compressed/misc.c | |||
@@ -77,11 +77,11 @@ static void gzip_release(void **); | |||
77 | */ | 77 | */ |
78 | static unsigned char *real_mode; /* Pointer to real-mode data */ | 78 | static unsigned char *real_mode; /* Pointer to real-mode data */ |
79 | 79 | ||
80 | #define EXT_MEM_K (*(unsigned short *)(real_mode + 0x2)) | 80 | #define RM_EXT_MEM_K (*(unsigned short *)(real_mode + 0x2)) |
81 | #ifndef STANDARD_MEMORY_BIOS_CALL | 81 | #ifndef STANDARD_MEMORY_BIOS_CALL |
82 | #define ALT_MEM_K (*(unsigned long *)(real_mode + 0x1e0)) | 82 | #define RM_ALT_MEM_K (*(unsigned long *)(real_mode + 0x1e0)) |
83 | #endif | 83 | #endif |
84 | #define SCREEN_INFO (*(struct screen_info *)(real_mode+0)) | 84 | #define RM_SCREEN_INFO (*(struct screen_info *)(real_mode+0)) |
85 | 85 | ||
86 | extern unsigned char input_data[]; | 86 | extern unsigned char input_data[]; |
87 | extern int input_len; | 87 | extern int input_len; |
@@ -92,9 +92,9 @@ static unsigned long output_ptr = 0; | |||
92 | 92 | ||
93 | static void *malloc(int size); | 93 | static void *malloc(int size); |
94 | static void free(void *where); | 94 | static void free(void *where); |
95 | 95 | ||
96 | void* memset(void* s, int c, unsigned n); | 96 | static void *memset(void *s, int c, unsigned n); |
97 | void* memcpy(void* dest, const void* src, unsigned n); | 97 | static void *memcpy(void *dest, const void *src, unsigned n); |
98 | 98 | ||
99 | static void putstr(const char *); | 99 | static void putstr(const char *); |
100 | 100 | ||
@@ -162,8 +162,8 @@ static void putstr(const char *s) | |||
162 | int x,y,pos; | 162 | int x,y,pos; |
163 | char c; | 163 | char c; |
164 | 164 | ||
165 | x = SCREEN_INFO.orig_x; | 165 | x = RM_SCREEN_INFO.orig_x; |
166 | y = SCREEN_INFO.orig_y; | 166 | y = RM_SCREEN_INFO.orig_y; |
167 | 167 | ||
168 | while ( ( c = *s++ ) != '\0' ) { | 168 | while ( ( c = *s++ ) != '\0' ) { |
169 | if ( c == '\n' ) { | 169 | if ( c == '\n' ) { |
@@ -184,8 +184,8 @@ static void putstr(const char *s) | |||
184 | } | 184 | } |
185 | } | 185 | } |
186 | 186 | ||
187 | SCREEN_INFO.orig_x = x; | 187 | RM_SCREEN_INFO.orig_x = x; |
188 | SCREEN_INFO.orig_y = y; | 188 | RM_SCREEN_INFO.orig_y = y; |
189 | 189 | ||
190 | pos = (x + cols * y) * 2; /* Update cursor position */ | 190 | pos = (x + cols * y) * 2; /* Update cursor position */ |
191 | outb_p(14, vidport); | 191 | outb_p(14, vidport); |
@@ -194,7 +194,7 @@ static void putstr(const char *s) | |||
194 | outb_p(0xff & (pos >> 1), vidport+1); | 194 | outb_p(0xff & (pos >> 1), vidport+1); |
195 | } | 195 | } |
196 | 196 | ||
197 | void* memset(void* s, int c, unsigned n) | 197 | static void* memset(void* s, int c, unsigned n) |
198 | { | 198 | { |
199 | int i; | 199 | int i; |
200 | char *ss = (char*)s; | 200 | char *ss = (char*)s; |
@@ -203,7 +203,7 @@ void* memset(void* s, int c, unsigned n) | |||
203 | return s; | 203 | return s; |
204 | } | 204 | } |
205 | 205 | ||
206 | void* memcpy(void* dest, const void* src, unsigned n) | 206 | static void* memcpy(void* dest, const void* src, unsigned n) |
207 | { | 207 | { |
208 | int i; | 208 | int i; |
209 | char *d = (char *)dest, *s = (char *)src; | 209 | char *d = (char *)dest, *s = (char *)src; |
@@ -278,15 +278,15 @@ static void error(char *x) | |||
278 | putstr(x); | 278 | putstr(x); |
279 | putstr("\n\n -- System halted"); | 279 | putstr("\n\n -- System halted"); |
280 | 280 | ||
281 | while(1); | 281 | while(1); /* Halt */ |
282 | } | 282 | } |
283 | 283 | ||
284 | void setup_normal_output_buffer(void) | 284 | static void setup_normal_output_buffer(void) |
285 | { | 285 | { |
286 | #ifdef STANDARD_MEMORY_BIOS_CALL | 286 | #ifdef STANDARD_MEMORY_BIOS_CALL |
287 | if (EXT_MEM_K < 1024) error("Less than 2MB of memory"); | 287 | if (RM_EXT_MEM_K < 1024) error("Less than 2MB of memory"); |
288 | #else | 288 | #else |
289 | if ((ALT_MEM_K > EXT_MEM_K ? ALT_MEM_K : EXT_MEM_K) < 1024) error("Less than 2MB of memory"); | 289 | if ((RM_ALT_MEM_K > RM_EXT_MEM_K ? RM_ALT_MEM_K : RM_EXT_MEM_K) < 1024) error("Less than 2MB of memory"); |
290 | #endif | 290 | #endif |
291 | output_data = (unsigned char *)__PHYSICAL_START; /* Normally Points to 1M */ | 291 | output_data = (unsigned char *)__PHYSICAL_START; /* Normally Points to 1M */ |
292 | free_mem_end_ptr = (long)real_mode; | 292 | free_mem_end_ptr = (long)real_mode; |
@@ -297,13 +297,13 @@ struct moveparams { | |||
297 | uch *high_buffer_start; int hcount; | 297 | uch *high_buffer_start; int hcount; |
298 | }; | 298 | }; |
299 | 299 | ||
300 | void setup_output_buffer_if_we_run_high(struct moveparams *mv) | 300 | static void setup_output_buffer_if_we_run_high(struct moveparams *mv) |
301 | { | 301 | { |
302 | high_buffer_start = (uch *)(((ulg)&end) + HEAP_SIZE); | 302 | high_buffer_start = (uch *)(((ulg)&end) + HEAP_SIZE); |
303 | #ifdef STANDARD_MEMORY_BIOS_CALL | 303 | #ifdef STANDARD_MEMORY_BIOS_CALL |
304 | if (EXT_MEM_K < (3*1024)) error("Less than 4MB of memory"); | 304 | if (RM_EXT_MEM_K < (3*1024)) error("Less than 4MB of memory"); |
305 | #else | 305 | #else |
306 | if ((ALT_MEM_K > EXT_MEM_K ? ALT_MEM_K : EXT_MEM_K) < (3*1024)) error("Less than 4MB of memory"); | 306 | if ((RM_ALT_MEM_K > RM_EXT_MEM_K ? RM_ALT_MEM_K : RM_EXT_MEM_K) < (3*1024)) error("Less than 4MB of memory"); |
307 | #endif | 307 | #endif |
308 | mv->low_buffer_start = output_data = (unsigned char *)LOW_BUFFER_START; | 308 | mv->low_buffer_start = output_data = (unsigned char *)LOW_BUFFER_START; |
309 | low_buffer_end = ((unsigned int)real_mode > LOW_BUFFER_MAX | 309 | low_buffer_end = ((unsigned int)real_mode > LOW_BUFFER_MAX |
@@ -319,7 +319,7 @@ void setup_output_buffer_if_we_run_high(struct moveparams *mv) | |||
319 | mv->high_buffer_start = high_buffer_start; | 319 | mv->high_buffer_start = high_buffer_start; |
320 | } | 320 | } |
321 | 321 | ||
322 | void close_output_buffer_if_we_run_high(struct moveparams *mv) | 322 | static void close_output_buffer_if_we_run_high(struct moveparams *mv) |
323 | { | 323 | { |
324 | if (bytes_out > low_buffer_size) { | 324 | if (bytes_out > low_buffer_size) { |
325 | mv->lcount = low_buffer_size; | 325 | mv->lcount = low_buffer_size; |
@@ -335,7 +335,7 @@ int decompress_kernel(struct moveparams *mv, void *rmode) | |||
335 | { | 335 | { |
336 | real_mode = rmode; | 336 | real_mode = rmode; |
337 | 337 | ||
338 | if (SCREEN_INFO.orig_video_mode == 7) { | 338 | if (RM_SCREEN_INFO.orig_video_mode == 7) { |
339 | vidmem = (char *) 0xb0000; | 339 | vidmem = (char *) 0xb0000; |
340 | vidport = 0x3b4; | 340 | vidport = 0x3b4; |
341 | } else { | 341 | } else { |
@@ -343,8 +343,8 @@ int decompress_kernel(struct moveparams *mv, void *rmode) | |||
343 | vidport = 0x3d4; | 343 | vidport = 0x3d4; |
344 | } | 344 | } |
345 | 345 | ||
346 | lines = SCREEN_INFO.orig_video_lines; | 346 | lines = RM_SCREEN_INFO.orig_video_lines; |
347 | cols = SCREEN_INFO.orig_video_cols; | 347 | cols = RM_SCREEN_INFO.orig_video_cols; |
348 | 348 | ||
349 | if (free_mem_ptr < 0x100000) setup_normal_output_buffer(); | 349 | if (free_mem_ptr < 0x100000) setup_normal_output_buffer(); |
350 | else setup_output_buffer_if_we_run_high(mv); | 350 | else setup_output_buffer_if_we_run_high(mv); |