lk中内联调用的dsb()
比如lk的uart_dm_init()函数就调用了dsb()
/* Configure the uart clock */ clock_config_uart_dm(id); dsb(); /*Configure GPIO to provide connectivity between UART block product ports and chip pads */ gpio_config_uart_dm(id); dsb();
dsb的在lkarcharmincludearchDefines.h中定义,如下:
#if ARM_ISA_ARMV7 #define dsb() __asm__ volatile("dsb" : : : "memory"); #define dmb() __asm__ volatile("dmb" : : : "memory"); #define isb() __asm__ volatile("isb" : : : "memory"); #elif ARM_ISA_ARMV6 #define dsb() __asm__ volatile ("mcrp15, 0, %0, c7, c10, 4" : : "r" (0): "memory"); #define dmb() __asm__ volatile ("mcrp15, 0, %0, c7, c10, 5" : : "r" (0): "memory"); #define isb() __asm__ volatile ("mcrp15, 0, %0, c7, c5, 4" : :"r" (0): "memory"); #endif
这里是内联汇编里的dsb指令,这是gcc的inline asssemble,主要功能是数据同步屏障,Datasynchronization barrier。
memory is an instruction to GCC that (sortof) says that the inline asm sequence has side effects on global memory, andhence not just effects on local variables need to be taken into account.
这都是 gcc的 inlineassemble
相关链接:
ARM嵌入式开发中的GCC内联汇编(ARM GCC Inline Assembler Cookbook)
http://blog.csdn.net/linglongqiongge/article/details/51678588