Skip to content

Commit

Permalink
Merge pull request #112 from georgekang/master
Browse files Browse the repository at this point in the history
Implement threaded irq in user space by IPC and provide example test case for this feature
  • Loading branch information
georgekang committed Mar 31, 2015
2 parents 8a85eec + 98e0691 commit 41b25bc
Show file tree
Hide file tree
Showing 28 changed files with 1,545 additions and 8 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ $(eval BOARD_$(BOARD)=y)
KCONFIG_FILES = \
platform/Kconfig \
kernel/Kconfig \
loader/Kconfig
loader/Kconfig \
user/Kconfig

# Read configurations about system features and characteristics
include mk/config.mk
Expand Down
86 changes: 86 additions & 0 deletions board/discoveryf4/defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,89 @@ CONFIG_KPROBES=y
CONFIG_SYMMAP=y
CONFIG_PANIC_DUMP_STACK=y
# CONFIG_LOADER is not set

#
# User IRQ
#
# CONFIG_WWDG_USER_IRQ is not set
# CONFIG_PVD_USER_IRQ is not set
# CONFIG_TAMP_STAMP_USER_IRQ is not set
# CONFIG_RTC_WKUP_USER_IRQ is not set
# CONFIG_FLASH_USER_IRQ is not set
# CONFIG_RCC_USER_IRQ is not set
# CONFIG_EXTI0_USER_IRQ is not set
# CONFIG_EXTI1_USER_IRQ is not set
# CONFIG_EXTI2_USER_IRQ is not set
# CONFIG_EXTI3_USER_IRQ is not set
# CONFIG_EXTI4_USER_IRQ is not set
# CONFIG_DMA1_Stream0_USER_IRQ is not set
# CONFIG_DMA1_Stream1_USER_IRQ is not set
# CONFIG_DMA1_Stream2_USER_IRQ is not set
# CONFIG_DMA1_Stream3_USER_IRQ is not set
# CONFIG_DMA1_Stream4_USER_IRQ is not set
# CONFIG_DMA1_Stream5_USER_IRQ is not set
# CONFIG_DMA1_Stream6_USER_IRQ is not set
# CONFIG_ADC_USER_IRQ is not set
# CONFIG_CAN1_TX_USER_IRQ is not set
# CONFIG_CAN1_RX_USER_IRQ is not set
# CONFIG_CAN1_RX1_USER_IRQ is not set
# CONFIG_CAN1_SCE_USER_IRQ is not set
# CONFIG_EXTI9_5_USER_IRQ is not set
# CONFIG_TIM1_BRK_TIM9_USER_IRQ is not set
# CONFIG_TIM1_UP_TIM10_USER_IRQ is not set
# CONFIG_TIM1_TRG_COM_TIM11_USER_IRQ is not set
# CONFIG_TIM1_CC_USER_IRQ is not set
# CONFIG_TIM2_USER_IRQ is not set
# CONFIG_TIM3_USER_IRQ is not set
# CONFIG_TIM4_USER_IRQ is not set
# CONFIG_I2C1_EV_USER_IRQ is not set
# CONFIG_I2C1_ER_USER_IRQ is not set
# CONFIG_I2C2_EV_USER_IRQ is not set
# CONFIG_I2C2_ER_USER_IRQ is not set
# CONFIG_SPI1_USER_IRQ is not set
# CONFIG_SPI2_USER_IRQ is not set
# CONFIG_USART1_USER_IRQ is not set
# CONFIG_USART2_USER_IRQ is not set
# CONFIG_USART3_USER_IRQ is not set
# CONFIG_EXTI15_10_USER_IRQ is not set
# CONFIG_RTC_Alarm_USER_IRQ is not set
# CONFIG_OTG_FS_WKUP_USER_IRQ is not set
# CONFIG_TIM8_BRK_TIM12_USER_IRQ is not set
# CONFIG_TIM8_UP_TIM13_USER_IRQ is not set
# CONFIG_TIM8_TRG_COM_TIM14_USER_IRQ is not set
# CONFIG_TIM8_CC_USER_IRQ is not set
# CONFIG_DMA1_Stream7_USER_IRQ is not set
# CONFIG_FSMC_USER_IRQ is not set
# CONFIG_SDIO_USER_IRQ is not set
# CONFIG_TIM5_USER_IRQ is not set
# CONFIG_SPI3_USER_IRQ is not set
# CONFIG_UART4_USER_IRQ is not set
# CONFIG_UART5_USER_IRQ is not set
# CONFIG_TIM6_DAC_USER_IRQ is not set
# CONFIG_TIM7_USER_IRQ is not set
# CONFIG_DMA2_Stream0_USER_IRQ is not set
# CONFIG_DMA2_Stream1_USER_IRQ is not set
# CONFIG_DMA2_Stream2_USER_IRQ is not set
# CONFIG_DMA2_Stream3_USER_IRQ is not set
# CONFIG_DMA2_Stream4_USER_IRQ is not set
# CONFIG_ETH_USER_IRQ is not set
# CONFIG_ETH_WKUP_USER_IRQ is not set
# CONFIG_CAN2_TX_USER_IRQ is not set
# CONFIG_CAN2_RX0_USER_IRQ is not set
# CONFIG_CAN2_RX1_USER_IRQ is not set
# CONFIG_CAN2_SCE_USER_IRQ is not set
# CONFIG_OTG_FS_USER_IRQ is not set
# CONFIG_DMA2_Stream5_USER_IRQ is not set
# CONFIG_DMA2_Stream6_USER_IRQ is not set
# CONFIG_DMA2_Stream7_USER_IRQ is not set
# CONFIG_USART6_USER_IRQ is not set
# CONFIG_I2C3_EV_USER_IRQ is not set
# CONFIG_I2C3_ER_USER_IRQ is not set
# CONFIG_OTG_HS_EP1_OUT_USER_IRQ is not set
# CONFIG_OTG_HS_EP1_IN_USER_IRQ is not set
# CONFIG_OTG_HS_WKUP_USER_IRQ is not set
# CONFIG_OTG_HS_USER_IRQ is not set
# CONFIG_DCMI_USER_IRQ is not set
# CONFIG_CRYP_USER_IRQ is not set
# CONFIG_HASH_RNG_USER_IRQ is not set
# CONFIG_FPU_USER_IRQ is not set
15 changes: 15 additions & 0 deletions include/interrupt.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#ifndef INTERRUPT_H_
#define INTERRUPT_H_

