Monday, February 8, 2010

Porting Linux Kernel 2.6 to Lexra 5820 Platform

I've been playing around with my wireless access point based-on RTL8186 SoC over the weekend and found probably I could try porting Linux kernel 2.6 into it. It has a Lexra 5820 CPU core which lacks the unaligned memory access instructions found on MIPS. Well, this is just a preliminary and spare time work because it has been running really well with kernel 2.4.18. I just couldn't resist the temptation to try porting kernel 2.6 into it. Well, maybe it's not going to be a time well spent but I believe the experience in doing so will be useful in the future.

Anyway, the lack of the unaligned memory access instructions made me had to work with the unaligned memory handling routine in the kernel source (arch/mips/kernel/unaligned.c) and the memcpy implementation files in the kernel source (arch/mips/lib/memcpy*).

The trick to emulate the unaligned memory access instructions (lwl, lwr, swl, swr) is to turn the routines which use them into byte-wise memory access routines. It's important to note that lwl, lwr, swl, swr instructions operate on word (4-byte) unaligned operands.