public void SetDescription(Rn reg, AsmDudeTools asmDudeTools)
        {
            string regStr = reg.ToString();

            this.Description.Inlines.Add(new Run("Register ")
            {
                FontWeight = FontWeights.Bold, Foreground = this._foreground
            });
            this.Description.Inlines.Add(new Run(regStr)
            {
                FontWeight = FontWeights.Bold, Foreground = new SolidColorBrush(AsmDudeToolsStatic.ConvertColor(Settings.Default.SyntaxHighlighting_Register))
            });

            Arch   arch    = RegisterTools.GetArch(reg);
            string archStr = (arch == Arch.ARCH_NONE) ? "" : " [" + ArchTools.ToString(arch) + "] ";
            string descr   = asmDudeTools.Get_Description(regStr);

            if (regStr.Length > (AsmDudePackage.maxNumberOfCharsInToolTips / 2))
            {
                descr = "\n" + descr;
            }
            string full_Descr = AsmSourceTools.Linewrap(":" + archStr + descr, AsmDudePackage.maxNumberOfCharsInToolTips);

            this.Description.Inlines.Add(new Run(full_Descr)
            {
                Foreground = this._foreground
            });
        }
Exemple #2
0
        private static int Recv(Thread current, ref Arch.ExceptionRegisters regs, UserPtr ptr_label, UserPtr userBuf, uint size)
        {
            Contract.Requires(current.VBinderState.Owner == current);

            if (!current.Parent.Space.VerifyWrite(userBuf, size) || !current.Parent.Space.VerifyWrite(ptr_label, sizeof(int)))
                return -ErrorCode.EFAULT;

            var b = current.VBinderState.NoPendingMessages();
            if (b)
            {
                var entry = new VBinderCompletion(current, ptr_label, userBuf, size);
                current.VBinderState.Completion = entry;

                current.SaveState(ref regs);
                current.AsyncReturn = true;
                return 0;
            }
            else
            {
                var msg = current.VBinderState.TakeMessage();

                Contract.Assert(msg.GhostTarget == current);

                var length = msg.Length;
                ptr_label.Write(current.Parent, msg.label);
                userBuf.Write(current, new Pointer(msg.payload.Location), length);
                msg.Recycle();
                return length;
            }
        }
Exemple #3
0
		public static Arch Arch; // default: = Arch.DEVICE;

		unsafe static void InitializePlatform (ref InitializationOptions options)
		{
			if (options.IsSimulator)
				Arch = Arch.SIMULATOR;

			UIApplication.Initialize ();
		}
        public static int Access(Thread current, ref Arch.ExceptionRegisters regs, UserPtr filenamePtr, int mode)
        {
            // XXX: This is vfs related, now let's assume that we're dealing with pass through fs.

            var buf = Globals.AllocateAlignedCompletionBuffer(PATH_MAX);

            if (!buf.isValid)
                return -ErrorCode.ENOMEM;

            var ret = filenamePtr.ReadString(current, buf);

            var accessCompletion = new BridgeCompletion(current, buf);

            ret = Arch.IPCStubs.AccessAsync(current.Parent.helperPid, current.impl._value.thread._value, new Pointer(buf.Location), mode);

            if (ret < 0)
            {
                accessCompletion.Dispose();
                return ret;
            }

            Globals.CompletionQueue.Enqueue(accessCompletion);
            current.SaveState(ref regs);
            current.AsyncReturn = true;
            return 0;
        }
Exemple #5
0
 public IMetaData(Arch arch, Atlas atlas, SlotGroup slotGroup, LayerEnum layer, LoadOrder loadOrder)
 {
     this.Archetype = arch;
     this.LoadOrder = loadOrder;
     this.Atlas     = atlas;
     this.SlotGroup = slotGroup;
     this.Layer     = layer;
 }
Exemple #6
0
        /// <summary>
        /// Binds to uc_open.
        /// </summary>
        /// <param name="arch"></param>
        /// <param name="mode"></param>
        public void Open(Arch arch, Mode mode)
        {
            var err = unicorn.uc_open((uc_arch)arch, (uc_mode)mode, ref _uc);

            if (err != uc_err.UC_ERR_OK)
            {
                throw new UnicornException(err);
            }
        }
        public static Arch Arch;         // default: = Arch.DEVICE;

        unsafe static void InitializePlatform(ref InitializationOptions options)
        {
            if (options.IsSimulator)
            {
                Arch = Arch.SIMULATOR;
            }

            UIApplication.Initialize();
        }
Exemple #8
0
        bool is_excluded_target_filename(string name)
        {
            int    len = name.Length - 4;
            string str1, str2;

            var start = name.LastIndexOfAny(new[] { '\\', '/' }) + 1;

            if (start == 0)
            {
                return(true);
            }

            var span  = name.Substring(start, len - start);
            var split = span.Split('_');

            if (split.Length == 3)
            {
                str1 = split[1];
                str2 = split[2];
            }
            else if (split.Length == 2)
            {
                str1 = split[1];
                str2 = "";
            }
            else
            {
                return(false);
            }

            OS   os1   = get_os(str1);
            Arch arch1 = get_arch(str1);
            OS   os2   = get_os(str2);
            Arch arch2 = get_arch(str2);

            if (arch1 != 0 && os2 != 0)
            {
                return(arch1 != target_arch || os2 != target_os);
            }
            else if (arch2 != 0 && os1 != 0)
            {
                return(arch2 != target_arch || os1 != target_os);
            }
            else if (os1 != 0)
            {
                return(os1 != target_os);
            }
            else if (arch1 != 0)
            {
                return(arch1 != target_arch);
            }
            else
            {
                return(false);
            }
        }
 private void Button_Click_1(object sender, RoutedEventArgs e)
 {
     if (_allArchs.Count(x => x.Name == _selectedArch.Name) == 0 && !string.IsNullOrEmpty(_selectedArch.Name) && _selectedArch.Max > 0)
     {
         _selectedArch.Id = 0;
         _repo.InsertItem <Arch>(_selectedArch);
         GetAllArchs();
         _selectedArch = new Arch();
     }
 }
Exemple #10
0
        public AddressSpace(Process owner, Arch.ArchAddressSpace impl)
        {
            Contract.Ensures(GhostOwner == owner);
            Contract.Ensures(Head.GhostOwner == GhostOwner);

            this.impl = impl;
            workingSet = new TableWorkingSet();
            Head = MemoryRegion.CreateUserSpaceRegion(owner);
            this.GhostOwner = owner;
        }
Exemple #11
0
 public x86DataAllocator(IdContainer Container, bool AllocRegsLists = true)
     : base(Container.State.Arch as x86Architecture, AllocRegsLists)
 {
     this.Container     = Container;
     this.State         = Container.State;
     this.FuncScope     = Container.FunctionScope;
     this.x86CallConv   = Arch.GetCallingConvention(FuncScope.Type.CallConv);
     this.ContainerData = Container.Data.Get <x86IdContainerData>();
     this.FSData        = FuncScope.Data.Get <x86FuncScopeData>();
 }
Exemple #12
0
        public Thread Lookup(Arch.L4Handle handle)
        {
            var h = handle._value;
            var t = next;

            while (t != null && t.thr.impl._value.thread._value != h)
                t = t.next;

            return t == null ? null : t.thr;
        }
Exemple #13
0
        private Thread(Arch.ArchThread impl, Process parent)
        {
            Contract.Requires(parent != null);
            Contract.Ensures(Parent == parent);
            Contract.Ensures(VBinderState.Owner == this);

            this.impl = impl;
            this.Parent = parent;
            this.TLSArray = Arch.NativeMethods.l4api_tls_array_alloc();
            this.VBinderState = new VBinderThreadState(this);
        }
        private void InitScreenData()
        {
            DisplayDataInGrid();
            GetStatusBarDetails();
            Arch arch = new Arch();

            if (SessionParameters.UserRole != Common.UserRole.Admin)
            {
                usersToolStripMenuItem.Enabled = false;
            }
        }
Exemple #15
0
        unsafe static void InitializePlatform(InitializationOptions *options)
        {
#if !__MACCATALYST__ && !NET
            if (options->IsSimulator)
            {
                Arch = Arch.SIMULATOR;
            }
#endif

            UIApplication.Initialize();
        }
 public DefaultClientChannelInboundHandler(
     CommandProcessorManager cmdProcessorManager,
     Arch.CMessaging.Client.MetaEntity.Entity.Endpoint endpoint,
     EndpointSession endpointSession,
     DefaultEndpointClient endpointClient,
     CoreConfig config)
 {
     this.cmdProcessorManager = cmdProcessorManager;
     this.endpoint = endpoint;
     this.endpointSession = endpointSession;
     this.endpointClient = endpointClient;
     this.config = config;
 }
        private void InitScreenData()
        {
            DisplayDataInGrid();
            GetStatusBarDetails();
            Arch arch = new Arch();

            if (SessionParameters.UserRole != Common.UserRole.Admin)
            {
                usersToolStripMenuItem.Enabled = false;
            }

            labelExpenseCurrency.Text = Configurations.ApplicationConfiguration.ExpenseCCY;
        }
