Skip to main content

Posts

Showing posts with the label how
Okay so I have posted a number of Linux kernel programming videos over at my YouTube channe , however I find that I need a place to post a sample code and the make file to build a module. So here it is. The Makefile obj-m := solidusmodule.o KERNEL_DIR = /lib/modules/3.2.0-25-generic/build PWD := $(shell pwd) all: $(MAKE) -C $(KERNEL_DIR) SUBDIRS=$(PWD) modules clean: rm -rf *.o *.ko *.mod.* *.symvers *.order *~ #include #include #include // file_operations structure- which of course allows use to open/close,read/write to device #include //this is a char driver; makes cdev available #include //used to access semaphores; sychronizatoin behaviors #include //copy_to_user;copy_from_user //(1) Create a structure for our fake device struct fake_device { char data[100]; struct semaphore sem; } virtual_device; //(2) To later register our device we need a cdev object and some other variables struct cdev *mcdev; //m stands 'my' int major_number;

AVR Programming

Hello internet, i just recently posted a video  on how to interface an AVR microcontroller with and LCD Screen (HD44780). Please watch the video and do comment.

Introduction to Linux Kernel Programming

The Linux kernel is designed as a mixture of a monolithic binary image and a micro-kernel.  This combination allows for the best of both worlds.  On the monolithic side, all the code for the kernel to work with the user and hardware is already installed and ready for fast access, but the downside is that to add more functionality you need to rebuild the entire kernel.   In a different manner, a micro-kernel is composed of small pieces  of code that can be meshed today and more pieces can be added or removed as needed.  However, the downside to micro-kernel is a slower performance. Adding a module to the Kernel Linux is organized as both monolithic, one huge binary, and micro-kernel, as you can add more functionality to it.  The process of adding more functionality to the kernel can be illustrated by the crude image to the left. The process begins by using the command insmod with the name of the kernel module you want (which usually ends with extension *.ko).  From here, the mod

Writing a Scripting Language

One of the projects that I am working on is how to write a scripting language using c++.  At first thought, I imagined the task to be hard, but to my surprise it is quiet easy. In this post I will introduce the basics.  However, I do suggest you visit my youtube channel and watch the video series . token evaluation process  As you can see from the image to the left, my script engine basically takes a string expression, converts it to tokens, determines its meaning, and then compiles the effective byte code. Byte code is the instruction set for my script language.  It will tell our virtual machine or virtual process what an instruction is suppose to do. In more detail, the script engine does a recursive call with the tokens to successfully generate all the corresponding byte code. Source Code This link contains the source code and is version 1 of script.

The Additon & Subtraction in Assembly

There is not much difficulty when it comes to addition and subtraction in assembly programming. Simply, additon and substraction breaks down to the following: add eax , ecx ; eax = eax + ecx, result in eax add eax , DWORD [ ebp - 4 ] ; eax = eax + localVar1, result in eax add DWORD [ ebp - 4 ] , DWORD [ ebp -4 ] ; illegal, with all instruction both operands can never be memory add DWORD [ ebp - 4 ] , eax ; [ebp-4] = [ebp-4] + eax sub eax , ecx ; eax = eax - ecx, result in eax sub eax , DWORD [ ebp - 4 ] ; eax = eax - localVar1, result in eax sub DWORD [ ebp - 4 ] , DWORD [ ebp -4 ] ; illegal, with all instruction both operands can never be memory sub DWORD [ ebp - 4 ] , eax ; [ebp-4] = [ebp-4] - eax A simple program to display the message about an arithetic operation like "Math: 8 + 4 = ?" can be achived b