Ticket #5822: boot-memory.2.diff

File boot-memory.2.diff, 2.0 KB (added by andreasf, 11 years ago)

updated patch

  • src/system/boot/platform/bios_ia32/mmu.cpp

    # HG changeset patch
    # Parent 3006a5ffd201017f040d92a994e7c5dfbd1d686c
    
    diff -r 3006a5ffd201 src/system/boot/platform/bios_ia32/mmu.cpp
    a b  
    309309        regs.edx = 'SMAP';
    310310
    311311        call_bios(0x15, &regs);
    312         if (regs.flags & CARRY_FLAG)
     312        if ((regs.flags & CARRY_FLAG) != 0)
    313313            return 0;
    314314
    315315        regs.edi += sizeof(extended_memory);
     
    716716            }
    717717        }
    718718    } else {
    719         // TODO: for now!
    720         dprintf("No extended memory block - using 64 MB (fix me!)\n");
    721         uint32 memSize = 64 * 1024 * 1024;
    722 
     719        bios_regs regs;
     720       
    723721        // We dont have an extended map, assume memory is contiguously mapped
    724722        // at 0x0, but leave out the BIOS range ((640k - 1 page) to 1 MB).
    725723        gKernelArgs.physical_memory_range[0].start = 0;
    726724        gKernelArgs.physical_memory_range[0].size = 0x9f000;
    727725        gKernelArgs.physical_memory_range[1].start = 0x100000;
    728         gKernelArgs.physical_memory_range[1].size = memSize - 0x100000;
    729         gKernelArgs.num_physical_memory_ranges = 2;
     726
     727        regs.eax = 0xe801; // AX
     728        call_bios(0x15, &regs);
     729        if ((regs.flags & CARRY_FLAG) != 0) {
     730            regs.eax = 0x8800; // AH 88h
     731            call_bios(0x15, &regs);
     732            if ((regs.flags & CARRY_FLAG) != 0) {
     733                // TODO: for now!
     734                dprintf("No memory size - using 64 MB (fix me!)\n");
     735                uint32 memSize = 64 * 1024 * 1024;
     736                gKernelArgs.physical_memory_range[1].size = memSize - 0x100000;
     737            } else {
     738                dprintf("Get Extended Memory Size succeeded.\n");
     739                gKernelArgs.physical_memory_range[1].size = regs.eax * 1024;
     740            }
     741            gKernelArgs.num_physical_memory_ranges = 2;
     742        } else {
     743            dprintf("Get Memory Size for Large Configurations succeeded.\n");
     744            gKernelArgs.physical_memory_range[1].size = regs.ecx * 1024;
     745            gKernelArgs.physical_memory_range[2].start = 0x1000000;
     746            gKernelArgs.physical_memory_range[2].size = regs.edx * 64 * 1024;
     747            gKernelArgs.num_physical_memory_ranges = 3;
     748        }
    730749    }
    731750
    732751    gKernelArgs.arch_args.page_hole = 0xffc00000;