Exemple #18
0
        static void Init()
        {
            Console.Title = "Unity Dark Skin v1.2";
            Console.WriteLine("Choose version:");
            Console.WriteLine("* Unity.exe (32 bit): type '1'");
            Console.WriteLine("* Unity.exe (64 bit): type '2'");
            Console.Write("Your answer: ");

            ConsoleKeyInfo key = Console.ReadKey();

            switch (key.KeyChar)
            {
            case '1':
                SystemType = Arch.x86;
                break;

            case '2':
            default:
                SystemType = Arch.x64;
                break;
            }

            Console.WriteLine("\n");
            Console.WriteLine("----------");

            if (SystemType == Arch.x64)
            {
                Console.WriteLine("Choose your Unity version:");
                Console.WriteLine("* 5.0 - 2018.2: type '1'");
                Console.WriteLine("* 2018.3: type '2'");
                Console.WriteLine("* 2019.1: type '3'");
                Console.Write("Your answer: ");

                key = Console.ReadKey();
                switch (key.KeyChar)
                {
                case '1':
                    Version = UnityVersion._2018_2_AND_OLDER;
                    break;

                case '2':
                    Version = UnityVersion._2018_3;
                    break;

                case '3':
                default:
                    Version = UnityVersion._2019_1;
                    break;
                }
            }
        }
Exemple #19
0
        static IList <Arch> Parse_Archs(string str)
        {
            IList <Arch> Results = new List <Arch>();

            foreach (string s in str.Replace(",", " ").Split(' '))
            {
                Arch a = ArchTools.ParseArch(s.Trim(), false);
                if (a != Arch.NONE)
                {
                    Results.Add(a);
                }
            }
            return(Results);
        }
Exemple #20
0
        public TlBaseXML(string Filename, bool Custom) : base("xml")
        {
            XMLLoader.Load(Filename, T, Custom);

            Name = T.ToolName;
            foreach (var A in T.ControllerTypes)
            {
                Arch.Add(A);
            }
            foreach (var T in T.Tags)
            {
                Tags.Add(T);
            }
        }
 private void autoattach_Tick(object sender, EventArgs e)
 {
     Thread.Sleep(7000);
     if (Arch.isRobloxOn())
     {
         if (!dll.isArchAttached())
         {
             dll.Attach();
         }
         else
         {
             return;
         }
     }
 }
Exemple #22
0
        private void InitScreenData()
        {
            DisplayDataInGrid();
            Arch arch = new Arch();

            arch.FillDataInCombo(cmbItem, Arch.ComboBoxItem.Item);
            GetStatusBarDetails();

            if (SessionParameters.UserRole != Common.UserRole.Admin)
            {
                MENU_FILE_ADD_USER.Enabled = false;
            }

            lblExpenseCCY.Text = Configurations.ApplicationConfiguration.ExpenseCCY;
        }
Exemple #23
0
        public static int Dispatch(Thread current, ref Arch.ExceptionRegisters regs, int cmd, int arg1, int arg2, int arg3)
        {
            Contract.Requires(current != null && current.VBinderState.Owner == current);
            switch (cmd)
            {
                case VBINDER_REGISTER_CHANNEL:
                    return CreateChannel(current, arg1, arg2);
                case VBINDER_ACQUIRE_CHANNEL:
                    return AcquireChannel(current, arg1, arg2);
                case VBINDER_SEND:
                    return Send(current, arg1, new UserPtr(arg2), (uint)arg3);
                case VBINDER_RECV:
                    return Recv(current, ref regs, new UserPtr(arg1), new UserPtr(arg2), (uint)arg3);
            }

            return -ErrorCode.ENOSYS;
        }
Exemple #24
0
        x86GRegLocation AllocGRegHelper(int Size, bool OneByteVariant,
                                        x86GRegisterList CantBe = new x86GRegisterList(), bool EnableParamLocs = false)
        {
            if (Size == 1)
            {
                OneByteVariant = false;
            }

            var Mask     = new x86RegisterMask(Size);
            var HighMask = new x86RegisterMask(1, 1);

            var Sequence = x86CallConv.AllocationSequence.GRegisters;

            for (var i = 0; i < Sequence.Length; i++)
            {
                var Reg = Sequence[i];
                if (Arch.IsGRegisterExists(Reg, Mask) && IsGRegisterFree(Reg, Mask, EnableParamLocs))
                {
                    if (CantBe.Initialized && !CantBe.IsFree(Reg, Mask))
                    {
                        continue;
                    }
                    if (OneByteVariant && !Arch.IsGRegisterExists(Reg, 0, 1))
                    {
                        continue;
                    }

                    GRegisters.SetUsed(Reg, Mask);
                    return(new x86GRegLocation(Arch, Reg, Mask));
                }

                if (Size == 1 && Arch.IsGRegisterExists(Reg, HighMask) &&
                    IsGRegisterFree(Reg, HighMask, EnableParamLocs))
                {
                    if (CantBe.Initialized && !CantBe.IsFree(Reg, HighMask))
                    {
                        continue;
                    }
                    GRegisters.SetUsed(Reg, HighMask);
                    return(new x86GRegLocation(Arch, Reg, HighMask));
                }
            }

            return(null);
        }
