2012-11-05 86 views
4

我們在KEIL IDE中爲LPC2148編寫了一個項目,其中包含RTX內核程序以及由ARM CC編譯的其他程序。現在,我們需要將IDE從KEIL (ARM CC)到Eclipse(GCC)。當我們嘗試在Eclipse GCC Compiler中編譯它時,它在RTX_Config.c和RTX_Config.h文件中顯示錯誤。其他文件使用GCC編譯器成功編譯。但RTXConfig.c文件具有編譯器特定的代碼,這些代碼不會被GCC編譯。是否有任何解決方案使用GCC編譯器在Eclipse IDE中編譯此項目?作爲初學者,請幫助我。在此先感謝在Eclipse IDE中使用GCC編譯器編譯RTX內核文件

我們有像IRQ一些KEIL特定的關鍵字,__swi,_ _Task,這是由ARM CC(KEIL)編譯成功,但是當我們試圖將它移植到GCC編譯器(Eclipse中)__asm,這編譯器無法編譯這些關鍵字並顯示錯誤。 有沒有什麼辦法可以在GCC編譯器中編譯這些keil特定的關鍵字?

回答

2

do_software_interrupt,do_irq和do_fiq分別是SWI,IRQ和FIQ的中斷服務例程。這些函數在c中使用gcc的屬性特性實現。下面是包含irq,fiq和軟件中斷例程的實際c代碼。

entry.c

void __attribute__((interrupt("IRQ"))) do_irq() 
{ 
    //your irq service code goes here 
} 

void __attribute__((interrupt("FIQ"))) do_fiq() 
{ 
    //your fiq service code goes here 
} 

void __attribute__((interrupt("SWI"))) do_software_interrupt() 
{ 
    volatile unsigned int int_num; 
    asm("LDR r0, [lr, #-4]"); 
    asm("BIC r0, #0xFF000000"); 
    asm("MOV %0, r0":"=r"(int_num):); 
    //based on int_num, you can determine which system call is called 
} 

void c_start() { 
    asm volatile ("SVC 0x5"); 
    while(1){} 
}