15
Project 4 Kristoffer Robin Stokke

Project 4 Kristoffer Robin Stokke. Direct Memory Access New hardware device to toy with! Hardware controller with direct access to physical devices as

Embed Size (px)

Citation preview

Page 1: Project 4 Kristoffer Robin Stokke. Direct Memory Access New hardware device to toy with! Hardware controller with direct access to physical devices as

Project 4Kristoffer Robin Stokke

Page 2: Project 4 Kristoffer Robin Stokke. Direct Memory Access New hardware device to toy with! Hardware controller with direct access to physical devices as

Direct Memory Access

• New hardware device to toy with! • Hardware controller with direct access to

physical devices as well as RAM• Used to transfer data from floppy to (physical)

memory in our project!• See the code in floppy.c

18. april 2023 2

Page 3: Project 4 Kristoffer Robin Stokke. Direct Memory Access New hardware device to toy with! Hardware controller with direct access to physical devices as

Direct Memory Access

• Limitations – Transfers to memory must be within the first 16

MBs!– Transfers must not cross a 64kB boundary!– All addresses are physical!– See the P4 FAQ!

18. april 2023 3

Page 4: Project 4 Kristoffer Robin Stokke. Direct Memory Access New hardware device to toy with! Hardware controller with direct access to physical devices as

Processes in P4

• User mode• Virtual address space

– ?

18. april 2023 4

Page 5: Project 4 Kristoffer Robin Stokke. Direct Memory Access New hardware device to toy with! Hardware controller with direct access to physical devices as

Virtual Address Space

• Each process «believes» to run in a separate address space entirely dedicated to itself

18. april 2023 5

Shell Virtual RAM

0x0

0xFFFFFFFF

Page 6: Project 4 Kristoffer Robin Stokke. Direct Memory Access New hardware device to toy with! Hardware controller with direct access to physical devices as

Virtual Address Space• Behind the scenes, the MMU maps virtual addresses

to physical addresses using paging mechanisms.

18. april 2023 6

Shell Virtual RAM

0x0

0xFFFFFFFF

Physical RAM

0x0

0xFFFFFFFF

Page 7: Project 4 Kristoffer Robin Stokke. Direct Memory Access New hardware device to toy with! Hardware controller with direct access to physical devices as

Virtual Address Space

• Code to set up processes with paging enabled have been given see kernel.c and paging.c

18. april 2023 7

Kernel

Process

Kernel

Process data, code, stack

Kernel

Processes ThreadsPhysical memory

0x1000000

1 – to - 1 1 – to - 1

0x0 0x0 0x0

Page 8: Project 4 Kristoffer Robin Stokke. Direct Memory Access New hardware device to toy with! Hardware controller with direct access to physical devices as

Process Management

• Dynamic loading – how?– Simple filesystem on floppy

containing process directory– Implement readdir()– Implement loadproc()– Who calls these functions?

18. april 2023 8

Page 9: Project 4 Kristoffer Robin Stokke. Direct Memory Access New hardware device to toy with! Hardware controller with direct access to physical devices as

readdir(uint32_t* buf)

• Systemcall called from shell• Copies data from floppy to memory (buf)

using DMA– From where?

• Is there a problem with that?– Explain in design!

18. april 2023 9

Page 10: Project 4 Kristoffer Robin Stokke. Direct Memory Access New hardware device to toy with! Hardware controller with direct access to physical devices as

loadproc()• Systemcall by shell to load a

process• Allocate space for data (see

memory.c)– Enough for code / data + 8kB stack!

• Load data into memory from floppy

• Use create_process() to setup the process18. april 2023 10

Page 11: Project 4 Kristoffer Robin Stokke. Direct Memory Access New hardware device to toy with! Hardware controller with direct access to physical devices as

Keyboard

• Keyboard is connected to the CPU like the interrupt controller– IRQ1 signals keypress– Key can be read from port 0x60

• Code set up for you in entry.S – Calls keyboard_interrupt(), which calls appropriate

handler, which might call putchar()

• Design getchar(), putchar() and init()18. april 2023 11

Page 12: Project 4 Kristoffer Robin Stokke. Direct Memory Access New hardware device to toy with! Hardware controller with direct access to physical devices as

Remember..

• Lots of small things that can go wrong!– Attempt to identify such sections and design

correctly to avoid them

• Use the makefile to test the different implementations as stated in the project description

18. april 2023 12

Page 13: Project 4 Kristoffer Robin Stokke. Direct Memory Access New hardware device to toy with! Hardware controller with direct access to physical devices as

Snake x86

18. april 2023 13

Page 14: Project 4 Kristoffer Robin Stokke. Direct Memory Access New hardware device to toy with! Hardware controller with direct access to physical devices as

A Word of Warning

18. april 2023 14

• Only one delivery; goes for printed documents as well as deliveries by mail.

• Correctors now take the first of the delivered items to avoid duplicate work.

• Is this OK?

Page 15: Project 4 Kristoffer Robin Stokke. Direct Memory Access New hardware device to toy with! Hardware controller with direct access to physical devices as

Good luck!

18. april 2023 15