Exemple #25
0
        private static void Init()
        {
            Console.Title = "Unity Dark Skin";
            SystemType    = Arch.x64;
            if (askForSystemVersion)
            {
                Console.WriteLine("Choose system version:");
                Console.WriteLine("Unity.exe (64 bit): type '1'");
                Console.WriteLine("Unity.exe (32 bit): type '2'");
                Console.Write("\nYour answer: ");

                ConsoleKeyInfo key = Console.ReadKey();
                switch (key.KeyChar)
                {
                case '2':
                    SystemType = Arch.x86;
                    break;

                default:
                    SystemType = Arch.x64;
                    break;
                }
            }

            UnityVersion = Version.higherThan2018_2;
            if (askForUnityVersion)
            {
                Console.WriteLine("\n\nChoose unity version:");
                Console.WriteLine("2018.3 or more: type '1'");
                Console.WriteLine("2018.2 or less: type '2'");
                Console.Write("\nYour answer: ");

                ConsoleKeyInfo key = Console.ReadKey();
                switch (key.KeyChar)
                {
                case '2':
                    UnityVersion = Version.lowerThan2018_2;
                    break;

                default:
                    UnityVersion = Version.higherThan2018_2;
                    break;
                }
            }
        }
        public bool IsCompatible()
        {
            var platform = Util.Platform;
            var arch     = Arch?.ToLowerInvariant();

            if (string.IsNullOrWhiteSpace(arch))
            {
                return(true);
            }

            return(arch switch
            {
                "osx" => platform == Platform.OSX,
                "osxArm64" => platform == Platform.OSX && Util.IsArm64,
                "win" => platform == Platform.Windows,
                "winArm64" => platform == Platform.Windows && Util.IsArm64,
                "win64" => platform == Platform.Windows && Util.Is64,
                "linux" => platform == Platform.Linux,
                _ => false
            });
        public LstManager(string iniPath, CompressedIo archive, Arch arch)
        {
            CompressedFile lstFile;

            if ((lstFile = archive.FindFile(iniPath.Replace(".ini", ".lst"))) == null)
            {
                lstFile = archive.FindFile(iniPath.Replace(".ini", "_" + arch + ".lst"));
            }

            UpdateLst = new List <LstFile>();
            string line;
            var    text = new StringReader(Encoding.Default.GetString(archive.GetFileBin(lstFile)));

            while ((line = text.ReadLine()) != null)
            {
                var lst = LstParser(line, archive, lstFile);
                lst.LstFileMetadata = lstFile;
                UpdateLst.Add(lst);
            }
        }
Exemple #28
0
        public static void Initialize(ref Arch.BootParam param)
        {
            BootParam = param;

            PageAllocator = new FreeListPageAllocator();
            PageAllocator.Initialize(param.MainMemoryStart, param.MainMemorySize >> Arch.ArchDefinition.PageShift);

            CompletionQueueAllocator = new FreeListPageAllocator();
            CompletionQueueAllocator.Initialize(param.CompletionQueueBase, param.CompletionQueueSize >> Arch.ArchDefinition.PageShift);

            Threads = ThreadList.CreateSentinal();
            FutexLists = FutexCompletionEntry.CreateSentinal();
            TimeoutQueue = new TimerQueue();
            SecurityManager = new SecurityManager();
            LinuxMemoryAllocator = new LinuxMemoryAllocator();
            CapabilityManager = new CapabilityManager();
            CompletionQueue = new CompletionQueue();

            SecureFS.Initialize(Util.StringToByteArray("ExpressOS-security", false));
            ReadBufferUnmarshaler.Initialize();
        }
Exemple #29
0
        public static string ToString(Arch arch)
        {
            switch (arch)
            {
            case Arch.ARCH_8086: return("8086");

            case Arch.ARCH_186: return("186");

            case Arch.ARCH_286: return("286");

            case Arch.ARCH_386: return("386");

            case Arch.ARCH_486: return("486");

            case Arch.ARCH_3DNOW: return("3DNOW");

            default:
                break;
            }
            return(arch.ToString());
        }
Exemple #30
0
        static void Init()
        {
            Console.Title = "Unity Dark Skin";
            Console.WriteLine("Choose version:");
            Console.WriteLine("Unity.exe (32 bit): type '1'");
            Console.WriteLine("Unity.exe (64 bit): type '2'");
            Console.Write("Your answer: ");

            ConsoleKeyInfo key = Console.ReadKey();

            switch (key.KeyChar)
            {
            case '1':
                SystemType = Arch.x86;
                break;

            case '2':
            default:
                SystemType = Arch.x64;
                break;
            }
        }
        private void Select_Prod_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var selected = SelectProd.SelectedValue.ToString().Split(' ')[1];

            switch (selected)
            {
            case "CM3D2_x86":
                _clientArch = Arch.X86;
                _reqGamever = "CM3D2.exe";
                break;

            case "CM3D2_x64":
                _clientArch = Arch.X64;
                _reqGamever = "CM3D2.exe";
                break;

            case "CM3D2OH_x86":
                _clientArch = Arch.X86;
                _reqGamever = "CM3D2OH.exe";
                break;

            case "CM3D2OH_x64":
                _clientArch = Arch.X64;
                _reqGamever = "CM3D2OH.exe";
                break;

            case "COM3D2":
                _clientArch = Arch.X64;
                _reqGamever = "COM3D2.exe";
                break;

            case "COM3D2OH":
                _clientArch = Arch.X64;
                _reqGamever = "COM3D2OH.exe";
                break;
            }
            Button_State(false);
        }
        private IList <Completion> selectedCompletions(bool useCapitals, HashSet <TokenType> selectedTypes)
        {
            IList <Completion> completions = new List <Completion>();

            foreach (string keyword in this._asmDudeTools.getKeywords())
            {
                TokenType type = this._asmDudeTools.getTokenType(keyword);
                if (selectedTypes.Contains(type))
                {
                    Arch arch     = this._asmDudeTools.getArchitecture(keyword);
                    bool selected = this.isArchSwitchedOn(arch);
                    //AsmDudeToolsStatic.Output(string.Format(CultureInfo.CurrentCulture, "INFO:{0}:AugmentCompletionSession; keyword={1}; arch={2}; selected={3}", this.ToString(), keyword, arch, selected));

                    if (selected)
                    {
                        //Debug.WriteLine("INFO: CompletionSource:AugmentCompletionSession: name keyword \"" + entry.Key + "\"");

                        // by default, the entry.Key is with capitals
                        string insertionText  = (useCapitals) ? keyword : keyword.ToLower();
                        string archStr        = (arch == Arch.NONE) ? "" : " [" + arch + "]";
                        string descriptionStr = this._asmDudeTools.getDescription(keyword);
                        descriptionStr = (descriptionStr.Length == 0) ? "" : " - " + descriptionStr;
                        //String description = keyword + archStr + descriptionStr;
                        String description = keyword.PadRight(15) + archStr.PadLeft(8) + descriptionStr;

                        ImageSource imageSource = null;
                        if (this._icons.ContainsKey(type))
                        {
                            imageSource = this._icons[type];
                        }
                        completions.Add(new Completion(description, insertionText, null, imageSource, ""));
                    }
                }
            }
            return(completions);
        }
Exemple #33
0
        public static string ToString(Arch arch)
        {
            switch (arch)
            {
            case Arch.ARCH_NONE: return("NONE");

            case Arch.ARCH_8086: return("8086");

            case Arch.ARCH_186: return("186");

            case Arch.ARCH_286: return("286");

            case Arch.ARCH_386: return("386");

            case Arch.ARCH_486: return("486");

            case Arch.ARCH_PENT: return("PENT");

            case Arch.ARCH_P6: return("P6");

            case Arch.ARCH_MMX: return("MMX");

            case Arch.ARCH_SSE: return("SSE");

            case Arch.ARCH_SSE2: return("SSE2");

            case Arch.ARCH_SSE3: return("SSE3");

            case Arch.ARCH_SSSE3: return("SSSE3");

            case Arch.ARCH_SSE4_1: return("SSE4_1");

            case Arch.ARCH_SSE4_2: return("SSE4_2");

            case Arch.ARCH_SSE4A: return("SSE4A");

            case Arch.ARCH_SSE5: return("SSE5");

            case Arch.ARCH_AVX: return("AVX");

            case Arch.ARCH_AVX2: return("AVX2");

            case Arch.ARCH_AVX512_F: return("AVX512_F");

            case Arch.ARCH_AVX512_CD: return("AVX512_CD");

            case Arch.ARCH_AVX512_ER: return("AVX512_ER");

            case Arch.ARCH_AVX512_PF: return("AVX512_PF");

            case Arch.ARCH_AVX512_BW: return("AVX512_BW");

            case Arch.ARCH_AVX512_DQ: return("AVX512_DQ");

            case Arch.ARCH_AVX512_VL: return("AVX512_VL");

            case Arch.ARCH_AVX512_IFMA: return("AVX512_IFMA");

            case Arch.ARCH_AVX512_VBMI: return("AVX512_VBMI");

            case Arch.ARCH_AVX512_VPOPCNTDQ: return("AVX512_VPOPCNTDQ");

            case Arch.ARCH_AVX512_4VNNIW: return("AVX512_4VNNIW");

            case Arch.ARCH_AVX512_4FMAPS: return("AVX512_4FMAPS");

            case Arch.ARCH_AVX512_VBMI2: return("AVX512_VBMI2");

            case Arch.ARCH_AVX512_VNNI: return("AVX512_VNNI");

            case Arch.ARCH_AVX512_BITALG: return("AVX512_BITALG");

            case Arch.ARCH_AVX512_GFNI: return("AVX512_GFNI");

            case Arch.ARCH_AVX512_VAES: return("AVX512_VAES");

            case Arch.ARCH_AVX512_VPCLMULQDQ: return("_AVX512_VPCLMULQDQ");

            case Arch.ARCH_ADX: return("ADX");

            case Arch.ARCH_AES: return("AES");

            case Arch.ARCH_BMI1: return("BMI1");

            case Arch.ARCH_BMI2: return("BMI2");

            case Arch.ARCH_F16C: return("F16C");

            case Arch.ARCH_FMA: return("FMA");

            case Arch.ARCH_FSGSBASE: return("FSGSBASE");

            case Arch.ARCH_HLE: return("HLE");

            case Arch.ARCH_INVPCID: return("INVPCID");

            case Arch.ARCH_SHA: return("SHA");

            case Arch.ARCH_RTM: return("RTM");

            case Arch.ARCH_MPX: return("MPX");

            case Arch.ARCH_PCLMULQDQ: return("PCLMULQDQ");

            case Arch.ARCH_LZCNT: return("LZCNT");

            case Arch.ARCH_PREFETCHWT1: return("PREFETCHWT1");

            case Arch.ARCH_PRFCHW: return("PRFCHW");

            case Arch.ARCH_RDPID: return("RDPID");

            case Arch.ARCH_RDRAND: return("RDRAND");

            case Arch.ARCH_RDSEED: return("RDSEED");

            case Arch.ARCH_XSAVEOPT: return("XSAVEOPT");

            case Arch.ARCH_SGX1: return("SGX1");

            case Arch.ARCH_SGX2: return("SGX2");

            case Arch.ARCH_SMX: return("SMX");

            case Arch.ARCH_CLDEMOTE: return("CLDEMOTE");

            case Arch.ARCH_MOVDIR64B: return("MOVDIR64B");

            case Arch.ARCH_MOVDIRI: return("MOVDIRI");

            case Arch.ARCH_PCONFIG: return("PCONFIG");

            case Arch.ARCH_WAITPKG: return("WAITPKG");

            case Arch.ARCH_X64: return("X64");

            case Arch.ARCH_IA64: return("IA64");

            case Arch.ARCH_UNDOC: return("UNDOC");

            case Arch.ARCH_AMD: return("AMD");

            case Arch.ARCH_TBM: return("TBM");

            case Arch.ARCH_3DNOW: return("3DNOW");

            case Arch.ARCH_CYRIX: return("CYRIX");

            case Arch.ARCH_CYRIXM: return("CYRIXM");

            case Arch.ARCH_VMX: return("VMX");

            default:
                break;
            }
            return(arch.ToString());
        }
