<?xml version="1.0"?>
<!DOCTYPE riscos-prm PUBLIC "-//Gerph//DTD PRM documentation 1.03//EN"
                            "http://gerph.org/dtd/103/prm.dtd">

<riscos-prm>
<chapter title="Hardware errors (supplement for Pyromaniac)">
<section title="Technical details">
<p>
Hardware errors are returned when a component of the system can no longer operate and must return a serious failure. The error range was defined in PRM 1-43 (Generating and handling errors), and expanded upon in RISC OS Select documentation. RISC OS Pyromaniac introduces another type of erro code.
</p>

<p>
The error numbers allocated all have their top 8 bits set to &hex;80 and are reserved in groups of 256. The following groups are reserved:
</p>

<p>
    <value-table head-number='Hex error number'>
        <value number='80000000'>Machine exceptions</value>
        <value number='80000100'>Coprocessor exceptions</value>
        <value number='80000200'>Floating point exceptions</value>
        <value number='80000300'>Econet exceptions</value>
        <value number='80000400'>Reserved (due to misallocation)</value>
        <value number='80000500'>Reserved for interpreted exceptions (aborting regions in RISC OS Select)</value>
        <value number='80000600'>VFP exceptions</value>
        <value number='80000700'>RISC OS Pyromaniac exceptions</value>
    </value-table>
</p>

<p>
    Some of the machine exceptions are documented below, together with the RISC OS Pyromaniac
    exception.
</p>
</section>


<section title="Error messages">

<error-definition name="PyromaniacSynthetic"
                  number="7FFFFF"
                  description="Unallocated error number for Pyromaniac code">
<use>
    <p>
        This error is generated by RISC OS Pyromaniac when no dedicated
        error number has been allocated and an exception is returned to
        the user. It is not strictly a hardware error, but may indicate
        a more serious problem with the system than a usual error. It
        may also indicate a lazy implementation which has not been given
        a proper error number.
    </p>
</use>
<related>
</related>
</error-definition>

<error-definition name="UndefinedInstruction"
                  number="80000000"
                  description="Undefined instruction executed"
                  >
<use>
    <p>
        This error is raised when an instruction which is not recognised by the CPU,
        or which is invalid at the current privilege level, is executed.
        During the processing of the error, the enviroment register dump will be
        updated with the registers at the time of the exception.
    </p>
    <p>
        <compatibility>
            <version riscos-ge="Select 3" supplier='RISCOS Ltd'>
                On RISC OS Select if the exception occurs within a privileged mode, the
                privileged stacks will be copied to the abort stack copy dynamic area.
            </version>
        </compatibility>
    </p>
</use>
<related>
<!-- <reference type="swi" name="Module_Register" /> -->
</related>
</error-definition>


<error-definition name="InstructionAbort"
                  number="80000001"
                  description="Abort on instruction fetch">
<use>
    <p>
        This error is raised when an attempt is made to execute code in a region of
        memory which is not available at the current privilege level.
        During the processing of the error, the enviroment register dump will be
        updated with the registers at the time of the exception.
    </p>
    <p>
        <compatibility>
            <version riscos-ge="Select 3" supplier='RISCOS Ltd'>
                On RISC OS Select if the exception occurs within a privileged mode, the
                privileged stacks will be copied to the abort stack copy dynamic area.
            </version>
        </compatibility>
    </p>
</use>
<related>
    <reference type='error' name='DataAbort'/>
</related>
</error-definition>

<error-definition name="DataAbort"
                  number="80000002"
                  description="Abort on data transfer">
<use>
    <p>
        This error is raised when an attempt is made to read from or write to
        a region of memory which is not available at the current privilege level.
        During the processing of the error, the enviroment register dump will be
        updated with the registers at the time of the exception.
    </p>
    <p>
        <compatibility>
            <version riscos-ge="Select 3" supplier='RISCOS Ltd'>
                On RISC OS Select if the exception occurs within a privileged mode, the
                privileged stacks will be copied to the abort stack copy dynamic area.
            </version>
        </compatibility>
    </p>
</use>
<related>
    <reference type='error' name='InstructionAbort'/>
</related>
</error-definition>

<error-definition name="AddressException"
                  number="80000003"
                  description="Address exception">
<use>
    <p>
        This error was raised for a request for an area of memory which is
        not accessible by the system. On older systems higher regions of memory
        were not addressable by the CPU. It is no longer raised as the entire
        memory range is accessible in 32bit systems.
    </p>
    <p>
        <compatibility>
            <version riscos-ge="3.5" state='unsupported'/>
        </compatibility>
    </p>
</use>
<related>
</related>
</error-definition>

<error-definition name="UnknownIRQ"
                  number="80000004"
                  description="Unknown IRQ">
<use>
    <p>
        This error was raised went an unknown interrupt was triggered. It is
        no longer generated by the OS.
    </p>
    <p>
        <!-- I'm not completely sure that this is after 3.5, but it seems about right -->
        <compatibility>
            <version riscos-ge="3.5" state='unsupported'/>
        </compatibility>
    </p>
