/*
 * 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.
 */


#include "hw/top_matcha/sw/autogen/top_matcha.h"
#include "sw/device/lib/arch/device.h"
#include "sw/device/lib/dif/dif_smc_ctrl.h"
#include "sw/device/lib/dif/dif_uart.h"
#include "sw/device/lib/runtime/hart.h"
#include "sw/device/lib/runtime/log.h"
#include "sw/device/lib/runtime/print.h"
#include "sw/device/lib/testing/test_framework/check.h"
#include "sw/device/lib/testing/test_framework/ottf_test_config.h"
#include "sw/device/lib/testing/test_framework/status.h"
#include "sw/device/lib/testing/test_framework/test_util.h"

OTTF_DEFINE_TEST_CONFIG();

static dif_uart_t uart;
static dif_smc_ctrl_t smc_ctrl;

void _ottf_main(void) {
  uint32_t en_result, regwen_result;

  // Initialize the UART to enable logging for non-DV simulation platforms.
  if (kDeviceType != kDeviceSimDV) {
    init_uart(TOP_MATCHA_UART0_BASE_ADDR, &uart);
  }

  LOG_INFO("Hello Shodan!");

  // Start testing
  test_status_set(kTestStatusInTest);

  CHECK_DIF_OK(dif_smc_ctrl_init(
      mmio_region_from_addr(TOP_MATCHA_SMC_CTRL_BASE_ADDR), &smc_ctrl));

  CHECK_DIF_OK(dif_smc_ctrl_read_en(&smc_ctrl, &en_result));
  CHECK(en_result == 0, "smc_ctrl is not initilized: expected : 0 | actual: %d",
        en_result);

  CHECK_DIF_OK(dif_smc_ctrl_set_en(&smc_ctrl), "Set CTRL_EN failed");

  CHECK_DIF_OK(dif_smc_ctrl_read_en(&smc_ctrl, &en_result));
  CHECK(en_result == 1, "ctrl_en is not set: expected : 1 | actual: %d",
        en_result);

  CHECK_DIF_OK(dif_smc_ctrl_read_regwen(&smc_ctrl, &regwen_result));
  CHECK(regwen_result == 1,
        "regwen is not initialized: expected : 1 | actual: %d", regwen_result);

  CHECK_DIF_OK(dif_smc_ctrl_clear_regwen(&smc_ctrl), "Clear REGWEN failed");

  CHECK_DIF_OK(dif_smc_ctrl_read_regwen(&smc_ctrl, &regwen_result));
  CHECK(regwen_result == 0, "regwen is not cleared: expected : 0 | actual: %d",
        regwen_result);

  CHECK_DIF_OK(dif_smc_ctrl_clear_en(&smc_ctrl),
               "Clear CTRL_EN with REGWEN as 0 failed");

  CHECK_DIF_OK(dif_smc_ctrl_read_en(&smc_ctrl, &en_result));
  CHECK(en_result == 1,
        "ctrl_en should not be cleared: expected : 1 | actual: %d", en_result);

  test_status_set(kTestStatusPassed);
}
