| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: exec.c,v 1.74 2019/09/13 02:19:46 manu Exp $ */ | | 1 | /* $NetBSD: exec.c,v 1.75 2019/12/07 02:29:03 christos Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * Redistribution and use in source and binary forms, with or without | | 7 | * Redistribution and use in source and binary forms, with or without |
8 | * modification, are permitted provided that the following conditions | | 8 | * modification, are permitted provided that the following conditions |
9 | * are met: | | 9 | * are met: |
10 | * 1. Redistributions of source code must retain the above copyright | | 10 | * 1. Redistributions of source code must retain the above copyright |
11 | * notice, this list of conditions and the following disclaimer. | | 11 | * notice, this list of conditions and the following disclaimer. |
12 | * 2. Redistributions in binary form must reproduce the above copyright | | 12 | * 2. Redistributions in binary form must reproduce the above copyright |
13 | * notice, this list of conditions and the following disclaimer in the | | 13 | * notice, this list of conditions and the following disclaimer in the |
14 | * documentation and/or other materials provided with the distribution. | | 14 | * documentation and/or other materials provided with the distribution. |
| @@ -311,40 +311,40 @@ common_load_prekern(const char *file, u_ | | | @@ -311,40 +311,40 @@ common_load_prekern(const char *file, u_ |
311 | paddr_t kernpa_start, kernpa_end; | | 311 | paddr_t kernpa_start, kernpa_end; |
312 | char prekernpath[] = "/prekern"; | | 312 | char prekernpath[] = "/prekern"; |
313 | u_long prekern_start; | | 313 | u_long prekern_start; |
314 | int fd, flags; | | 314 | int fd, flags; |
315 | | | 315 | |
316 | *extmem = getextmem(); | | 316 | *extmem = getextmem(); |
317 | *basemem = getbasemem(); | | 317 | *basemem = getbasemem(); |
318 | | | 318 | |
319 | marks[MARK_START] = loadaddr; | | 319 | marks[MARK_START] = loadaddr; |
320 | | | 320 | |
321 | /* Load the prekern (static) */ | | 321 | /* Load the prekern (static) */ |
322 | flags = LOAD_KERNEL & ~(LOAD_HDR|LOAD_SYM); | | 322 | flags = LOAD_KERNEL & ~(LOAD_HDR|LOAD_SYM); |
323 | if ((fd = loadfile(prekernpath, marks, flags)) == -1) | | 323 | if ((fd = loadfile(prekernpath, marks, flags)) == -1) |
324 | return EIO; | | 324 | return errno; |
325 | close(fd); | | 325 | close(fd); |
326 | | | 326 | |
327 | prekern_start = marks[MARK_START]; | | 327 | prekern_start = marks[MARK_START]; |
328 | | | 328 | |
329 | /* The kernel starts at 2MB. */ | | 329 | /* The kernel starts at 2MB. */ |
330 | marks[MARK_START] = loadaddr; | | 330 | marks[MARK_START] = loadaddr; |
331 | marks[MARK_END] = loadaddr + (1UL << 21); | | 331 | marks[MARK_END] = loadaddr + (1UL << 21); |
332 | kernpa_start = (1UL << 21); | | 332 | kernpa_start = (1UL << 21); |
333 | | | 333 | |
334 | /* Load the kernel (dynamic) */ | | 334 | /* Load the kernel (dynamic) */ |
335 | flags = (LOAD_KERNEL | LOAD_DYN) & ~(floppy ? LOAD_BACKWARDS : 0); | | 335 | flags = (LOAD_KERNEL | LOAD_DYN) & ~(floppy ? LOAD_BACKWARDS : 0); |
336 | if ((fd = loadfile(file, marks, flags)) == -1) | | 336 | if ((fd = loadfile(file, marks, flags)) == -1) |
337 | return EIO; | | 337 | return errno; |
338 | close(fd); | | 338 | close(fd); |
339 | | | 339 | |
340 | kernpa_end = marks[MARK_END] - loadaddr; | | 340 | kernpa_end = marks[MARK_END] - loadaddr; |
341 | | | 341 | |
342 | /* If the root fs type is unusual, load its module. */ | | 342 | /* If the root fs type is unusual, load its module. */ |
343 | if (fsmod != NULL) | | 343 | if (fsmod != NULL) |
344 | module_add_split(fsmod, BM_TYPE_KMOD); | | 344 | module_add_split(fsmod, BM_TYPE_KMOD); |
345 | | | 345 | |
346 | bi_prekern.kernpa_start = kernpa_start; | | 346 | bi_prekern.kernpa_start = kernpa_start; |
347 | bi_prekern.kernpa_end = kernpa_end; | | 347 | bi_prekern.kernpa_end = kernpa_end; |
348 | BI_ADD(&bi_prekern, BTINFO_PREKERN, sizeof(struct btinfo_prekern)); | | 348 | BI_ADD(&bi_prekern, BTINFO_PREKERN, sizeof(struct btinfo_prekern)); |
349 | | | 349 | |
350 | /* | | 350 | /* |
| @@ -389,41 +389,41 @@ common_load_kernel(const char *file, u_l | | | @@ -389,41 +389,41 @@ common_load_kernel(const char *file, u_l |
389 | * With "CONSERVATIVE_MEMDETECT", extmem is 0 because | | 389 | * With "CONSERVATIVE_MEMDETECT", extmem is 0 because |
390 | * getextmem() is getextmem1(). Without, the "smart" | | 390 | * getextmem() is getextmem1(). Without, the "smart" |
391 | * methods could fail to report all memory as well. | | 391 | * methods could fail to report all memory as well. |
392 | * xmsmem is a few kB less than the actual size, but | | 392 | * xmsmem is a few kB less than the actual size, but |
393 | * better than nothing. | | 393 | * better than nothing. |
394 | */ | | 394 | */ |
395 | if (xmsmem > *extmem) | | 395 | if (xmsmem > *extmem) |
396 | *extmem = xmsmem; | | 396 | *extmem = xmsmem; |
397 | /* | | 397 | /* |
398 | * Get the size of the kernel | | 398 | * Get the size of the kernel |
399 | */ | | 399 | */ |
400 | marks[MARK_START] = loadaddr; | | 400 | marks[MARK_START] = loadaddr; |
401 | if ((fd = loadfile(file, marks, COUNT_KERNEL)) == -1) | | 401 | if ((fd = loadfile(file, marks, COUNT_KERNEL)) == -1) |
402 | return EIO; | | 402 | return errno; |
403 | close(fd); | | 403 | close(fd); |
404 | | | 404 | |
405 | kernsize = marks[MARK_END]; | | 405 | kernsize = marks[MARK_END]; |
406 | kernsize = (kernsize + 1023) / 1024; | | 406 | kernsize = (kernsize + 1023) / 1024; |
407 | | | 407 | |
408 | loadaddr = xmsalloc(kernsize); | | 408 | loadaddr = xmsalloc(kernsize); |
409 | if (!loadaddr) | | 409 | if (!loadaddr) |
410 | return ENOMEM; | | 410 | return ENOMEM; |
411 | } | | 411 | } |
412 | #endif | | 412 | #endif |
413 | marks[MARK_START] = loadaddr; | | 413 | marks[MARK_START] = loadaddr; |
414 | if ((fd = loadfile(file, marks, | | 414 | if ((fd = loadfile(file, marks, |
415 | LOAD_KERNEL & ~(floppy ? LOAD_BACKWARDS : 0))) == -1) | | 415 | LOAD_KERNEL & ~(floppy ? LOAD_BACKWARDS : 0))) == -1) |
416 | return EIO; | | 416 | return errno; |
417 | | | 417 | |
418 | close(fd); | | 418 | close(fd); |
419 | | | 419 | |
420 | /* If the root fs type is unusual, load its module. */ | | 420 | /* If the root fs type is unusual, load its module. */ |
421 | if (fsmod != NULL) | | 421 | if (fsmod != NULL) |
422 | module_add_split(fsmod, BM_TYPE_KMOD); | | 422 | module_add_split(fsmod, BM_TYPE_KMOD); |
423 | | | 423 | |
424 | /* | | 424 | /* |
425 | * Gather some information for the kernel. Do this after the | | 425 | * Gather some information for the kernel. Do this after the |
426 | * "point of no return" to avoid memory leaks. | | 426 | * "point of no return" to avoid memory leaks. |
427 | * (but before DOS might be trashed in the XMS case) | | 427 | * (but before DOS might be trashed in the XMS case) |
428 | */ | | 428 | */ |
429 | #ifdef PASS_BIOSGEOM | | 429 | #ifdef PASS_BIOSGEOM |