{"id":345,"date":"2020-12-11T18:25:51","date_gmt":"2020-12-11T18:25:51","guid":{"rendered":"http:\/\/qedevelopment.co.uk\/?p=345"},"modified":"2020-12-11T18:25:53","modified_gmt":"2020-12-11T18:25:53","slug":"arm-processor-modes-what-are-they-and-why-are-they","status":"publish","type":"post","link":"https:\/\/qedevelopment.co.uk\/?p=345","title":{"rendered":"Arm Processor Modes: What are they and Why are they"},"content":{"rendered":"\n<p>Simple processors used to have two modes. The first would handle the everyday processing tasks, whilst the second would kick in when an interrupt occurred. The interrupt would result in the processor saving its current state and then jumping to some predefined location to service the interrupt. Modern processors are required to do much more complicated things, servicing many tasks\/programs at the same time. Keeping these tasks separate from each other and from the OS requires additional levels of privilege and hence a need for additional modes.<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_55 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<p class=\"ez-toc-title\">Table of Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-6a095463119f7\"><span class=\"\"><span style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-6a095463119f7\"  aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/qedevelopment.co.uk\/?p=345\/#User_Mode\" title=\"User Mode\">User Mode<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/qedevelopment.co.uk\/?p=345\/#System_Mode\" title=\"System Mode\">System Mode<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/qedevelopment.co.uk\/?p=345\/#Fast_Interrupt_Mode_FIQ\" title=\"Fast Interrupt Mode (FIQ)\">Fast Interrupt Mode (FIQ)<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/qedevelopment.co.uk\/?p=345\/#Normal_Interrupt_Mode_IRQ\" title=\"Normal Interrupt Mode (IRQ)\">Normal Interrupt Mode (IRQ)<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/qedevelopment.co.uk\/?p=345\/#Abort_Mode\" title=\"Abort Mode\">Abort Mode<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/qedevelopment.co.uk\/?p=345\/#Supervisor_Mode_SVC\" title=\"Supervisor Mode (SVC)\">Supervisor Mode (SVC)<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/qedevelopment.co.uk\/?p=345\/#Undefined_Mode\" title=\"Undefined Mode\">Undefined Mode<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/qedevelopment.co.uk\/?p=345\/#Monitor_Mode_MON\" title=\"Monitor Mode (MON)\">Monitor Mode (MON)<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/qedevelopment.co.uk\/?p=345\/#Hypervisor_Mode\" title=\"Hypervisor Mode\">Hypervisor Mode<\/a><\/li><\/ul><\/nav><\/div>\n<h2><span class=\"ez-toc-section\" id=\"User_Mode\"><\/span>User Mode<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>This is the default, unprivileged mode under which most processes run.<\/p>\n\n\n\n<h2><span class=\"ez-toc-section\" id=\"System_Mode\"><\/span>System Mode<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>System Mode provides a means for the exception handler to execute subroutines without the potential for further exceptions over-writing the return address stored in R14.<\/p>\n\n\n\n<h2><span class=\"ez-toc-section\" id=\"Fast_Interrupt_Mode_FIQ\"><\/span>Fast Interrupt Mode (FIQ)<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Fast Interrupt Requests are essentially higher priority interrupts which operate in a dedicated mode. FIQ mode has seven dedicated registers (R8-R14) allowing a degree os persistence between interrupts. Under Linux, which only uses IRQs, the use of this system allows the software to implement a degree of real-time code. Writing the code does however require the use of assembler because of the register restrictions.<\/p>\n\n\n\n<h2><span class=\"ez-toc-section\" id=\"Normal_Interrupt_Mode_IRQ\"><\/span>Normal Interrupt Mode (IRQ)<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>IRQ mode is entered when a regular, low priority interrupt is raised. As with all exceptions, when an IRQ occurs the processor copies the CPSR register to the mode appropriate SPSR and assigns the return address to the mode appropriate return address. The CPSR mode bits are modified as according to the new mode and the program counter is set according to an address taken from the exception vector table<\/p>\n\n\n\n<h2><span class=\"ez-toc-section\" id=\"Abort_Mode\"><\/span>Abort Mode<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Abort mode is entered after a data or instruction prefetch is aborted. This occurs as a result of an application attempting to access an illegal memory location. It is usually possible to calculate the address of the instruction that caused the exception by looking at the value of the link register (R14) and subtraction 8.<\/p>\n\n\n\n<h2><span class=\"ez-toc-section\" id=\"Supervisor_Mode_SVC\"><\/span>Supervisor Mode (SVC)<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>When code executing in user mode requires access to privileged parts of the system this is typically achieved by an SVC call and a switch to Supervisor Mode.<\/p>\n\n\n\n<h2><span class=\"ez-toc-section\" id=\"Undefined_Mode\"><\/span>Undefined Mode<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>If an unrecognised instruction is encountered the processor vectors off into undefined mode so that software emulation of co-processors or other extensions to the instruction set can be carried out.<\/p>\n\n\n\n<h2><span class=\"ez-toc-section\" id=\"Monitor_Mode_MON\"><\/span>Monitor Mode (MON)<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Monitor Mode is there to facilitate the debugging of an application without stopping the core entirely. The continued servicing of critical interrupt routines can therefore continue whilst the core is being probed by the debugger.<\/p>\n\n\n\n<h2><span class=\"ez-toc-section\" id=\"Hypervisor_Mode\"><\/span>Hypervisor Mode<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Hypervisor Mode is there to facilitate virtualization. In the same way that user-space uses the SVC instruction to switch into kernel-space (SVC mode), the processor needs to be switched into Hypervisor mode in order to make use of the virtualization extensions.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Simple processors used to have two modes. The first would handle the everyday processing tasks, whilst the second would kick in when an interrupt occurred. The interrupt would result in the processor saving its current state and then jumping to some predefined location to service the interrupt. Modern processors are required to do much more &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/qedevelopment.co.uk\/?p=345\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Arm Processor Modes: What are they and Why are they&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_mi_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0},"categories":[37,16],"tags":[36],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/qedevelopment.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/345"}],"collection":[{"href":"https:\/\/qedevelopment.co.uk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/qedevelopment.co.uk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/qedevelopment.co.uk\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/qedevelopment.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=345"}],"version-history":[{"count":5,"href":"https:\/\/qedevelopment.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/345\/revisions"}],"predecessor-version":[{"id":351,"href":"https:\/\/qedevelopment.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/345\/revisions\/351"}],"wp:attachment":[{"href":"https:\/\/qedevelopment.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=345"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/qedevelopment.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=345"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/qedevelopment.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=345"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}