Upload
joann
View
46
Download
0
Embed Size (px)
DESCRIPTION
COM509 Computer Systems. Lecture 1. Embedded Systems vs General-Purpose Systems. Prof. Taeweon Suh Computer Science Education Korea University. Embedded Systems. Embedded System is a special-purpose computer system designed to perform one or a few dedicated functions -- Wikipedia - PowerPoint PPT Presentation
Citation preview
Lecture 1. Embedded Systems vs General-Purpose Systems
Prof. Taeweon SuhComputer Science Education
Korea University
COM509 Computer Systems
Korea Univ
Embedded Systems
• Embedded System is a special-purpose computer system designed to perform one or a few dedicated functions -- Wikipedia In general, it does not provide
programmability to users, as opposed to general purpose computer systems like PC
Embedded systems are virtually everywhere in your daily life
2
Korea Univ
iPhone Generations
3http://en.wikipedia.org/wiki/History_of_the_iPhone
Original iPhone(iPhone 2G)
June 2007
iPhone 3G
June 2008
http://apple.wikia.com/wiki/IPhone_3G
iPhone 3GS
June 2009
iPhone 4
June 2010
Oct. 2011
iPhone 4SiPhone 5
Sep. 2012
iPhone 5siPhone 5c
Sep. 2013
Korea Univ
Galaxy S Series
4http://phandroid.com/2012/07/17/samsung-galaxy-s-blaze-4g-gets-quick-maintenance-upgrade/http://www.phonearena.com/news/Is-Android-4.2.2-the-end-of-the-line-for-the-Samsung-Galaxy-S-II-and-Samsung-GALAXY-Note_id41162
Galaxy SAndroid 2.3.6Single-core Cortex A8
June 2010
Galaxy S3Android 4.0.4 Ice Cream Sandwich Dual-core Cortex A9
May 2012
Galaxy S2Android 2.3 Gingerbread Dual-core Cortex A9
May 2011
Galaxy S4Android 4.2.2 Jelly Bean(Quad-core Cortex A15 & Quad-core Cortex-A7) or Quad-core Krait 300 (Qualcomm Snapdragon)
April 2013
Galaxy S5
Korea Univ
Smartphone War
5http://www.sleetherz.com/2011/10/smartphone-war-in-fatal-three-way-iphone-4s-vs-droid-razr-vs-galaxy-nexus/
Korea Univ
Embedded Systems (Cont)
• Even though embedded systems cover a wide range of special-purpose systems, there are common characteristics Low cost
• Should be cheap to be competitive Memory is typically very small compared
to a general purpose computer system Lightweight processors are used in
embedded systems
Low power• Should consume low power especially in
case of portable devices• Low-power processors are used in
embedded systems
6
Korea Univ
Embedded Systems (Cont)
High performance• Should meet the computing
requirements of applications Users want to watch video on portable
devices• Audio should be in sync with video
Gaming gadgets like playstation should provide high performance
Real-time property• Job should be done within a time limit
Aerospace applications, Car control systems, Medical gadgets are critical in terms of time constraint – Otherwise, it could lead to catastrophe such as loss of life
• Will talk more about this
7
Korea Univ
Embedded Systems (Cont)
• It is challenging to satisfy the characteristics You may not be able to achieve high
performance while utilizing cheap components and maintaining low power consumption
So, you got to do your best in a given circumstance to be competitive in the market
8
Korea Univ
HW/SW Stack of Embedded Systems
• Identical to the general computer systems
9
OS / Device Drivers
Hardware
Application Software
Korea Univ
iPhone 4 Teardown
10
http://news.cnet.com/8301-13924_3-20006904-64.html
http://www.ifixit.com/Teardown/iPhone-4-Teardown/3130/1
GSM (Global System for Mobile communications): 2G, 3G, 4G ..UMTS (Universal Mobile Telecommunications Systems): one of 3G technologies being developed into 4G
http://www.pcmag.com/encyclopedia/term/62034/antennagate
Korea Univ
iPhone 4 Teardown
11
A4 Processor (ARM Cortex A8) designed by Apple manufactured by Samsung
GSM and more
GSM (Global System for Mobile communications): 3G
Samsung flash memory (32GB): K9PFG08
Audio Codec (Cirrus Logic)
512MB Mobile DDR
Korea Univ
iPhone 4 Teardown
• Accelerometer detects when the user has rotated the device from portrait to landscape, then automatically changes the contents of the display accordingly
• Proximity sensor detects when you lift iPhone to your ear and immediately turns off the display to save power and prevent inadvertent touches until iPhone is moved away
• Ambient light sensor automatically adjusts the display’s brightness to the appropriate level for the current ambient light, enhancing the user experience and saving power at the same time
12
Korea Univ
iPhone 5 Teardown
13http://www.ifixit.com/Teardown/iPhone+5+Teardown/10525/2
16GB NAND Flash from Hynix
3-axis gyroscope
Wi-Fi module
A6 application processor, based off the ARMv7 ISA 1GB Elpida LP (Low Power) DDR2 integrated according to Chipworks
Touchscreen controller
Accelerometer
LTE modem
Korea Univ
Galaxy S3 Teardown
14http://www.ifixit.com/Teardown/Samsung-Galaxy-S-III-Teardown/
Exynos 4412: Quad-core A9 with 1GB DDR2
Intel Wireless Processor
Samsung 16GB eMMC (MultiMediCard) + 64MB NAND Flash
http://www.samsung.com/
Korea Univ
Exynos 4412 Block Diagram
15PoP: Package-on-Package
MFC: Multi Format Codec
Korea Univ
Components of Embedded Systems
• Hardware It is mainly composed of processor (1 or more), memory,
I/O devices including network devices, timers, sensors etc.
16
Korea Univ
Components of Embedded Systems
• Software - System software Operating systems
• Many times, a multitasking (multithreaded) OS is required, as embedded applications become complicated
Networking, GUI, Audio, Video CPU is context-switched to process multiple jobs
• Operating system footprint should be small enough to fit into memory of an embedded system
In the past and even now, real-time operating systems (RTOS) such as VxWorks and uC/OS-II have been used because they are light-weighted in terms of memory requirement
Nowadays, heavy-weighted OSs such as iOS, Android, Windows Mobile, and embedded Linux (uClinux) are used, as embedded processors support computing power and advanced capabilities such as MMU (Memory Management Unit)
Device drivers for I/O devices
17
Korea Univ
Components of Embedded Systems (Cont)
• Software (cont.) - Application software Run on top of operating system Execute tasks that users wish to perform
• Web surfing, Social Network Service, Audio, Video playback
18
Korea Univ
Real-Time Systems
• Real-time operating system (RTOS): Multitasking operating system for real-time applications RTOS is valued for how quickly and/or
predictably respond to a particular event• Hard real-time systems are required to
complete a critical task within a guaranteed amount of time
• Soft real-time systems are less restrictive Implementing real-time system requires a
careful design of scheduler• System must have the priority-based scheduling
Real-time processes must have the highest priority Priority inheritance (next slide)
• Solve the priority inversion problem
• Process dispatch latency must be small
19
Hard real-time systems
Korea Univ
Priority Inversion Problem
• Pathfinder mission on Mars in 1997 Used VxWorks, an RTOS kernel, from WindRiver Software problems caused the total system resets
of the Pathfinder spacecraft in mission• Watchdog timer goes off, informing that something has
gone dramatically wrong and initiating the system reset
20
Korea Univ
Priority Inversion Problem
• VxWorks provides preemptive priority scheduling of threads Tasks on the Pathfinder spacecraft were executed as threads with
priorities that were assigned in the usual manner reflecting the relative urgency of these tasks.
21
Task 3(lowest priority)
Task 2(medium priority)
Task 1(highest priority)
TimeTask 3 gets semaphore
Task 1 preempts Task3
Task 1 tries to get the semaphore
Task 3 is resumed
Task 2 preempts task 3
Task 3 is resumed
Task 3 releases the semaphore
Task 1 gets the semaphore and execute
Priority Inversion
Korea Univ
Priority Inheritance
• A lower priority process could be accessing a critical section (a shared resource) that the higher priority process needs The process with a lower priority inherits the higher priority until they are
done with the resource When they are finished, its priority reverts to its original value
22
Task 3(lowest priority)
Task 2(medium priority)
Task 1(highest priority)
TimeTask 3 gets semaphore
Task 1 preempts Task3
Task 1 tries to get the semaphore(Priority of Task 3 is raised to Task 1’s)
Task 3 is resumed with the highest priority
Task 1 completesPriority Inversion
Task 3 releases the semaphore
Korea Univ
Operating Systems for Embedded Systems
• RTOSs pSOS VxWorks VRTX (Versatile Real-Time Executive) uC/OS-II
• Palm OS & Symbian OS(source: Wikipedia) Palm OS: Embedded operating system initially developed by
U.S. Robotics-owned Palm Computing, Inc. for personal digital assistants (PDAs) in 1996
Symbian OS: Proprietary operating system designed for mobile devices by Symbian Ltd. A descendant of Psion's EPOC and runs exclusively on ARM processors
• Android (http://www.android.com/) Open Handset Alliance Project Based on modified version of Linux 2.6 kernel Currently supporting ARM, MIPS, and x86
23
Korea Univ
A Computer System (~ 2010)
24
CPU
North Bridge
South Bridg
e
Main Memor
y
FSB (Front-Side Bus)
DMI (Direct Media I/F)
Hard disk
USB
PCIe card
Peripheral devices
Graphics card
But, don’t forget the big picture!
Korea Univ
Evolution of Computer Systems
25
Keep in mind that CPU and computer systems are evolving at a fast pace
CPU
North Bridge
South Bridge
Main Memor
y(DDR2)
FSB (Front-Side Bus)
DMI (Direct Media I/F)
• Core 2 Duo – based Systems
• Core i7– based Systems
CPU
IOH (Input/Outpu
t Hub)
South Bridge
Main Memor
y(DDR3)
DMI (Direct Media I/F)
Quickpath (Intel) orHypertransport (AMD)
Korea Univ
Core i7 (Ivy Bridge)-based Systems
26
FDI: Flexible Display Interface SPI: Serial Peripheral Interface SMBus: System Management Bus
Korea Univ
x86?
• What is x86? Generic term referring to processors from Intel, AMD and VIA Derived from the model numbers of the first few generations of
processors: • 8086, 80286, 80386, 80486 x86
Now it generally refers to processors from Intel, AMD, and VIA• x86-16: 16-bit processor• x86-32 (aka IA32): 32-bit processor * IA: Intel Architecture• x86-64: 64-bit processor
• Intel takes about 80% of the PC market and AMD takes about 20% Apple also have been introducing Intel-based Mac from Nov. 2006
27* aka: also known as
Korea Univ
x86 History (as of 2008)
28
Korea Univ
x86 History (Cont.)
29
32-bit (i386)
32-bit (i586) 64-bit (x86_64)32-bit (i686)
8-bit 16-bit 4-bit
2009 20111st Gen. Core i7
(Nehalem)2nd Gen. Core i7(Sandy Bridge)
20123rd Gen. Core i7
(Ivy Bridge)
20134th Gen. Core i7
(Haswell)
Korea Univ
Chipset
• We call North and South Bridges as Chipset
• Chipset has many PCIe devices inside
• North Bridge Memory controller PCI express ports to connect Graphics card http://www.intel.com/Assets/PDF/datasheet/316966.pdf
• South Bridge HDD (Hard-disk) controller USB controller Various peripherals connected
• Keyboard, mouse, timer etc PCI express ports http://www.intel.com/Assets/PDF/datasheet/316972.pdf
• Note that the landscape is being changed! For example, memory controller is integrated into CPU
30
Korea Univ
PCI, PCI Express Devices
31
• PCI (Peripheral Component Interconnect) Computer bus connecting all the peripheral devices to the
computer motherboard
• PCIe (PCI Express) Replaced PCI in 2004 Point-to-point connection
PCI slotPCI express slots PCI express slot
x16
http://www.pcisig.com/specifications/pciexpress/
Korea Univ
An Old GP Computer System Example
32
Korea Univ
PCI Express Slots in GP Systems
33
PCI express slot
Korea Univ
GP Computer System in terms of PCIe
34
North Bridge
South Bridge
Korea Univ
Software Stack
35
Computer Hardware(CPU, Chipset, PCIe cards ...)
BIOS (AMI, Phoenix Technologies …)
Operating System(Linux, Vista, Mac OS …)
Applications(MS-office, Google Earth…)
API (Application Program I/F)
BIOS provides common I/Fs
Korea Univ
How the GP Computer System Works?
36
• x86-based system starts to execute from the reset address 0xFFFF_FFF0 The first instruction is “jmp xxx” off from BIOS ROM
• BIOS (Basic Input/Output System) Detect and initialize all the devices (including PCI devices
via PCI enumeration) on the system Provide common interfaces to OS Hand over the control to OS
• OS Manage the system resources such as main memory
• Control and coordinate the use of the hardware among various application programs for the various users
Provide APIs for system and application programming
Korea Univ
So… What?
• How is it different from embedded systems? General-purpose computer systems provide
programmability to end-users• You can do any kinds of programming on your PC
C, C++, C#, Java etc
General-purpose systems should provide backward compatibility
• A new system should be able to run legacy software, which could be in the form of binaries with no source codes written 30 years ago
So, general purpose computer system becomes messy and complicated, still containing all legacy hardware functionalities
37
Korea Univ38
x86 Operation Modes
• Real Mode (= real address mode) Programming environment of the 8086 processor 8086 is a 16-bit processor from Intel
• Protected Mode Native state of the 32-bit Intel processor
• For example, Windows is running in protected mode if 32-bit Windows is installed on your PC
32-bit mode
• IA-32e mode (IA-32 Extended Mode) There are 2 sub modes
• Compatibility mode• 64-bit mode
Korea Univ
Registers in 8086
• Registers inside the 8086 16-bit segment registers
• CS, DS, SS, ES
General-purpose registers • all 16-bits• AX, BX, CX, DX, SP, BP, SI, DI
• Registers in x86-32
39
Korea Univ40
Real Mode Addressing
• In real mode (8086), general purpose registers are all 16-bit wide
• Real model Segment registers specify the base address of each segment Segment registers
• CS: Code Segment -> used to access instructions• DS: Data Segment -> used to store data• SS: Stack Segment -> Stack• ES: Extra Segment -> could be used to store more data
Addressing method• Segment << 4 + offset = physical address• Example:
mov ax, 2000hmov ds, ax Data segment starts from 20000h (2000h << 4)
Main Memory(1MB)
Korea Univ41
Data Segment in Real Mode
• Memory addressing in real mode (8086)
Main Memory(1MB)
2000hDS
mov ax, 2000hmov ds, axmov al, [100h]
100hoffset
0x0
0xFFFFF
20000h = 2000h << 4
20100h
Korea Univ
A20M
• 8088/8086 allows only 1MB memory access since they have only 20-bit physical address lines 220 = 1MB
• Memory is accessed with segment:offset in 8086/8088 (still the same though) What if CS=0xFFFF, IP=0x0020?
• CS << 4 + IP = 0x100010• But, we have only 20 address lines. So, 8088 ends up accessing 0x00010
ignoring the “1” in A20
• Some (weird?) programmers took advantage of this mechanism
42
Korea Univ
A20M (Cont)
• How about now? Your Core 2 Duo has 48-bit physical address lines What happens if there is no protection in the previous
case• Processor will access 0x100010, breaking the legacy code
So, x86 provides a mechanism called A20M (A20 Mask) to make it compatible with the old generations
43
Korea Univ
A20M (Cont)
44
Korea Univ
Another Example
• Protected mode addressing (32-bit) As application programs become larger, 1MB
main memory is too small Intel introduced protected mode to address a
larger memory (up to 4GB) But, Intel still wants to use 16-bit segment
registers for the backward compatability How to access a 4GB space with a 16-bit
register?
45
Korea Univ46
Protected Mode Addressing
IndexSegment Selector TI
RPL
15 3 2 1 0
GDT LDT
TI = 0 TI = 1
Segment Descriptor
Segment Descriptor
Segment Descriptor
Segment Descriptor
Segment Descriptor
Segment Descriptor
Segment Descriptor
Segment Descriptor
Segment Descriptor
Segment Descriptor
Base Access info
31 0 19 0
Limit
HardwareInside the CPU
(Registers)
Mainmemory
Visible to software
Invisible to software
•TI: Table Indicator•RPL: Requested Privilege Level
Korea Univ47
Segment Descriptor Format
• Software (OS) creates descriptor tables (GDT, LDT)
Korea Univ48
Address Translation in Protected Mode
Korea Univ
One More Example
• 8259 Interrupt Controller
49
IR0IR1IR2IR3IR4IR5IR6IR7
INTR
IR0IR1IR2IR3IR4IR5IR6IR7
INTR
INTA
INTA
INTR82C59A(Master)
82C59A(Slave)
CPU (8086)
CPU
North Bridge
South Bridge
Main Memory(DDR)
FSB (Front-Side Bus)
DMI (Direct Media I/F)
Still in South Bridge
Korea Univ
APICs and 8259s
50DMI: Direct Media Interface, ESI: Enterprise SouthbBridge Interface
Local APICs
IO APICs
8259s
APIC: Advanced Programmable Interrupt Controller
Korea Univ
Backup Slides
51
Korea Univ
8259 in Prehistoric Era
52