These files are used for part 4 of your project. The files included in the zip are:
* dvfs.c/h: Kernel module code. All of your modifications will be made here!
* pmu.s: ARM assembly code for accessing performance counters.
* Makefile: Used for compiling your code as a kernel module

********************
WHAT YOU NEED TO DO
********************
1) Disable core 1.
2) Implement your policy in dvfs.c!

********************
FLASH THE KERNEL
********************
* ONLY FOLLOW THESE STEPS IF YOU HAVE NOT HAD THE KERNEL FLASHED BY ONE OF THE TAs!
* We are providing a new kernel in order to enable the corresponding module
* Download the boot.img from the class website, and place it in some folder <BOOT>.
* Connect the phone to your Ubuntu machine, and make sure it is detected with "sudo adb devices".
* Place the phone in bootloader mode:
	$ adb reboot bootloader
* Check that the device is indeed in bootloader mode with the following command:
	$ fastboot devices
* You should see your device in the list above. IF YOU DO NOT SEE YOUR DEVICE HERE, DO NOT PROCEED! CONTACT THE TAs! 
* Navigate to the <BOOT> folder, and flash the kernel with the following command:
	$ fastboot flash boot boot.img
* Reboot the device with the following command:
	$ fastboot reboot
* Your device should boot into the Android OS properly.

********************
DISABLE CPU1
********************
* Having CPU1 on can interfere with the kernel module you are implementing. Disable it:
* THIS MUST BE DONE EVERY TIME YOU BOOT UP THE PHONE.
* 1) Stop the mpdecision process:
** $ /system/bin/stop mpdecison
* 2) Turn off CPU 1:
** $ echo 0 > /sys/devices/system/cpu/cpu1/online
* 3) Verify that mpdecision is turned off (you should see nothing in the output)
** $ ps | /data/data/com.qualcomm.qview/qview/busybox grep mpdecison

********************
OPTION 1: UPDATE THE SOURCE
********************
* There is a patch to the kernel code to ensure that new module can access kernel components.
* To make the update, replace the following source files using the updates on the website:
** ~/UCSD-CSE237A-Android/kernel/kernel/sched.c
** ~/UCSD-CSE237A-Android/kernel/arch/arm/mach-msm/acpuclock-arm11.c
** ~/UCSD-CSE237A-Android/kernel/arch/arm/mach-msm/acpuclock-8x60.c
*
* Recompile the source code with the following instructions:
** $ cd ~/UCSD-CSE237A-Android
** $ source build/envsetup.sh
** $ choosecombo 1 msm8660_surf eng
** $ make -j4

********************
OPTION 2: COMPILE FROM DYNAMO
********************
* Alternatively, we have provided a build environment within your dynamo accounts by which you can
* compile the source yourselves. You can move your dvfs.c file to this location:
** $ cd ~/dvfs_kernel_module_wes
** $ scp <source_machine>:<path_to_dvfs.c>/dvfs.c ./dvfs.c

**********************
COMPILING AND RUNNING
**********************
* To compile your module, simply run 'make'. This will generate dvfs_module.ko. This is your kernel module.
* Push it to your device: adb push dvfs_module.ko /sdcard/.
* IMPORTANT: Set scaling_governor to userspace before trying to use your module!
** If you forget that step, your kernel module wont do anything
* To insert a kernel module: insmod dvfs_module.ko
* To see the currently running kernel modules: lsmod
* To remove a kernel module: rmmod dvfs_module
* To see the output from the kernel module, along with other system debug information: dmesg

*******************
TIPS
*******************
* When running your module, the info in cpufreq and cpufreq/stats WILL NOT BE ACCURATE! You must track statistics from within your module.
* Disable the animated wallpaper on the phone. This will reduce some of the CPU utilization
* You do not need to modify any file except for dvfs.c
* I have provided many helper functions to get you started
* 1 tick = 10ms. Therefore 100 ticks = 1 second
* To control how often your kernel module makes a decision, modify the definition NUMTICKS at the top of the file. For example, if #define NUMTICKS 100, then your policy will make a decision every 1 second.
* You will implement your policy in dvfs_ticks(void)
* You may modify the last part of init_module to define what frequency and counters are used when first starting

* You can track four events using the performance counters at a time
* Please refer to the cortex pdf provided in the Project Part 4 folder for a list of all possible events to track using the performance counters.

* cycle_count: the number of cycles where the cpu was utilized
* counter0, counter1, counter2, counter3: Configurable events you are tracking. See ARM link for more info on what you can track.

* You must disable the PMU before you try accessing or configuring it, and then re-enable it. The first part of dvfs_tick shows how to do it properly.
* You don't need to worry about this unless you start changing the provided code (which is not recommended)
** Example: 	disable_pmu();
		cycle_count += read_ccnt();
		configPMU(0x2,0x7);
		enable_pmu();

Please feel free to post any questions you may have!

