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

using Antmicro.Renode.Core;
using Antmicro.Renode.Logging;
using Antmicro.Renode.Peripherals.Bus;

// All this stub does is mark an address range as always returning a fixed
// value.

namespace Antmicro.Renode.Peripherals
{
    public class AddressRangeStub : IDoubleWordPeripheral, IKnownSize
    {
        public AddressRangeStub(long size, uint value)
        {
            this.size = size;
            this.value = value;
        }

        public void Reset()
        {
        }

        public uint ReadDoubleWord(long offset)
        {
            return this.value;
        }

        public void WriteDoubleWord(long offset, uint value)
        {
        }
        public long Size { get { return this.size; } }

        long size;
        uint value;
    }
}