Exemple #34
0
 internal int Write(Thread current, ref Arch.ExceptionRegisters regs, ref ByteBufferRef buf, int len)
 {
     Contract.Requires(GhostOwner == current.Parent);
     var ret = inode.Write(current, ref regs, ref buf, len, position, this);
     return ret;
 }
Exemple #35
0
    public override bool Execute()
    {
        Utils.Logger = Log;
        bool isDevice = Arch.Equals("arm64", StringComparison.InvariantCultureIgnoreCase);

        if (!File.Exists(Path.Combine(AppDir, MainLibraryFileName)))
        {
            throw new ArgumentException($"MainLibraryFileName='{MainLibraryFileName}' was not found in AppDir='{AppDir}'");
        }

        if (ProjectName.Contains(" "))
        {
            throw new ArgumentException($"ProjectName='{ProjectName}' should not contain spaces");
        }

        string[] excludes = new string[0];
        if (ExcludeFromAppDir != null)
        {
            excludes = ExcludeFromAppDir
                       .Where(i => !string.IsNullOrEmpty(i.ItemSpec))
                       .Select(i => i.ItemSpec)
                       .ToArray();
        }

        string binDir = Path.Combine(AppDir, $"bin-{ProjectName}-{Arch}");

        if (!string.IsNullOrEmpty(OutputDirectory))
        {
            binDir = OutputDirectory;
        }
        Directory.CreateDirectory(binDir);

        var assemblerFiles = new List <string>();

        foreach (ITaskItem file in Assemblies)
        {
            // use AOT files if available
            var obj = file.GetMetadata("AssemblerFile");
            if (!String.IsNullOrEmpty(obj))
            {
                assemblerFiles.Add(obj);
            }
        }

        if (isDevice && !assemblerFiles.Any())
        {
            throw new InvalidOperationException("Need list of AOT files for device builds.");
        }

        // generate modules.m
        GenerateLinkAllFile(
            assemblerFiles,
            Path.Combine(binDir, "modules.m"));

        if (GenerateXcodeProject)
        {
            XcodeProjectPath = Xcode.GenerateXCode(ProjectName, MainLibraryFileName, assemblerFiles,
                                                   AppDir, binDir, MonoRuntimeHeaders, !isDevice, UseConsoleUITemplate, NativeMainSource);

            if (BuildAppBundle)
            {
                if (isDevice && string.IsNullOrEmpty(DevTeamProvisioning))
                {
                    // DevTeamProvisioning shouldn't be empty for arm64 builds
                    Utils.LogInfo("DevTeamProvisioning is not set, BuildAppBundle step is skipped.");
                }
                else
                {
                    AppBundlePath = Xcode.BuildAppBundle(
                        Path.Combine(binDir, ProjectName, ProjectName + ".xcodeproj"),
                        Arch, Optimized, DevTeamProvisioning);
                }
            }
        }

        return(true);
    }
Exemple #36
0
 public int Ioctl(Thread current, ref Arch.ExceptionRegisters regs, int arg0, int arg1)
 {
     return inode.Ioctl(current, ref regs, arg0, arg1);
 }
Exemple #37
0
        private int HandleWriteRead(Thread current, UserPtr userBwr, ref Arch.ExceptionRegisters pt_regs)
        {
            var bwr = new binder_write_read();

            if (userBwr.Read(current, out bwr) != 0)
                return -ErrorCode.EFAULT;

            if (bwr.write_size > 0 || bwr.read_size > 0)
            {
                var ret = HandleWriteRead(current, ref pt_regs, userBwr, bwr);
                if (ret < 0)
                {
                    bwr.read_consumed = 0;
                    if (userBwr.Write(current, ref bwr) != 0)
                        return -ErrorCode.EFAULT;
                }
            }

            if (userBwr.Write(current, ref bwr) != 0)
                return -ErrorCode.EFAULT;

            return 0;
        }
Exemple #38
0
        private int HandleWriteRead(Thread current, ref Arch.ExceptionRegisters regs, UserPtr userBwr, binder_write_read bwr)
        {
            var writeBuf = bwr.write_buffer;
            var writeSize = bwr.write_size;
            var buf = Globals.AllocateAlignedCompletionBuffer(MARSHAL_BUF_PAGES * Arch.ArchDefinition.PageSize);
            if (!buf.isValid)
                return -ErrorCode.ENOMEM;

            var marshaler = new BinderIPCMarshaler(current, buf);

            if (bwr.write_consumed != 0)
            {
                Arch.Console.WriteLine("BinderINode::HandleWriteRead: write_consumed != 0");
                Utils.Panic();
            }

            var r = marshaler.Marshal(writeBuf, writeSize);
            if (r < 0)
            {
                Arch.Console.WriteLine("Marshaling error");
                Globals.CompletionQueueAllocator.FreePages(new Pointer(buf.Location), MARSHAL_BUF_PAGES);
                return -1;
            }

            sys_binder_write_desc desc;
            desc.buffer_size = marshaler.WriteCursor;
            desc.bwr_write_size = writeSize;
            desc.write_buffer = new Pointer(buf.Location);
            desc.patch_table_entries = marshaler.CurrentPatchEntry;
            desc.patch_table_offset = marshaler.PatchTableOffset;
            desc.read_consumed = 0;
            desc.write_consumed = 0;

            var binder_cp = new BinderCompletion(current, userBwr, desc, buf);

            r = Arch.IPCStubs.linux_sys_binder_write_read_async(current.Parent.helperPid, current.impl._value.thread._value, desc);

            if (r < 0)
            {
                binder_cp.Dispose();
                return r;
            }

            Globals.CompletionQueue.Enqueue(binder_cp);
            current.SaveState(ref regs);
            current.AsyncReturn = true;
            return 0;
        }
Exemple #39
0
        internal int Ioctl(Thread current, ref Arch.ExceptionRegisters regs, int arg0, int arg1)
        {
            switch (kind)
            {
                case INodeKind.BinderINodeKind:
                    return BinderINode.Ioctl(current, ref regs, (uint)arg0, new UserPtr(arg1));

                // There's no good way to figure out the type of a bindersharednode is.
                // So we have to guess a little bit..
                case INodeKind.AshmemINodeKind:
                case INodeKind.BinderSharedINodeKind:
                case INodeKind.ArchINodeKind:
                case INodeKind.SocketINodeKind:
                    return Ioctl(current, (uint)arg0, new UserPtr(arg1));
            }
            return -ErrorCode.EINVAL;
        }
Exemple #40
0
        internal int Read(Thread current, ref Arch.ExceptionRegisters regs, UserPtr userBuf, int len, uint pos, File file)
        {
            switch (kind)
            {
                case INodeKind.ArchINodeKind:
                case INodeKind.SocketINodeKind:
                    return ArchINode.ArchRead(current, ref regs, userBuf, len, pos, file);

                case INodeKind.SecureFSINodeKind:
                    return SFSINode.SFSRead(current, ref regs, userBuf, len, pos, file);
            }
            return -ErrorCode.EINVAL;
        }
Exemple #41
0
        public static int Writev(Thread current, ref Arch.ExceptionRegisters regs, int fd, UserPtr iovPtr, int iovcnt)
        {
            if (iovcnt < 0)
                return -ErrorCode.EINVAL;

            if (iovcnt == 0)
                return 0;

            var proc = current.Parent;
            var file = proc.LookupFile(fd);

            if (file == null)
                return -ErrorCode.EBADF;

            var mode = file.flags & FileFlags.ReadWriteMask;

            if (mode == FileFlags.ReadOnly)
                return -ErrorCode.EPERM;

            var iovec_buf = new byte[IOVector.Size * iovcnt];

            if (iovPtr.Read(current, iovec_buf, iovec_buf.Length) != 0)
            {
                Arch.Console.WriteLine("Cannot read iovec");
                return -ErrorCode.EFAULT;
            }

            int totalLength = 0;
            for (int i = 0; i < iovcnt; ++i)
            {
                Contract.Assert((i + 1) * IOVector.Size <= iovec_buf.Length);
                var iovec = IOVector.Deserialize(iovec_buf, i * IOVector.Size);
                totalLength += iovec.iov_len;
            }

            var buf = Globals.AllocateAlignedCompletionBuffer(totalLength);
            if (!buf.isValid)
                return -ErrorCode.ENOMEM;

            int cursor = 0;
            for (int i = 0; i < iovcnt; ++i)
            {
                Contract.Assert((i + 1) * IOVector.Size <= iovec_buf.Length);
                var iovec = IOVector.Deserialize(iovec_buf, i * IOVector.Size);

                var chunk = buf.Slice(cursor, iovec.iov_len);

                // Post condition of Slice
                Contract.Assume(chunk.Length >= iovec.iov_len);
                if (iovec.iov_base.Read(current, chunk, iovec.iov_len) != 0)
                {
                    Globals.CompletionQueueAllocator.FreePages(new Pointer(buf.Location), buf.Length >> Arch.ArchDefinition.PageShift);
                    return -ErrorCode.EFAULT;
                }

                cursor += iovec.iov_len;
            }

            int ret = file.Write(current, ref regs, ref buf, totalLength);

            if (buf.isValid)
                Globals.CompletionQueueAllocator.FreePages(new Pointer(buf.Location), buf.Length >> Arch.ArchDefinition.PageShift);
            return ret;
        }
