/*
 * 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_cam_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_cam_ctrl_t cam_ctrl;

void _ottf_main(void) {
  uint32_t en_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_cam_ctrl_init(
      mmio_region_from_addr(TOP_MATCHA_CAM_CTRL_BASE_ADDR), &cam_ctrl));

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

  CHECK_DIF_OK(dif_cam_ctrl_set_en(&cam_ctrl), "Set CAM_CTRL failed");

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

  CHECK_DIF_OK(dif_cam_ctrl_clear_en(&cam_ctrl), "Clear CAM_CTRL failed");

  CHECK_DIF_OK(dif_cam_ctrl_read_en(&cam_ctrl, &en_result));
  CHECK(en_result == 0, "cam_ctrl is not cleared: expected : 0 | actual: %d",
        en_result);

  test_status_set(kTestStatusPassed);
}
