x86: Add pic_unmask_irq() helper
This patch implements the pic_unmask_irq() helper and uses it where applicable. This function zeros the corresponding bit from the IRQ number in IMR register. This patch doesn't implement the pic_mask_irq() helper since it is not useful at this moment.
This commit is contained in:
parent
b8056b9c97
commit
826ff7cb29
5 changed files with 55 additions and 5 deletions
|
@ -1,6 +1,6 @@
|
|||
CONTIKI_CPU_DIRS = . drivers
|
||||
|
||||
CONTIKI_SOURCEFILES += mtarch.c gdt.c helpers.S idt.c cpu.c rtc.c pit.c
|
||||
CONTIKI_SOURCEFILES += mtarch.c gdt.c helpers.S idt.c cpu.c rtc.c pit.c pic.c
|
||||
|
||||
### Compiler definitions
|
||||
CC = gcc
|
||||
|
|
48
cpu/x86/drivers/pic.c
Normal file
48
cpu/x86/drivers/pic.c
Normal file
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* Copyright (C) 2015, Intel Corporation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "drivers/pic.h"
|
||||
|
||||
void
|
||||
pic_unmask_irq(unsigned int num)
|
||||
{
|
||||
uint16_t port;
|
||||
uint8_t bitmap;
|
||||
|
||||
if(num <= 7) {
|
||||
port = PIC1_DATA_PORT;
|
||||
} else {
|
||||
port = PIC2_DATA_PORT;
|
||||
num -= 8;
|
||||
}
|
||||
|
||||
bitmap = inb(port);
|
||||
outb(port, bitmap & ~BIT(num));
|
||||
}
|
|
@ -38,6 +38,8 @@
|
|||
#define PIC2_CMD_PORT 0xA0
|
||||
#define PIC2_DATA_PORT 0xA1
|
||||
|
||||
void pic_unmask_irq(unsigned int num);
|
||||
|
||||
/* This function initializes the daisy-chained Master and Slave 8259 PICs.
|
||||
* It is only called once, so let's give the compiler the option to inline it.
|
||||
* For more information about the ICWs, please refer to http://stanislavs.org/helppc/8259.html.
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
|
||||
#include <math.h>
|
||||
|
||||
#include "drivers/pic.h"
|
||||
#include "pit.h"
|
||||
#include "helpers.h"
|
||||
#include "interrupt.h"
|
||||
|
@ -75,6 +76,5 @@ pit_init(uint32_t ticks_rate, pit_int_callback cb)
|
|||
outb(PIT_COUNTER0_PORT, divisor & 0xFF); /* Write least significant bytes first. */
|
||||
outb(PIT_COUNTER0_PORT, (divisor >> 8) & 0xFF);
|
||||
|
||||
/* FIXME: Unmask IRQ0 from Master PIC. Add a pic_set_mask() or similar and call it here. */
|
||||
outb(0x21, 0xfa);
|
||||
pic_unmask_irq(0);
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
*/
|
||||
|
||||
#include "drivers/rtc.h"
|
||||
#include "drivers/pic.h"
|
||||
#include "helpers.h"
|
||||
#include "interrupt.h"
|
||||
|
||||
|
@ -87,6 +88,5 @@ rtc_init(rtc_frequency_t frequency, void (*callback)(void))
|
|||
outb(RTC_INDEX_REGISTER, 0x0B);
|
||||
outb(RTC_TARGET_REGISTER, reg_b | BIT(6));
|
||||
|
||||
/* Unmask IRQ8 */
|
||||
outb(0xA1, 0xFE);
|
||||
pic_unmask_irq(8);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue