diff options
authorAustin Adams <git@austinjadams.com>2018-12-22 22:40:18 -0500
committerAustin Adams <git@austinjadams.com>2018-12-22 22:40:18 -0500
commitc0da3f5037c6ac4a7c4c59a3de31ddcce6e75ea0 (patch)
parent56be2f0e55720dfe52f9c3732f6b2cf45f48e9e1 (diff)
autograding DMA: Link to MIT hw, mention volatile *volatile
1 files changed, 12 insertions, 5 deletions
diff --git a/content/blog/autograding-gba-dma.md b/content/blog/autograding-gba-dma.md
index 97aeaf6..ff861fd 100644
--- a/content/blog/autograding-gba-dma.md
+++ b/content/blog/autograding-gba-dma.md
@@ -83,11 +83,11 @@ square. So that ain't gonna work.
Consequently, before this semester, we never autograded DMA. Instead, we
would `grep` students' code for `for` loops to see if they were
manipulating the videoBuffer pixel-by-pixel[^^1] without DMA and then
-would make sure the emulator showed the right image. But my goal in 2110 is
-to autograde as much as possible (especially because TAs would be
-grading the timed lab during or right before their final exams), so I
-decided to take this opportunity to flex so hard I caused permanent
-muscle damage.
+would make sure the emulator showed the right image. But my goal in 2110
+is to autograde as much as possible, especially because TAs would've
+needed to grade this timed lab during or right before their final exams,
+so I decided to try to adapt [my favorite homework from my Operating
+Systems class][5] into an autograder.
Abusing Virtual Memory to Solve Your Life Problems
@@ -146,6 +146,12 @@ A visualization for all this follows:
On Linux, you can map pages with `mmap()`, change their permissions with
`mprotect()`, and catch page faults by registering a `SIGSEGV` handler.
+And to make sure the compiler loads the address of the fake DMA page
+from memory every time we dereference the `DMA` macro, we can define the
+`DMA` macro such that it expands to a `volatile *volatile`. That is, a
+pointer to volatile memory that itself is volatile, like
+ #define DMA ((volatile DMA_CONTROLLER *volatile) fake_dma_page)
Simulating DMA
@@ -330,3 +336,4 @@ requires the CS 2110 GBA toolchain, but that's not really the fun part
[2]: https://en.wikipedia.org/wiki/Direct_memory_access
[3]: https://en.wikipedia.org/wiki/Loop_unrolling
[4]: https://github.com/ausbin/dma-autograder-template/
+[5]: https://pdos.csail.mit.edu/6.828/2017/homework/mmap.html