/***************************************************************************
 * Copyright (C) 2026 Eclipse ThreadX contributors
 *
 * This program and the accompanying materials are made available under the
 * terms of the MIT License which is available at
 * https://opensource.org/licenses/MIT.
 *
 * AI Disclosure: This file was largely AI-generated by Copilot (Sonnet 4.6).
 * The AI-generated portions may be considered public domain (CC0-1.0)
 * and not subject to the project's licence. The human contributor has
 * reviewed and verified that the code is correct.
 *
 * SPDX-License-Identifier: MIT and CC0-1.0
 **************************************************************************/

#ifndef MMIO_MOCK_H
#define MMIO_MOCK_H

#include <stdint.h>
#include <string.h>

#define CORE_V_MCU_MMIO_MOCK 1
#define MOCK_MMIO_SIZE 1024U

extern uint32_t mock_mmio[MOCK_MMIO_SIZE];

static inline void writew(uint32_t val, uintptr_t addr)
{
    if (addr < (uintptr_t)(MOCK_MMIO_SIZE * 4U))
    {
        mock_mmio[addr / 4U] = val;
    }
}

static inline uint32_t readw(const uintptr_t addr)
{
    if (addr < (uintptr_t)(MOCK_MMIO_SIZE * 4U))
    {
        return mock_mmio[addr / 4U];
    }

    return 0U;
}

#endif /* MMIO_MOCK_H */
