Subversion Repositories HelenOS-historic

Compare Revisions

Ignore whitespace Rev 1479 → Rev 1480

/kernel/trunk/arch/ppc32/include/interrupt.h
31,13 → 31,18
 
#include <arch/exception.h>
 
#define IRQ_COUNT 1
#define IVT_ITEMS 15
#define INT_OFFSET 0
#define IRQ_COUNT 64
 
 
#define IVT_ITEMS (16 + IRQ_COUNT)
#define INT_OFFSET 16
 
#define int_register(it, name, handler) exc_register(((it)+INT_OFFSET),name,handler)
 
#define VECTOR_DECREMENTER 10
 
extern void start_decrementer(void);
extern void interrupt_init(void);
extern void extint_handler(int n, istate_t *istate);
 
#endif
/kernel/trunk/arch/ppc32/include/drivers/pic.h
0,0 → 1,48
/*
* Copyright (C) 2006 Ondrej Palkovsky
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - 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.
* - The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
*/
 
#ifndef __PIC_H_
#define __PIC_H_
 
/* PIC handler, read from pearpc source codes */
#define PIC_HW_ADDR 0x80800000
 
#define PIC_PENDING_LOW 8
#define PIC_PENDING_HIGH 4
#define PIC_MASK_LOW 9
#define PIC_MASK_HIGH 5
#define PIC_ACK_LOW 10
#define PIC_ACK_HIGH 6
 
void pic_init(void);
void pic_enable_interrupt(int intnum);
void pic_disable_interrupt(int intnum);
void pic_ack_interrupt(int intnum);
int pic_get_pending(void);
 
#endif
/kernel/trunk/arch/ppc32/include/drivers/cuda.h
31,6 → 31,8
 
#include <arch/types.h>
 
#define CUDA_IRQ 10
 
extern void cuda_init(void);
extern void cuda_packet(const __u8 data);
 
/kernel/trunk/arch/ppc32/Makefile.inc
78,4 → 78,5
arch/$(ARCH)/src/mm/frame.c \
arch/$(ARCH)/src/mm/memory_init.c \
arch/$(ARCH)/src/mm/page.c \
arch/$(ARCH)/src/mm/tlb.c
arch/$(ARCH)/src/mm/tlb.c \
arch/$(ARCH)/src/drivers/pic.c
/kernel/trunk/arch/ppc32/src/exception.S
185,8 → 185,15
.org 0x500
.global exc_external
exc_external:
b exc_external
CONTEXT_STORE
 
lis r12, extint_handler@ha
addi r12, r12, extint_handler@l
mtsrr0 r12
 
li r3, 0
b jump_to_kernel
 
.org 0x600
.global exc_alignment
exc_alignment:
/kernel/trunk/arch/ppc32/src/ppc32.c
35,6 → 35,7
#include <userspace.h>
#include <proc/uarg.h>
#include <console/console.h>
#include <arch/drivers/pic.h>
 
bootinfo_t bootinfo;
 
55,10 → 56,9
{
/* Initialize dispatch table */
interrupt_init();
 
/* Start decrementer */
start_decrementer();
cuda_init();
}
 
void arch_post_mm_init(void)
66,6 → 66,10
if (config.cpu_active == 1) {
fb_init(bootinfo.screen.addr, bootinfo.screen.width, bootinfo.screen.height, bootinfo.screen.bpp, bootinfo.screen.scanline);
/* Initialize PIC */
pic_init();
cuda_init();
/* Merge all zones to 1 big zone */
zone_merge_all();
}
/kernel/trunk/arch/ppc32/src/interrupt.c
32,6 → 32,7
#include <arch.h>
#include <time/clock.h>
#include <ipc/sysipc.h>
#include <arch/drivers/pic.h>
 
 
void start_decrementer(void)
64,3 → 65,15
panic("not implemented\n");
/* TODO */
}
 
#include <print.h>
/** Handler of externul interrupts */
void extint_handler(int n, istate_t *istate)
{
int inum;
 
while ((inum = pic_get_pending()) != -1) {
exc_dispatch(inum+INT_OFFSET, istate);
pic_ack_interrupt(inum);
}
}
/kernel/trunk/arch/ppc32/src/drivers/pic.c
0,0 → 1,85
/*
* Copyright (C) 2006 Ondrej Palkovsky
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - 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.
* - The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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 <arch/asm.h>
#include <arch/drivers/pic.h>
#include <byteorder.h>
#include <bitops.h>
 
static volatile __u32 *pic;
 
void pic_init(void)
{
pic = (__u32 *)hw_map(PIC_HW_ADDR, PAGE_SIZE);
}
 
 
 
void pic_enable_interrupt(int intnum)
{
if (intnum < 32) {
pic[PIC_MASK_LOW] = pic[PIC_MASK_LOW] | (1 << intnum);
} else {
pic[PIC_MASK_HIGH] = pic[PIC_MASK_HIGH] | (1 << (intnum-32));
}
}
 
void pic_disable_interrupt(int intnum)
{
if (intnum < 32) {
pic[PIC_MASK_LOW] = pic[PIC_MASK_LOW] & (~(1 << intnum));
} else {
pic[PIC_MASK_HIGH] = pic[PIC_MASK_HIGH] & (~(1 << (intnum-32)));
}
}
 
void pic_ack_interrupt(int intnum)
{
if (intnum < 32)
pic[PIC_ACK_LOW] = 1 << intnum;
else
pic[PIC_ACK_HIGH] = 1 << (intnum-32);
}
 
/** Return number of pending interrupt */
int pic_get_pending(void)
{
int pending;
 
pending = pic[PIC_PENDING_LOW];
if (pending) {
return fnzb32(pending);
}
pending = pic[PIC_PENDING_HIGH];
if (pending) {
return fnzb32(pending) + 32;
}
return -1;
}
/kernel/trunk/arch/ppc32/src/drivers/cuda.c
30,6 → 30,8
#include <arch/asm.h>
#include <console/chardev.h>
#include <console/console.h>
#include <arch/drivers/pic.h>
#include <interrupt.h>
 
#define CUDA_PACKET 0x01
#define CUDA_POWERDOWN 0x0a
47,9 → 49,16
 
static volatile __u8 *cuda = (__u8 *) 0xf2000000;
 
#include <print.h>
static void cuda_irq(int n, istate_t *istate)
{
printf("Got cuda msg\n");
}
 
void cuda_init(void)
{
int_register(CUDA_IRQ, "cuda", cuda_irq);
pic_enable_interrupt(CUDA_IRQ);
}