X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=KernelLand%2FModules%2Farmv7%2FGIC%2Fgic.c;h=1de851dc5ee15fade2e499150ce858d2212d3ed6;hb=2015e19b71476d1fee2480aef4de60d22ed5438d;hp=a918f68e2ff83bd6651ea8566719ca4d19c197fb;hpb=7ba570fe3cc5418f42decf5b72ac2295cce9e60f;p=tpg%2Facess2.git diff --git a/KernelLand/Modules/armv7/GIC/gic.c b/KernelLand/Modules/armv7/GIC/gic.c index a918f68e..1de851dc 100644 --- a/KernelLand/Modules/armv7/GIC/gic.c +++ b/KernelLand/Modules/armv7/GIC/gic.c @@ -39,14 +39,11 @@ int GIC_Install(char **Arguments) // Initialise Log_Debug("GIC", "Dist: %P, Interface: %P", gGIC_DistributorAddr, gGIC_InterfaceAddr); - gpGIC_InterfaceBase = (void*)MM_MapHWPages(gGIC_InterfaceAddr, 1); - LOG("gpGIC_InterfaceBase = %p", gpGIC_InterfaceBase); + gpGIC_InterfaceBase = (Uint32*)MM_MapHWPages(gGIC_InterfaceAddr, 1) + + (gGIC_InterfaceAddr & (PAGE_SIZE-1))/4; gpGIC_DistributorBase = (void*)MM_MapHWPages(gGIC_DistributorAddr, 1); - LOG("gpGIC_DistributorBase = %p", gpGIC_DistributorBase); gpGIC_InterfaceBase[GICC_CTLR] = 0; // Disable CPU interaface - LOG("GICC_IAR = %x (CTLR=0)", gpGIC_InterfaceBase[GICC_IAR]); - gpGIC_InterfaceBase[GICC_PMR] = 0xFF; // Effectively disable prioritories gpGIC_InterfaceBase[GICC_CTLR] = 1; // Enable CPU gpGIC_DistributorBase[GICD_CTLR] = 1; // Enable Distributor @@ -80,8 +77,12 @@ int GIC_Install(char **Arguments) void GIC_IRQHandler(void) { Uint32 num = gpGIC_InterfaceBase[GICC_IAR]; - Log_Debug("GIC", "IRQ 0x%x", num); - gaIRQ_Handlers[num]( num, gaIRQ_HandlerData[num] ); + if( gaIRQ_Handlers[num] ) { + gaIRQ_Handlers[num]( num, gaIRQ_HandlerData[num] ); + } + else { + Log_Debug("GIC", "IRQ 0x%x unhandled", num); + } gpGIC_InterfaceBase[GICC_EOIR] = num; } @@ -96,6 +97,7 @@ int IRQ_AddHandler(int IRQ, tIRQ_Handler Handler, void *Ptr) gpGIC_DistributorBase[GICD_ISENABLER0+IRQ/32] = 1 << (IRQ & (32-1)); ((Uint8*)&gpGIC_DistributorBase[GICD_ITARGETSR0])[IRQ] = 1; gpGIC_DistributorBase[GICD_ICPENDR0+IRQ/32] = 1 << (IRQ & (32-1)); + gpGIC_DistributorBase[GICD_ICFGR0+IRQ/16] |= 2 << ((IRQ & 15)*2); // TODO: Does the GIC need to handle IRQ sharing? if( gaIRQ_Handlers[IRQ] ) { @@ -108,9 +110,6 @@ int IRQ_AddHandler(int IRQ, tIRQ_Handler Handler, void *Ptr) gaIRQ_HandlerData[IRQ] = Ptr; Log_Debug("GIC", "IRQ %i handled by %p(%p)", IRQ, Handler, Ptr); - - // DEBUG! Trip the interrupt - gpGIC_DistributorBase[GICD_ISPENDR0+IRQ/32] = 1 << (IRQ & (32-1)); return 0; }