⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 irq.c

📁 Bycore是一个嵌入式操作系统内核。Bycore包括内存管理、任务管理、中断管理、任务互斥、同步与通信管理等功能。Bycore全部由C语言完成
💻 C
字号:
/** *  irq.c - Interruption management. * *  Copyright (C) 2008  ZhangHu *  All rights reserved. *  E-MAIL: anmnmnly@gmail.com * *  This program is free software: you can redistribute it and/or modify *  it under the terms of the GNU General Public License as published by *  the Free Software Foundation, either version 3 of the License, or *  (at your option) any later version. * *  This program is distributed in the hope that it will be useful, *  but WITHOUT ANY WARRANTY; without even the implied warranty of *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the *  GNU General Public License for more details. * *  You should have received a copy of the GNU General Public License *  along with this program.  If not, see <http://www.gnu.org/licenses/>. */#include "include/irq.h"#include "include/mem.h"#include "include/list.h"uword_t int_cnt;   /* The number of interruption nesting */word_t int_flag;   /* Interruption flag */list_t israrry[ISR_NUM];  /* An array store all interruption service handle *//** * initirq - Initialize interruption management. * @return: * * @notes: Now, it is the only thing to initialize 'israrray[]'. */void initirq(void) {    uword_t i;    for(i = 0; i < ISR_NUM; i++) {        israrry[i].next = &israrry[i];        israrry[i].prev = &israrry[i];    }}/** * isr_install - Installing a ISR for a interruption. * @IntNum: Serial number of interruption that vary from architecture. * @IrqNo: ISR Serial number for a interruption. * @phdl: Pointer to the entry of ISR. * @return: * * @notes: There are many ISRs for a special interruption. */void isr_install(uword_t IntNum, char_t IrqNo, void(*phdl)(void)) {    isr_t *ptmp;    ptmp = (isr_t*)allocate(sizeof(isr_t));    if(ptmp != NULL) {        ptmp->pisr = phdl;        ptmp->irq_no = IrqNo;        add_node_list_rear(&israrry[IntNum], &ptmp->link);    }}/** * isr_uninstall - Uninstalling a ISR of a interruption. * @IntNum: Serial number of interruption that vary from architecture. * @IrqNo: ISR Serial number for a interruption. * @return: * * @notes: */void isr_uninstall(uword_t IntNum, char_t IrqNo) {    list_t *plist;    isr_t *pisr;    plist = israrry[IntNum].next;    while(plist != NULL) {        pisr = mac_find_entry(plist, isr_t, link);        if(pisr->irq_no == IrqNo) {            del_node_list(&israrry[IntNum], plist);            free(pisr);            break;        }        plist = plist->next;    }}/** * isrHandler - Handle all interruptions. * @return: * * @notes: All interruption service routines have been installed *         in a array named 'israrry[]'. whenever any interruption occured *         this routine execute immediately. */void isrHandler(void) {    uword_t isrnum;    list_t *plist;    isr_t *phdl;    int_cnt++;    int_flag = TRUE;    isrnum = get_isr_num();    plist = israrry[isrnum].prev;    do {        if(plist !=  &israrry[isrnum]) {            phdl = mac_find_entry(plist, isr_t, link);            phdl->pisr();            plist = plist->prev;        }    } while(plist != israrry[isrnum].prev);    isr_after_handle(isrnum);    scheduler();}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -