SlideShare a Scribd company logo
Page 1
Direct Memory Access
By,
Sharmila Chidaravalli
Assistant Professor,
Department of CS&E,
AIeMS
Page 2
Introduction
The direct memory access (DMA) I/O technique provides
direct access to the memory while the microprocessor is
temporarily disabled.
• A DMA controller temporarily borrows the address bus, data
bus, and control bus from the microprocessor and transfers the
data bytes directly between an I/O port and a series of memory
locations.
• The DMA transfer is also used to do high-speed memory-to
memory transfers.
• Used in disk controllers, video/sound cards etc, or between
memory locations.
Page 3
Basic DMA operation
• Two control signals are used to request and acknowledge a
DMA transfer in the microprocessor-based system.
HOLD pin - is an input used to request a DMA action
HLDA pin - is an output that acknowledges the DMA action
Page 4
•The HOLD signal is a bus request signal which asks the
microprocessor to release control of the buses after the current bus
cycle.
•HOLD is sampled in any clocking cycle
•when the processor recognizes the hold, it stops executing software
and enters hold cycles
• The HLDA signal is a bus grant signal which indicates that the
microprocessor has indeed released control of its buses by placing
the buses at their high-impedance states.
• The HOLD input has a higher priority than the INTR or NMI
interrupt inputs.
Page 5
Basic DMA Definitions
Direct memory accesses normally occur between an I/O device
and memory without the use of the microprocessor.
DMA read - transfers data from the memory
to the I/O device
DMA write - transfers data from an I/O device
to memory
Memory & I/O are controlled simultaneously.
which is why the system contains separate memory and
I/O control signals
Page 6
A DMA read causes the MRDC and IOWC signals to activate
simultaneously.
-transferring data from memory to the I/O device
A DMA write causes the MWTC and IORC signals to both
activate.
The control Buses are available to all microprocessors in the Intel
family expect 8086/8088.
8086/8088 require a controller or circuit for control bus signal
generation.
Page 7
Data transfers are performed by the control circuit that is a part of the I/O device
interface called DMA controller
DMA controller can transfer data without intervention of the processor, but its
operation must be under the control of a program executed by the processor.
To initiate the transfer of a block words, the processor sends the starting address,
the number of words in the block and the direction of the transfer.
Data transfer speed is determined by speed of the memory device or a DMA
controller.
-if memory speed is 50 ns, DMA transfers occur at rates up to 1/50 ns or 20
M bytes per second
-if the DMA controller functions at a maximum rate of 15 MHz with 50 ns
memory, maximum transfer rate is 15 MHz because the DMA controller is
slower than the memory
In many cases, the DMA controller slows the speed of the system when transfers
occur.
Page 8
• DMA is implemented using a DMA controller
– DMA controller
• Acts as slave to processor
• Receives instructions from processor
– Processor gives details to the DMA controller
» I/O device number
» Main memory Starting address
» Number of bytes to transfer
» Direction of transfer (memory  I/O device, or
vice versa)
• On receiving this information, the DMA controller proceeds to
perform the requested operation.
• After completing, it informs the processor
Page 9
• Steps in a DMA operation
– Processor initiates the DMA controller
• Gives device number, memory buffer pointer, …
– Called channel initialization
• Once initialized, it is ready for data transfer
– When ready, I/O device informs the DMA controller
• DMA controller starts the data transfer process
– Obtains bus by going through bus arbitration
– Places memory address and appropriate control signals
– Completes transfer and releases the bus
– Updates memory address and count value
– If more to read, loops back to repeat the process
– Notify the processor when done
• Typically uses an interrupt
Page 10
Interrupts
By,
Sharmila Chidaravalli
Assistant Professor,
Department of CS&E,
AIeMS
Page 11
What Are Interrupts ?
Interrupts alter a program’s flow of control
∗ Behavior is similar to a procedure call
» Some significant differences between the two
• Interrupt causes transfer of control to an interrupt
service routine (ISR) or Interrupt Service Procedure
» ISR is also called a handler
• When the ISR is completed, the original program resumes
execution
• Interrupts provide an efficient way to handle unanticipated
events
Page 12
Page 13
Types of interrupts
∗ Software interrupts
∗ Hardware interrupts
∗ Exceptions
Page 14
Interrupt Vector Table
Page 15
The processor uses the interrupt vector to determine the address of
the ISR of the interrupting device.
In the 8088/8086 processor as well as in the 80386/80486/Pentium
processors operating in Real Mode (16-bit operation), the interrupt
vector is a pointer to the Interrupt Vector Table.
The Interrupt Vector Table occupies the address range from 00000H
to 003FFH (the first 1024 bytes in the memory map).
Each entry in the Interrupt Vector Table is 4 bytes long:
The first two represent the offset address and the last two the segment address
of the ISR.
The first 5 vectors are reserved by Intel to be used by the processor.
The vectors 5 to 255 are free to be used by the user.
Page 16
• Interrupt numbers range from 0 to 255
• Interrupt number acts as an index into the interrupt vector table
• Since each vector takes 4 bytes, interrupt number is multiplied by 4
to get the corresponding ISR pointer
Example
• For interrupt 2, the memory address is 2 ∗ 4 = 8H
• The first two bytes at 8H are taken as the offset value
• The next two bytes (i.e., at address AH) are used as the CS value
Page 17
Interrupt Types
Type 0: Divide error – Division overflow or division by zero
Type 1: Single step or Trap – After the execution of each instruction
when trap flag set
Type 2: NMI Hardware Interrupt – ‘1’ in the NMI pin
Type 3: One-byte Interrupt – INT3 instruction (used for
breakpoints)
Type 4: Overflow – INTO instruction with an overflow flag
Type 5: BOUND – Register contents out-of-bounds
Type 6: Invalid Opcode – Undefined opcode occurred in program
Type 7: Coprocessor not available – MSW indicates a coprocessor
Type 8: Double Fault – Two separate interrupts occur during the
same instruction
Type 9: Coprocessor Segment Overrun – Coprocessor call operand
exceeds FFFFH
Page 18
Interrupt Types
Type 10: Invalid Task State Segment – TSS invalid (probably not
initialized)
Type 11: Segment not present – Descriptor P bit indicates segment
not present or invalid
Type 12: Stack Segment Overrun – Stack segment not present or
exceeded
Type 13: General Protection – Protection violation in 286 (general
protection fault)
Type 14: Page Fault – 80386 and above
Type 16: Coprocessor Error – ERROR΄ = ‘0’ (80386 and above)
Type 17: Alignment Check – Word/Doubleword data addressed at
odd location (486 and above)
Type 18: Machine Check – Memory Management interrupt
(Pentium and above)
Page 19
Operation of a Real Mode Interrupt
Push Flags
Clear IF
Clear TF
Push CS
Push IP
Fetch ISR Address
Pop IP
Pop CS
Pop Flags
Mainline Program
ISR
Push Register
Pop Register
IRET
Page 20
Operation of a Protected Mode Interrupt
In the 80386/80486/Pentium processors operating in the Protected
Mode (32-bit operation), the interrupt vector is a pointer to the
Interrupt Descriptor Table.
The Interrupt Descriptor Table can be located anywhere in the
memory.
Its starting address is pointed by the Interrupt Descriptor Table Register
(IDTR).
Each entry in the Interrupt Vector Table is 8 bytes long:
Four bytes represent the 32-bit offset address, two the segment selector and
the rest information such as the privilege level.
The first 32 vectors are reserved by Intel to be used by the
processor.
The vectors 33 to 255 are free to be used by the user.
0
2
4
6
1
3
5
7 Offset (A31 - A16)
Offset (A15 - A0)
Segment Selector
00H01110PFThe protected mode
interrupt descriptor
Page 21
Exception Interrupts
Divide by zero error
CPU generates a type 0 interrupt whenever the div/idiv
instructions result in a quotient that is larger than the
destination specified or an attempt is made to divide by zero.
Single step Interrupt
∗ Useful in debugging
∗ To single step, Trap Flag (TF) should be set
∗ CPU automatically generates a type 1 interrupt after
executing each instruction if TF is set
∗ Type 1 ISR can be used to present the system state to
the user
Page 22
Exception Interrupts
There exists no instruction to directly set or reset trap flag.
TF=1 can be set by executing the following sequence of instructions:
PUSHF
MOV BP,SP
OR WORD PTR[BP+0],0100H
POPF
TF=0 can be set by executing the following sequence of instructions:
PUSHF
MOV BP,SP
AND WORD PTR[BP+0],0FEFFH
POPF
Page 23
Software Interrupts
Initiated by executing an instruction
INT, INTO, INT 3, BOUND
INT and INT3 behave in a similar way.
INT n:
- n is an integer from range 0 to 255
- Calls ISR located at vector n (n*4).
- The INT instruction requires two bytes of memory, opcode
plus n.
- Each interrupt type can be parameterized to provide
several services.
- For example, DOS interrupt service int 21H
provides more than 80 different services
∗ AH register is used to identify the required
service under int 21H.
Page 24
BOUND and INTO are both conditional.
BOUND:
Bound AX,DATA
AX is compared with DATA and DATA+1, if less than an
interrupt occurs.
AX is compared with DATA+2 and DATA+3, if greater than an
interrupt occurs.
INTO:
Checks the overflow flag (OF). If OF=1, the ISR is called.
IRET removes 6 bytes from the stack, 2 for IP, 2 for CS and 2 for
FLAGS.
Page 25
Hardware Interrupts
• Software interrupts are synchronous events
∗ Caused by executing the int
instruction
• Hardware interrupts are of hardware origin and
asynchronous in nature
∗ Typically caused by applying an
electrical signal to the processor chip
• Hardware interrupts can be
∗ Maskable (INTR)
∗ Non-maskable (NMI)
» Causes a type 2 interrupt
Page 26
Non-Maskable Interrupt
Non-maskable interrupt is triggered by applying an electrical signal to
the NMI pin of Pentium
∗ Processor always responds to this signal
∗ Cannot be disabled under program control
The non-maskable interrupt (NMI) is an edge-triggered input that
requests an interrupt on the positive edge (0-to-1 transition).
after a positive edge, the NMI pin must remain logic 1 until
recognized by the microprocessor
before the positive edge is recognized, NMI pin must be logic 0
for at least two clocking periods
The NMI input is often used for parity errors and other major faults,
such as power failures.
power failures are easily detected by monitoring the AC power
line and causing an NMI interrupt whenever AC power drops out .
Page 27
INTR and INTA
The INTR pin must be externally decoded to select a vector.
Any vector is possible, but the interrupt vectors between
20H and FFH are usually used (Intel reserves vectors
between 00H and 1FH).
INTA is an output of the microprocessor to signal the external
decoder to place the interrupt number on data bus connections
D7-D0.
The INTR pin is set by an external device (8259A) and cleared
in the ISR.
The input is automatically disabled by the microprocessor
once it is recognized and re-enabled by IRET or IRETD
instruction.
Page 28
INTR: Interrupt Request. Activated by a peripheral device to
interrupt the processor.
Level triggered. Activated with a logic 1.
INTA: Interrupt Acknowledge. Activated by the processor to
inform the interrupting device the interrupt request (INTR) is
accepted.
Level triggered. Activated with a logic 0.
Ad

More Related Content

What's hot (20)

Direct access memory
Direct access memoryDirect access memory
Direct access memory
maliksiddique1
 
Direct Memory Access
Direct Memory AccessDirect Memory Access
Direct Memory Access
Hetauda City College
 
Direct memory access
Direct memory accessDirect memory access
Direct memory access
shubham kuwar
 
Direct Memory Access
Direct Memory AccessDirect Memory Access
Direct Memory Access
Tuqa Rmahi
 
Modes of transfer
Modes of transferModes of transfer
Modes of transfer
Andhra University
 
DMA presentation [By- Digvijay]
DMA presentation [By- Digvijay]DMA presentation [By- Digvijay]
DMA presentation [By- Digvijay]
Digvijay Singh Karakoti
 
Programed I/O Modul..
Programed I/O Modul..Programed I/O Modul..
Programed I/O Modul..
Myster Rius
 
Modes Of Transfer in Input/Output Organization
Modes Of Transfer in Input/Output OrganizationModes Of Transfer in Input/Output Organization
Modes Of Transfer in Input/Output Organization
MOHIT AGARWAL
 
DMA operation
DMA operationDMA operation
DMA operation
Imran Khan
 
Microprogrammed Control Unit
Microprogrammed Control UnitMicroprogrammed Control Unit
Microprogrammed Control Unit
PreethiSureshkumar1
 
Memory mapping
Memory mappingMemory mapping
Memory mapping
SnehalataAgasti
 
Architecture of 8086 Microprocessor
Architecture of 8086 Microprocessor  Architecture of 8086 Microprocessor
Architecture of 8086 Microprocessor
Mustapha Fatty
 
Modes of transfer - Computer Organization & Architecture - Nithiyapriya Pasav...
Modes of transfer - Computer Organization & Architecture - Nithiyapriya Pasav...Modes of transfer - Computer Organization & Architecture - Nithiyapriya Pasav...
Modes of transfer - Computer Organization & Architecture - Nithiyapriya Pasav...
priya Nithya
 
Modes of data transfer
Modes of data transferModes of data transfer
Modes of data transfer
Shah Ishtiyaq Mehfooze
 
I2C Protocol
I2C ProtocolI2C Protocol
I2C Protocol
Sudhanshu Janwadkar
 
Interface
InterfaceInterface
Interface
Siddique Ibrahim
 
Asynchronous data transfer
Asynchronous data transferAsynchronous data transfer
Asynchronous data transfer
priya Nithya
 
Computer organization memory
Computer organization memoryComputer organization memory
Computer organization memory
Deepak John
 
Register transfer language
Register transfer languageRegister transfer language
Register transfer language
Sanjeev Patel
 
Computer registers
Computer registersComputer registers
Computer registers
DeepikaT13
 
Direct memory access
Direct memory accessDirect memory access
Direct memory access
shubham kuwar
 
Direct Memory Access
Direct Memory AccessDirect Memory Access
Direct Memory Access
Tuqa Rmahi
 
Programed I/O Modul..
Programed I/O Modul..Programed I/O Modul..
Programed I/O Modul..
Myster Rius
 
Modes Of Transfer in Input/Output Organization
Modes Of Transfer in Input/Output OrganizationModes Of Transfer in Input/Output Organization
Modes Of Transfer in Input/Output Organization
MOHIT AGARWAL
 
Architecture of 8086 Microprocessor
Architecture of 8086 Microprocessor  Architecture of 8086 Microprocessor
Architecture of 8086 Microprocessor
Mustapha Fatty
 
Modes of transfer - Computer Organization & Architecture - Nithiyapriya Pasav...
Modes of transfer - Computer Organization & Architecture - Nithiyapriya Pasav...Modes of transfer - Computer Organization & Architecture - Nithiyapriya Pasav...
Modes of transfer - Computer Organization & Architecture - Nithiyapriya Pasav...
priya Nithya
 
Asynchronous data transfer
Asynchronous data transferAsynchronous data transfer
Asynchronous data transfer
priya Nithya
 
Computer organization memory
Computer organization memoryComputer organization memory
Computer organization memory
Deepak John
 
Register transfer language
Register transfer languageRegister transfer language
Register transfer language
Sanjeev Patel
 
Computer registers
Computer registersComputer registers
Computer registers
DeepikaT13
 

Similar to Direct Memory Access & Interrrupts (20)

Timing n interrupt.pptx
Timing n interrupt.pptxTiming n interrupt.pptx
Timing n interrupt.pptx
JasaRChoudhary
 
8555046.ppt
8555046.ppt8555046.ppt
8555046.ppt
ssuser1b065a
 
chapter_49_2019_01_06!10_26_04_PMghh.ppt
chapter_49_2019_01_06!10_26_04_PMghh.pptchapter_49_2019_01_06!10_26_04_PMghh.ppt
chapter_49_2019_01_06!10_26_04_PMghh.ppt
Shwetamaurya36
 
Ec 1303 microprocessor_its_applications
Ec 1303 microprocessor_its_applicationsEc 1303 microprocessor_its_applications
Ec 1303 microprocessor_its_applications
Merin Jesuraj
 
Assembly programming
Assembly programmingAssembly programming
Assembly programming
Omar Sanchez
 
Input output accessing
Input output accessingInput output accessing
Input output accessing
ankitraosingh
 
Computer organization I/O organization details
Computer organization I/O organization detailsComputer organization I/O organization details
Computer organization I/O organization details
423ec0007
 
COMPUTER ARCHITECTURE REGISTER TRAN.pptX
COMPUTER ARCHITECTURE REGISTER TRAN.pptXCOMPUTER ARCHITECTURE REGISTER TRAN.pptX
COMPUTER ARCHITECTURE REGISTER TRAN.pptX
Shwetamaurya36
 
UNIT 2 8086 System Bus Structure.pptx
UNIT 2 8086 System Bus Structure.pptxUNIT 2 8086 System Bus Structure.pptx
UNIT 2 8086 System Bus Structure.pptx
Gowrishankar C
 
Important questions
Important questionsImportant questions
Important questions
ASHOKA INSTITUTE OF TECHNOLOGY & MANAGEMENT,VARANASI,U.P.
 
microprocessepjr chapter five-seven.pptx
microprocessepjr chapter five-seven.pptxmicroprocessepjr chapter five-seven.pptx
microprocessepjr chapter five-seven.pptx
TesfalegnYakob
 
Ch 01 os8e
Ch 01  os8eCh 01  os8e
Ch 01 os8e
Syed Faisal
 
Computer organization
Computer organizationComputer organization
Computer organization
Rvishnupriya2
 
Computer organization
Computer organization Computer organization
Computer organization
vishnu973656
 
8086 – CPU –Pin Diagram.pptx
8086 – CPU –Pin Diagram.pptx8086 – CPU –Pin Diagram.pptx
8086 – CPU –Pin Diagram.pptx
5G8Rajendra
 
Important questions
Important questionsImportant questions
Important questions
ASHOKA INSTITUTE OF TECHNOLOGY & MANAGEMENT,VARANASI,U.P.
 
UNIT 2.pptx
UNIT 2.pptxUNIT 2.pptx
UNIT 2.pptx
BASKARS53
 
EC 8691 Microprocessor and Microcontroller.pptx
EC 8691 Microprocessor and Microcontroller.pptxEC 8691 Microprocessor and Microcontroller.pptx
EC 8691 Microprocessor and Microcontroller.pptx
GobinathAECEJRF1101
 
COA-Unit5-ppt2.pptx
COA-Unit5-ppt2.pptxCOA-Unit5-ppt2.pptx
COA-Unit5-ppt2.pptx
Ruhul Amin
 
I/O Channel IBM 370
I/O Channel IBM 370I/O Channel IBM 370
I/O Channel IBM 370
Äkshäý M S
 
Ad

More from SharmilaChidaravalli (11)

Big Data Tools MapReduce,Hive and Pig.pdf
Big Data Tools MapReduce,Hive and Pig.pdfBig Data Tools MapReduce,Hive and Pig.pdf
Big Data Tools MapReduce,Hive and Pig.pdf
SharmilaChidaravalli
 
NoSQL BIg Data Analytics Mongo DB and Cassandra .pdf
NoSQL BIg Data Analytics Mongo DB and Cassandra .pdfNoSQL BIg Data Analytics Mongo DB and Cassandra .pdf
NoSQL BIg Data Analytics Mongo DB and Cassandra .pdf
SharmilaChidaravalli
 
Big Data Intoduction & Hadoop ArchitectureModule1.pdf
Big Data Intoduction & Hadoop ArchitectureModule1.pdfBig Data Intoduction & Hadoop ArchitectureModule1.pdf
Big Data Intoduction & Hadoop ArchitectureModule1.pdf
SharmilaChidaravalli
 
NUMPY
NUMPY NUMPY
NUMPY
SharmilaChidaravalli
 
DBMS SQL
DBMS SQLDBMS SQL
DBMS SQL
SharmilaChidaravalli
 
Dms introduction Sharmila Chidaravalli
Dms introduction Sharmila ChidaravalliDms introduction Sharmila Chidaravalli
Dms introduction Sharmila Chidaravalli
SharmilaChidaravalli
 
Assembly code
Assembly codeAssembly code
Assembly code
SharmilaChidaravalli
 
8255 Introduction
8255 Introduction8255 Introduction
8255 Introduction
SharmilaChidaravalli
 
System Modeling & Simulation Introduction
System Modeling & Simulation  IntroductionSystem Modeling & Simulation  Introduction
System Modeling & Simulation Introduction
SharmilaChidaravalli
 
Travelling Salesperson Problem-Branch & Bound
Travelling Salesperson Problem-Branch & BoundTravelling Salesperson Problem-Branch & Bound
Travelling Salesperson Problem-Branch & Bound
SharmilaChidaravalli
 
Bellman ford algorithm -Shortest Path
Bellman ford algorithm -Shortest PathBellman ford algorithm -Shortest Path
Bellman ford algorithm -Shortest Path
SharmilaChidaravalli
 
Ad

Recently uploaded (20)

five-year-soluhhhhhhhhhhhhhhhhhtions.pdf
five-year-soluhhhhhhhhhhhhhhhhhtions.pdffive-year-soluhhhhhhhhhhhhhhhhhtions.pdf
five-year-soluhhhhhhhhhhhhhhhhhtions.pdf
AdityaSharma944496
 
DSP and MV the Color image processing.ppt
DSP and MV the  Color image processing.pptDSP and MV the  Color image processing.ppt
DSP and MV the Color image processing.ppt
HafizAhamed8
 
Mathematical foundation machine learning.pdf
Mathematical foundation machine learning.pdfMathematical foundation machine learning.pdf
Mathematical foundation machine learning.pdf
TalhaShahid49
 
Avnet Silica's PCIM 2025 Highlights Flyer
Avnet Silica's PCIM 2025 Highlights FlyerAvnet Silica's PCIM 2025 Highlights Flyer
Avnet Silica's PCIM 2025 Highlights Flyer
WillDavies22
 
Level 1-Safety.pptx Presentation of Electrical Safety
Level 1-Safety.pptx Presentation of Electrical SafetyLevel 1-Safety.pptx Presentation of Electrical Safety
Level 1-Safety.pptx Presentation of Electrical Safety
JoseAlbertoCariasDel
 
new ppt artificial intelligence historyyy
new ppt artificial intelligence historyyynew ppt artificial intelligence historyyy
new ppt artificial intelligence historyyy
PianoPianist
 
Smart Storage Solutions.pptx for production engineering
Smart Storage Solutions.pptx for production engineeringSmart Storage Solutions.pptx for production engineering
Smart Storage Solutions.pptx for production engineering
rushikeshnavghare94
 
Introduction to FLUID MECHANICS & KINEMATICS
Introduction to FLUID MECHANICS &  KINEMATICSIntroduction to FLUID MECHANICS &  KINEMATICS
Introduction to FLUID MECHANICS & KINEMATICS
narayanaswamygdas
 
railway wheels, descaling after reheating and before forging
railway wheels, descaling after reheating and before forgingrailway wheels, descaling after reheating and before forging
railway wheels, descaling after reheating and before forging
Javad Kadkhodapour
 
Artificial Intelligence (AI) basics.pptx
Artificial Intelligence (AI) basics.pptxArtificial Intelligence (AI) basics.pptx
Artificial Intelligence (AI) basics.pptx
aditichinar
 
Explainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptx
Explainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptxExplainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptx
Explainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptx
MahaveerVPandit
 
ELectronics Boards & Product Testing_Shiju.pdf
ELectronics Boards & Product Testing_Shiju.pdfELectronics Boards & Product Testing_Shiju.pdf
ELectronics Boards & Product Testing_Shiju.pdf
Shiju Jacob
 
IntroSlides-April-BuildWithAI-VertexAI.pdf
IntroSlides-April-BuildWithAI-VertexAI.pdfIntroSlides-April-BuildWithAI-VertexAI.pdf
IntroSlides-April-BuildWithAI-VertexAI.pdf
Luiz Carneiro
 
Process Parameter Optimization for Minimizing Springback in Cold Drawing Proc...
Process Parameter Optimization for Minimizing Springback in Cold Drawing Proc...Process Parameter Optimization for Minimizing Springback in Cold Drawing Proc...
Process Parameter Optimization for Minimizing Springback in Cold Drawing Proc...
Journal of Soft Computing in Civil Engineering
 
RICS Membership-(The Royal Institution of Chartered Surveyors).pdf
RICS Membership-(The Royal Institution of Chartered Surveyors).pdfRICS Membership-(The Royal Institution of Chartered Surveyors).pdf
RICS Membership-(The Royal Institution of Chartered Surveyors).pdf
MohamedAbdelkader115
 
theory-slides-for react for beginners.pptx
theory-slides-for react for beginners.pptxtheory-slides-for react for beginners.pptx
theory-slides-for react for beginners.pptx
sanchezvanessa7896
 
Raish Khanji GTU 8th sem Internship Report.pdf
Raish Khanji GTU 8th sem Internship Report.pdfRaish Khanji GTU 8th sem Internship Report.pdf
Raish Khanji GTU 8th sem Internship Report.pdf
RaishKhanji
 
"Boiler Feed Pump (BFP): Working, Applications, Advantages, and Limitations E...
"Boiler Feed Pump (BFP): Working, Applications, Advantages, and Limitations E..."Boiler Feed Pump (BFP): Working, Applications, Advantages, and Limitations E...
"Boiler Feed Pump (BFP): Working, Applications, Advantages, and Limitations E...
Infopitaara
 
DT REPORT by Tech titan GROUP to introduce the subject design Thinking
DT REPORT by Tech titan GROUP to introduce the subject design ThinkingDT REPORT by Tech titan GROUP to introduce the subject design Thinking
DT REPORT by Tech titan GROUP to introduce the subject design Thinking
DhruvChotaliya2
 
Oil-gas_Unconventional oil and gass_reseviours.pdf
Oil-gas_Unconventional oil and gass_reseviours.pdfOil-gas_Unconventional oil and gass_reseviours.pdf
Oil-gas_Unconventional oil and gass_reseviours.pdf
M7md3li2
 
five-year-soluhhhhhhhhhhhhhhhhhtions.pdf
five-year-soluhhhhhhhhhhhhhhhhhtions.pdffive-year-soluhhhhhhhhhhhhhhhhhtions.pdf
five-year-soluhhhhhhhhhhhhhhhhhtions.pdf
AdityaSharma944496
 
DSP and MV the Color image processing.ppt
DSP and MV the  Color image processing.pptDSP and MV the  Color image processing.ppt
DSP and MV the Color image processing.ppt
HafizAhamed8
 
Mathematical foundation machine learning.pdf
Mathematical foundation machine learning.pdfMathematical foundation machine learning.pdf
Mathematical foundation machine learning.pdf
TalhaShahid49
 
Avnet Silica's PCIM 2025 Highlights Flyer
Avnet Silica's PCIM 2025 Highlights FlyerAvnet Silica's PCIM 2025 Highlights Flyer
Avnet Silica's PCIM 2025 Highlights Flyer
WillDavies22
 
Level 1-Safety.pptx Presentation of Electrical Safety
Level 1-Safety.pptx Presentation of Electrical SafetyLevel 1-Safety.pptx Presentation of Electrical Safety
Level 1-Safety.pptx Presentation of Electrical Safety
JoseAlbertoCariasDel
 
new ppt artificial intelligence historyyy
new ppt artificial intelligence historyyynew ppt artificial intelligence historyyy
new ppt artificial intelligence historyyy
PianoPianist
 
Smart Storage Solutions.pptx for production engineering
Smart Storage Solutions.pptx for production engineeringSmart Storage Solutions.pptx for production engineering
Smart Storage Solutions.pptx for production engineering
rushikeshnavghare94
 
Introduction to FLUID MECHANICS & KINEMATICS
Introduction to FLUID MECHANICS &  KINEMATICSIntroduction to FLUID MECHANICS &  KINEMATICS
Introduction to FLUID MECHANICS & KINEMATICS
narayanaswamygdas
 
railway wheels, descaling after reheating and before forging
railway wheels, descaling after reheating and before forgingrailway wheels, descaling after reheating and before forging
railway wheels, descaling after reheating and before forging
Javad Kadkhodapour
 
Artificial Intelligence (AI) basics.pptx
Artificial Intelligence (AI) basics.pptxArtificial Intelligence (AI) basics.pptx
Artificial Intelligence (AI) basics.pptx
aditichinar
 
Explainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptx
Explainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptxExplainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptx
Explainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptx
MahaveerVPandit
 
ELectronics Boards & Product Testing_Shiju.pdf
ELectronics Boards & Product Testing_Shiju.pdfELectronics Boards & Product Testing_Shiju.pdf
ELectronics Boards & Product Testing_Shiju.pdf
Shiju Jacob
 
IntroSlides-April-BuildWithAI-VertexAI.pdf
IntroSlides-April-BuildWithAI-VertexAI.pdfIntroSlides-April-BuildWithAI-VertexAI.pdf
IntroSlides-April-BuildWithAI-VertexAI.pdf
Luiz Carneiro
 
RICS Membership-(The Royal Institution of Chartered Surveyors).pdf
RICS Membership-(The Royal Institution of Chartered Surveyors).pdfRICS Membership-(The Royal Institution of Chartered Surveyors).pdf
RICS Membership-(The Royal Institution of Chartered Surveyors).pdf
MohamedAbdelkader115
 
theory-slides-for react for beginners.pptx
theory-slides-for react for beginners.pptxtheory-slides-for react for beginners.pptx
theory-slides-for react for beginners.pptx
sanchezvanessa7896
 
Raish Khanji GTU 8th sem Internship Report.pdf
Raish Khanji GTU 8th sem Internship Report.pdfRaish Khanji GTU 8th sem Internship Report.pdf
Raish Khanji GTU 8th sem Internship Report.pdf
RaishKhanji
 
"Boiler Feed Pump (BFP): Working, Applications, Advantages, and Limitations E...
"Boiler Feed Pump (BFP): Working, Applications, Advantages, and Limitations E..."Boiler Feed Pump (BFP): Working, Applications, Advantages, and Limitations E...
"Boiler Feed Pump (BFP): Working, Applications, Advantages, and Limitations E...
Infopitaara
 
DT REPORT by Tech titan GROUP to introduce the subject design Thinking
DT REPORT by Tech titan GROUP to introduce the subject design ThinkingDT REPORT by Tech titan GROUP to introduce the subject design Thinking
DT REPORT by Tech titan GROUP to introduce the subject design Thinking
DhruvChotaliya2
 
Oil-gas_Unconventional oil and gass_reseviours.pdf
Oil-gas_Unconventional oil and gass_reseviours.pdfOil-gas_Unconventional oil and gass_reseviours.pdf
Oil-gas_Unconventional oil and gass_reseviours.pdf
M7md3li2
 

Direct Memory Access & Interrrupts

  • 1. Page 1 Direct Memory Access By, Sharmila Chidaravalli Assistant Professor, Department of CS&E, AIeMS
  • 2. Page 2 Introduction The direct memory access (DMA) I/O technique provides direct access to the memory while the microprocessor is temporarily disabled. • A DMA controller temporarily borrows the address bus, data bus, and control bus from the microprocessor and transfers the data bytes directly between an I/O port and a series of memory locations. • The DMA transfer is also used to do high-speed memory-to memory transfers. • Used in disk controllers, video/sound cards etc, or between memory locations.
  • 3. Page 3 Basic DMA operation • Two control signals are used to request and acknowledge a DMA transfer in the microprocessor-based system. HOLD pin - is an input used to request a DMA action HLDA pin - is an output that acknowledges the DMA action
  • 4. Page 4 •The HOLD signal is a bus request signal which asks the microprocessor to release control of the buses after the current bus cycle. •HOLD is sampled in any clocking cycle •when the processor recognizes the hold, it stops executing software and enters hold cycles • The HLDA signal is a bus grant signal which indicates that the microprocessor has indeed released control of its buses by placing the buses at their high-impedance states. • The HOLD input has a higher priority than the INTR or NMI interrupt inputs.
  • 5. Page 5 Basic DMA Definitions Direct memory accesses normally occur between an I/O device and memory without the use of the microprocessor. DMA read - transfers data from the memory to the I/O device DMA write - transfers data from an I/O device to memory Memory & I/O are controlled simultaneously. which is why the system contains separate memory and I/O control signals
  • 6. Page 6 A DMA read causes the MRDC and IOWC signals to activate simultaneously. -transferring data from memory to the I/O device A DMA write causes the MWTC and IORC signals to both activate. The control Buses are available to all microprocessors in the Intel family expect 8086/8088. 8086/8088 require a controller or circuit for control bus signal generation.
  • 7. Page 7 Data transfers are performed by the control circuit that is a part of the I/O device interface called DMA controller DMA controller can transfer data without intervention of the processor, but its operation must be under the control of a program executed by the processor. To initiate the transfer of a block words, the processor sends the starting address, the number of words in the block and the direction of the transfer. Data transfer speed is determined by speed of the memory device or a DMA controller. -if memory speed is 50 ns, DMA transfers occur at rates up to 1/50 ns or 20 M bytes per second -if the DMA controller functions at a maximum rate of 15 MHz with 50 ns memory, maximum transfer rate is 15 MHz because the DMA controller is slower than the memory In many cases, the DMA controller slows the speed of the system when transfers occur.
  • 8. Page 8 • DMA is implemented using a DMA controller – DMA controller • Acts as slave to processor • Receives instructions from processor – Processor gives details to the DMA controller » I/O device number » Main memory Starting address » Number of bytes to transfer » Direction of transfer (memory  I/O device, or vice versa) • On receiving this information, the DMA controller proceeds to perform the requested operation. • After completing, it informs the processor
  • 9. Page 9 • Steps in a DMA operation – Processor initiates the DMA controller • Gives device number, memory buffer pointer, … – Called channel initialization • Once initialized, it is ready for data transfer – When ready, I/O device informs the DMA controller • DMA controller starts the data transfer process – Obtains bus by going through bus arbitration – Places memory address and appropriate control signals – Completes transfer and releases the bus – Updates memory address and count value – If more to read, loops back to repeat the process – Notify the processor when done • Typically uses an interrupt
  • 10. Page 10 Interrupts By, Sharmila Chidaravalli Assistant Professor, Department of CS&E, AIeMS
  • 11. Page 11 What Are Interrupts ? Interrupts alter a program’s flow of control ∗ Behavior is similar to a procedure call » Some significant differences between the two • Interrupt causes transfer of control to an interrupt service routine (ISR) or Interrupt Service Procedure » ISR is also called a handler • When the ISR is completed, the original program resumes execution • Interrupts provide an efficient way to handle unanticipated events
  • 13. Page 13 Types of interrupts ∗ Software interrupts ∗ Hardware interrupts ∗ Exceptions
  • 15. Page 15 The processor uses the interrupt vector to determine the address of the ISR of the interrupting device. In the 8088/8086 processor as well as in the 80386/80486/Pentium processors operating in Real Mode (16-bit operation), the interrupt vector is a pointer to the Interrupt Vector Table. The Interrupt Vector Table occupies the address range from 00000H to 003FFH (the first 1024 bytes in the memory map). Each entry in the Interrupt Vector Table is 4 bytes long: The first two represent the offset address and the last two the segment address of the ISR. The first 5 vectors are reserved by Intel to be used by the processor. The vectors 5 to 255 are free to be used by the user.
  • 16. Page 16 • Interrupt numbers range from 0 to 255 • Interrupt number acts as an index into the interrupt vector table • Since each vector takes 4 bytes, interrupt number is multiplied by 4 to get the corresponding ISR pointer Example • For interrupt 2, the memory address is 2 ∗ 4 = 8H • The first two bytes at 8H are taken as the offset value • The next two bytes (i.e., at address AH) are used as the CS value
  • 17. Page 17 Interrupt Types Type 0: Divide error – Division overflow or division by zero Type 1: Single step or Trap – After the execution of each instruction when trap flag set Type 2: NMI Hardware Interrupt – ‘1’ in the NMI pin Type 3: One-byte Interrupt – INT3 instruction (used for breakpoints) Type 4: Overflow – INTO instruction with an overflow flag Type 5: BOUND – Register contents out-of-bounds Type 6: Invalid Opcode – Undefined opcode occurred in program Type 7: Coprocessor not available – MSW indicates a coprocessor Type 8: Double Fault – Two separate interrupts occur during the same instruction Type 9: Coprocessor Segment Overrun – Coprocessor call operand exceeds FFFFH
  • 18. Page 18 Interrupt Types Type 10: Invalid Task State Segment – TSS invalid (probably not initialized) Type 11: Segment not present – Descriptor P bit indicates segment not present or invalid Type 12: Stack Segment Overrun – Stack segment not present or exceeded Type 13: General Protection – Protection violation in 286 (general protection fault) Type 14: Page Fault – 80386 and above Type 16: Coprocessor Error – ERROR΄ = ‘0’ (80386 and above) Type 17: Alignment Check – Word/Doubleword data addressed at odd location (486 and above) Type 18: Machine Check – Memory Management interrupt (Pentium and above)
  • 19. Page 19 Operation of a Real Mode Interrupt Push Flags Clear IF Clear TF Push CS Push IP Fetch ISR Address Pop IP Pop CS Pop Flags Mainline Program ISR Push Register Pop Register IRET
  • 20. Page 20 Operation of a Protected Mode Interrupt In the 80386/80486/Pentium processors operating in the Protected Mode (32-bit operation), the interrupt vector is a pointer to the Interrupt Descriptor Table. The Interrupt Descriptor Table can be located anywhere in the memory. Its starting address is pointed by the Interrupt Descriptor Table Register (IDTR). Each entry in the Interrupt Vector Table is 8 bytes long: Four bytes represent the 32-bit offset address, two the segment selector and the rest information such as the privilege level. The first 32 vectors are reserved by Intel to be used by the processor. The vectors 33 to 255 are free to be used by the user. 0 2 4 6 1 3 5 7 Offset (A31 - A16) Offset (A15 - A0) Segment Selector 00H01110PFThe protected mode interrupt descriptor
  • 21. Page 21 Exception Interrupts Divide by zero error CPU generates a type 0 interrupt whenever the div/idiv instructions result in a quotient that is larger than the destination specified or an attempt is made to divide by zero. Single step Interrupt ∗ Useful in debugging ∗ To single step, Trap Flag (TF) should be set ∗ CPU automatically generates a type 1 interrupt after executing each instruction if TF is set ∗ Type 1 ISR can be used to present the system state to the user
  • 22. Page 22 Exception Interrupts There exists no instruction to directly set or reset trap flag. TF=1 can be set by executing the following sequence of instructions: PUSHF MOV BP,SP OR WORD PTR[BP+0],0100H POPF TF=0 can be set by executing the following sequence of instructions: PUSHF MOV BP,SP AND WORD PTR[BP+0],0FEFFH POPF
  • 23. Page 23 Software Interrupts Initiated by executing an instruction INT, INTO, INT 3, BOUND INT and INT3 behave in a similar way. INT n: - n is an integer from range 0 to 255 - Calls ISR located at vector n (n*4). - The INT instruction requires two bytes of memory, opcode plus n. - Each interrupt type can be parameterized to provide several services. - For example, DOS interrupt service int 21H provides more than 80 different services ∗ AH register is used to identify the required service under int 21H.
  • 24. Page 24 BOUND and INTO are both conditional. BOUND: Bound AX,DATA AX is compared with DATA and DATA+1, if less than an interrupt occurs. AX is compared with DATA+2 and DATA+3, if greater than an interrupt occurs. INTO: Checks the overflow flag (OF). If OF=1, the ISR is called. IRET removes 6 bytes from the stack, 2 for IP, 2 for CS and 2 for FLAGS.
  • 25. Page 25 Hardware Interrupts • Software interrupts are synchronous events ∗ Caused by executing the int instruction • Hardware interrupts are of hardware origin and asynchronous in nature ∗ Typically caused by applying an electrical signal to the processor chip • Hardware interrupts can be ∗ Maskable (INTR) ∗ Non-maskable (NMI) » Causes a type 2 interrupt
  • 26. Page 26 Non-Maskable Interrupt Non-maskable interrupt is triggered by applying an electrical signal to the NMI pin of Pentium ∗ Processor always responds to this signal ∗ Cannot be disabled under program control The non-maskable interrupt (NMI) is an edge-triggered input that requests an interrupt on the positive edge (0-to-1 transition). after a positive edge, the NMI pin must remain logic 1 until recognized by the microprocessor before the positive edge is recognized, NMI pin must be logic 0 for at least two clocking periods The NMI input is often used for parity errors and other major faults, such as power failures. power failures are easily detected by monitoring the AC power line and causing an NMI interrupt whenever AC power drops out .
  • 27. Page 27 INTR and INTA The INTR pin must be externally decoded to select a vector. Any vector is possible, but the interrupt vectors between 20H and FFH are usually used (Intel reserves vectors between 00H and 1FH). INTA is an output of the microprocessor to signal the external decoder to place the interrupt number on data bus connections D7-D0. The INTR pin is set by an external device (8259A) and cleared in the ISR. The input is automatically disabled by the microprocessor once it is recognized and re-enabled by IRET or IRETD instruction.
  • 28. Page 28 INTR: Interrupt Request. Activated by a peripheral device to interrupt the processor. Level triggered. Activated with a logic 1. INTA: Interrupt Acknowledge. Activated by the processor to inform the interrupting device the interrupt request (INTR) is accepted. Level triggered. Activated with a logic 0.