Пример #1
0
        private void UpdateAttributes()
        {
            // Remove XIP/RAM attrib before we work out the type...
            iAttributes &= ~TAttributes.EAttributeRAM;
            iAttributes &= ~TAttributes.EAttributeXIP;

            MemoryModel.TMemoryModelType type = MemoryModel.TypeByAddress(AddressStart);
            if (type != MemoryModel.TMemoryModelType.EMemoryModelUnknown)
            {
                MemoryModel.TMemoryModelRegion region = MemoryModel.RegionByAddress(AddressStart, type);
                //
                if (region == MemoryModel.TMemoryModelRegion.EMemoryModelRegionROM)
                {
                    iAttributes |= TAttributes.EAttributeXIP;
                }
                else if (region == MemoryModel.TMemoryModelRegion.EMemoryModelRegionRAMLoadedCode)
                {
                    iAttributes |= TAttributes.EAttributeRAM;
                }
            }
        }
Пример #2
0
        private void UpdateLengthOfPreviousSymbol(GenericSymbol aNewSymbol)
        {
            bool clearFlag = false;

            //
            if ((iFlags & TFlags.EFlagsCalculateLengthOfPreviousSymbol) == TFlags.EFlagsCalculateLengthOfPreviousSymbol)
            {
                // Must have some existing symbol.
                System.Diagnostics.Debug.Assert(Count > 0);

                // Last symbol must have bad size?
                GenericSymbol previousSymbol = InternalLastSymbol;
                System.Diagnostics.Debug.Assert(previousSymbol.Size == 0);

                // The new symbol must be exactly the same address as the last symbol
                // (in which case, the new symbol must have a valid size or else we're
                // unable to do anything sensible with it)
                //
                // OR
                //
                // The new symbol must be after the last symbol. It cannot be before.
                System.Diagnostics.Debug.Assert(aNewSymbol.Address >= previousSymbol.Address);
                if (aNewSymbol.Address == previousSymbol.Address)
                {
                    if (aNewSymbol.Size > 0)
                    {
                        // Okay, the new symbol has a valid size, the old one didn't.
                        clearFlag           = true;
                        previousSymbol.Size = aNewSymbol.Size;
                    }
                    else
                    {
                        // Hmm, neither the last or new symbol have a valid size.
                        // Nothing we can do in this case...
                    }
                }
                else
                {
                    // Need to work out the length of the previous symbol by comparing the
                    // address of this symbol against it.
                    //
                    // Only do this if the region type hasn't changed.
                    MemoryModel.TMemoryModelRegion previousType = MemoryModel.RegionByAddress(previousSymbol.Address, aNewSymbol.MemoryModelType);
                    MemoryModel.TMemoryModelRegion regionType   = MemoryModel.RegionByAddress(aNewSymbol.Address, aNewSymbol.MemoryModelType);
                    if (regionType == previousType)
                    {
                        // If this new symbol and the old symbol have the same address, then
                        // also check the size of the previous symbol. If it was zero, then discard it
                        // and keep this new entry. Otherwise, discard this new one instead.
                        long delta = aNewSymbol.Address - previousSymbol.Address;
                        if (delta > 1)
                        {
                            // It's okay, this symbol had a later address than the last one
                            // This is normal.
                            previousSymbol.Size = delta;
                        }
                        else
                        {
                            // This is not good. Two symbols both have the same address.
                            iEntries.Remove(previousSymbol);
                        }
                    }

                    clearFlag = true;
                }
            }

            if (clearFlag)
            {
                iFlags &= ~TFlags.EFlagsCalculateLengthOfPreviousSymbol;
            }
        }
Пример #3
0
        public CodeSegDefinition Resolve(CodeSegDefinition aDefinition, bool aMapFileMustExistsWhenCreatingEntry)
        {
            CodeSegDefinition ret = aDefinition;

            // ... and now try to resolve real file name on the PC side
            string realPCMapFileName = ResolveByImageCodeSegmentFileName(ret.ImageFileNameAndPath);

            if (realPCMapFileName != string.Empty)
            {
                ret.EnvironmentFileNameAndPath = realPCMapFileName;
            }
            else if (aMapFileMustExistsWhenCreatingEntry == false)
            {
                MemoryModel.TMemoryModelType   memModelType   = MemoryModel.TypeByAddress(ret.AddressStart);
                MemoryModel.TMemoryModelRegion memModelRegion = MemoryModel.RegionByAddress(ret.AddressStart, memModelType);

                // Don't cache ROM code segments
                switch (memModelRegion)
                {
                case MemoryModel.TMemoryModelRegion.EMemoryModelRegionRAMLoadedCode:
                case MemoryModel.TMemoryModelRegion.EMemoryModelRegionUserGlobalArea:
                case MemoryModel.TMemoryModelRegion.EMemoryModelRegionDLLStaticData:
                case MemoryModel.TMemoryModelRegion.EMemoryModelRegionKernelGlobalsInitialStackKernelHeap:
                case MemoryModel.TMemoryModelRegion.EMemoryModelRegionKernelCode:
                case MemoryModel.TMemoryModelRegion.EMemoryModelRegionMovingProcessData:
                case MemoryModel.TMemoryModelRegion.EMemoryModelRegionFixedProcesses:
                case MemoryModel.TMemoryModelRegion.EMemoryModelRegionUserCode:
                    System.Diagnostics.Debug.WriteLine("[WARNING] Map file for: " + ret.ImageFileNameAndPath + " was not found => creating empty MapFile for this RAM-loaded code seg.");
                    ret.EnvironmentFileNameAndPath = CreateDefaultReleaseFileName(ret.ImageFileName);
                    break;

                // Common
                case MemoryModel.TMemoryModelRegion.EMemoryModelRegionUnmapped:
                case MemoryModel.TMemoryModelRegion.EMemoryModelRegionRAMDrive:
                case MemoryModel.TMemoryModelRegion.EMemoryModelRegionSuperAndCPUPages:
                case MemoryModel.TMemoryModelRegion.EMemoryModelRegionPageTableInfo:
                case MemoryModel.TMemoryModelRegion.EMemoryModelRegionPageDirectories:
                case MemoryModel.TMemoryModelRegion.EMemoryModelRegionPageTables:
                case MemoryModel.TMemoryModelRegion.EMemoryModelRegionPrimaryIOMappings:
                case MemoryModel.TMemoryModelRegion.EMemoryModelRegionUnknown:
                case MemoryModel.TMemoryModelRegion.EMemoryModelRegionExtraKernelMappings:
                case MemoryModel.TMemoryModelRegion.EMemoryModelRegionExceptionVectors:
                case MemoryModel.TMemoryModelRegion.EMemoryModelRegionROM:

                // Moving
                case MemoryModel.TMemoryModelRegion.EMemoryModelRegionCacheFlushArea:
                case MemoryModel.TMemoryModelRegion.EMemoryModelRegionCacheFlushAreaAlternate:

                // Multiple
                case MemoryModel.TMemoryModelRegion.EMemoryModelRegionSharedData:
                case MemoryModel.TMemoryModelRegion.EMemoryModelRegionLocalData:
                case MemoryModel.TMemoryModelRegion.EMemoryModelRegionASIDInfo:
                case MemoryModel.TMemoryModelRegion.EMemoryModelRegionKernelStacks:
                    ret = null;
                    break;
                }
            }
            else
            {
                ret = null;
            }

            return(ret);
        }