Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[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>

authored by

Carl-Daniel Hailfinger and committed by
Linus Torvalds
b79c4df7 83f4fcce

+35 -43
+12 -20
arch/i386/boot/compressed/misc.c
··· 24 24 25 25 #undef memset 26 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 27 #define memzero(s, n) memset ((s), 0, (n)) 36 28 37 29 typedef unsigned char uch; ··· 85 93 #endif 86 94 #define RM_SCREEN_INFO (*(struct screen_info *)(real_mode+0)) 87 95 88 - extern char input_data[]; 96 + extern unsigned char input_data[]; 89 97 extern int input_len; 90 98 91 99 static long bytes_out = 0; ··· 94 102 95 103 static void *malloc(int size); 96 104 static void free(void *where); 105 + 106 + static void *memset(void *s, int c, unsigned n); 107 + static void *memcpy(void *dest, const void *src, unsigned n); 97 108 98 109 static void putstr(const char *); 99 110 ··· 200 205 outb_p(0xff & (pos >> 1), vidport+1); 201 206 } 202 207 203 - static void* memset(void* s, int c, size_t n) 208 + static void* memset(void* s, int c, unsigned n) 204 209 { 205 210 int i; 206 211 char *ss = (char*)s; ··· 209 214 return s; 210 215 } 211 216 212 - static void* memcpy(void* __dest, __const void* __src, 213 - size_t __n) 217 + static void* memcpy(void* dest, const void* src, unsigned n) 214 218 { 215 219 int i; 216 - char *d = (char *)__dest, *s = (char *)__src; 220 + char *d = (char *)dest, *s = (char *)src; 217 221 218 - for (i=0;i<__n;i++) d[i] = s[i]; 219 - return __dest; 222 + for (i=0;i<n;i++) d[i] = s[i]; 223 + return dest; 220 224 } 221 225 222 226 /* =========================================================================== ··· 303 309 #else 304 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"); 305 311 #endif 306 - output_data = (char *)__PHYSICAL_START; /* Normally Points to 1M */ 312 + output_data = (unsigned char *)__PHYSICAL_START; /* Normally Points to 1M */ 307 313 free_mem_end_ptr = (long)real_mode; 308 314 } 309 315 ··· 318 324 #ifdef STANDARD_MEMORY_BIOS_CALL 319 325 if (RM_EXT_MEM_K < (3*1024)) error("Less than 4MB of memory"); 320 326 #else 321 - if ((RM_ALT_MEM_K > RM_EXT_MEM_K ? RM_ALT_MEM_K : RM_EXT_MEM_K) < 322 - (3*1024)) 323 - error("Less than 4MB of memory"); 327 + 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"); 324 328 #endif 325 - mv->low_buffer_start = output_data = (char *)LOW_BUFFER_START; 329 + mv->low_buffer_start = output_data = (unsigned char *)LOW_BUFFER_START; 326 330 low_buffer_end = ((unsigned int)real_mode > LOW_BUFFER_MAX 327 331 ? LOW_BUFFER_MAX : (unsigned int)real_mode) & ~0xfff; 328 332 low_buffer_size = low_buffer_end - LOW_BUFFER_START;
+23 -23
arch/x86_64/boot/compressed/misc.c
··· 77 77 */ 78 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 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 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 86 extern unsigned char input_data[]; 87 87 extern int input_len; ··· 92 92 93 93 static void *malloc(int size); 94 94 static void free(void *where); 95 - 96 - void* memset(void* s, int c, unsigned n); 97 - void* memcpy(void* dest, const void* src, unsigned n); 95 + 96 + static void *memset(void *s, int c, unsigned n); 97 + static void *memcpy(void *dest, const void *src, unsigned n); 98 98 99 99 static void putstr(const char *); 100 100 ··· 162 162 int x,y,pos; 163 163 char c; 164 164 165 - x = SCREEN_INFO.orig_x; 166 - y = SCREEN_INFO.orig_y; 165 + x = RM_SCREEN_INFO.orig_x; 166 + y = RM_SCREEN_INFO.orig_y; 167 167 168 168 while ( ( c = *s++ ) != '\0' ) { 169 169 if ( c == '\n' ) { ··· 184 184 } 185 185 } 186 186 187 - SCREEN_INFO.orig_x = x; 188 - SCREEN_INFO.orig_y = y; 187 + RM_SCREEN_INFO.orig_x = x; 188 + RM_SCREEN_INFO.orig_y = y; 189 189 190 190 pos = (x + cols * y) * 2; /* Update cursor position */ 191 191 outb_p(14, vidport); ··· 194 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 199 int i; 200 200 char *ss = (char*)s; ··· 203 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 208 int i; 209 209 char *d = (char *)dest, *s = (char *)src; ··· 278 278 putstr(x); 279 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 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 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 290 #endif 291 291 output_data = (unsigned char *)__PHYSICAL_START; /* Normally Points to 1M */ 292 292 free_mem_end_ptr = (long)real_mode; ··· 297 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 302 high_buffer_start = (uch *)(((ulg)&end) + HEAP_SIZE); 303 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 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 307 #endif 308 308 mv->low_buffer_start = output_data = (unsigned char *)LOW_BUFFER_START; 309 309 low_buffer_end = ((unsigned int)real_mode > LOW_BUFFER_MAX ··· 319 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 324 if (bytes_out > low_buffer_size) { 325 325 mv->lcount = low_buffer_size; ··· 335 335 { 336 336 real_mode = rmode; 337 337 338 - if (SCREEN_INFO.orig_video_mode == 7) { 338 + if (RM_SCREEN_INFO.orig_video_mode == 7) { 339 339 vidmem = (char *) 0xb0000; 340 340 vidport = 0x3b4; 341 341 } else { ··· 343 343 vidport = 0x3d4; 344 344 } 345 345 346 - lines = SCREEN_INFO.orig_video_lines; 347 - cols = SCREEN_INFO.orig_video_cols; 346 + lines = RM_SCREEN_INFO.orig_video_lines; 347 + cols = RM_SCREEN_INFO.orig_video_cols; 348 348 349 349 if (free_mem_ptr < 0x100000) setup_normal_output_buffer(); 350 350 else setup_output_buffer_if_we_run_high(mv);