--
-- Copyright 2023 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.

set_project("CHERIoT soundstream demo")

local shodan_dir = os.getenv("ROOTDIR")
if shodan_dir == nil or shodan_dir == '' then
  raise("ROOTDIR not set")
end
local cheriot_out_dir = os.getenv("CHERIOT_OUT_DIR")
if cheriot_out_dir == nil or cheriot_out_dir == '' then
  raise("CHERIOT_OUT_DIR not set")
end

local sdkdir = path.join(shodan_dir, "sw/cheriot-rtos/sdk")
includes(sdkdir)
set_toolchains("cheriot-clang")

option("board")
    set_default("sencha")

local matcha_dir = path.join(shodan_dir, "hw/matcha")
local dif_dir = path.join(matcha_dir, "sw/device/lib/dif")
local dif_autogen_dir = path.join(dif_dir, "autogen")
local opentitan_dir = path.join(shodan_dir, "hw/opentitan-upstream")
local matcha_gen_dir = path.join(cheriot_out_dir, "opentitan-gen/include/opentitan")

-- Support libraries
includes(path.join(sdkdir, "lib"))
includes(path.join(sdkdir, "lib/freestanding"))

local function is_sencha()
    return is_config("board", "sencha")
end

-- Each driver operates in a compartment.
compartment("i2s")
    add_files("i2s.cc")
    add_files(path.join(dif_dir, "dif_i2s.c"),
              path.join(dif_autogen_dir, "dif_i2s_autogen.c"))
    add_includedirs(matcha_dir, matcha_gen_dir, opentitan_dir)
    add_defines("CHERIOT_NO_AMBIENT_MALLOC")

if is_sencha() then
compartment("mailbox")
    add_files("mailbox.cc")
    add_files(path.join(dif_dir, "dif_tlul_mailbox.c"),
              path.join(dif_autogen_dir, "dif_tlul_mailbox_autogen.c"))
    add_includedirs(matcha_dir, matcha_gen_dir, opentitan_dir)
    add_defines("CHERIOT_NO_AMBIENT_MALLOC")
end

compartment("ml_top")
    add_files("ml_top.cc")
    add_files(path.join(dif_dir, "dif_ml_top.c"),
              path.join(dif_autogen_dir, "dif_ml_top_autogen.c"))
    add_includedirs(matcha_dir, matcha_gen_dir, opentitan_dir)
    add_defines("CHERIOT_NO_AMBIENT_MALLOC")

-- Soundstream application.
compartment("soundstream")
    add_files("soundstream.cc", "encode.cc")
    add_files(path.join(matcha_dir, "hw/top_matcha/sw/autogen/top_matcha.c"));
    add_includedirs(matcha_dir, matcha_gen_dir, opentitan_dir)
    add_defines("CHERIOT_NO_AMBIENT_MALLOC")

-- Firmware image.
firmware("soundstream-firmware")
    add_deps("i2s", "ml_top")
    if is_sencha() then
        add_deps("mailbox")
    end
    add_deps("soundstream")
    add_deps("freestanding", "debug")
    on_load(function(target)
        target:values_set("board", "$(board)")
        -- NB: trusted_stack_frames is a guess; +1'd for any
        --     compartment error handler usage?
        local threads = {
            {
                compartment = "soundstream",
                priority = 1,
                entry_point = "entry",
                stack_size = 0x1000, -- 4KB
                trusted_stack_frames = 5
            },
            -- NB: stack sizes bumped for logging
            {
                compartment = "i2s",
                priority = 10,
                entry_point = "i2s_isr",
                stack_size = 0x400, -- 512B
                trusted_stack_frames = 3
            },
            {
                compartment = "ml_top",
                priority = 10,
                entry_point = "ml_top_isr",
                stack_size = 0x400, -- 512B
                trusted_stack_frames = 3
            },
        }
        if is_sencha() then
            table.insert(threads, {
                compartment = "mailbox",
                priority = 10,
                entry_point = "mailbox_isr",
                stack_size = 0x400, -- 512B
                trusted_stack_frames = 3
            })
        end
        target:values_set("threads", threads, {expand = false})
    end)