#define DEFAULT_PRIORITY 1

void user_interrupt_config(tcb_t *from);
void user_interrupt_handler_update(tcb_t *thr);

/* Platform depended */
void user_irq_enable(int irq);
void user_irq_disable(int irq);
void user_irq_set_pending(int irq);
void user_irq_clear_pending(int irq);

#endif
24 changes: 24 additions & 0 deletions include/interrupt_ipc.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#ifndef INTERRUPT_IPC_H_
#define INTERRUPT_IPC_H_

/* interrupt ipc message */
enum {
IRQ_IPC_IRQN = 0,
IRQ_IPC_TID = 1,
IRQ_IPC_HANDLER = 2,
IRQ_IPC_ACTION = 3,
IRQ_IPC_PRIORITY = 4
};

#define IRQ_IPC_MSG_NUM IRQ_IPC_PRIORITY

/* irq actions */
enum {
USER_IRQ_ENABLE = 0,
USER_IRQ_DISABLE = 1,
USER_IRQ_FREE = 2
};

#define USER_INTERRUPT_LABEL 0x928

#endif
3 changes: 3 additions & 0 deletions include/ipc.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,7 @@
void sys_ipc(uint32_t *param1);
uint32_t ipc_deliver(void *data);

uint32_t ipc_read_mr(tcb_t *from, int i);
void ipc_write_mr(tcb_t *to, int i, uint32_t data);

#endif /* IPC_H_ */
1 change: 1 addition & 0 deletions include/platform/stm32f1/nvic.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ typedef enum IRQn {
EXTI15_10_IRQn = 40, /*!< External Line[15:10] Interrupts */
RTC_Alarm_IRQn = 41, /*!< RTC Alarm (A and B) through EXTI Line Interrupt */
OTG_FS_WKUP_IRQn = 42, /*!< USB OTG FS Wakeup through EXTI line interrupt */
IRQn_NUM,
} IRQn_Type;

#define MAX_IRQn FPU_IRQn
Expand Down
28 changes: 28 additions & 0 deletions include/platform/stm32f4/exti.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#ifndef PLATFORM_STM32F4_EXTI_H_
#define PLATFORM_STM32F4_EXTI_H_

#include <platform/stm32f4/registers.h>
#include <platform/stm32f4/gpio.h>

/* EXTI mode */
#define EXTI_INTERRUPT_MODE 0x0
#define EXTI_EVENT_MODE 0x4

/* EXTI trigger type */
#define EXTI_RISING_TRIGGER 0x8
#define EXTI_FALLING_TRIGGER 0xc
#define EXTI_RISING_FALLING_TRIGGER 0x10

#define EXTI_LINE(x) ((uint32_t)0x1 << x)

struct exti_regs {
volatile uint32_t IMR;
volatile uint32_t EMR;
volatile uint32_t RTSR;
volatile uint32_t FTSR;
volatile uint32_t SWIER;
volatile uint32_t PR;
};


#endif
2 changes: 2 additions & 0 deletions include/platform/stm32f4/nvic.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ typedef enum IRQn {
CRYP_IRQn = 79, /*!< CRYP crypto global interrupt */
HASH_RNG_IRQn = 80, /*!< Hash and Rng global interrupt */
FPU_IRQn = 81, /*!< FPU global interrupt */
IRQn_NUM,
} IRQn_Type;

#define MAX_IRQn FPU_IRQn
Expand Down Expand Up @@ -268,4 +269,5 @@ inline static uint32_t NVIC_GetActive(IRQn_Type IRQn)
(1 << ((uint32_t)(IRQn) & 0x1F))) ? 1 : 0);
}

int nvic_is_setup(int irq);
#endif /* __PLATFORM_STM32F4_NVIC_H__ */
Loading

0 comments on commit 41b25bc

Please sign in to comment.