/*
 * Copyright 2022 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

TCM_LENGTH  = DEFINED(__tcm_length__)  ? __tcm_length__  : 4M;
WINDOW_LENGTH = 0x1000000;

MEMORY
{
        TEXT (rx) : ORIGIN = 0x80000000, LENGTH = TCM_LENGTH
        CONSTANT_DATA (r) : ORIGIN = 0x80000000 + WINDOW_LENGTH, LENGTH = TCM_LENGTH
        MODEL_OUTPUT (rw) : ORIGIN = 0x80000000 + 2*WINDOW_LENGTH, LENGTH = TCM_LENGTH
        STATIC_DATA (rw) : ORIGIN = 0x80000000 + 3*WINDOW_LENGTH, LENGTH = TCM_LENGTH
        MODEL_INPUT (r) : ORIGIN = 0x80000000 + 4*WINDOW_LENGTH, LENGTH = TCM_LENGTH
        TEMPORARY_DATA (rw) : ORIGIN = 0x80000000 + 5*WINDOW_LENGTH, LENGTH = TCM_LENGTH
}

HEAP_SIZE = DEFINED(HEADP_SIZE) ? HEAP_SIZE : DEFINED(__heap_size__) ? __heap_size__ : 1250K;
STACK_SIZE = DEFINED(STACK_SIZE) ? STACK_SIZE : DEFINED(__stack_size__) ? __stack_size__ : 0x2000;

ENTRY(_start)

SECTIONS
{
        .text :
        {
                _stext = .;
                KEEP(*(.text._start))
                *(.text*)
                _etext = .;
        } > TEXT

        .rodata :
        {
                . = ALIGN(64);
                _srodata = .;
                *(.rodata*)
                _erodata = .;
        } > CONSTANT_DATA

        .preinit_array :
        {
                PROVIDE(__preinit_array_start = .);
                KEEP(*(.preinit_array))
                PROVIDE(__preinit_array_end = .);
        } > CONSTANT_DATA

        .init_array :
        {
                PROVIDE(__init_array_start = .);
                KEEP(*(SORT(.init_array.*)))
                KEEP(*(.init_array))
                PROVIDE(__init_array_end = .);
        } > CONSTANT_DATA

        .fini_array :
        {
                PROVIDE(__fini_array_start = .);
                KEEP(*(SORT(.fini_array.*)))
                KEEP(*(.fini_array))
                PROVIDE(__fini_array_end = .);
        } > CONSTANT_DATA

        .model_output :
        {
                . = ALIGN(64);
                _smodel_output = .;
                _ret = .;
                *(.model_output_header*)
                *(.model_output*)
                _emodel_output = .;
        } > MODEL_OUTPUT

        .data :
        {
                . = ALIGN(64);
                _global_pointer = . + 0x800;
                _sdata = .;
                *(.data*)
                _edata = .;
        } > STATIC_DATA

        .bss (NOLOAD) :
        {
                . = ALIGN(64);
                _sbss = .;
                *(.bss*)
                *(COMMON)
                _ebss = .;
        } > TEMPORARY_DATA

        .heap (NOLOAD) :
        {
                . = ALIGN(64);
                _sheap = .;
                . = . + HEAP_SIZE;
                . = ALIGN(64);
                _eheap = .;
        } > TEMPORARY_DATA

        .stack (NOLOAD) :
        {
                _sstack = .;
                PROVIDE(_stack_start_sentinel = .);
                . = . + STACK_SIZE;
                PROVIDE(_stack_ptr = .);
                PROVIDE(_stack_end_sentinel = .);
                . = ALIGN(64);
                . = . + 64;
                _estack = .;
        } > TEMPORARY_DATA

        _end = .;
}
