LLVM: Cleaning up instructions

My recent task is to clean up the instructions from LLVM code. One must wonder why do I need to clean up the instructions, well perhaps the definition of my recent task was not adequately explain here. AEMB is considered as binary compatible to the Xilink Microblaze (Wikipedia link), however it is not a ‘drop in’ replacement. For a quite distinctive example, AEMB does not support floating point instructions. Yet. Fortunately, due to the compatibility of their instruction-set, I was Read more

Should You Join a Startup? The Answer Is Increasingly Yes!

Just read another interesting piece on why it is becoming increasingly more beneficial for people to join startups instead of large corporations. Quoting the main bits of the article: The Steady Income Myth In an adequately funded startup company one is guaranteed to have an interesting two year run, constantly learning more and something very valuable to walk away with afterwards regardless of what happens. The Influence In a startup you get to directly influence the product you are building. Read more

QEMU: Carry and Carry Copy

AEMB is a family of highly-rated open-source embedded microprocessor core. All the programs for AEMB have to run in a simulation environment, because the core has not yet been implemented in silicone chip. Recently, one of the interns is assigned with the porting of AEMB for QEMU. With the QEMU ported for AEMB, it serves as a platform for application to run the embedded microprocessor. QEMU is a processor emulator that relies on dynamic binary translation to achieve a reasonable speed. The core of QEMU is Tiny Code Read more

uCLinux: Timer Interrupt Handler

Having the understanding of HZ, jiffies, and system timer, it is appropriate to discuss the implementation of time management. Most of the jobs in time management are handled by a dedicated function called timer handler. In Microblaze, the kernel registers timer_interrupt as the interrupt handler: irqreturn_t TIMER_TEXT timer_interrupt(int irq, void *dev_id) { timer_ack(); write_seqlock(&xtime_lock); do_timer(1); update_process_times(user_mode(get_irq_regs())); profile_tick(CPU_PROFILING); write_sequnlock(&xtime_lock); return IRQ_HANDLED; } When kernel is executing timer handler, the timer is first acknowledged, followed by obtaining the xtime_lock lock, which protects access to jiffies and Read more

uCLinux: System Timer

Time management is crucial to Linux kernel. A massive of kernel functions are time-driven and therefore it is heavily dependent on time management. In Linux kernel, time management is handled by a piece of programmable hardware, known as system timer. The main job of system timer is to generate an interrupt at a fixed frequency. A dedicated code, known as timer interrupt routine is executed for each issued interrupt to update system time and perform periodic work. In hardwave abstraction, timer is implemented Read more

LLVM: Target Specific Attributes.

In LLVM system compiler, there is an option in the command command -mattr called target specific attributes. You may check each target attributes by using this command. llvm-as < /dev/null || llc -march=aemb -mattr=help note that -march=aemb is to select target architecture, in my case, aeMB. A list of attributes will appear as below. Available features for this target: barrel – Implements barrel shifter. div – Implements hardware divider. efsl – Implements extended FSL instructions. esr – Implements ESR and Read more

uCLinux: Jiffies in the Kernel

Having the discussion of tick rate in my previous post, it is therefore appropriate to introduce jiffies in linux kernel. Jiffies is a global variable declared in <linux/jiffies.h> as: extern unsigned long volatile jiffies; Its only usage is to store the number of ticks occurred since system start-up. On kernel boot-up, jiffies is initialized to a special initial value, and it is incremented by one for each timer interrupt. As discussed in the previous post, since there are HZ ticks occurred in one Read more

LLVM: Customize your Instructions.

For the past few weeks, I was given a task by my supervisor. The task sound simple, whenever there NOP (No operation) instruction will be use, LLVM should change it into XOR R0, R0, R0 which basically doing nothing since in aeMB, register zero (R0) always have zero values. NOP –change to–> XOR R0, R0, R0 So I start digging. First I look into *InstrInfo.td because thats where all target specific instructions were define. And the tablegen will automatically generate Read more

uCLinux: Tick Rate

With a large number of kernel functions are time-driven, the time management in kernel is very important. The frequency of the system timer (tick rate) is programmed on system boot based on a static preprocessor define, HZ. The value of HZ is architecture-dependent, and it is defined in: <asm/param.h>. The tick rate has a frequency of HZ hertz and a period of 1/HZ seconds. For example, by default the architecture defines HZ to be 100. Therefore, the timer interrupt on the system has a Read more

After life: There is a Need to Improve

I had officially completed my internship life in AESTE. Finishing my internship makes me wonders about my future. This feeling was never so intense. I never worried about my future so much before, when I was in my university. My supervisor told me that engineering is all about efficiency. He showed how naively I had implemented my code, without considering much about readability and capable for other people to handle in the future. These are really inspiring. These does not Read more