예제 #1
0
int kbd_subscribe_int(void )
{
	hook = BITORDER;
	if( sys_irqsetpolicy(KBD_IRQ, IRQ_REENABLE | IRQ_EXCLUSIVE, &hook) == OK && sys_irqenable(&hook) == OK)
		return BITORDER;
	return -1;
}
예제 #2
0
int mouse_subscribe_int() {

	sys_irqsetpolicy(MOUSE_IRQ,IRQ_REENABLE|IRQ_EXCLUSIVE,&mousehook);
	sys_irqenable(&mousehook);

	return 1;
}
예제 #3
0
파일: dp.c 프로젝트: Spenser309/CS551
/*
**  Name:	void do_first_init(dpeth_t *dep, dp_conf_t *dcp);
**  Function:	Init action to setup task
*/
static void do_first_init(dpeth_t *dep, const dp_conf_t *dcp)
{

  if (dep->de_linmem != 0) {
	dep->de_memsegm = BIOS_SEG;
	/* phys2seg(&dep->de_memsegm, &dep->de_memoffs, dep->de_linmem); */
  } else
	dep->de_linmem = 0xFFFF0000;

  /* Make sure statisics are cleared */
  memset((void *) &(dep->de_stat), 0, sizeof(eth_stat_t));

  /* Device specific initialization */
  (*dep->de_initf) (dep);

  /* Set the interrupt handler policy. Request interrupts not to be reenabled
   * automatically. Return the IRQ line number when an interrupt occurs.
   */
  dep->de_hook = dep->de_irq;
  sys_irqsetpolicy(dep->de_irq, 0 /*IRQ_REENABLE*/, &dep->de_hook);
  dep->de_int_pending = FALSE;
  sys_irqenable(&dep->de_hook);

  return;
}
예제 #4
0
파일: virtio.c 프로젝트: wmdwjwm/minix
static void
virtio_irq_register(struct virtio_device *dev)
{
	int r;
	if ((r = sys_irqsetpolicy(dev->irq, 0, &dev->irq_hook) != OK))
		panic("%s: Unable to register IRQ %d", dev->name, r);
}
예제 #5
0
파일: vbox.c 프로젝트: anuragpeshne/minix
/*===========================================================================*
 *				vbox_init				     *
 *===========================================================================*/
static int vbox_init(int UNUSED(type), sef_init_info_t *UNUSED(info))
{
	/* Initialize the device. */
	int devind;
	u16_t vid, did;
	struct VMMDevReportGuestInfo *req;
	int r;

	interval = DEFAULT_INTERVAL;
	drift = DEFAULT_DRIFT;

	if (env_argc > 1)
		optset_parse(optset_table, env_argv[1]);

	pci_init();

	r = pci_first_dev(&devind, &vid, &did);

	for (;;) {
		if (r != 1)
			panic("backdoor device not found");

		if (vid == VMMDEV_PCI_VID && did == VMMDEV_PCI_DID)
			break;

		r = pci_next_dev(&devind, &vid, &did);
	}

	pci_reserve(devind);

	port = pci_attr_r32(devind, PCI_BAR) & PCI_BAR_IO_MASK;

	irq = pci_attr_r8(devind, PCI_ILR);
	hook_id = 0;

	if ((r = sys_irqsetpolicy(irq, 0 /* IRQ_REENABLE */, &hook_id)) != OK)
		panic("unable to register IRQ: %d", r);

	if ((r = sys_irqenable(&hook_id)) != OK)
		panic("unable to enable IRQ: %d", r);

	if ((vir_ptr = alloc_contig(VMMDEV_BUF_SIZE, 0, &phys_ptr)) == NULL)
		panic("unable to allocate memory");

	req = (struct VMMDevReportGuestInfo *) vir_ptr;
	req->add_version = VMMDEV_GUEST_VERSION;
	req->os_type = VMMDEV_GUEST_OS_OTHER;

	if ((r = vbox_request(&req->header, phys_ptr,
			VMMDEV_REQ_REPORTGUESTINFO, sizeof(*req))) !=
			VMMDEV_ERR_OK)
		panic("backdoor device not functioning");

	ticks = sys_hz() * interval;

	sys_setalarm(ticks, 0);

	return OK;
}
예제 #6
0
파일: timer.c 프로젝트: PTJohe/LCOM
int timer_subscribe_int(void) {

	hook_id = 0;
	if (sys_irqsetpolicy(TIMER0_IRQ, IRQ_REENABLE, &hook_id) == OK && sys_irqenable(&hook_id) == OK)
		return EXIT_SUCCESS;
	else
		return EXIT_FAILURE;
}
예제 #7
0
int timer_subscribe(void) {
	hookID_t = 0;
	unsigned int bitmask = BIT(hookID_t); // bit de subscricao
	if(sys_irqsetpolicy(TIMER0_IRQ, IRQ_REENABLE, &hookID_t) != OK || sys_irqenable(&hookID_t) != OK){
		return -1;
	}
	return bitmask;
}
예제 #8
0
int timer_subscribe_int(void ) {
	unsigned int bit_sel=1;
	hook_id=bit_sel;
    if(sys_irqsetpolicy(TIMER0_IRQ, IRQ_REENABLE , &hook_id) != OK)
    	return -1;
    if(sys_irqenable(&hook_id) != OK)
        return -1;
	return BIT(bit_sel);
}
예제 #9
0
파일: Timer.c 프로젝트: kissthink/os
int subscribeTimer(void) {
	int bitmask = BIT(hook);

	if (sys_irqsetpolicy(TIMER0_IRQ, IRQ_REENABLE, &hook) != OK
			|| sys_irqenable(&hook) != OK)
		return -1;

	return bitmask;
}
예제 #10
0
int timer_subscribe_int(void )
{
	int hook;
	hook = hook_id;
	if (sys_irqsetpolicy(TIMER0_IRQ,IRQ_REENABLE,&hook_id) == OK)
		if (sys_irqenable(&hook_id) == OK)
			return BIT(hook);

	return -1;
}
예제 #11
0
int timer_subscribe_int()
{
	//para nao perder o valor original de hook_id (vai ser preciso para depois reconhecer a notificacao)
	int hook_temp = hook_id_timer;

	if (OK == sys_irqsetpolicy(TIMER0_IRQ, IRQ_REENABLE, &hook_id_timer))
		if (OK == sys_irqenable(&hook_id_timer))
			return BIT(hook_temp);
	return -1;
}
예제 #12
0
int kbd_subscribe_int() {
	int bit_order = kbd_hook;
	if (sys_irqsetpolicy(KBD_IRQ, IRQ_REENABLE | IRQ_EXCLUSIVE, &kbd_hook)
			!= 0) {
		return ERROR;
	}
	if (sys_irqenable(&kbd_hook) != 0) {
		return ERROR;
	}
	return BIT(bit_order);
}
예제 #13
0
int KBD_subscribe_int(void )
{

	int hook;
	hook = hook_id2;
	if (sys_irqsetpolicy(KBD_IRQ,IRQ_REENABLE | IRQ_EXCLUSIVE,&hook_id2) == OK)
		if (sys_irqenable(&hook_id2) == OK)
			return BIT(hook);

	return -1;
}
예제 #14
0
int timer_subscribe_int(void ) {
	irq_hook_id = TIMER0_HOOK_BIT;
	if (sys_irqsetpolicy(TIMER0_IRQ, IRQ_REENABLE, &irq_hook_id) == OK)
	{
		if (sys_irqenable(&irq_hook_id) == OK)
		{
			return TIMER0_HOOK_BIT;
		}
	}
	return 1;
}
예제 #15
0
파일: mouse.c 프로젝트: oindividuo/LCOM1
int ms_subscribe_int(void) {
	hooke_id = MS_IRQ;  //Mouse IRQ number is 12.
	if (sys_irqsetpolicy(MS_IRQ, IRQ_REENABLE | IRQ_EXCLUSIVE, &hooke_id)
			!= OK) { //output the EOI command to the PIC
		printf("Irqsetpolicy failed \n");
		return -1;
	} else if (sys_irqenable((&hooke_id)) != OK) { //enables interrupts on the IRQ line associated with the hook_id
		printf("Irqenable failed \n");
		return -1;
	} else
		return MS_IRQ;
}
예제 #16
0
파일: kbd.c 프로젝트: BSantos22/lcom
int kbd_subscribe_int() {
	kbd_hook_id = KBD_HOOK_BIT;

	if (sys_irqsetpolicy(KBD_IRQ, IRQ_REENABLE | IRQ_EXCLUSIVE, &kbd_hook_id)
			== OK) {
		if (sys_irqenable(&kbd_hook_id) == OK) {
			return KBD_HOOK_BIT;
		}
	}

	return -1;
}
예제 #17
0
int timer_subscribe_int(void )
{
	int hook;
	hook = hook_id3;
	if (sys_irqsetpolicy(TIMER0_IRQ,IRQ_REENABLE,&hook_id3) == OK)
		if (sys_irqenable(&hook_id3) == OK)
			return BIT(hook);

	printf("erro no timer subscribe!!\n");

	return -1;
}
예제 #18
0
파일: mouse.c 프로젝트: joaofidalgo23/LCOM
int mouse_subscribe() {
	if (sys_irqsetpolicy(IRQ_MOUSE, IRQ_REENABLE | IRQ_EXCLUSIVE, &hook_id) != 0){
			printf("\nMouse_subscribe() failed \n");
			return -1;
	}
	if (sys_irqenable(&hook_id) != 0) {
			printf("\nMouse_subscribe() failed \n");
			return -1;
	}
	mouse_write(STREAM_MODE);
	mouse_write(ENABLE_PACKETS);
	return BIT(MOUSE_HOOK_ID);
}
예제 #19
0
int rtc_subscribe_int() {

	int hook_temp = hook_id_rtc;

	if (OK == sys_irqsetpolicy(RTC_IRQ, IRQ_REENABLE, &hook_id_rtc))
		if (OK == sys_irqenable(&hook_id_rtc))
		{
			rtc_enable_interrupts();
			return BIT(hook_temp);
		}
	return -1;

}
예제 #20
0
int ser_subscribe_com2_int(void)
{
	int returnvalue = BIT(ser_com2_hook_id);
	if(sys_irqsetpolicy(ORIGINAL_SER_COM2_HOOK_ID,IRQ_EXCLUSIVE | IRQ_REENABLE, &ser_com2_hook_id)!= OK){
		printf("ser_subscribe_com2_int(): sys_irqsetpolicy() failed\n");
		return -1;
	}
	if(sys_irqenable(&ser_com2_hook_id)!=OK){
		printf("ser_subscribe_com2_int(): sys_irqenable() failed\n");
		return -1;
	}
	return returnvalue;//return value with bit number (original hook_id) set to 1
}
예제 #21
0
파일: e1000.c 프로젝트: Hooman3/minix
/*
 * Initialize the hardware.  Return the ethernet address.
 */
