Interrupts & Syscalls
Interrupts Interrupt : (aka Exceptions) Signal to CPU that something needs to happen Hardware Interrupts Input/output ready Ctrl-C Code needs help Trap from math overflow Request for OS
ARM Users ARM Modes Triggered by different interrupts ARMSim does not model other modes
Interrupt Handling
Interrupt Handling Interrupts complete before normal processing resumes May be interrupted by higher priorty interrupts
Interrupts ARMv7 maintains shadow registers for interrupts Avoid save/reload
Interrupts ARMv8 On Exception, processor stores Current instruction to Exception Link Register ELR Exception readon to Exception Syndrome Register ESR Then branches to known address for OS to run handler
Interrupts Vectored Interrupts: Each interrupt matched to special memory address Addresses contain addresses of Interrupt Service Routines (ISR)
Interrupts On exception Processor loads address given in vector Loads that address and sets PC to it MEMORY 0x0000 0x01A0 0x0004 0x0200 0x0008 0x04F2 0x000C 0x0500 … Code for Reset Code for SWI
ARM Linux Syscalls
Syscalls Operating system has control over hardare resources Filesystem Memory Etc…
Syscalls System Calls : Software generated exception Ask OS to do a job it can’t
Syscalls Syscalls defined by OS Linux different than Windows Way to call them defined by platform convention
ARM Linux Syscalls SWI 0 used to trigger all system calls:
ARM Linux Syscalls R7 used to specify syscall to do https://w3challs.com/syscalls/?arch=arm_thumb
Syscalls Basic system call cheat sheet:
Syscalls File Handles: Number identifying “file” File 0 is always stdin (console input) File 1 is stdout (console output) File 2 is stderr (console output but can be treated different)
Hello World Write to console:
Echo Input Read a line to buffer…
Echo Input …write it out
Real Files Open takes file name Via address to string in memory
Real Files Open returns fileHandle Number identifying opened file -1 if error Should be 3 for your first opened file Store fileHandle for use with read/write
Real Files Flags : Mode to open file in
Real Files Mode : Use 0644 - means 0 : Octal number 6 : you can read write 4 : group can read 4 : others can read
Real Files File write: