예제 #1
0
void
isci_interrupt_legacy_handler(void *arg)
{
    struct ISCI_INTERRUPT_INFO *interrupt_info =
        (struct ISCI_INTERRUPT_INFO *)arg;
    struct isci_softc *isci =
        (struct isci_softc *)interrupt_info->interrupt_target_handle;
    SCIC_CONTROLLER_INTERRUPT_HANDLER  interrupt_handler;
    SCIC_CONTROLLER_COMPLETION_HANDLER completion_handler;
    int index;

    interrupt_handler =  interrupt_info->handlers->interrupt_handler;
    completion_handler = interrupt_info->handlers->completion_handler;

    for (index = 0; index < isci->controller_count; index++) {
        struct ISCI_CONTROLLER *controller = &isci->controllers[index];

        /* If controller_count > 0, we will get interrupts here for
         *  controller 0 before controller 1 has even started.  So
         *  we need to make sure we don't call the completion handler
         *  for a non-started controller.
         */
        if (controller->is_started == TRUE) {
            SCI_CONTROLLER_HANDLE_T scic_controller_handle =
                scif_controller_get_scic_handle(
                    controller->scif_controller_handle);

            if (interrupt_handler(scic_controller_handle)) {
                mtx_lock(&controller->lock);
                completion_handler(scic_controller_handle);
                mtx_unlock(&controller->lock);
            }
        }
    }
}
예제 #2
0
void
isci_interrupt_msix_handler(void *arg)
{
	struct ISCI_INTERRUPT_INFO *interrupt_info =
	    (struct ISCI_INTERRUPT_INFO *)arg;
	struct ISCI_CONTROLLER *controller =
	    (struct ISCI_CONTROLLER *)interrupt_info->interrupt_target_handle;
	SCIC_CONTROLLER_INTERRUPT_HANDLER  interrupt_handler;
	SCIC_CONTROLLER_COMPLETION_HANDLER completion_handler;

	interrupt_handler =  interrupt_info->handlers->interrupt_handler;
	completion_handler = interrupt_info->handlers->completion_handler;

	SCI_CONTROLLER_HANDLE_T scic_controller_handle;

	scic_controller_handle = scif_controller_get_scic_handle(
	    controller->scif_controller_handle);

	if (interrupt_handler(scic_controller_handle)) {
		mtx_lock(&controller->lock);
		completion_handler(scic_controller_handle);
		/*
		 * isci_controller_release_queued_ccb() is a relatively
		 *  expensive routine, so we don't call it until the controller
		 *  level flag is set to TRUE.
		 */
		if (controller->release_queued_ccbs == TRUE)
			isci_controller_release_queued_ccbs(controller);
		mtx_unlock(&controller->lock);
	}
}
예제 #3
0
IOReturn FakeSMCDevice::causeInterrupt(int source)
{
	if(interrupt_handler)
		interrupt_handler(interrupt_target, interrupt_refcon, this, interrupt_source);
    
	return kIOReturnSuccess;
}
예제 #4
0
void handle_top_interrupt(){
	while(!isEmpty()){
		print_no_more = false;
		struct interrupt topInterrupt = findMin();
		if(topInterrupt.instr_no == isa_inst_count){
			printf("Handling current interrupt(s)   %d \n", isa_inst_count);
			deleteMin();
			// handle interrupt
			interrupt_handler(topInterrupt);
			if(!ke->running_list_head){
				printf("Something wrong happened 22\n");
			}
		}	
		else break;
	}
}
예제 #5
0
void trap_handler(struct mips_core_data *state, unsigned int status, unsigned int cause)
{
  if (debug) printf("trap_handler: status=0x%08x cause=0x%08x on core %d\n", status, cause, current_cpu_id());
  // diagnose the cause of the trap
  int ecode = (cause & 0x7c) >> 2;
  switch (ecode) {
    case ECODE_INT:	  /* external interrupt */
      interrupt_handler(cause);
      return; /* this is the only exception we currently handle; all others cause a shutdown() */
    case ECODE_MOD:	  /* attempt to write to a non-writable page */
      printf("trap_handler: some code is trying to write to a non-writable page!\n");
      break;
    case ECODE_TLBL:	  /* page fault during load or instruction fetch */
    case ECODE_TLBS:	  /* page fault during store */
      printf("trap_handler: some code is trying to access a bad virtual address!\n");
      break;
    case ECODE_ADDRL:	  /* unaligned address during load or instruction fetch */
    case ECODE_ADDRS:	  /* unaligned address during store */
      printf("trap_handler: some code is trying to access a mis-aligned address!\n");
      break;
    case ECODE_IBUS:	  /* instruction fetch bus error */
      printf("trap_handler: some code is trying to execute non-RAM physical addresses!\n");
      break;
    case ECODE_DBUS:	  /* data load/store bus error */
      printf("trap_handler: some code is read or write physical address that can't be!\n");
      break;
    case ECODE_SYSCALL:	  /* system call */
      printf("trap_handler: who is doing a syscall? not in this project...\n");
      break;
    case ECODE_BKPT:	  /* breakpoint */
      printf("trap_handler: reached breakpoint, or maybe did a divide by zero!\n");
      break;
    case ECODE_RI:	  /* reserved opcode */
      printf("trap_handler: trying to execute something that isn't a valid instruction!\n");
      break;
    case ECODE_OVF:	  /* arithmetic overflow */
      printf("trap_handler: some code had an arithmetic overflow!\n");
      break;
    case ECODE_NOEX:	  /* attempt to execute to a non-executable page */
      printf("trap_handler: some code attempted to execute a non-executable virtual address!\n");
      break;
    default:
      printf("trap_handler: unknown error code 0x%x\n", ecode);
      break;
  }
  shutdown();
}
예제 #6
0
파일: trap.c 프로젝트: tansinan/ucore_plus
static void trap_dispatch(struct trapframe *tf)
{
	int i;
	int code = GET_CAUSE_EXCODE(tf->tf_cause);
	switch (code) {
	case EX_IRQ:
		interrupt_handler(tf);
		break;
	case EX_MOD:
		handle_tlbmiss(tf, 1, 1);
		break;
	case EX_TLBL:
		handle_tlbmiss(tf, 0, 0);
		break;
	case EX_TLBS:
		handle_tlbmiss(tf, 1, 0);
		break;
  case EX_RI: {
    if(tf->tf_cause & (1 << 31)) {
      print_trapframe(tf);
      panic("Cannot fix unimplemented instruction in branch delay slot.");
    }
    const uint32_t DIV_OPCODE_MASK = 0xFC00FFFF;
    const uint32_t DIV_OPCODE = 0x0000001A;
    const uint32_t DIVU_OPCODE = 0x0000001B;
    const uint32_t MULTU_OPCODE = 0x00000019;
    uint32_t instruction = *(uint32_t*)tf->tf_epc;
    if((instruction & DIV_OPCODE_MASK) == DIV_OPCODE) {
      int rt = (instruction >> 16) & 0x1F;
      int rs = (instruction >> 21) & 0x1F;
      int dividend = rs == 0 ? 0 : tf->tf_regs.reg_r[rs - 1];
      int division = rt == 0 ? 0 : tf->tf_regs.reg_r[rt - 1];
      tf->tf_lo = __divsi3(dividend, division);
      tf->tf_hi = __modsi3(dividend, division);
      tf->tf_epc = (void*)((uint32_t)tf->tf_epc + 4);
      break;
    }
    else if((instruction & DIV_OPCODE_MASK) == DIVU_OPCODE) {
      int rt = (instruction >> 16) & 0x1F;
      int rs = (instruction >> 21) & 0x1F;
      int dividend = rs == 0 ? 0 : tf->tf_regs.reg_r[rs - 1];
      int division = rt == 0 ? 0 : tf->tf_regs.reg_r[rt - 1];
      tf->tf_lo = udivmodsi4(dividend, division, 0);
      tf->tf_hi = udivmodsi4(dividend, division, 1);
      tf->tf_epc = (void*)((uint32_t)tf->tf_epc + 4);
      break;
    }
예제 #7
0
파일: 1.c 프로젝트: TySag/project
static void
trap_dispatch(struct trapframe *tf) {
  int code = GET_CAUSE_EXCODE(tf->tf_cause);
  switch(code){
    case EX_IRQ:
      interrupt_handler(tf);
      break;
    case EX_TLBL:
      handle_tlbmiss(tf, 0);
      break;
    case EX_TLBS:
      handle_tlbmiss(tf, 1);
      break;
    case EX_RI:
      print_trapframe(tf);
      kprintf("inst not include, I will use software to implement\n");
      tf->tf_epc += 4;
      //panic("hey man! Do NOT use that insn!");
      break;
    case EX_SYS:
      //print_trapframe(tf);
      tf->tf_epc += 4;
      syscall();
      break;
      /* alignment error or access kernel
       * address space in user mode */
    case EX_ADEL:
    case EX_ADES:
      if(trap_in_kernel(tf)){
        print_trapframe(tf);
        panic("Alignment Error");
      }else{
        print_trapframe(tf);
        do_exit(-E_KILLED);
      }
      break;
    default:
      print_trapframe(tf);
      panic("Unhandled Exception");
  }

}
예제 #8
0
void
isci_interrupt_msix_handler(void *arg)
{
    struct ISCI_INTERRUPT_INFO *interrupt_info =
        (struct ISCI_INTERRUPT_INFO *)arg;
    struct ISCI_CONTROLLER *controller =
        (struct ISCI_CONTROLLER *)interrupt_info->interrupt_target_handle;
    SCIC_CONTROLLER_INTERRUPT_HANDLER  interrupt_handler;
    SCIC_CONTROLLER_COMPLETION_HANDLER completion_handler;

    interrupt_handler =  interrupt_info->handlers->interrupt_handler;
    completion_handler = interrupt_info->handlers->completion_handler;

    SCI_CONTROLLER_HANDLE_T scic_controller_handle;

    scic_controller_handle = scif_controller_get_scic_handle(
                                 controller->scif_controller_handle);

    if (interrupt_handler(scic_controller_handle)) {
        mtx_lock(&controller->lock);
        completion_handler(scic_controller_handle);
        mtx_unlock(&controller->lock);
    }
}
예제 #9
0
static void
trap_dispatch(struct trapframe *tf) {
  int code = GET_CAUSE_EXCODE(tf->tf_cause);
  switch(code){
    case EX_IRQ:
      interrupt_handler(tf);
      break;
    case EX_TLBL:
    case EX_TLBS:
      break;
    case EX_RI:
      print_trapframe(tf);
      while(1);
      break;
    case EX_SYS:
      print_trapframe(tf);
      tf->tf_epc += 4;
      break;
    default:
      print_trapframe(tf);
      while(1);
  }

}
예제 #10
0
파일: main.c 프로젝트: Laxa/quals-2016
/**
* Run the application code (display messages from the radio and send responses)
*/
int main(void) 
{
	char pFlagData[32];

	/* Porting code -- Don't need to do this
	WDTCTL = WDTPW | WDTHOLD;	// Disable watchdog timer

	P1OUT  = 0x00;                     // Port data output
	P2OUT  = 0x00;
 
	P1DIR  = 0x00;                     // Port direction register
	P2DIR  = 0xff;
 
	P1IES  = 0x00;                     // Port interrupt enable (0=dis 1=enabled)
	P2IES  = 0x00;
	P1IE   = 0x0F;                     // Port interrupt Edge Select (0=pos 1=neg)
	P2IE   = 0x00;
	*/

	// Setup no buffering for XINETD service
        setvbuf( stdout, NULL, _IONBF, 0 );

	FILE *pFlagFile = fopen( FLAG_FILE_NAME, "r" );

	if ( !pFlagFile )
	{
		printf( "Failed to read flag data!\n" );
		exit(1);
	}

	memset( pFlagData, 0, 32 );	
	fgets( pFlagData, 32, pFlagFile );

	fclose( pFlagFile );
       
	// Setup sig alarm handler
        signal( SIGALRM, sig_alarm_handler );
        alarm( MAX_IDLE_SECS );
	
	sram_init();
	cli_init_uart();
	radio_init_uart();
	//init_gui();
	
	// PORT: OLD: g_myTeamID = TEAM_ID_ADDR; 
	g_myTeamID = 0; // PPP now 



	puts( "This is an infamous challenge from DEF CON CTF Finals in 2014, in which a custom hardware badge was made by the LegitBS team, I've ported it to work here, enjoy.\n" );	
	puts( "The buttons are mapped to the arrow keys.\n" );
	puts( ".........................................\n" );

	puts( "Application Core v1.0" );
	puts( "openMSP430 core by Oliver Girard" );
	puts( "p.s. I modded the core to make data executable -sirgoon" );

	// Enable interrupts
	eint();

	// Run process loop

	/*
	while ( 1 )
	{
		LPM0;
		cli_run();
		radio_uart_run();
	}
	*/
	interrupt_handler();
}
예제 #11
0
/**
   Internal function used by input_common_readch to read one byte from fd 1. This function should only be called by
   input_common_readch().
*/
static wint_t readb()
{
	unsigned char arr[1];
	int do_loop = 0;
	
	do
	{
		fd_set fd;	
		int fd_max=1;
		int res;
		
		FD_ZERO( &fd );
		FD_SET( 0, &fd );
		if( env_universal_server.fd > 0 )
		{
			FD_SET( env_universal_server.fd, &fd );
			fd_max = env_universal_server.fd+1;
		}
		
		do_loop = 0;			
		
		res = select( fd_max, &fd, 0, 0, 0 );
		if( res==-1 )
		{
			switch( errno )
			{
				case EINTR:
				case EAGAIN:
				{
					if( interrupt_handler )
					{
						int res = interrupt_handler();
						if( res )
						{
							return res;
						}
						if( lookahead_count )
						{
							return lookahead_arr[--lookahead_count];
						}
						
					}
					
					
					do_loop = 1;
					break;
				}
				default:
				{
					/*
					  The terminal has been closed. Save and exit.
					*/
					return R_EOF;
				}
			}	
		}
		else
		{
			if( env_universal_server.fd > 0 )
			{
				if( FD_ISSET( env_universal_server.fd, &fd ) )
				{
					debug( 3, L"Wake up on universal variable event" );					
					env_universal_read_all();
					do_loop = 1;

					if( lookahead_count )
					{
						return lookahead_arr[--lookahead_count];
					}
				}				
			}
			if( FD_ISSET( 0, &fd ) )
			{
				if( read_blocked( 0, arr, 1 ) != 1 )
				{
					/*
					  The teminal has been closed. Save and exit.
					*/
					return R_EOF;
				}
				do_loop = 0;
			}				
		}
	}
	while( do_loop );
	
	return arr[0];
}
예제 #12
0
/// Internal function used by input_common_readch to read one byte from fd 0. This function should
/// only be called by input_common_readch().
static wint_t readb() {
    // do_loop must be set on every path through the loop; leaving it uninitialized allows the
    // static analyzer to assist in catching mistakes.
    unsigned char arr[1];
    bool do_loop;

    do {
        // Flush callbacks.
        input_flush_callbacks();

        fd_set fdset;
        int fd_max = 0;
        int ioport = iothread_port();
        int res;

        FD_ZERO(&fdset);
        FD_SET(0, &fdset);
        if (ioport > 0) {
            FD_SET(ioport, &fdset);
            fd_max = maxi(fd_max, ioport);
        }

        // Get our uvar notifier.
        universal_notifier_t &notifier = universal_notifier_t::default_notifier();

        // Get the notification fd (possibly none).
        int notifier_fd = notifier.notification_fd();
        if (notifier_fd > 0) {
            FD_SET(notifier_fd, &fdset);
            fd_max = maxi(fd_max, notifier_fd);
        }

        // Get its suggested delay (possibly none).
        struct timeval tv = {};
        const unsigned long usecs_delay = notifier.usec_delay_between_polls();
        if (usecs_delay > 0) {
            unsigned long usecs_per_sec = 1000000;
            tv.tv_sec = (int)(usecs_delay / usecs_per_sec);
            tv.tv_usec = (int)(usecs_delay % usecs_per_sec);
        }

        res = select(fd_max + 1, &fdset, 0, 0, usecs_delay > 0 ? &tv : NULL);
        if (res == -1) {
            if (errno == EINTR || errno == EAGAIN) {
                if (interrupt_handler) {
                    int res = interrupt_handler();
                    if (res) return res;
                    if (has_lookahead()) return lookahead_pop();
                }

                do_loop = true;
            } else {
                // The terminal has been closed. Save and exit.
                return R_EOF;
            }
        } else {
            // Assume we loop unless we see a character in stdin.
            do_loop = true;

            // Check to see if we want a universal variable barrier.
            bool barrier_from_poll = notifier.poll();
            bool barrier_from_readability = false;
            if (notifier_fd > 0 && FD_ISSET(notifier_fd, &fdset)) {
                barrier_from_readability = notifier.notification_fd_became_readable(notifier_fd);
            }
            if (barrier_from_poll || barrier_from_readability) {
                env_universal_barrier();
            }

            if (ioport > 0 && FD_ISSET(ioport, &fdset)) {
                iothread_service_completion();
                if (has_lookahead()) {
                    return lookahead_pop();
                }
            }

            if (FD_ISSET(STDIN_FILENO, &fdset)) {
                if (read_blocked(0, arr, 1) != 1) {
                    // The teminal has been closed. Save and exit.
                    return R_EOF;
                }

                // We read from stdin, so don't loop.
                do_loop = false;
            }
        }
    } while (do_loop);

    return arr[0];
}