Skip to content

Latest commit

 

History

History
81 lines (59 loc) · 2.86 KB

File metadata and controls

81 lines (59 loc) · 2.86 KB

Code: PCI.[c, h], ConsleShell.[c, h]

Explanation

What does the code do?

Problem

MINT64OS uses IDE controller to access HDD. The problem is that modern computers use SATA controllers instead of IDE controllers. Adding SATA controller driver can be a way, but I do not want to mess up with my computer's storage for work. Unfortunately, MINT64OS book doesn't explain how to use a storage device other than an IDE HDD.

Solution

The best way I can think of is using USB storage that has MINT64OS image. Because USB 3.0 host controllers (XHCI) are connected to PCI bus, PCI driver is required. In this chapter, PCI driver is implmeneted before implementing XHCI drivers.

How does PCI driver work in MINT64OS?

  1. Currently, the purpose of PCI driver is using USB, so very simple PCI interfaces and simple struct types are implmeneted.

    • Reading and writing to PCI configuration is supported.
    • A handy tool is provided that tells how much memory is being used and where.

References

  1. OSDev PCI
  2. USB: The Universal Serial Bus

MINT64OS Characteristics

  1. Memory Layout up to CH16

    • start(inclusive) ~ end(exclusive)

    • 0x00000 ~ 0x00400 (Interrupt Vector Table for real mode)

    • 0x07C00 ~ 0x07E00 (Bootloader)

    • 0x07E00 ~ 0x10000 (Stack for real mode and protected mode)

    • 0x10000 ~ ... (32 bit code of OS; EntryPoint.S + Main.c + ...)

    • 0x20000 ~ 0x20004 (number of memory map entries)

    • 0x20004 ~ ... (memory map entires)

    • 0xA0000 ~ ... (video memory for graphic mode)

    • 0xB8000 ~ ... (video memory for text mode)

    • 0x100000(1MB) ~ 0x142000 (IA-32 mode page table tree structure, 264KB)

    • 0x142000 ~ 0x142010 (GDTR, 16 bytes)

    • 0x142010 ~ 0x142038 (GDT, 40 bytes = 3 * 8 bytes + 1 * 16 bytes)

    • 0x142038 ~ 0x1420A0 (TSS, 104 bytes = 1 * 104 bytes)

    • 0x1420A0 ~ 0x1420B0 (IDTR, 16 bytes)

    • 0x1420B0 ~ 0x1426F0 (IDT, 1600 bytes = 100 * 16 bytes)

    • 0x200000(2MB) ~ ...

      • 64 bit code of OS; EntryPoint.S + Main.c + task stack + task manager + ...
    • 0x600000(6MB) ~ 0x700000(7MB) (Stack for long mode kernel)

    • 0x700000(7MB) ~ 0x800000(8MB) (IST1 stack area)

    • 0x800000(8MB) ~ 0x8CC000 (Task Pool, 816 KB = 816 bytes * 1024)

    • 0x849000 ~ 0x103A000 (Task Stack Pool, 8MB = 8192 * 1024)

    • 0x1100000(17MB) ~... (Dynamic Memory Manager)

  2. code in Filesystem.c checks if primary slave hdd has MINT filesystem. Because of that, we need to run QEMU with primary slave hdd. Execute below command (this command is executed when you run make run)

    • qemu-system-x86_64.exe -m 64 -hda ./Disk.img -hdb ./HDD.img -rtc base=localtime -M pc

    • See 24-1.md to create HDD.img.