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

parisc: PA-Linux requires at least 32 MB RAM

Even a 32-bit kernel requires at least 27 MB to decompress itself, so
halt the system with a message if the system has less memory than 32 MB.

Signed-off-by: Helge Deller <deller@gmx.de>

+20 -11
+20 -11
arch/parisc/boot/compressed/misc.c
··· 145 145 146 146 void __noreturn error(char *x) 147 147 { 148 - puts("\n\n"); 149 - puts(x); 150 - puts("\n\n -- System halted"); 148 + if (x) puts(x); 149 + puts("\n -- System halted\n"); 151 150 while (1) /* wait forever */ 152 151 ; 153 152 } 154 153 155 - static int print_hex(unsigned long num) 154 + static int print_num(unsigned long num, int base) 156 155 { 157 156 const char hex[] = "0123456789abcdef"; 158 157 char str[40]; ··· 159 160 160 161 str[i--] = '\0'; 161 162 do { 162 - str[i--] = hex[num & 0x0f]; 163 - num >>= 4; 163 + str[i--] = hex[num % base]; 164 + num = num / base; 164 165 } while (num); 165 166 166 - str[i--] = 'x'; 167 - str[i] = '0'; 167 + if (base == 16) { 168 + str[i--] = 'x'; 169 + str[i] = '0'; 170 + } else i++; 168 171 puts(&str[i]); 169 172 170 173 return 0; ··· 188 187 189 188 if (fmt[++i] == '%') 190 189 goto put; 190 + print_num(va_arg(args, unsigned long), 191 + fmt[i] == 'x' ? 16:10); 191 192 ++i; 192 - print_hex(va_arg(args, unsigned long)); 193 193 } 194 194 195 195 va_end(args); ··· 329 327 free_mem_end_ptr = rd_start; 330 328 #endif 331 329 332 - if (free_mem_ptr >= free_mem_end_ptr) 333 - error("Kernel too big for machine."); 330 + if (free_mem_ptr >= free_mem_end_ptr) { 331 + int free_ram; 332 + free_ram = (free_mem_ptr >> 20) + 1; 333 + if (free_ram < 32) 334 + free_ram = 32; 335 + printf("\nKernel requires at least %d MB RAM.\n", 336 + free_ram); 337 + error(NULL); 338 + } 334 339 335 340 #ifdef DEBUG 336 341 printf("\n");