int getextmemx() { int buf[5], i; int extmem = getextmem1(); #ifdef SUPPORT_PS2 struct { uint16_t len; uint32_t dta[8]; /* pad to 64 bytes - without this, machine would reset */ uint8_t __pad[30]; } __packed bufps2; #endif #ifdef DEBUG_MEMSIZE printf("extmem1: %xk\n", extmem); #endif if (!getextmem2(buf)) { #ifdef DEBUG_MEMSIZE printf("extmem2: %xk + %xk\n", buf[0], buf[1] * 64); #endif if (buf[0] <= 15 * 1024) { int help = buf[0]; if (help == 15 * 1024) help += buf[1] * 64; if (extmem < help) extmem = help; } } i = 0; do { if (getmementry(&i, buf)) break; #ifdef DEBUG_MEMSIZE printf("mementry: (%d) %x %x %x %x %x\n", i, buf[0], buf[1], buf[2], buf[3], buf[4]); #endif if ((buf[4] == 1 && buf[0] == 0x100000) && extmem < buf[2] / 1024) extmem = buf[2] / 1024; } while (i); #ifdef SUPPORT_PS2 /* use local memory information from RETURN MEMORY-MAP INFORMATION */ if (!getextmemps2((void *) &bufps2)) { int help = bufps2.dta[0]; if (help == 15 * 1024) help += bufps2.dta[1]; if (extmem < help) extmem = help; } #endif return (extmem); }
static int common_load_kernel(const char *file, u_long *basemem, u_long *extmem, physaddr_t loadaddr, int floppy, u_long marks[MARK_MAX]) { int fd; #ifdef XMS u_long xmsmem; physaddr_t origaddr = loadaddr; #endif *extmem = getextmem(); *basemem = getbasemem(); #ifdef XMS if ((getextmem1() == 0) && (xmsmem = checkxms())) { u_long kernsize; /* * With "CONSERVATIVE_MEMDETECT", extmem is 0 because * getextmem() is getextmem1(). Without, the "smart" * methods could fail to report all memory as well. * xmsmem is a few kB less than the actual size, but * better than nothing. */ if (xmsmem > *extmem) *extmem = xmsmem; /* * Get the size of the kernel */ marks[MARK_START] = loadaddr; if ((fd = loadfile(file, marks, COUNT_KERNEL)) == -1) return EIO; close(fd); kernsize = marks[MARK_END]; kernsize = (kernsize + 1023) / 1024; loadaddr = xmsalloc(kernsize); if (!loadaddr) return ENOMEM; } #endif marks[MARK_START] = loadaddr; if ((fd = loadfile(file, marks, LOAD_KERNEL & ~(floppy ? LOAD_BACKWARDS : 0))) == -1) return EIO; close(fd); /* Now we know the root fs type, load modules for it. */ if (fsmod != NULL) module_add(fsmod); if (fsmod !=NULL && fsmod2 != NULL && strcmp(fsmod, fsmod2) != 0) module_add(fsmod2); /* * Gather some information for the kernel. Do this after the * "point of no return" to avoid memory leaks. * (but before DOS might be trashed in the XMS case) */ #ifdef PASS_BIOSGEOM bi_getbiosgeom(); #endif #ifdef PASS_MEMMAP bi_getmemmap(); #endif #ifdef XMS if (loadaddr != origaddr) { /* * We now have done our last DOS IO, so we may * trash the OS. Copy the data from the temporary * buffer to its real address. */ marks[MARK_START] -= loadaddr; marks[MARK_END] -= loadaddr; marks[MARK_SYM] -= loadaddr; marks[MARK_END] -= loadaddr; ppbcopy(loadaddr, origaddr, marks[MARK_END]); } #endif marks[MARK_END] = (((u_long) marks[MARK_END] + sizeof(int) - 1)) & (-sizeof(int)); image_end = marks[MARK_END]; kernel_loaded = true; return 0; }