ECE472/572 (UCLX) Assignment 5 - version for kernel 3.x

"Everything is hard before it's easy" - Thomas Fuller

Prepare for the lab

Answer these questions while doing this lab – they will help you understand the procedure and better prepare for the tests.

Activity (40pts.)

This activity was initially tested for the Kernal 3.x and subsequently enhanced by Mr. Tim De Pasion, Theo Wiersema, and Alex Schmidt, class of 2016. It was validated for the Kernel v.4 on Ubuntu 16-04 by Andrew Schulz, Michelle Ohlson, class of 2018. It was further checked for correctness by Karim Elrafie, class of 2018 and Vishal Bharadwa Yellapragada, class of 2017.

The previous lab that was dealing with kernel 2.6 has the following history of enhancements: Updated to Ubuntu 10.04 by Mr. Bhavani Prasad Dhulipalla, class of 2011, troubleshooting Kernel Panic provided by Mr. Matthew Guttag, class of 2012. This activity was verified to run on Ubuntu 12.04 even though it uses kernel 3.2 instead of 2.6 by Mr. Anthony Gaught, class of 2013. Mr. Swakin Reddy Battu, class of 2016 tested and adjusted it for fresh install of Ubuntu 14.04.3. If interested, see the earlier version of this lab.

Custom Kernel

You are now ready to build your custom kernel. However, we will make all the changes necessary to create a system call so we do not have to rebuild the kernel twice.We will create a system call named test_call, which will print “Hello World!” in the system log.

/*----------Start of test_call.c----------*/
#include <linux/linkage.h> #include <linux/kernel.h> asmlinkage long sys_test_call(unsigned short n) { unsigned short i; for (i=0; i<n; i++) printk(KERN_EMERG "Kernel Hello World! by <insert your name here>\n"); return n; } /*-----------End of test_call.c-----------*/
########## Start of Makefile ##########
obj-y := test_call.o
########## End of Makefile ##########
  • Add test_call to core-y in Makefile
  • Add new call to syscall tables for x86 and x64 architectures at the end of each list. Pay attention to using the correct system call number.
  • Add new call to system call header file just before the final #endif
  • Now let's record content of all created or midified files for the sake of the submission of this lab.

    Now we will complete building the kernel with the new system call in place.

    “-custom” is the name for your new kernel build. You change it to something else if you like. However, it must start with a dash (-) and cannot contain any whitespace. The terminal will give you an error if your naming is not compatible.

    After the last line, your kernel will start compiling. This may take a few hours depending on your computer.

    In case of Kernel Panic during boot time

    Running Your Custom Kernel

    To run your system call, you will need to write a short program. Make sure that you compile it while using your version of the kernel as you depend on your modified header files to do the call.

    /*----------Start of test_call_run.c----------*/
    #include <stdio.h>
    #include <unistd.h>  // to use syscall
    
    // Reminding that sys_test_call function is filed under the system call XXX
    #define __NR_test_call XXX
    
    // Calling a macro to define a system call with N parameters that returns a long
    long test_call()
    {
        return( syscall(__NR_test_call, 3) );
    }
    
    int main()
    {
        long status = test_call();
        printf("Our test system call was called and returned status %ld\n", status);
        return(0);
    }
    /*-----------End of test_call_run.c-----------*/

    Cleanup - optional

    So now you wander whether now you need to live with your custom Kernel until the end of the course, or perhaps your hard drive life cycle?

    Submission

    Use tar and then gzip or bz2 to combine all script files required for the lab submission into one file. A "convenience fee" may be charged for use of other kinds of compression.

    Drop the file with the information collected during the exercise as instructed in the corresponding assignment drop box on Sakai. The installed Ubuntu disks or the virtual machine configurations will not be collected.

    Thank you.

    web site front local main page local list page general bookmarks software bookmarks go back copyright info