Exemple #1
0
        public BusMasterDma(IdeConfig !ideConfig)
        {
            ideConfigHandle = ideConfig;

            // Set up BusMaster ports for this controller
            // <command, status, PRD table>
            commandPort = ideConfig.DmaBase.PortAtOffset(0, 1, Access.ReadWrite);
            statusPort  = ideConfig.DmaBase.PortAtOffset(2, 1, Access.ReadWrite);
            prdPort     = ideConfig.DmaBase.PortAtOffset(4, 4, Access.ReadWrite);
            // PRD needs to be 4-byte aligned and within one 4k page.
            prdRegion =
                IoMemory.AllocatePhysical(PRD_MAX_ENTRIES * PRD_BYTES_PER_ENTRY,
                                          PRD_ALIGNMENT);
        } // BusMasterInitialize
        static Mmu()
        {
            ttb = GetTTB();

            // NB Table is 1MB section and 1MB aligned to avoid modifying page table entries on
            // page containing pool of

            l2TablePool = IoMemory.AllocatePhysical(L1SectionSize, L1SectionSize);
            DebugStub.Assert(RangeIsPageAligned(l2TablePool.VirtualAddress,
                                                (uint)l2TablePool.Length,
                                                L1SectionSize));

            MaxL2Tables = L1SectionSize / L2TableSize;

            l2UsedBitmap = new uint [MaxL2Tables / 32];
        }
Exemple #3
0
        // HelloMpLoad skips several procedures to be able to
        // load HelloMp.x86 properly
        public static PEImage HelloMpLoad(Process process, IoMemory rawMemory,
                                          out IoMemory loadedMemory)
        {
            UIntPtr entryPoint = UIntPtr.Zero;

            loadedMemory = null;

            if (null == rawMemory || 0 == rawMemory.Length)
            {
                DebugStub.WriteLine("No PXE image to load!");
                return(null);
            }

            Kernel.Waypoint(580);
            Tracing.Log(Tracing.Debug, "Loading:");
            PEImage image = new PEImage(rawMemory);

            image.DumpLimitedToStream();

            Kernel.Waypoint(581);
            if (0 == image.loadedSize)
            {
                throw new BadImageFormatException("Invalid PE, no content");
            }

            try {
                // The loadedImage is current loaded to physical memory
                // directly
                loadedMemory = IoMemory.AllocatePhysical
                                   ((UIntPtr)image.loadedSize);

                Kernel.Waypoint(582);

                // Copy the header so the debugger can find it.
                IoMemory.Copy(rawMemory, 0, loadedMemory, 0,
                              (int)image.sizeOfHeaders);
                Kernel.Waypoint(583);
                // load sections into memory where they belong.
                for (int i = 0; i < image.numberOfSections; i++)
                {
                    if (image.sections[i].IsDiscardable ||
                        image.sections[i].sizeOfRawData == 0)
                    {
                        continue;
                    }
                    int  targetOffset = (int)image.sections[i].virtualAddress;
                    int  sourceOffset = (int)image.sections[i].pointerToRawData;
                    uint rawSize      = Math.Min(image.sections[i].sizeOfRawData,
                                                 image.sections[i].virtualSize);
                    IoMemory.Copy(rawMemory, sourceOffset, loadedMemory,
                                  targetOffset, (int)rawSize);
                }
                Kernel.Waypoint(584);

                int     relocationTableOffset = (int)image.GetRelocationsRaw();
                UIntPtr diff = (UIntPtr)loadedMemory.VirtualAddress -
                               (UIntPtr)image.imageBase;
                entryPoint = (UIntPtr)loadedMemory.VirtualAddress +
                             image.addressOfEntryPoint;
            }
            finally {
                if (entryPoint == UIntPtr.Zero && loadedMemory != null)
                {
                    // TODO: Need to dispose of target Range.
                    loadedMemory = null;
                }
            }
            return(image);
        }