Skip to content

Commit

Permalink
documentation: memory_mapping: Fix TODO numbering
Browse files Browse the repository at this point in the history
 - Change TODO numbering to match code template
 - Fix and improve testing instructions
  • Loading branch information
ionhoria authored and dbaluta committed May 11, 2020
1 parent f653460 commit 8603156
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions Documentation/teaching/labs/memory_mapping.rst
Original file line number Diff line number Diff line change
Expand Up @@ -353,8 +353,13 @@ Implement the :c:func:`mmap` driver function.
To convert a physical address to its PFN, shift the address
with PAGE_SHIFT bits to the right.

For testing, use :file:`test/mmap-test`. If everything goes well, the test
will show "matched" messages.
For testing, load the kernel module and run:

.. code-block:: shell
root@qemux86:~# skels/memory_mapping/test/mmap-test 1
If everything goes well, the test will show "matched" messages.

2. Mapping non-contiguous physical memory to userspace
------------------------------------------------------
Expand All @@ -364,7 +369,7 @@ Implement a device driver that maps non-contiguous physical memory

Review the `Device driver memory mapping`_ section, generate the
skeleton for the task named **vmmap** and fill in the areas marked
with **TODO 2**.
with **TODO 1**.

Allocate a memory area of NPAGES with :c:func:`vmalloc`.

Expand Down Expand Up @@ -398,8 +403,13 @@ Implement the mmap driver function.
Make sure the that you determine the physical address
each time and that you use a range of one page for mapping.

For testing, use *test/mmap-test*. If everything goes well the test
will show "matched" messages.
For testing, load the kernel module and run:

.. code-block:: shell
root@qemux86:~# skels/memory_mapping/test/mmap-test 1
If everything goes well, the test will show "matched" messages.

3. Read / write operations in mapped memory
-------------------------------------------
Expand All @@ -409,17 +419,17 @@ your device. This is a didactic exercise to see that the same space
can also be used with the :c:func:`mmap` call and with :c:func:`read`
and :c:func:`write` calls.

Fill in areas marked with **TODO 3**.
Fill in areas marked with **TODO 2**.

.. note:: The offset parameter sent to the read / write operation can
be ignored as all reads / writes from the test program will
be done with 0 offsets.

For testing run :file:`test/mmap-test` with 3 as parameter:
For testing, load the kernel module and run:

.. code-block:: shell
root@qemux86:~# skels/memory_mapping/test/mmap-test 3
root@qemux86:~# skels/memory_mapping/test/mmap-test 2
4. Display memory mapped in procfs
Expand All @@ -428,7 +438,7 @@ For testing run :file:`test/mmap-test` with 3 as parameter:
Using one of the previous modules, create a procfs file in which you
display the total memory mapped by the calling process.

Fill in the areas marked with **TODO 4**.
Fill in the areas marked with **TODO 3**.

Create a new entry in procfs (:c:macro:`PROC_ENTRY_NAME`, defined in
:file:`mmap-test.h`) that will show the total memory mapped by the process
Expand Down Expand Up @@ -481,11 +491,11 @@ In :c:func:`my_seq_open` register the display function

.. note:: :c:func:`single_open` can use :c:macro:`NULL` as its third argument.

For testing run :file:`kmmap/mmap-test` with 4 as parameter:
For testing, load the kernel module and run:

.. code-block:: shell
root@qemux86:~# skels/memory_mapping/kmmap/mmap-test 4
root@qemux86:~# skels/memory_mapping/test/mmap-test 3
.. note:: The test waits for a while (it has an internal sleep
instruction). As long as the test waits, use the
Expand Down

0 comments on commit 8603156

Please sign in to comment.