1 /** 2 * @file softirq.h 3 * @author fslongjin (longjin@RinGoTek.cn) 4 * @brief 软中断 5 * @version 0.1 6 * @date 2022-04-08 7 * 8 * @copyright Copyright (c) 2022 9 * 10 */ 11 #pragma once 12 13 #include <common/glib.h> 14 15 #define MAX_SOFTIRQ_NUM 64 16 17 #define TIMER_SIRQ 0 // 时钟软中断号 18 #define VIDEO_REFRESH_SIRQ 1 // 帧缓冲区刷新软中断 19 20 /** 21 * @brief 发起软中断 22 * 23 */ 24 #define raise_softirq(sirq_num) \ 25 do \ 26 { \ 27 set_softirq_pending(1 << sirq_num); \ 28 } while (0); 29 30 31 32 33 struct softirq_t 34 { 35 void (*action)(void *data); // 软中断处理函数 36 void *data; 37 }; 38 39 struct softirq_t softirq_vector[MAX_SOFTIRQ_NUM] = {0}; 40 41 /** 42 * @brief 软中断注册函数 43 * 44 * @param irq_num 软中断号 45 * @param action 响应函数 46 * @param data 响应数据结构体 47 */ 48 void register_softirq(uint32_t irq_num, void (*action)(void *data), void *data); 49 50 /** 51 * @brief 卸载软中断 52 * 53 * @param irq_num 软中断号 54 */ 55 void unregister_softirq(uint32_t irq_num); 56 57 void set_softirq_pending(uint64_t status); 58 uint64_t get_softirq_pending(); 59 60 int clear_softirq_pending(uint32_t irq_num); 61 /** 62 * @brief 软中断处理程序 63 * 64 */ 65 void do_softirq(); 66 67 void softirq_init();