# Copyright 2022 Google, Inc.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met: redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer;
# redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution;
# neither the name of the copyright holders nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

from m5.params import *
from m5.objects.SimObject import SimObject
from m5.objects.Device import PioDevice


class QemuFwCfgItem(SimObject):
    type = "QemuFwCfgItem"
    cxx_class = "gem5::qemu::FwCfgItemFactoryBase"
    cxx_header = "dev/qemu/fw_cfg.hh"
    abstract = True

    # The path this item will be listed under in the firmware config directory.
    arch_specific = Param.Bool(False, "if this item is archiecture specific")
    index = Param.Unsigned(0, "Fixed index, or 0 for automatic")
    path = Param.String("Path to item in the firmware config directory")


class QemuFwCfgItemFile(QemuFwCfgItem):
    type = "QemuFwCfgItemFile"
    cxx_class = "gem5::qemu::FwCfgItemFactory<gem5::qemu::FwCfgItemFile>"
    cxx_template_params = ["class ItemType"]
    cxx_header = "dev/qemu/fw_cfg.hh"

    # The path to the file that will be used to populate this item.
    file = Param.String("Path to file to export")


class QemuFwCfgItemString(QemuFwCfgItem):
    type = "QemuFwCfgItemString"
    cxx_class = "gem5::qemu::FwCfgItemFactory<gem5::qemu::FwCfgItemString>"
    cxx_template_params = ["class ItemType"]
    cxx_header = "dev/qemu/fw_cfg.hh"

    # The string which directly populates this item.
    string = Param.String("String to export")


class QemuFwCfgItemBytes(QemuFwCfgItem):
    type = "QemuFwCfgItemBytes"
    cxx_class = "gem5::qemu::FwCfgItemFactory<gem5::qemu::FwCfgItemBytes>"
    cxx_template_params = ["class ItemType"]
    cxx_header = "dev/qemu/fw_cfg.hh"

    data = VectorParam.UInt8("Bytes to export")


class QemuFwCfg(PioDevice):
    type = "QemuFwCfg"
    cxx_class = "gem5::qemu::FwCfg"
    cxx_header = "dev/qemu/fw_cfg.hh"
    abstract = True

    items = VectorParam.QemuFwCfgItem(
        [], "Items exported by the firmware config device"
    )


class QemuFwCfgIo(QemuFwCfg):
    type = "QemuFwCfgIo"
    cxx_class = "gem5::qemu::FwCfgIo"
    cxx_header = "dev/qemu/fw_cfg.hh"

    # The selector register is 16 bits wide, and little endian. The data
    # register must be one port ahead of the selector.
    selector_addr = Param.Addr("IO port for the selector register")


class QemuFwCfgMmio(QemuFwCfg):
    type = "QemuFwCfgMmio"
    cxx_class = "gem5::qemu::FwCfgMmio"
    cxx_header = "dev/qemu/fw_cfg.hh"

    # The selector register is 16 bits wide, and big endian.
    selector_addr = Param.Addr("Memory address for the selector register")

    # The data register is 8, 16, 32 or 64 bits wide.
    data_addr_range = Param.AddrRange(
        "Memory address range for the data register"
    )
