Preface | p. xiii |
Introduction | p. 1 |
What is an Embedded System? | p. 1 |
What's Unique About the Design Goals for Embedded Software? | p. 3 |
What Does "Real-Time" Mean? | p. 5 |
What Does "Multitasking" Mean? | p. 6 |
How Powerful Are Embedded Processors? | p. 7 |
What Programming Languages Are Used? | p. 7 |
What Is a "Real-Time Kernel"? | p. 8 |
How Is Building an Embedded Application Unique? | p. 9 |
How Big Are Typical Embedded Programs? | p. 11 |
The Software Used in This Book | p. 12 |
Problems | p. 14 |
Data Representation | p. 15 |
Fixed-Precision Binary Numbers | p. 15 |
Positional Number Systems | p. 16 |
Binary-to-Decimal Conversion | p. 17 |
Decimal-to-Binary Conversion | p. 17 |
Counting | p. 19 |
Fixed Precision and Rollover | p. 19 |
Hexadecimal Representation | p. 20 |
Binary Representation of Integers | p. 21 |
Signed Integers | p. 21 |
Positive and Negative Representations of the Same Magnitude | p. 22 |
Interpreting the Value of a 2's-Complement Number | p. 23 |
More on Range and Overflow | p. 24 |
2's Complement and Hardware Complexity | p. 25 |
Binary Representation of Real Numbers | p. 28 |
Fixed-Point Representation | p. 28 |
Fixed-Point Using a Universal 16.16 Format | p. 30 |
Fixed-Point Using a Universal 32.32 Format | p. 32 |
Floating-Point Representation | p. 35 |
ASCII Representation of Text | p. 37 |
Binary-Coded Decimal (BCD) | p. 39 |
Problems | p. 40 |
Getting the Most Out of C | p. 43 |
Integer Data Types | p. 43 |
Mixing Data Types | p. 46 |
Useful Typedefs and Defines | p. 47 |
Manipulating Bits in Memory | p. 48 |
Testing Bits | p. 50 |
Setting, Clearing, and Inverting Bits | p. 51 |
Extracting Bits | p. 52 |
Inserting Bits | p. 52 |
Manipulating Bits in I/O Ports | p. 53 |
Write-Only I/O Ports | p. 53 |
Ports Differentiated by Reads Versus Writes | p. 54 |
Ports Differentiated by Sequential Access | p. 54 |
Ports Differentiated by Bits in the Written Data | p. 55 |
Accessing Memory-Mapped I/O Devices | p. 55 |
Accessing Data Through a Pointer | p. 55 |
Arrays, Pointers, and the "Address Of" Operator | p. 56 |
Structures | p. 58 |
Packed Structures | p. 59 |
Bit Fields | p. 60 |
Variant Access | p. 61 |
Casting the Address of an Object | p. 61 |
Using Unions | p. 63 |
Problems | p. 63 |
A Programmer's View of Computer Organization | p. 65 |
Memory | p. 65 |
The Central Processing Unit (CPU) | p. 67 |
The Arithmetic and Logic Unit (ALU) | p. 67 |
Other Registers | p. 68 |
The Control Unit | p. 69 |
Input/Output (I/O) | p. 70 |
Introduction to the Intel Architecture | p. 71 |
Instruction Formats | p. 72 |
Instruction Operands | p. 73 |
Operand Restrictions | p. 74 |
Registers | p. 75 |
The Stack | p. 77 |
The Intel Real Mode Architecture | p. 78 |
Segmented Addressing | p. 79 |
Addressing Modes | p. 81 |
The Intel Protected Mode Architecture | p. 83 |
Segment Registers and The Global Descriptor Table | p. 84 |
The Flat Memory Model | p. 85 |
Addressing Modes | p. 85 |
Operand and Address-Size Override Prefixes | p. 86 |
The Intel Data Manipulation Instructions | p. 86 |
Data Movement, Stack, and I/O Instructions | p. 87 |
Arithmetic Instructions | p. 89 |
Bitwise Instructions | p. 91 |
Shift Instructions | p. 91 |
Problems | p. 93 |
Mixing C and Assembly | p. 96 |
Programming in Assembly | p. 96 |
Register Usage Conventions | p. 98 |
Typical Use of Addressing Options | p. 98 |
Accessing Data Whose Address is a Constant | p. 99 |
Accessing Data Whose Address is a Variable | p. 100 |
Instruction Sequencing | p. 101 |
Compound Conditionals | p. 102 |
If-Then-Else Statements | p. 104 |
Building Loops | p. 105 |
Faster Loops with String Instructions | p. 106 |
Procedure Call and Return | p. 107 |
Parameter Passing | p. 108 |
Retrieving Parameters | p. 110 |
Everything is Pass by Value | p. 112 |
Temporary Variables | p. 112 |
Problems | p. 115 |
Input/Output Programming | p. 117 |
The Intel I/O Instructions | p. 118 |
Synchronization, Transfer Rate, and Latency | p. 118 |
Polled Waiting Loops | p. 119 |
Interrupt-Driven I/O | p. 121 |
The Hardware Response | p. 121 |
The Interrupt Service Routine | p. 124 |
Programmable Interrupt Controllers | p. 125 |
Buffers and Queues | p. 126 |
Writing Interrupt Service Routines in Assembly | p. 128 |
Writing Interrupt Service Routines in C | p. 129 |
Nonmaskable Interrupts | p. 130 |
Software Interrupts | p. 130 |
Exceptions | p. 132 |
Direct Memory Access | p. 132 |
Double Buffering | p. 133 |
Comparison of Methods | p. 134 |
Problems | p. 135 |
Concurrent Software | p. 138 |
Foreground/Background Systems | p. 138 |
Thread State and Serialization | p. 139 |
Managing Latency | p. 139 |
Preventing Interrupt Overrun | p. 143 |
Moving Work into the Background | p. 144 |
Multithreaded Programming | p. 145 |
Concurrent Execution of Independent Threads | p. 145 |
Context Switching | p. 146 |
Nonpreemptive (Cooperative) Multitasking | p. 147 |
Preemptive Multitasking | p. 147 |
Shared Resources and Critical Sections | p. 148 |
Disabling Interrupts | p. 150 |
Disabling Task Switching | p. 150 |
Spin Locks | p. 151 |
Mutex Objects | p. 152 |
Semaphores | p. 152 |
Problems | p. 153 |
Scheduling | p. 155 |
Thread States | p. 155 |
Pending Threads | p. 156 |
Context Switching | p. 157 |
Round-Robin Scheduling | p. 158 |
Priority-Based Scheduling | p. 159 |
Priority Inversion | p. 159 |
The Priority Inheritance Protocol | p. 160 |
The Priority Ceiling Protocol | p. 161 |
Assigning Priorities | p. 161 |
Deadline-Driven Scheduling | p. 161 |
Rate-Monotonic Scheduling | p. 162 |
Deadlock | p. 163 |
Watchdog Timers | p. 164 |
Problems | p. 166 |
Memory Management | p. 168 |
Objects in C | p. 168 |
Scope | p. 169 |
Refining Local Scope | p. 169 |
Refining Global Scope | p. 170 |
Lifetime | p. 171 |
Automatic Allocation | p. 172 |
Storage Class "Register" | p. 173 |
Static Allocation | p. 174 |
Three Programs to Distinguish Static from Automatic | p. 174 |
Object Creation | p. 175 |
Object Initialization | p. 175 |
Object Destruction | p. 176 |
Dynamic Allocation | p. 177 |
Fragmentation | p. 178 |
Memory Allocation Pools | p. 179 |
Automatic Allocation with Variable Size (alloca) | p. 179 |
Variable-Size Arrays | p. 180 |
Recursive Functions and Memory Allocation | p. 181 |
Problems | p. 182 |
Shared Memory | p. 189 |
Recognizing Shared Objects | p. 189 |
Shared Global Data | p. 190 |
Shared Private Data | p. 190 |
Shared Functions | p. 190 |
Reentrant Functions | p. 190 |
Read-Only Data | p. 191 |
Type Qualifier "const" | p. 191 |
Coding Practices to Avoid | p. 192 |
Functions That Keep Internal State in Local Static Objects | p. 192 |
Functions That Return the Address of a Local Static Object | p. 194 |
Accessing Shared Memory | p. 195 |
The Effect of Processor Word Size | p. 196 |
Read-Only and Write-Only Access | p. 197 |
Type Qualifier "volatile" | p. 198 |
Problems | p. 200 |
System Initialization | p. 203 |
Memory Layout | p. 203 |
The CPU | p. 204 |
Setting Up a Flat Memory Model | p. 204 |
Switching into Protected Mode | p. 207 |
C Run-Time Environment | p. 207 |
Copying from ROM to RAM | p. 208 |
Zeroing Uninitialized Statics | p. 208 |
Setting Up a Heap | p. 209 |
System Timer | p. 211 |
Timer 0: Timer Tick | p. 211 |
Timer 1: Memory Refresh | p. 212 |
Timer 2: Speaker Frequency | p. 212 |
Interrupt System | p. 213 |
Initializing the IDT | p. 213 |
Initializing the 8259 PICs | p. 215 |
Installing a New Interrupt Service Routine | p. 216 |
Contents of the CD-Rom | p. 219 |
The DJGPP C/C++ Compiler | p. 220 |
Installation | p. 220 |
Compilation | p. 221 |
On-Line Documentation (Info) | p. 222 |
The NASM Assembler | p. 223 |
Installation | p. 223 |
Running NASM | p. 223 |
Programming Projects | p. 225 |
Files Required from the CD-ROM for All Applications | p. 225 |
Files Required for Nonpreemptive Multithreaded Applications | p. 225 |
Files Required for Preemptive Multithreaded Applications | p. 226 |
Compiling and Assembling Your Embedded Application | p. 226 |
Linking Your Embedded Application | p. 226 |
Preparing the Boot Diskette | p. 227 |
Running Your Embedded Application | p. 227 |
Getting Started with the DJGPP Compiler Tools | p. 228 |
Using Fixed-Point Real Numbers | p. 230 |
Using Macros and Packed Operands | p. 231 |
Using "Makefiles" | p. 232 |
Coding Extended Precision Multiplication in Assembly | p. 235 |
Coding Extended Precision Division in Assembly | p. 237 |
Polled Waiting Loop and Interrupt-Driven I/O | p. 238 |
A Simple Nonpreemptive Multithreaded Application | p. 240 |
Preemptive Kernels and Shared Resources | p. 242 |
Avoiding Unbounded Priority Inversion | p. 245 |
Avoiding Deadlock | p. 246 |
The libepc Library | p. 247 |
Memory Layout and Initialization | p. 247 |
Display Functions (display.c) | p. 248 |
Window Functions (window.c) | p. 250 |
Keyboard Functions (keyboard.c) | p. 251 |
Speaker Functions (speaker.c) | p. 252 |
Timer Functions (timer.c, cycles.asm) | p. 252 |
Interrupt Vector Access Functions (init-idt.c) | p. 253 |
Dyamic Memory Allocation Functions (heap.c) | p. 254 |
Fixed Point (fixedpt.asm) | p. 254 |
Interfunction Jumps (setjmp.asm) | p. 255 |
Miscellaneous Functions (init-crt.c) | p. 256 |
The Boot Loader | p. 257 |
Index | p. 258 |
Table of Contents provided by Syndetics. All Rights Reserved. |
The New copy of this book will include any supplemental materials advertised. Please check the title of the book to determine if it should include any access cards, study guides, lab manuals, CDs, etc.
The Used, Rental and eBook copies of this book are not guaranteed to include any supplemental materials. Typically, only the book itself is included. This is true even if the title states it includes any access cards, study guides, lab manuals, CDs, etc.