Exemple #42
0
        public static int Write(Thread current, ref Arch.ExceptionRegisters regs, int fd, UserPtr userBuf, int len)
        {
            if (len == 0)
                return 0;

            if (len < 0)
                return -ErrorCode.EINVAL;

            var proc = current.Parent;
            var file = proc.LookupFile(fd);

            if (file == null)
                return -ErrorCode.EBADF;

            var mode = file.flags & FileFlags.ReadWriteMask;

            if (mode == FileFlags.ReadOnly)
                return -ErrorCode.EPERM;

            int ret = file.Write(current, ref regs, userBuf, len);
            return ret;
        }
Exemple #43
0
        internal int Write(Thread current, ref Arch.ExceptionRegisters regs, UserPtr userBuf, int len, uint pos, File file)
        {
            var buf = Globals.AllocateAlignedCompletionBuffer(len);

            if (!buf.isValid)
                return -ErrorCode.ENOMEM;

            var l = userBuf.Read(current, buf, len);
            var bytesToBeWritten = len - l;

            var ret = Write(current, ref regs, ref buf, bytesToBeWritten, pos, file);

            // Buffer hasn't been taken by write(), free it here
            if (buf.isValid)
                Globals.CompletionQueueAllocator.FreePages(new Pointer(buf.Location), buf.Length >> Arch.ArchDefinition.PageShift);

            return ret;
        }
Exemple #44
0
        /// <summary>
        /// Writes the schema name in JSON format
        /// </summary>
        /// <param name="writer">JSON writer</param>
        /// <param name="names">list of named schemas already written</param>
        /// <param name="encspace">enclosing namespace of the schema</param>
		internal void WriteJson(Arch.CMessaging.Client.Newtonsoft.Json.JsonTextWriter writer, SchemaNames names, string encspace)
        {
            if (null != this.Name)  // write only if not anonymous
            {
                JsonHelper.writeIfNotNullOrEmpty(writer, "name", this.Name);
                if (!String.IsNullOrEmpty(this.Space))
                    JsonHelper.writeIfNotNullOrEmpty(writer, "namespace", this.Space);
                else if (!String.IsNullOrEmpty(this.EncSpace)) // need to put enclosing name space for code generated classes
                    JsonHelper.writeIfNotNullOrEmpty(writer, "namespace", this.EncSpace);
            }
        }
Exemple #45
0
 public int Read(Thread current, ref Arch.ExceptionRegisters regs, UserPtr userBuf, int len, uint pos)
 {
     Contract.Requires(GhostOwner == current.Parent);
     var ret = inode.Read(current, ref regs, userBuf, len, pos, null);
     return ret;
 }