</use>
<related>
</related>
</error-definition>

<error-definition name="BranchThrough0"
                  number="80000005"
                  description="Branch through zero">
<use>
    <p>
        This error is generated by the OS when an attempt is made to execute
        code at address 0.
        During the processing of the error, the enviroment register dump will be
        updated with the registers at the time of the exception.
    </p>
    <p>
        <compatibility>
            <version riscos-ge="Select 3" supplier='RISCOS Ltd'>
                On RISC OS Select if the exception occurs within a privileged mode, the
                privileged stacks will be copied to the abort stack copy dynamic area.
            </version>
        </compatibility>
    </p>
</use>
<related>
    <reference type='error' name='InstructionAbort'/>
</related>
</error-definition>

<error-definition name="BTSCorruption"
                  number="80000006"
                  description="Privileged mode stack corruption">
<use>
    <p>
        This error is geneated by the OS when it detects that one of the
        privileged mode stacks (SVC or IRQ) has become corrupted in a
        way that prevents the system from reporting its backtrace
        information.
    </p>
    <p>
        <compatibility>
            <version riscos-ge="Select 3" supplier='RISCOS Ltd' state='supported'/>
        </compatibility>
    </p>
</use>
<related>
    <reference type='error' name='SVCStackCorruption'/>
</related>
</error-definition>

<error-definition name="SVCStackOverflow"
                  number="80000007"
                  description="Privileged mode stack overflow">
<use>
    <p>
        This error is generated by the OS when an access is made to the memory
        at the base of the privileged mode stack. This indicates that the stack
        has become full. Earlier versions of RISC OS would report such overflows
        as a data abort.
    </p>
    <p>
        <compatibility>
            <version riscos-ge="Select 3" supplier='RISCOS Ltd' state='supported'/>
            <version riscos-ge="7.45" supplier='RISC OS Pyromaniac' state='supported'/>
        </compatibility>
    </p>
</use>
<related>
    <reference type='error' name='PyromaniacSWIRecursionLimit'/>
</related>
</error-definition>

<error-definition name="SVCStackCorrupt"
                  number="80000008"
                  description="Privileged mode stack corrupt">
<use>
    <p>
        This error is generated by the OS when it detects that one of the
        privileged mode stacks (SVC or IRQ) has become corrupted. Examples
        of corruption might include the stack pointer being out of range,
        the stack pointer being misaligned, or guard values being
        overwritten.
    </p>
    <p>
        <compatibility>
            <version riscos-ge="Select 3" supplier='RISCOS Ltd' state='supported'/>
            <version riscos-ge="7.45" supplier='RISC OS Pyromaniac' state='supported'/>
        </compatibility>
    </p>
</use>
<related>
</related>
</error-definition>

<error-definition name="PyromaniacError"
                  number="80000700"
                  description="Pyromaniac Python exception">
<use>
    <p>
        This error is generated by the OS when an exception occurs in the
        Python code providing the implemention of the processor emulation
        or OS interfaces. The Python backtrace and exception information
        may be reported on the host console, with the exception text
        reported as the RISC OS error message.
    </p>
    <p>
        <compatibility>
            <version riscos-ge="7.09" supplier='RISC OS Pyromaniac' state='supported'/>
        </compatibility>
    </p>
</use>
<related>
</related>
</error-definition>

<error-definition name="PyromaniacSWIRecursionLimit"
                  number="80000701"
                  description="SWI call nesting limit reached">
<use>
    <p>
        This error is generated by the OS when the configured limit of
        nested SWI calls is reached. Under RISC OS Pyromaniac, a limit
        is configurable for the number of SWI calls that may be made
        within one another. This limit is intended to protect against
        very complex system calls, or infinite recursion long before
        it would be caught by the
        <reference type='error' name='SVCStackOverflow'/> error.
    </p>
    <p>
        <compatibility>
            <version riscos-ge="7.13" supplier='RISC OS Pyromaniac' state='supported'/>
        </compatibility>
    </p>
</use>
<related>
    <reference type='error' name='SVCStackOverflow'/>
</related>
</error-definition>

</section>

</chapter>

<!-- MetaData -->
<meta>
 <maintainer>
  <email name="Gerph" address="gerph@gerph.org" />
 </maintainer>
 <disclaimer>
    <p>
        &copy; Gerph, 2023.
    </p>
 </disclaimer>

 <history>
  <revision number="1" author="Gerph" date="27 Dec 2022" title="PRM-in-XML conversion">
    <change>Created from original Select documentation.</change>
    <change>Updated with information for RISC OS Pyromaniac.</change>
  </revision>
  <revision number="2" author="Gerph" date="16 Mar 2023" title="SVC stack errors">
    <change>RISC OS Pyromaniac now supports the SVC stack corruption and overflow error.</change>
  </revision>
 </history>
</meta>
</riscos-prm>
