Demo entry 5862254

cpp

   

Submitted by peng on Jul 28, 2016 at 11:56
Language: C#. Code size: 1.9 kB.

#include "gic_handler.h"
#include "gic_reg.h"
#include "gic_misc.h"

//extern void handle_rtc();     
//extern void handle_wdt();
extern void handle_wdt()
{
    int wdt_base = 0x50440000;
	volatile int *wdt_addr = (int *)wdt_base;
	int i = 0;
	volatile int wdt_rst = 0xf;
	
    wdt_rst = wdt_addr[0x10/4];   //read interrupt status
	wdt_rst = wdt_addr[0x14/4];  //read clear wdt
	wdt_addr[0x0/4] = 0x0;   //disable
}
extern void handle_rtc()
{
    int rtc_base = 0x50480000;
	volatile int *rtc_addr = (int *)rtc_base;
	int i = 0;
	volatile int rtc_rst = 0xf;
	
	rtc_rst = rtc_addr[4];  //read interrupt status
	rtc_rst = rtc_addr[0x18/4];  //read clear RTC
	rtc_addr[3] = 0;  //disable
}
void Fiq_Interrupt_Handler()
{
    volatile unsigned pending = 0, ack = 0, priority = 0;
	unsigned int temp_eoi_wr_data;
	//read the CPU_IF pending  reg to verify the sti firing
	pending = gic_dist->Interrupt_Set_Pending_Register0;
	
	//rd ACK reg and results are discarded
	ack = gic_cpuif->Interrupt_Acknowledge_Register;
	
	if (ack < 1023) {
	//EOI wr value = CPU_source_ID + Interrupt_ID
	temp_eoi_wr_data = ack;
	gic_cpuif->End_Of_Interrupt_Register = temp_eoi_wr_data;
	}
}

void Irq_Interrupt_Handler()
{
    volatile unsigned pending = 0, ack = 0, priority = 0;
	unsigned int temp_eoi_wr_data;
	// read the CPU_IF pending reg to verify the sti firing
	pending = gic_dist->Interrupt_Set_Pending_Register0;
	//rd ACK reg and results are discarded
	ack = gic_cpuif->Interrupt_Acknowledge_Register;
	if (ack < 1023) {
	switch(ack)
	{
	case 33 :
	    handle_rtc();
		break;
	case 62 :
	    handle_wdt();
		break;
	default :
	    break;
		}
	//EOI wr value = CPU_source_ID + Interrupt_ID
	temp_eoi_wr_data = ack;
    gic_cpuif->End_Of_Interrupt_Register = temp_eoi_wr_data;
    }
	
    return;	
	
}

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).