Exemple #46
0
        internal int Ioctl(Thread current, ref Arch.ExceptionRegisters pt_regs, uint cmd, UserPtr userBuf)
        {
            switch (cmd)
            {
                case BINDER_WRITE_READ:
                    return HandleWriteRead(current, userBuf, ref pt_regs);

                case BINDER_VERSION:
                    if (userBuf.Write(current, BINDER_CURRENT_PROTOCOL_VERSION) != 0)
                        return -ErrorCode.EINVAL;

                    return 0;

                case BINDER_SET_IDLE_TIMEOUT:
                case BINDER_SET_MAX_THREADS:
                case BINDER_SET_IDLE_PRIORITY:
                case BINDER_SET_CONTEXT_MGR:
                case BINDER_THREAD_EXIT:
                    // skipping
                    return 0;

                default:
                    return -ErrorCode.EINVAL;
            }
        }
        /// <summary>
        /// Writes the fixed schema class in JSON format
        /// </summary>
        /// <param name="writer">JSON writer</param>
        /// <param name="names">list of named schema already written</param>
        /// <param name="encspace">enclosing namespace for the fixed schema</param>
		protected internal override void WriteJsonFields(Arch.CMessaging.Client.Newtonsoft.Json.JsonTextWriter writer, SchemaNames names, string encspace)
        {
            base.WriteJsonFields(writer, names, encspace);
            writer.WritePropertyName("size");
            writer.WriteValue(this.Size);
        }
        /// <summary>
        /// Writes union schema in JSON format
        /// </summary>
        /// <param name="writer">JSON writer</param>
        /// <param name="names">list of named schemas already written</param>
        /// <param name="encspace">enclosing namespace of the schema</param>
		protected internal override void WriteJson(Arch.CMessaging.Client.Newtonsoft.Json.JsonTextWriter writer, SchemaNames names, string encspace)
        {
            writer.WriteStartArray();
            foreach (Schema schema in this.Schemas)
                schema.WriteJson(writer, names, encspace);
            writer.WriteEndArray();
        }
		public override CPPOutput CompileCPPFiles(UEBuildTarget Target, CPPEnvironment CompileEnvironment, List<FileItem> SourceFiles, string ModuleName)
		{
			if (Arches.Count == 0)
			{
				throw new BuildException("At least one architecture (armv7, x86, etc) needs to be selected in the project settings to build");
			}

			if (!bHasPrintedApiLevel)
			{
				Console.WriteLine("Compiling Native code with NDK API '{0}'", GetNdkApiLevel());
				bHasPrintedApiLevel = true;
			}

			string BaseArguments = "";

			if (CompileEnvironment.Config.PrecompiledHeaderAction != PrecompiledHeaderAction.Create)
			{
				BaseArguments += " -Werror";

			}

			// Directly added NDK files for NDK extensions
			ConditionallyAddNDKSourceFiles(SourceFiles, ModuleName);

			// Deal with dynamic modules removed by architecture
			GenerateEmptyLinkFunctionsForRemovedModules(SourceFiles, ModuleName, CompileEnvironment.Config.OutputDirectory);

			// Add preprocessor definitions to the argument list.
			foreach (string Definition in CompileEnvironment.Config.Definitions)
			{
				BaseArguments += string.Format(" -D \"{0}\"", Definition);
			}

			var BuildPlatform = UEBuildPlatform.GetBuildPlatformForCPPTargetPlatform(CompileEnvironment.Config.Target.Platform);
			var NDKRoot = Environment.GetEnvironmentVariable("NDKROOT").Replace("\\", "/");

			string BasePCHName = "";
			var PCHExtension = UEBuildPlatform.GetBuildPlatform(UnrealTargetPlatform.Android).GetBinaryExtension(UEBuildBinaryType.PrecompiledHeader);
			if (CompileEnvironment.Config.PrecompiledHeaderAction == PrecompiledHeaderAction.Include)
			{
				BasePCHName = RemoveArchName(CompileEnvironment.PrecompiledHeaderFile.AbsolutePath).Replace(PCHExtension, "");
			}

			// Create a compile action for each source file.
			CPPOutput Result = new CPPOutput();
			foreach (string Arch in Arches)
			{
				if (ShouldSkipModule(ModuleName, Arch))
				{
					continue;
				}

				foreach (string GPUArchitecture in GPUArchitectures)
				{
					// which toolchain to use
					string Arguments = GetCLArguments_Global(CompileEnvironment, Arch) + BaseArguments;

					switch (Arch)
					{
						case "-armv7": Arguments += " -DPLATFORM_64BITS=0 -DPLATFORM_ANDROID_ARM=1"; break;
						case "-arm64": Arguments += " -DPLATFORM_64BITS=1 -DPLATFORM_ANDROID_ARM64=1"; break;
						case "-x86": Arguments += " -DPLATFORM_64BITS=0 -DPLATFORM_ANDROID_X86=1"; break;
						case "-x64": Arguments += " -DPLATFORM_64BITS=1 -DPLATFORM_ANDROID_X64=1"; break;
						default: Arguments += " -DPLATFORM_64BITS=0 -DPLATFORM_ANDROID_ARM=1"; break;
					}

                    if (GPUArchitecture == "-esdeferred")
					{
						Arguments += " -DPLATFORM_ANDROIDESDEFERRED=1";
					}

					// which PCH file to include
					string PCHArguments = "";
					if (CompileEnvironment.Config.PrecompiledHeaderAction == PrecompiledHeaderAction.Include)
					{
						// Add the precompiled header file's path to the include path so Clang can find it.
						// This needs to be before the other include paths to ensure Clang uses it instead of the source header file.
						PCHArguments += string.Format(" -include \"{0}\"", InlineArchName(BasePCHName, Arch, GPUArchitecture));
					}

					// Add include paths to the argument list (filtered by architecture)
					foreach (string IncludePath in CompileEnvironment.Config.CPPIncludeInfo.SystemIncludePaths)
					{
						if (IsDirectoryForArch(IncludePath, Arch))
						{
							Arguments += string.Format(" -I\"{0}\"", IncludePath);
						}
					}
					foreach (string IncludePath in CompileEnvironment.Config.CPPIncludeInfo.IncludePaths)
					{
						if (IsDirectoryForArch(IncludePath, Arch))
						{
							Arguments += string.Format(" -I\"{0}\"", IncludePath);
						}
					}

					foreach (FileItem SourceFile in SourceFiles)
					{
						Action CompileAction = new Action(ActionType.Compile);
						string FileArguments = "";
						bool bIsPlainCFile = Path.GetExtension(SourceFile.AbsolutePath).ToUpperInvariant() == ".C";
						bool bDisableShadowWarning = false;

						// should we disable optimizations on this file?
						// @todo android - We wouldn't need this if we could disable optimizations per function (via pragma)
						bool bDisableOptimizations = false;// SourceFile.AbsolutePath.ToUpperInvariant().IndexOf("\\SLATE\\") != -1;
						if (bDisableOptimizations && CompileEnvironment.Config.Target.Configuration != CPPTargetConfiguration.Debug)
						{
							Log.TraceWarning("Disabling optimizations on {0}", SourceFile.AbsolutePath);
						}

						bDisableOptimizations = bDisableOptimizations || CompileEnvironment.Config.Target.Configuration == CPPTargetConfiguration.Debug;

						// Add C or C++ specific compiler arguments.
						if (CompileEnvironment.Config.PrecompiledHeaderAction == PrecompiledHeaderAction.Create)
						{
							FileArguments += GetCompileArguments_PCH(bDisableOptimizations);
						}
						else if (bIsPlainCFile)
						{
							FileArguments += GetCompileArguments_C(bDisableOptimizations);

							// remove shadow variable warnings for NDK files
							if (SourceFile.AbsolutePath.Replace("\\", "/").StartsWith(NDKRoot))
							{
								bDisableShadowWarning = true;
							}
						}
						else
						{
							FileArguments += GetCompileArguments_CPP(bDisableOptimizations);

							// only use PCH for .cpp files
							FileArguments += PCHArguments;
						}

						// Add the C++ source file and its included files to the prerequisite item list.
						AddPrerequisiteSourceFile(Target, BuildPlatform, CompileEnvironment, SourceFile, CompileAction.PrerequisiteItems);

						if (CompileEnvironment.Config.PrecompiledHeaderAction == PrecompiledHeaderAction.Create)
						{
							// Add the precompiled header file to the produced item list.
							FileItem PrecompiledHeaderFile = FileItem.GetItemByFileReference(
								FileReference.Combine(
									CompileEnvironment.Config.OutputDirectory,
									Path.GetFileName(InlineArchName(SourceFile.AbsolutePath, Arch, GPUArchitecture) + PCHExtension)
									)
								);

							CompileAction.ProducedItems.Add(PrecompiledHeaderFile);
							Result.PrecompiledHeaderFile = PrecompiledHeaderFile;

							// Add the parameters needed to compile the precompiled header file to the command-line.
							FileArguments += string.Format(" -o \"{0}\"", PrecompiledHeaderFile.AbsolutePath, false);
						}
						else
						{
							if (CompileEnvironment.Config.PrecompiledHeaderAction == PrecompiledHeaderAction.Include)
							{
								CompileAction.bIsUsingPCH = true;
								FileItem ArchPrecompiledHeaderFile = FileItem.GetItemByPath(InlineArchName(BasePCHName, Arch, GPUArchitecture) + PCHExtension);
								CompileAction.PrerequisiteItems.Add(ArchPrecompiledHeaderFile);
							}

							var ObjectFileExtension = UEBuildPlatform.GetBuildPlatform(UnrealTargetPlatform.Android).GetBinaryExtension(UEBuildBinaryType.Object);

							// Add the object file to the produced item list.
							FileItem ObjectFile = FileItem.GetItemByFileReference(
								FileReference.Combine(
									CompileEnvironment.Config.OutputDirectory,
									InlineArchName(Path.GetFileName(SourceFile.AbsolutePath) + ObjectFileExtension, Arch, GPUArchitecture)
									)
								);
							CompileAction.ProducedItems.Add(ObjectFile);
							Result.ObjectFiles.Add(ObjectFile);

							FileArguments += string.Format(" -o \"{0}\"", ObjectFile.AbsolutePath, false);
						}

						// Add the source file path to the command-line.
						FileArguments += string.Format(" \"{0}\"", SourceFile.AbsolutePath);

						// Build a full argument list
						string AllArguments = Arguments + FileArguments + CompileEnvironment.Config.AdditionalArguments;
						AllArguments = ActionThread.ExpandEnvironmentVariables(AllArguments);
						AllArguments = AllArguments.Replace("\\", "/");

						// Remove shadow warning for this file if requested
						if (bDisableShadowWarning)
						{
							int WarningIndex = AllArguments.IndexOf(" -Wshadow");
							if (WarningIndex > 0)
							{
								AllArguments = AllArguments.Remove(WarningIndex, 9);
							}
						}

						// Create the response file
						FileReference ResponseFileName = CompileAction.ProducedItems[0].Reference + "_" + AllArguments.GetHashCode().ToString("X") + ".response";
						string ResponseArgument = string.Format("@\"{0}\"", ResponseFile.Create(ResponseFileName, new List<string> { AllArguments }).FullName);

						CompileAction.WorkingDirectory = UnrealBuildTool.EngineSourceDirectory.FullName;
						CompileAction.CommandPath = ClangPath;
						CompileAction.CommandArguments = ResponseArgument;
						CompileAction.StatusDescription = string.Format("{0} [{1}-{2}]", Path.GetFileName(SourceFile.AbsolutePath), Arch.Replace("-", ""), GPUArchitecture.Replace("-", ""));

						// VC++ always outputs the source file name being compiled, so we don't need to emit this ourselves
						CompileAction.bShouldOutputStatusDescription = true;

						// Don't farm out creation of pre-compiled headers as it is the critical path task.
						CompileAction.bCanExecuteRemotely =
							CompileEnvironment.Config.PrecompiledHeaderAction != PrecompiledHeaderAction.Create ||
							BuildConfiguration.bAllowRemotelyCompiledPCHs;
					}
				}
			}

			return Result;
		}
Exemple #50
0
 public static int Yield(Thread current, ref Arch.ExceptionRegisters regs)
 {
     // Arch.API.l4api_thread_yield();
     return 0;
 }
Exemple #51
0
    public override bool Execute()
    {
        Utils.Logger = Log;
        bool isDevice = Arch.Equals("arm64", StringComparison.InvariantCultureIgnoreCase);

        if (isDevice && string.IsNullOrEmpty(CrossCompiler))
        {
            throw new ArgumentException("arm64 arch requires CrossCompiler");
        }

        if (!File.Exists(Path.Combine(AppDir, MainLibraryFileName)))
        {
            throw new ArgumentException($"MainLibraryFileName='{MainLibraryFileName}' was not found in AppDir='{AppDir}'");
        }

        if (ProjectName.Contains(" "))
        {
            throw new ArgumentException($"ProjectName='{ProjectName}' should not contain spaces");
        }

        if (UseLlvm && string.IsNullOrEmpty(LlvmPath))
        {
            // otherwise we might accidentally use some random llc/opt from PATH (installed with clang)
            throw new ArgumentException($"LlvmPath shoun't be empty when UseLlvm is set");
        }

        string[] excludes = new string[0];
        if (ExcludeFromAppDir != null)
        {
            excludes = ExcludeFromAppDir
                       .Where(i => !string.IsNullOrEmpty(i.ItemSpec))
                       .Select(i => i.ItemSpec)
                       .ToArray();
        }
        string[] libsToAot = Directory.GetFiles(AppDir, "*.dll")
                             .Where(f => !excludes.Contains(Path.GetFileName(f)))
                             .ToArray();

        string binDir = Path.Combine(AppDir, $"bin-{ProjectName}-{Arch}");

        if (!string.IsNullOrEmpty(OutputDirectory))
        {
            binDir = OutputDirectory;
        }
        Directory.CreateDirectory(binDir);

        // run AOT compilation only for devices
        if (isDevice)
        {
            if (string.IsNullOrEmpty(CrossCompiler))
            {
                throw new InvalidOperationException("cross-compiler is not set");
            }

            AotCompiler.PrecompileLibraries(CrossCompiler, Arch, !DisableParallelAot, binDir, libsToAot,
                                            new Dictionary <string, string> {
                { "MONO_PATH", AppDir }
            },
                                            Optimized, UseLlvm, LlvmPath);
        }

        // generate modules.m
        AotCompiler.GenerateLinkAllFile(
            Directory.GetFiles(binDir, "*.dll.o"),
            Path.Combine(binDir, "modules.m"));

        if (GenerateXcodeProject)
        {
            XcodeProjectPath = Xcode.GenerateXCode(ProjectName, MainLibraryFileName,
                                                   AppDir, binDir, MonoRuntimeHeaders, !isDevice, UseConsoleUITemplate, NativeMainSource);

            if (BuildAppBundle)
            {
                if (isDevice && string.IsNullOrEmpty(DevTeamProvisioning))
                {
                    // DevTeamProvisioning shouldn't be empty for arm64 builds
                    Utils.LogInfo("DevTeamProvisioning is not set, BuildAppBundle step is skipped.");
                }
                else
                {
                    AppBundlePath = Xcode.BuildAppBundle(
                        Path.Combine(binDir, ProjectName, ProjectName + ".xcodeproj"),
                        Arch, Optimized, DevTeamProvisioning);
                }
            }
        }

        return(true);
    }
        public static IEnumerable<string> GetSymbols(string deviceName, Arch arch)
        {
            var deviceSymbol = GetDeviceNameMacro(deviceName);

            var symbols = new List<string>() {deviceSymbol};

            if (arch == Arch.AVR)
                symbols.AddRange(avr8CommonCompilerDefinedSymbols);

            return symbols;
        }
    public override bool Execute()
    {
        Utils.Logger = Log;
        bool isDevice = Arch.Equals("arm64", StringComparison.InvariantCultureIgnoreCase) && TargetOS != TargetNames.MacCatalyst;

        if (!File.Exists(Path.Combine(AppDir, MainLibraryFileName)))
        {
            throw new ArgumentException($"MainLibraryFileName='{MainLibraryFileName}' was not found in AppDir='{AppDir}'");
        }

        if (ProjectName.Contains(" "))
        {
            throw new ArgumentException($"ProjectName='{ProjectName}' should not contain spaces");
        }

        string[] excludes = Array.Empty <string>();
        if (ExcludeFromAppDir != null)
        {
            excludes = ExcludeFromAppDir
                       .Where(i => !string.IsNullOrEmpty(i.ItemSpec))
                       .Select(i => i.ItemSpec)
                       .ToArray();
        }

        string binDir = Path.Combine(AppDir, $"bin-{ProjectName}-{Arch}");

        if (!string.IsNullOrEmpty(OutputDirectory))
        {
            binDir = OutputDirectory;
        }
        Directory.CreateDirectory(binDir);

        var assemblerFiles = new List <string>();

        foreach (ITaskItem file in Assemblies)
        {
            // use AOT files if available
            var obj = file.GetMetadata("AssemblerFile");
            if (!string.IsNullOrEmpty(obj))
            {
                assemblerFiles.Add(obj);
            }
        }

        if (((!ForceInterpreter && (isDevice || ForceAOT)) && !assemblerFiles.Any()))
        {
            throw new InvalidOperationException("Need list of AOT files for device builds.");
        }

        if (ForceInterpreter && ForceAOT)
        {
            throw new InvalidOperationException("Interpreter and AOT cannot be enabled at the same time");
        }

        if (GenerateXcodeProject)
        {
            Xcode generator = new Xcode(TargetOS);
            generator.EnableRuntimeLogging = EnableRuntimeLogging;

            XcodeProjectPath = generator.GenerateXCode(ProjectName, MainLibraryFileName, assemblerFiles,
                                                       AppDir, binDir, MonoRuntimeHeaders, !isDevice, UseConsoleUITemplate, ForceAOT, ForceInterpreter, InvariantGlobalization, Optimized, NativeMainSource);

            if (BuildAppBundle)
            {
                if (isDevice && string.IsNullOrEmpty(DevTeamProvisioning))
                {
                    // DevTeamProvisioning shouldn't be empty for arm64 builds
                    Utils.LogInfo("DevTeamProvisioning is not set, BuildAppBundle step is skipped.");
                }
                else
                {
                    AppBundlePath = generator.BuildAppBundle(XcodeProjectPath, Arch, Optimized, DevTeamProvisioning);
                }
            }
        }

        return(true);
    }
Exemple #54
0
        public static int Nanosleep(Thread current, ref Arch.ExceptionRegisters regs, UserPtr rqtp, UserPtr rmtp)
        {
            timespec ts;
            timespec trem;

            trem.tv_sec = 0;
            trem.tv_nsec = 0;

            if (rqtp.Read(current, out ts) != 0 || rmtp.Write(current, ref trem) != 0)
                return -ErrorCode.EFAULT;

            Globals.TimeoutQueue.Enqueue(ts.ToMilliseconds(), current);
            var c = new SleepCompletion(current);

            Globals.CompletionQueue.Enqueue(c);
            current.SaveState(ref regs);
            current.AsyncReturn = true;
            return 0;
        }
Exemple #55
0
        public static string ArchDocumentation(Arch arch)
        {
            switch (arch)
            {
            case Arch.ARCH_NONE: return("");

            case Arch.ARCH_8086: return("");

            case Arch.ARCH_186: return("");

            case Arch.ARCH_286: return("");

            case Arch.ARCH_386: return("");

            case Arch.ARCH_486: return("");

            case Arch.ARCH_PENT: return("Instruction set of the Pentium, 1994 (also known as i585)");

            case Arch.ARCH_P6: return("Instruction set of the Pentium 6, 1995 (also knows as i686)");

            case Arch.ARCH_MMX: return("");

            case Arch.ARCH_SSE: return("");

            case Arch.ARCH_SSE2: return("");

            case Arch.ARCH_SSE3: return("");

            case Arch.ARCH_SSSE3: return("");

            case Arch.ARCH_SSE4_1: return("");

            case Arch.ARCH_SSE4_2: return("");

            case Arch.ARCH_SSE4A: return("Instruction set SSE4A, AMD");

            case Arch.ARCH_SSE5: return("Instruction set SSE5, AMD");

            case Arch.ARCH_AVX: return("");

            case Arch.ARCH_AVX2: return("");

            case Arch.ARCH_AVX512_F: return("AVX512-F - Foundation");

            case Arch.ARCH_AVX512_CD: return("AVX512-CD - Conflict Detection");

            case Arch.ARCH_AVX512_ER: return("AVX512-ER - Exponential and Reciprocal");

            case Arch.ARCH_AVX512_PF: return("AVX512-PF - Prefetch");

            case Arch.ARCH_AVX512_BW: return("AVX512-BW - Byte and Word");

            case Arch.ARCH_AVX512_DQ: return("AVX512-DQ - Doubleword and QuadWord");

            case Arch.ARCH_AVX512_VL: return("AVX512-VL - Vector Length Extensions");

            case Arch.ARCH_AVX512_IFMA: return("AVX512-IFMA - Integer Fused Multiply Add");

            case Arch.ARCH_AVX512_VBMI: return("AVX512-VBMI - Vector Byte Manipulation Instructions");

            case Arch.ARCH_AVX512_VPOPCNTDQ: return("AVX512-VPOPCNTDQ - Vector Population Count instructions for Dwords and Qwords");

            case Arch.ARCH_AVX512_4VNNIW: return("AVX512-4VNNIW - Vector Neural Network Instructions Word variable precision");

            case Arch.ARCH_AVX512_4FMAPS: return("AVX512-4FMAPS - Fused Multiply Accumulation Packed Single precision");

            case Arch.ARCH_ADX: return("Multi-Precision Add-Carry Instruction Extension");

            case Arch.ARCH_AES: return("Advanced Encryption Standard Extension");

            case Arch.ARCH_VMX: return("Virtual Machine Extension");

            case Arch.ARCH_BMI1: return("Bit Manipulation Instruction Set 1");

            case Arch.ARCH_BMI2: return("Bit Manipulation Instruction Set 2");

            case Arch.ARCH_F16C: return("Half Precision Floating Point Conversion Instructions");

            case Arch.ARCH_FMA: return("Fused Multiply-Add Instructions");

            case Arch.ARCH_FSGSBASE: return("");

            case Arch.ARCH_HLE: return("Hardware Lock Elision Instructions");

            case Arch.ARCH_INVPCID: return("Invalidate Translation Lookaside Buffers (TLBs)");

            case Arch.ARCH_SHA: return("Secure Hash Algorithm Extensions");

            case Arch.ARCH_RTM: return("Transactional Synchronization Extensions");

            case Arch.ARCH_MPX: return("Memory Protection Extensions");

            case Arch.ARCH_PCLMULQDQ: return("Carry-Less Multiplication Instructions");

            case Arch.ARCH_LZCNT: return("");

            case Arch.ARCH_PREFETCHWT1: return("");

            case Arch.ARCH_PRFCHW: return("");

            case Arch.ARCH_RDPID: return("Read processor ID");

            case Arch.ARCH_RDRAND: return("Read random number");

            case Arch.ARCH_RDSEED: return("Reed random seed");

            case Arch.ARCH_XSAVEOPT: return("Save Processor Extended States Optimized");

            case Arch.ARCH_X64: return("64-bit Mode Instructions");

            case Arch.ARCH_IA64: return("Intel Architecture 64");

            case Arch.ARCH_UNDOC: return("Undocumented Instructions");

            case Arch.ARCH_AMD: return("AMD");

            case Arch.ARCH_TBM: return("Trailing Bit Manipulation (AMD)");

            case Arch.ARCH_3DNOW: return("3DNow (AMD)");

            case Arch.ARCH_CYRIX: return("Cyrix Instructions Set");

            case Arch.ARCH_CYRIXM: return("Cyrix M Instruction Set");

            case Arch.ARCH_CLDEMOTE: return("");

            case Arch.ARCH_MOVDIR64B: return("");

            case Arch.ARCH_MOVDIRI: return("");

            case Arch.ARCH_PCONFIG: return("");

            case Arch.ARCH_WAITPKG: return("");

            default:
                return("");
            }
        }
