Ticket #5822: boot-memory.diff

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

proposed patch

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

    # HG changeset patch
    # Parent ea67c07499d8891b3ba9318f313db0896ff3b6eb
    
    diff -r ea67c07499d8 src/system/boot/platform/bios_ia32/mmu.cpp
    a b  
    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) {
     730            regs.eax = 0x8800; // AH 88h
     731            call_bios(0x15, &regs);
     732            if (regs.flags & CARRY_FLAG) {
     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;