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

📄 pic.c

📁 一个微型操作系统源码
💻 C
字号:
/* * OSV * Copyright (C) 2002 Ciprian DOSOFTEI <rocksoul@mail.com> * All rights reserved. *  * http://backster.free.fr/osv * * This file is part of the OSV project. OSV is free software, also known as * "open source"; you can redistribute it and/or modify it under the terms  * of the GNU General Public License (GPL), version 2, as published by the Free * Software Foundation (FSF). To explore alternate licensing terms, contact  * the author at rocksoul@mail.com or +40740649907. *  * OSV 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 GPL for more details.  You should have * received a copy of the GPL along with OSV; see the file COPYING.  If * not, write to the FSF, 59 Temple Place #330, Boston, MA 02111-1307, USA. */#include <pic.h>static word IRQmask;#define SLAVE_IRQ 8#define MASTER_SLAVE 2#define	ICU0 0x20#define	ICU1 0xA0#define	ICU_RESET 0x11void reprogramPIC(ushort master, ushort slave) {    outb(ICU0, ICU_RESET); io_wait();    outb(ICU1, ICU_RESET); io_wait();    outb(ICU0+1, master); io_wait();    outb(ICU1+1, slave); io_wait();    outb(ICU0+1, 0x04); io_wait();    outb(ICU1+1, 0x02); io_wait();    outb(ICU0+1, 0x01); io_wait();    outb(ICU1+1, 0x01); io_wait();    outb(ICU0+1, 0xFB); io_wait();    outb(ICU1+1, 0xFF);    IRQmask = 0xFFFB;}void unmaskIRQ(int irq) {    IRQmask &= ~(1 << irq);    if(irq < 8)	outb(ICU0+1, IRQmask & 0xFF);    else	outb(ICU1+1, IRQmask >> 8);}void maskIRQ(int irq) {    IRQmask |= (1 << irq);    if(irq < 8)	outb(ICU0+1,IRQmask & 0xFF);    else	outb(ICU1+1,IRQmask >> 8);}void refreshIRQs(void) {    outb(ICU0+1,IRQmask & 0xFF);    outb(ICU1+1,IRQmask >> 8);}void registerIRQ(int irq, dword handler, int level) {    interruptIDT(&IDT[32+irq], KERNEL_CS,handler, level);    unmaskIRQ(irq);}

⌨️ 快捷键说明

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