Exemple #56
0
        /// <summary>
        /// Writes map schema in JSON format
        /// </summary>
        /// <param name="writer">JSON writer</param>
        /// <param name="names">list of named schemas already written</param>
        /// <param name="encspace">enclosing namespace of the map schema</param>
		protected internal override void WriteJsonFields(Arch.CMessaging.Client.Newtonsoft.Json.JsonTextWriter writer, SchemaNames names, string encspace)
        {
            writer.WritePropertyName("values");
            ValueSchema.WriteJson(writer, names, encspace);
        }
Exemple #57
0
        public static int Ioctl(Thread current, ref Arch.ExceptionRegisters regs, int fd, int arg0, int arg1)
        {
            Contract.Requires(current.Parent != null);

            var proc = current.Parent;
            var file = proc.LookupFile(fd);

            if (file == null)
            {
                Arch.Console.Write("Ioctl: invalid fd=");
                Arch.Console.Write(fd);
                Arch.Console.WriteLine();
                return -ErrorCode.EBADF;
            }

            return file.Ioctl(current, ref regs, arg0, arg1);
        }
Exemple #58
0
        /*
         * Write a segment buffer.
         *
         * The buffer itself is passed as a reference, because some inode might take the ownership
         * of the buffer and put it as a part of its completion. In this case the buf is set to empty
         */
        internal int Write(Thread current, ref Arch.ExceptionRegisters regs, ref ByteBufferRef buf, int len, uint pos, File file)
        {
            switch (kind)
            {
                case INodeKind.ConsoleINodeKind:
                    {
                        uint dummy = 0;
                        return ConsoleINode.WriteImpl(current, buf, len, ref dummy);
                    }
                case INodeKind.ArchINodeKind:
                case INodeKind.SocketINodeKind:
                    return ArchINode.ArchWrite(current, ref regs, ref buf, len, pos, file);

                case INodeKind.SecureFSINodeKind:
                    return SFSINode.SFSWrite(current, ref regs, buf, len, pos, file);
            }
            return -ErrorCode.EINVAL;
        }
        private bool isArchSwitchedOn(Arch arch)
        {
            if (false)
            {
                switch (arch)
                {
                case Arch.X86: return(this._package.OptionsPageCodeCompletion._x86);

                case Arch.I686: return(this._package.OptionsPageCodeCompletion._i686);

                case Arch.MMX: return(this._package.OptionsPageCodeCompletion._mmx);

                case Arch.SSE: return(this._package.OptionsPageCodeCompletion._sse);

                case Arch.SSE2: return(this._package.OptionsPageCodeCompletion._sse2);

                case Arch.SSE3: return(this._package.OptionsPageCodeCompletion._sse3);

                case Arch.SSSE3: return(this._package.OptionsPageCodeCompletion._ssse3);

                case Arch.SSE41: return(this._package.OptionsPageCodeCompletion._sse41);

                case Arch.SSE42: return(this._package.OptionsPageCodeCompletion._sse42);

                case Arch.AVX: return(this._package.OptionsPageCodeCompletion._avx);

                case Arch.AVX2: return(this._package.OptionsPageCodeCompletion._avx2);

                case Arch.KNC: return(this._package.OptionsPageCodeCompletion._knc);

                case Arch.NONE: return(true);

                default:
                    Debug.WriteLine(string.Format(CultureInfo.CurrentCulture, "INFO:isArchSwitchedOn; unsupported arch {0}", arch));
                    return(true);
                }
            }
            else
            {
                switch (arch)
                {
                case Arch.X86: return(Settings.Default.CodeCompletion_x86);

                case Arch.I686: return(Settings.Default.CodeCompletion_x86);

                case Arch.MMX: return(Settings.Default.CodeCompletion_mmx);

                case Arch.SSE: return(Settings.Default.CodeCompletion_sse);

                case Arch.SSE2: return(Settings.Default.CodeCompletion_sse2);

                case Arch.SSE3: return(Settings.Default.CodeCompletion_sse3);

                case Arch.SSSE3: return(Settings.Default.CodeCompletion_ssse3);

                case Arch.SSE41: return(Settings.Default.CodeCompletion_sse41);

                case Arch.SSE42: return(Settings.Default.CodeCompletion_sse42);

                case Arch.AVX: return(Settings.Default.CodeCompletion_avx);

                case Arch.AVX2: return(Settings.Default.CodeCompletion_avx2);

                case Arch.KNC: return(Settings.Default.CodeCompletion_knc);

                case Arch.NONE: return(true);

                default:
                    Debug.WriteLine(string.Format(CultureInfo.CurrentCulture, "INFO:isArchSwitchedOn; unsupported arch {0}", arch));
                    return(true);
                }
            }
        }
Exemple #60
0
        public static int Open(Thread current, ref Arch.ExceptionRegisters regs, UserPtr filenamePtr, int flags, int mode)
        {
            // TODO: Deal with current path
            var filenameBuf = new byte[PATH_MAX];
            var ret = filenamePtr.ReadString(current, filenameBuf);

            var proc = current.Parent;
            int fd = 0;
            GenericINode inode = null;

            var startTime = Arch.NativeMethods.l4api_get_system_clock();

            if (Util.ByteStringCompare(filenameBuf, IPCFilename.GetByteString()) == 0)
            {
                fd = proc.GetUnusedFd();
                inode = BinderINode.Instance;
            }
            else if (Util.ByteStringCompare(filenameBuf, AshmemFileName.GetByteString()) == 0)
            {
                var linux_fd = Arch.ArchFS.OpenAndReturnLinuxFd(current.Parent.helperPid, new ASCIIString(filenameBuf), flags, mode);
                if (linux_fd < 0)
                    return linux_fd;

                inode = new AshmemINode(linux_fd, current.Parent.helperPid);
                fd = proc.GetUnusedFd();
            }
            else if (SecureFS.IsSecureFS(current, filenameBuf))
            {
                var completion = SecureFS.OpenAndReadPagesAsync(current, filenameBuf, flags, mode);
                if (completion == null)
                    return -ErrorCode.ENOMEM;

                Globals.CompletionQueue.Enqueue(completion);
                current.SaveState(ref regs);
                current.AsyncReturn = true;
                return 0;
            }
            else
            {
                var filename_len = ret;

                var completion = Arch.ArchFS.OpenAndGetSizeAsync(current, filenameBuf, flags, mode);
                if (completion == null)
                    return -ErrorCode.ENOMEM;

                Globals.CompletionQueue.Enqueue(completion);
                current.SaveState(ref regs);
                current.AsyncReturn = true;
                return 0;
            }

            if (fd > 0)
            {
                var file = new File(proc, inode, flags, mode);
                proc.InstallFd(fd, file);
            }

            if (SyscallProfiler.Enable)
            {
                var endTime = Arch.NativeMethods.l4api_get_system_clock();
                SyscallProfiler.AccountOpen((int)inode.kind, (long)(endTime - startTime));
            }

            return fd;
        }