static void
e1000_init_hw(e1000_t * e, ether_addr_t * addr)
{
	int r, i;

	e->irq_hook = e->irq;

	/*
	 * Set the interrupt handler and policy.  Do not automatically
	 * reenable interrupts.  Return the IRQ line number on interrupts.
	 */
	if ((r = sys_irqsetpolicy(e->irq, 0, &e->irq_hook)) != OK)
		panic("sys_irqsetpolicy failed: %d", r);
	if ((r = sys_irqenable(&e->irq_hook)) != OK)
		panic("sys_irqenable failed: %d", r);

	/* Reset hardware. */
	e1000_reset_hw(e);

	/*
	 * Initialize appropriately, according to section 14.3 General
	 * Configuration of Intel's Gigabit Ethernet Controllers Software
	 * Developer's Manual.
	 */
	e1000_reg_set(e, E1000_REG_CTRL,
	    E1000_REG_CTRL_ASDE | E1000_REG_CTRL_SLU);
	e1000_reg_unset(e, E1000_REG_CTRL, E1000_REG_CTRL_LRST);
	e1000_reg_unset(e, E1000_REG_CTRL, E1000_REG_CTRL_PHY_RST);
	e1000_reg_unset(e, E1000_REG_CTRL, E1000_REG_CTRL_ILOS);
	e1000_reg_write(e, E1000_REG_FCAL, 0);
	e1000_reg_write(e, E1000_REG_FCAH, 0);
	e1000_reg_write(e, E1000_REG_FCT, 0);
	e1000_reg_write(e, E1000_REG_FCTTV, 0);
	e1000_reg_unset(e, E1000_REG_CTRL, E1000_REG_CTRL_VME);

	/* Clear Multicast Table Array (MTA). */
	for (i = 0; i < 128; i++)
		e1000_reg_write(e, E1000_REG_MTA + i * 4, 0);

	/* Initialize statistics registers. */
	for (i = 0; i < 64; i++)
		e1000_reg_write(e, E1000_REG_CRCERRS + i * 4, 0);

	/* Acquire MAC address and set up RX/TX buffers. */
	e1000_init_addr(e, addr);
	e1000_init_buf(e);

	/* Enable interrupts. */
	e1000_reg_set(e, E1000_REG_IMS, E1000_REG_IMS_LSC | E1000_REG_IMS_RXO |
	    E1000_REG_IMS_RXT | E1000_REG_IMS_TXQE | E1000_REG_IMS_TXDW);
}
예제 #22
0
int timer_subscribe_int(void ) {

	if(sys_irqsetpolicy(TIMER0_IRQ, IRQ_REENABLE, &(timerInt.bit)) != OK){
		printf("ERROR SETTING POLICY!\n");
		return -1;
	}
	if(sys_irqenable(&(timerInt.bit)) != OK){
		printf("ERROR ENABLING SUBSCRIPTION!\n");
		return -1;
	}

	timerInt.counter = 0;
	return timerInt.bit;
}
예제 #23
0
int kbd_subscribe_int()
{
	//para nao perder o valor original de khook_id (vai ser preciso para depois reconhecer a notificacao)
	int hook_temp = hook_id_keyboard;

	if (OK == sys_irqsetpolicy(KBC_IRQ, IRQ_REENABLE | IRQ_EXCLUSIVE, &hook_id_keyboard))
	{
		if (OK == sys_irqenable(&hook_id_keyboard))
		{
			return BIT(hook_temp);
		}
	}
	return -1;
}
예제 #24
0
int subscribe_mouse(void) {
	hookID = 12;
	unsigned long bitmask = BIT(hookID);

	mouse_write_byte(DISABLE_DATA_PACKETS);

	if (sys_irqsetpolicy(IRQ_MOUSE, IRQ_REENABLE | IRQ_EXCLUSIVE, &hookID) != OK
			|| sys_irqenable(&hookID) != OK) {
		return -1;
	}
	mouse_write_byte(DATA_PACKETS);
	mouse_write_byte(STREAM_MODE);
	return bitmask;
}
예제 #25
0
파일: mouse.c 프로젝트: tomislaaaav/LCOM
int mouse_subscribe_int(){
	//para nao perder o valor original de mhook_id (vai ser preciso para depois reconhecer a notificacao)
	int hook_temp = mhook_id;

	if (OK == sys_irqsetpolicy(MOUSE_IRQ, IRQ_REENABLE | IRQ_EXCLUSIVE, &mhook_id))
	{
		if (OK == sys_irqenable(&mhook_id))
		{
			return BIT(hook_temp);
		}
	}
	return -1;

}
예제 #26
0
파일: kbd.c 프로젝트: pedro93/LCOM
int keyboard_subscribe_int()
{
if(sys_irqsetpolicy(IRQ_KBD,(IRQ_REENABLE|IRQ_EXCLUSIVE),&hook_id_kbd)!=OK)
{
	printf("IRQ_SETPOLICY failure /n");
	return -1;
}
if(sys_irqenable(&hook_id_kbd)!=OK)
{
	printf("IRQENABLE failure /n");
	return -1;
}

return hook_id_kbd;
}
예제 #27
0
//subscribe mouse interrupts
int mouse_subscribe_int(void)
{
	int returnvalue = BIT(mouse_hook_id);
	int irqpolicy = IRQ_EXCLUSIVE | IRQ_REENABLE;
	if(sys_irqsetpolicy(MOUSE_IRQ, irqpolicy, &mouse_hook_id)!= OK){
		printf("mouse_subscribe_int(): sys_irqsetpolicy() failed\n");
		return -1;
	}

	if(sys_irqenable(&mouse_hook_id)!=OK){
		printf("mouse_subscribe_int(): sys_irqenable() failed\n");
		return -1;
	}
	return returnvalue;//return value with bit number (original hook_id) set to 1
}
예제 #28
0
int mouse_subscribe_int(unsigned* hook_id)
{
	unsigned char hook_bit = (unsigned char)*hook_id;
	if (hook_bit != *hook_id)
	{
		return -1;
	}
	if (sys_irqsetpolicy(I8042_MOUSE_IRQ, IRQ_REENABLE | IRQ_EXCLUSIVE, (int *)hook_id) == OK)
	{
		memset(packet, 0, sizeof(packet));	// Clean the array to make sure bit 3 is off in all bytes
		next_byte = 0;
		return hook_bit;
	}
	return -1;
}
예제 #29
0
파일: timer.c 프로젝트: joaofidalgo23/LCOM
int timer_subscribe_int(void) {
	// atualiza hook_id, passando a ser 0
	hook_id = TIMER_HOOK_BIT;

	int bitmask = BIT(hook_id);
	/*The policy you should specify in sys_irqsetpolicy() is IRQ_REENABLE, so
	 that the generic interrupt handler will acknowledge the interrupt. */
	if (sys_irqsetpolicy(TIMER0_IRQ, IRQ_REENABLE, &hook_id) != 0
			|| sys_irqenable(&hook_id) != 0) {
		printf("\ntimer_subscribe_int() failed \n");
		return -1;
	} else {
		return bitmask;
	}
}
예제 #30
0
PRIVATE int init_driver(void) {
  u32_t i; char irq;
  static int executed = 0;
  sub_dev_t* sub_dev_ptr;
  
  /* init variables, get dma buffers */
  for (i = 0; i < drv.NrOfSubDevices; i++) {
  
    sub_dev_ptr = &sub_dev[i];
    
    sub_dev_ptr->Opened = FALSE;
    sub_dev_ptr->DmaBusy = FALSE;
    sub_dev_ptr->DmaMode = NO_DMA;
    sub_dev_ptr->DmaReadNext = 0;
    sub_dev_ptr->DmaFillNext = 0;
    sub_dev_ptr->DmaLength = 0;
    sub_dev_ptr->BufReadNext = 0;
    sub_dev_ptr->BufFillNext = 0;
    sub_dev_ptr->RevivePending = FALSE;
    sub_dev_ptr->OutOfData = FALSE;
    sub_dev_ptr->Nr = i;
  }
  
  /* initialize hardware*/
  if (drv_init_hw() != OK) {
    error("%s: Could not initialize hardware\n", drv.DriverName, 0);
    return EIO;
  }
  
	/* get irq from device driver...*/
	if (drv_get_irq(&irq) != OK) {
	  error("%s: init driver couldn't get IRQ", drv.DriverName, i);
	  return EIO;
	}
	/* todo: execute the rest of this function only once 
     we don't want to set irq policy twice */
  if (executed) return OK;
  executed = TRUE;
  
	/* ...and register interrupt vector */
  if ((i=sys_irqsetpolicy(irq, 0, &irq_hook_id )) != OK){
  	error("%s: init driver couldn't set IRQ policy", drv.DriverName, i);
  	return EIO;
  }
  irq_hook_set = TRUE; /* now msg_sig_stop knows it must unregister policy*/
	return OK;
}