Skip to content

Latest commit

 

History

History
48 lines (37 loc) · 1.44 KB

File metadata and controls

48 lines (37 loc) · 1.44 KB

Code: Part of Main.c that check if system has enough memory

// Check if computer has enough memory address that MINT64OS can use.
// MINT64OS requires 64MB
BOOL kIsMemoryEnough(void) {
    // 0x100000 == 1MB
    DWORD* pdwCurrentAddress = (DWORD*) 0x100000;

    // loop up to 0x4000000(64MB)
    while ( (DWORD) pdwCurrentAddress < 0x4000000) {
        *pdwCurrentAddress = 0x12345678;


        // there is possibility that computer pretends that is allows
        // to write to specific memory area. To make sure that the addr exists,
        // reading the addr is necessary
        if (*pdwCurrentAddress != 0x12345678) {
            return FALSE;
        }

        // Do not check every single byte. Instead, check first byte of
        // every megabyte
        pdwCurrentAddress += (0x100000 / 4);
    }
    return TRUE;
}

Explanation

MINT64OS Characteristics

  1. MINT64OS's IA-32e mode code accesses up to 64MB.

  2. If you run QEMU with -m 32 option, you will see that a memory shortage message

     qemu-system-x86_64.exe -m 32 -fda .\Disk.img -rtc base=localtime -M pc
    
  3. Memory Layout up to CH08

    • start(inclusive) ~ end(exclusive)
    • 0x00000 ~ 0x00400 (Interrupt Vector Table)
    • 0x07C00 ~ 0x07E00 (Bootloader)
    • 0x07E00 ~ 0x10000 (Stack)
    • 0x10000 ~ 0x10400 (32 bits code of OS; EntryPoint.S + Main.c)
    • 0xA0000 ~ ... (video memory for graphic mode)
    • 0xB8000 ~ ... (video memory for text mode)