Upload
alexia-zachry
View
218
Download
2
Tags:
Embed Size (px)
Citation preview
Project 4Kristoffer Robin Stokke
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
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
Processes in P4
• User mode• Virtual address space
– ?
18. april 2023 4
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
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
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
Process Management
• Dynamic loading – how?– Simple filesystem on floppy
containing process directory– Implement readdir()– Implement loadproc()– Who calls these functions?
18. april 2023 8
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
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
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
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
Snake x86
18. april 2023 13
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?
Good luck!
18. april 2023 15