File size: 2,601 Bytes
829b19c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/* SPDX-License-Identifier: AGPL-3.0-or-later */
/* Copyright 2025 Ahmad Ali Parr / SnapKitty οΏ½ https://github.com/SNAPKITTYWEST/phaser-ags */
## ═══════════════════════════════════════════════════════════════════
##  PHASER AGS β€” RV32I kernel linker script
##
##  Memory map (matches Chisel Rv32iCore boot address 0x20000000):
##    SRAM  @ 0x20000000  (256 KB β€” on-chip, boot)
##    DRAM  @ 0x30000000  (64 MB  β€” MT48H32M16LF-7 via SDRC)
##    MMIO  @ 0x48000000  (OMAP3530 peripheral space)
##
##  Kernel loaded at SRAM base, uses DRAM for heap/page alloc.
## ═══════════════════════════════════════════════════════════════════

OUTPUT_ARCH("riscv")
ENTRY(_start)

MEMORY
{
    SRAM  (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00040000   /* 256 KB */
    DRAM  (rwx) : ORIGIN = 0x30000000, LENGTH = 0x04000000   /* 64 MB  */
    MMIO  (rw)  : ORIGIN = 0x48000000, LENGTH = 0x20000000   /* 512 MB */
}

SECTIONS
{
    /* ── Boot vectors in SRAM ── */
    .text.boot : {
        *(.text.boot)
        *(.text.trap)
    } > SRAM

    /* ── Main kernel code ── */
    .text : {
        *(.text .text.*)
    } > SRAM

    /* ── Read-only data ── */
    .rodata : ALIGN(16) {
        *(.rodata .rodata.*)
        *(.srodata .srodata.*)
    } > SRAM

    /* ── Initialized data ── */
    .data : ALIGN(16) {
        *(.data .data.*)
        *(.sdata .sdata.*)
        PROVIDE(__global_pointer$ = . + 0x800);
    } > SRAM

    /* ── BSS (zeroed by start.S) ── */
    .bss : ALIGN(16) {
        __bss_start = .;
        *(.bss .bss.*)
        *(.sbss .sbss.*)
        *(COMMON)
        __bss_end = .;
    } > SRAM

    /* ── Stack grows down from end of SRAM ── */
    .stack (NOLOAD) : ALIGN(16) {
        __stack_bottom = .;
        . = . + 0x8000;    /* 32 KB stack */
        __stack_top = .;
    } > SRAM

    /* ── Kernel heap in SRAM (remaining space) ── */
    .heap (NOLOAD) : ALIGN(4096) {
        __heap_start = .;
        . = ORIGIN(SRAM) + LENGTH(SRAM);
        __heap_end = .;
    } > SRAM

    /* ── Page-allocatable DRAM ── */
    .pages (NOLOAD) : ALIGN(4096) {
        __pages_start = .;
        . = ORIGIN(DRAM) + LENGTH(DRAM);
        __pages_end = .;
    } > DRAM

    /DISCARD/ : {
        *(.eh_frame)
        *(.comment)
        *(.note.*)
    }
}