Basic Interrupt Stack Design and Implementation
Basic Interrupt Stack Design and Implementation
Implementation
Exception Handlers and Stack Design in ARM-Based Systems
1. Location:
The stack's location in the memory map must be
determined.
ARM-based systems typically have a stack that descends
downwards, starting from a high memory address and growing
towards lower addresses.
2.Stack Size:
The size of the stack depends on the type of interrupt
handler.
Nested interrupt handlers require more memory because
the stack grows with each nested interrupt.
Preventing Stack Overflow
A well-designed stack should prevent stack overflow, which can
lead to system instability. Two main software techniques are
used to detect and handle overflow:
• Two typical memory layouts for stacks in a linear address space are
shown in Figure 9.6:
1. Layout A:
- The interrupt stack is located underneath the code segment.
- This traditional layout has the potential risk of corrupting the vector
table in the event of a stack overflow.
2. Layout B:
- The interrupt stack is placed at the top of memory, above the user
stack.
- The main advantage of this layout is that it prevents the corruption
of the vector table during a stack overflow, giving the system a
chance to recover
Firmware
• Definition: Firmware is the deeply embedded, low-
level software that provides an interface between the
hardware and the application or operating system
level software.
• It resides in the ROM and executes when power is
applied to the embedded hardware system.
• Firmware can remain active after system
initialization to support basic system operations.
Functionality
• Provides a stable mechanism to load and boot an
operating system.
• Ensures the platform is correctly initialized,
including configuring system registers and setting
up the memory map.
• Identifies and discovers the exact core and platform
it is operating on, typically by reading specific
registers or peripherals.
Bootloader
1. System Initialization:
- Sets up the target platform and processor core.
- Can be simple or complex depending on the platform.
3. LED Support:
- Controls LEDs for simple user feedback and operational status
display.
4. Timer Support:
- Sets up periodic interrupts, essential for preemptive context-
switching operating systems.
5. Interrupt Controllers:
- Supports various interrupt controllers.
μHAL CLI and Boot Monitor
-μHAL includes a command-line interface (CLI) for
interacting with the boot monitor.
- Setting breakpoints.
1. SWI Instructions:
- Provides APIs for programs to open,
read, and write to a host filing system.
2. IRQ/FIQ Interrupts:
- Used for communication with the host
debugger.
3. Host Debugger Control:
- All controls are managed through the
host debugger, requiring access to the SWI,
IRQ, or FIQ vectors.
Key Features of RedBoot
1. Communication:
-Serial Communication: Uses the X-Modem
protocol to communicate with GDB over a
serial connection.
-Ethernet Communication: Utilizes TCP to
communicate with GDB over Ethernet.
- Network Standards: Supports bootp, telnet,
and tftp, enabling versatile network
communication options.
. Flash ROM Memory Management:
- Code:
```assembly
sandstone_init1
LDR r3, =SYSCFG ; where SYSCFG=0x03ff0000
LDR r4, =0x03ffffa0
STR r4, [r3]
```
Step 3: Remap Memory
• Initial Memory State: • ```assembly
• - Flash ROM: 0x00000000 - • LDR r14, =sandstone_init2
0x00080000 (512K) • LDR r4, =0x01800000 ; new
• - SRAM bank 0: Unavailable flash ROM location
(256K) • ADD r14, r14, r4
• - SRAM bank 1: Unavailable • ADRL r0,
(256K) memorymaptable_str
• - **New Memory State**: • LDMIA r0, {r1-r12}
• - Flash ROM: 0x01800000 - • LDR r0, =EXTDBWTH ;
0x01880000 (512K) =(SYSCFG + 0x3010)
• - SRAM bank 0: 0x00000000 • STMIA r0, {r1-r12}
- 0x00040000 (256K) • MOV pc, r14 ; jump to
• - SRAM bank 1: 0x00040000 remapped memory
- 0x00080000 (256K) • sandstone_init2
• -Code:
Step 4: Initialize Communication
Hardware
• Settings: 9600 baud, no parity, one stop bit, no flow
control.
• Banner:
• ```
• Sandstone Firmware (0.01)
• - platform ......... e7t
• - status ........... alive
• - memory ........... remapped
• + booting payload ...
• ```
Step 5: Bootloader—Copy Payload
and Relinquish Control
• - **Code**: • BLT _copy
• ```assembly • MOV pc,#0
• sandstone_load_and_boot • payload_start_address
• MOV r13,#0 ; destination addr • DCD startAddress
• LDR • payload_end_address
r12,payload_start_address ; start • DCD endAddress
addr • ```
• LDR r14,payload_end_address ; •
end addr
• This sequence ensures the
• _copy payload is loaded into SRAM and
• LDMIA r12!,{r0-r11} executed, completing the boot
• STMIA r13!,{r0-r11} process.
• CMP r12,r14
MODULE -5
CACHES
• Cache policies are essential to the efficient
operation of a cache memory system.
• They determine how data is managed within
the cache, particularly when the cache is
full and new data needs to be brought in.
• There are primarily three types of cache
policies:
– Cache Replacement Policy
– Write Policy
– Allocation Policy
1. Cache Replacement Policy
• Processor Core: The heart of the system, containing the register file
for immediate data access.
• Chip Level:
– Tightly Coupled Memory (TCM): High-speed memory directly accessible by
the processor core.
– Level 1 Cache (L1 Cache): Small, fast cache for storing frequently accessed
data and instructions.
– Write Buffer: Temporary storage for data to be written to main memory,
improving write performance.
• Board Level:
– SRAM: Fast static random access memory.
– DRAM: Main system memory, slower than SRAM but larger in capacity.
– Flash Memory: Non-volatile memory for storing data persistently.
• Device Level:
– Secondary Storage: Slower, larger capacity storage like hard drives, SSDs,
and optical drives.
Key Concepts