Beispiel #1
0
 /// <summary>allocate <paramref name="size"/> bytes starting at a particular address <paramref name="start"/></summary>
 /// <exception cref="ArgumentOutOfRangeException"><paramref name="start"/> is not aligned or <paramref name="size"/> is <c>0</c></exception>
 protected MemoryBlockBase(ulong start, ulong size)
 {
     if (!WaterboxUtils.Aligned(start))
     {
         throw new ArgumentOutOfRangeException(nameof(start), start, "start address must be aligned");
     }
     if (size == 0)
     {
         throw new ArgumentOutOfRangeException(nameof(size), size, "cannot create 0-length block");
     }
     Size         = WaterboxUtils.AlignUp(size);
     AddressRange = start.RangeToExclusive(start + Size);
     _pageData    = new Protection[1 + GetPage(AddressRange.EndInclusive)];
 }
Beispiel #2
0
        /// <summary>allocate <paramref name="size"/> bytes</summary>
        /// <exception cref="ArgumentOutOfRangeException"><paramref name="size"/> is not aligned or is <c>0</c></exception>
        public MemoryBlock(ulong size)
        {
            if (!WaterboxUtils.Aligned(size))
            {
                throw new ArgumentOutOfRangeException(nameof(size), size, "size must be aligned");
            }
            if (size == 0)
            {
                throw new ArgumentOutOfRangeException(nameof(size), size, "cannot create 0-length block");
            }
            Size = WaterboxUtils.AlignUp(size);

            _pal = OSTailoredCode.IsUnixHost
                                ? (IMemoryBlockPal) new MemoryBlockLinuxPal(Size)
                                : new MemoryBlockWindowsPal(Size);
            Start        = _pal !.Start;
            EndExclusive = Start + Size;
        }
Beispiel #3
0
        /// <summary>allocate <paramref name="size"/> bytes starting at a particular address <paramref name="start"/></summary>
        /// <exception cref="ArgumentOutOfRangeException"><paramref name="start"/> is not aligned or <paramref name="size"/> is <c>0</c></exception>
        public MemoryBlock(ulong start, ulong size)
        {
            if (!WaterboxUtils.Aligned(start))
            {
                throw new ArgumentOutOfRangeException(nameof(start), start, "start address must be aligned");
            }
            if (size == 0)
            {
                throw new ArgumentOutOfRangeException(nameof(size), size, "cannot create 0-length block");
            }
            Start        = start;
            Size         = WaterboxUtils.AlignUp(size);
            EndExclusive = Start + Size;
            _pageData    = new Protection[GetPage(EndExclusive - 1) + 1];

            _pal = OSTailoredCode.IsUnixHost
                                ? (IMemoryBlockPal) new MemoryBlockUnixPal(Start, Size)
                                : new MemoryBlockWindowsPal(Start, Size);
        }
Beispiel #4
0
        /// <summary>allocate <paramref name="size"/> bytes starting at a particular address <paramref name="start"/></summary>
        /// <exception cref="ArgumentOutOfRangeException"><paramref name="start"/> is not aligned or <paramref name="size"/> is <c>0</c></exception>
        public MemoryBlock(ulong start, ulong size)
        {
            if (!WaterboxUtils.Aligned(start))
            {
                throw new ArgumentOutOfRangeException(nameof(start), start, "start address must be aligned");
            }
            if (size == 0)
            {
                throw new ArgumentOutOfRangeException(nameof(size), size, "cannot create 0-length block");
            }
            if (start == 0)
            {
                throw new NotImplementedException("Start == 0 doesn't work right now, not really");
            }
            Start        = start;
            Size         = WaterboxUtils.AlignUp(size);
            EndExclusive = Start + Size;
            _pageData    = (Protection[])(object)new byte[GetPage(EndExclusive - 1) + 1];

            _pal = OSTailoredCode.IsUnixHost
                                ? (IMemoryBlockPal) new MemoryBlockLinuxPal(Start, Size)
                                : new MemoryBlockWindowsPal(Start, Size);
        }