Magic‐1 Memory Map - retrotruestory/M1DEV GitHub Wiki

Based on the provided Magic-1 source files, here's the comprehensive memory mapping information:

Magic-1 Memory Map

Overall Memory Layout

0x0000-0x3FFF: ROM (16KB)
0x4000-0x7FFF: Device SRAM (16KB)
0x8000-0xF7FF: Main Memory
0xF800-0xFFFF: Device Page (Peripherals)

Device Page Details (0xF800-0xFFFF)

0xFFA0: Front Panel Switches
0xFFC0: POST Code Register
0xFFD0: Real Time Clock (RTC)
0xFFE0: UART1 (Auxiliary)
0xFF98: CF Card Interface
0xFFB0-0xFFB3: IDE Interface (8255)
0xFFF0: UART0 (Console)

IDE/CF Interface Registers

// 8255 PPI Registers
#define IDE_8255_LSB   0xFFB1  // Low 8 bits
#define IDE_8255_MSB   0xFFB0  // High 8 bits
#define IDE_8255_CTL   0xFFB3  // IDE control lines
#define CFG_8255       0xFFB2  // 8255 config register

Memory Management

// Page Table Entry flags
#define PAGE_PRESENT       0x8000
#define PAGE_NOT_PRESENT   0x0000
#define PAGE_WRITEABLE     0x4000
#define PAGE_NOT_WRITEABLE 0x0000
#define PAGE_SRAM         0x2000
#define PAGE_DEVICE       0x0000
#define PAGE_WAIT         0x0000
#define PAGE_NO_WAIT      0x1000
#define PAGE_SIZE         2048    // 2KB pages

Special Memory Regions

// Stack location
#define STACK_START    0x8000  // Stack grows down from here

// Boot Image Layout 
// Sector 0-1: Reserved
// Sector 2: Image Table Directory
// Sectors 3+: Boot Images (256 sectors per image)

Page Table Organization

// Page Table Structure
- Code pages mapped starting at PID * 64
- Data pages mapped at:
  - Split mode: base_code_page + 32
  - Joined mode: base_code_page
- Last page (0xF800-0xFFFF) always mapped to device space

Key Features:

  1. Separate code and data spaces possible
  2. Hardware page protection
  3. Device page always mapped at top of memory
  4. 2KB page size
  5. ROM can be remapped to RAM after boot

The memory map is managed through the page table entries that control:

  • Memory type (SRAM vs Device)
  • Access permissions (Read/Write)
  • Wait states
  • Present/Not Present status