bios-OS/doc/MEMORY_MAP.md
2026-02-07 14:39:15 +01:00

6.2 KiB

Memory Map / Cartographie Mémoire

🇬🇧 English

Physical Memory Layout (Real Mode)

The processor starts in Real Mode, addressing 1 MB of memory.

Physical Start Physical End Size Description Segment Source File
0x00000 0x003FF 1 KB IVT (Interrupt Vector Table) 0x0000 boot.asm / generic.asm
0x00400 0x004FF 256 B BDA (BIOS Data Area) Standard 0x0040 common/bda.asm
0x00500 0x005FF ~256 B Custom BDA (Driver Data) 0x0050 common/bda.asm
... ... ... Free / Reserved
0x08000 0x09FFF 8 KB Stack Bottom 0x0800 boot.asm
0x0A000 0x0AFFF ~4 KB GUI RAM (Widget Allocation) 0x0A00 gui/lib.asm
0x0B000 0x17FFE ~52 KB Stack Top (Grows downwards) 0x0800 boot.asm
... ... ... Conventional RAM Free
0xB8000 0xBFFFF 32 KB VRAM (CGA / MCGA) 0xB800 drivers/gfx_cgam.asm
0xC0000 0xDFFFF 128 KB Option ROMs (e.g., VGA BIOS) 0xC000 boot.asm
... ... ... System Reserved
0xF0000 0xFFFFF 64 KB System BIOS ROM (Code) 0xF000 boot.asm

Detailed Zones

Interrupt Vector Table (IVT)

  • Location: 0000:0000
  • Usage: Interrupt pointer table (256 entries of 4 bytes).
  • Initialization:
    • ivt_setup fills the table with a default handler (default_isr).
    • ivt_setvector installs specific IRQs (e.g., Timer on INT 08h).

BIOS Data Area (BDA)

The project separates the standard IBM BDA from its own variables to avoid conflicts with the VGA BIOS loaded at 0xC000.

  • Standard BDA (0040:0000): Used mainly by the VGA BIOS (loaded via QEMU) to store video modes (0x0049) and column count (0x004A).
  • Custom BDA (0050:0000): Defined by BDA_DATA_SEG. Stores driver states:
    • Mouse: Input buffer, status, coordinates, background buffer (for cursor).
    • Gfx: Text cursor position, attributes.

Stack & GUI RAM

  • Stack: Segment 0x0800, SP 0xFFFE. Grows downwards from physical address 0x17FFE.
  • GUI RAM: Segment 0x0A00 (Physical 0x0A000).
  • Layout: The GUI RAM sits at the "bottom" of the stack segment's physical range, but since the stack starts at the top (0x17FFE) and grows down, there is approximately 56 KB of safe space before collision.

Video RAM (CGA High-Res)

  • Segment: 0xB800
  • Mode: 640x200 Monochrome (1 bit per pixel).
  • Organization: Interleaved.
    • Even Lines (0, 2, 4...): Offset 0x0000 - 0x1F3F (Bank 0).
    • Odd Lines (1, 3, 5...): Offset 0x2000 - 0x3F3F (Bank 1).

ROM

  • Option ROMs (0xC0000): Scanned by setup_load_rom to initialize the VGA BIOS.
  • System ROM (0xF0000): Contains the compiled binary code. The Reset Vector is at 0xFFFF0.

🇫🇷 Français

Cartographie Mémoire Physique (Mode Réel)

Le processeur démarre en mode réel, adressant 1 Mo de mémoire.

Adresse Physique (Début) Adresse Physique (Fin) Taille Description Segment Fichier Source
0x00000 0x003FF 1 Ko IVT (Interrupt Vector Table) 0x0000 boot.asm / generic.asm
0x00400 0x004FF 256 o BDA (BIOS Data Area) Standard 0x0040 common/bda.asm
0x00500 0x005FF ~256 o Custom BDA (Données Drivers) 0x0050 common/bda.asm
... ... ... Mémoire Libre / Réservée
0x08000 0x09FFF 8 Ko Bas de la Pile (Stack Bottom) 0x0800 boot.asm
0x0A000 0x0AFFF ~4 Ko GUI RAM (Allocation Widgets) 0x0A00 gui/lib.asm
0x0B000 0x17FFE ~52 Ko Haut de la Pile (Stack Top) 0x0800 boot.asm
... ... ... RAM Conventionnelle Libre
0xB8000 0xBFFFF 32 Ko VRAM (CGA / MCGA) 0xB800 drivers/gfx_cgam.asm
0xC0000 0xDFFFF 128 Ko Option ROMs (ex: VGA BIOS) 0xC000 boot.asm
... ... ... Réservé Système
0xF0000 0xFFFFF 64 Ko System BIOS ROM (Code) 0xF000 boot.asm

Détails des Zones

Interrupt Vector Table (IVT)

  • Emplacement : 0000:0000
  • Usage : Table des pointeurs d'interruption (256 entrées de 4 octets).
  • Initialisation :
    • ivt_setup remplit la table avec un handler par défaut (default_isr).
    • ivt_setvector installe les IRQ spécifiques (ex: Timer sur INT 08h).

BIOS Data Area (BDA)

Le projet sépare la BDA standard IBM de ses propres variables pour éviter les conflits avec le BIOS VGA chargé en 0xC000.

  • BDA Standard (0040:0000) : Utilisée principalement par le BIOS VGA (chargé via QEMU) pour stocker les modes vidéo (0x0049) et le nombre de colonnes (0x004A).
  • Custom BDA (0050:0000) : Définie par BDA_DATA_SEG. Stocke l'état des drivers :
    • Souris : Buffer d'entrée, état, coordonnées, buffer de sauvegarde du fond (pour le curseur).
    • Gfx : Position du curseur texte, attributs.

Stack & GUI RAM

  • Stack : Segment 0x0800, SP 0xFFFE. Grandit vers le bas depuis l'adresse physique 0x17FFE.
  • GUI RAM : Segment 0x0A00 (Physique 0x0A000).
  • Organisation : La RAM GUI se trouve "en bas" de la plage physique du segment de pile, mais comme la pile commence tout en haut (0x17FFE) et descend, il y a environ 56 Ko d'espace libre avant collision.

Video RAM (CGA High-Res)

  • Segment : 0xB800
  • Mode : 640x200 Monochrome (1 bit par pixel).
  • Organisation : Entrelacée (Interleaved).
    • Lignes Paires (0, 2, 4...) : Offset 0x0000 à 0x1F3F (Bank 0).
    • Lignes Impaires (1, 3, 5...) : Offset 0x2000 à 0x3F3F (Bank 1).

ROM

  • Option ROMs (0xC0000) : Espace scanné par setup_load_rom pour initialiser le BIOS VGA.
  • System ROM (0xF0000) : Contient le code binaire compilé. Le Vecteur de Reset est situé à 0xFFFF0.