Example #1
0
File: irq.c Project: mischief/los
/*
 * Deallocate an irq.
 */
void
free_irq(unsigned int irq, void *dev_id)
{
    struct task_struct *cur = current;
    struct int_handler *temp, *last;

    temp = handlers[irq];

    if (!temp)
        return;

    /* one element -- free the irq */
    if (!temp->next) {
        void (*intr_handler)(void *);

        if (temp->dev_id != dev_id)
            return;
        handlers[irq]=NULL;
        intr_handler = (temp->flags & SA_PROBE) ?
                       probe_intr : linux_intr;
        osenv_irq_free(irq, intr_handler, (void*)irq);
        osenv_mem_free(temp, 0, sizeof(struct int_handler));
        shared[irq] = 1;

        current = cur;
        return;
    }

    last = temp;

    /* find the correct element and remove it */
    while (temp && (temp->dev_id != dev_id)) {
        last = temp;
        temp = temp->next;
    }

    if (!temp)	/* not found */
        return;

    if (temp == last) {	/* first node */
        handlers[irq] = temp->next;
        osenv_mem_free(temp, 0, sizeof(struct int_handler));
    } else {
        last->next = temp->next;
        osenv_mem_free(temp, 0, sizeof(struct int_handler));
    }

    current = cur;
}
Example #2
0
void free (void *addr, int type)
{
    struct proc *p;
    p = curproc;
    osenv_mem_free(addr, OSENV_AUTO_SIZE, 0);
    curproc = p;
}
Example #3
0
void
freebsd_linker_set_add(struct linker_set *set, void *sym)
{
	void **new_items;

	new_items = (void *)osenv_mem_alloc((set->ls_length + 2) * sizeof(void *), 0, 0);

#if 0
	printf("in %s: ",__FUNCTION__);
	printf("add %x to %x (%d entries)\n", sym, set, set->ls_length);
#endif

	bcopy(set->ls_items, new_items, set->ls_length * sizeof(void *));
	new_items[set->ls_length] = sym;
	set->ls_length++;
	new_items[set->ls_length] = NULL;

	if (set->ls_items)
		osenv_mem_free(set->ls_items, 0, 
			       set->ls_length * sizeof(void *));

#if 0
	printf("set->ls_items is %x; new_items is %x\n", set->ls_items, 
	       new_items);
#endif

	set->ls_items = new_items;
}
Example #4
0
oskit_error_t
osenv_rootbus_remchild(oskit_device_t *dev)
{
	struct node **np, *n;

	for (np = &nodes; (n = *np) != NULL; np = &n->next) {
		/*
		 * XXX Technically this isn't correct COM procedure;
		 * we should be comparing the IUnknown interfaces...
		 */
		if (n->dev == dev) {
			*np = n->next;
			oskit_device_release(n->dev);
			osenv_mem_free(n, OSENV_PHYS_WIRED, sizeof(*n));
			return 0;
		}
	}

	return OSKIT_E_DEV_NOSUCH_CHILD;
}
/*
 * Exit hook to shut down the network device. Going to sleep 1 second
 * to allow the network to settle. 
 */
static void
release_network(void *arg)
{
	int i;
#if VERBOSITY > 0
	printf("Shutting down network ... ");
#endif
	sleep(1);
	
	/* close etherdev and release net_io devices */
	for (i = 0; i < eif_count; i++) {
		if (eif[i] != NULL)
			start_conf_network_close_eif(eif[i]);
	}
	osenv_mem_free(eif, 0, sizeof(*eif) * eif_count);
	free(edev);

#if VERBOSITY > 0
	printf("Done!\n");
#endif
}
Example #6
0
/*
 * This is called when the netio object created is no longer used.
 * We `cleanup' -- release the storage, since there are
 * no more references to it anyway.
 */
static void
cleanup(void *param)
{
	osenv_mem_free(param, 0, sizeof(oskit_pd_t));
}
Example #7
0
File: irq.c Project: mischief/los
/*
 * Attach a handler to an IRQ.
 */
int
request_irq(unsigned int irq, void (*handler)(int, void *, struct pt_regs *),
            unsigned long flags, const char *device, void *dev_id)
{
    void (*intr_handler)(void *);
    struct task_struct *cur = current;
    int rc;
    int fdev_flags;
    struct int_handler *temp;

    /* Make sure it is valid to assign this handler */
#ifdef IRQ_DEBUG
    osenv_log(OSENV_LOG_DEBUG, "IRQ %d requested by %s at %p\n",
              irq, (device ? device : ""), handler);
#endif

    if (!handler) {
        return (-EINVAL);
    }

    if (!shared[irq]) {
        return (-EBUSY);
    }

    /* If owned by sharing, and we won't share, we're done too */
    if (handlers[irq] && ((flags & SA_SHIRQ) == 0)) {
        return (-EBUSY);
    }

    /* okay, now set up the handler */

    temp = osenv_mem_alloc(sizeof(struct int_handler), 0, 1);
    if (!temp)
        return (-ENOMEM);

    temp->next = handlers[irq];
    handlers[irq] = temp;

    handlers[irq]->func = handler;
    handlers[irq]->flags = flags;
    handlers[irq]->dev_id = dev_id;

    if (handlers[irq]->next) { /* already have the IRQ from FDEV. */
        osenv_log(OSENV_LOG_DEBUG,
                  "adding another linux handler to irq %d, tag = %x\n",
                  irq, (unsigned)handler);
    } else {

        intr_handler = (flags & SA_PROBE) ? probe_intr : linux_intr;
        fdev_flags = (flags & SA_SHIRQ) ? OSENV_IRQ_SHAREABLE : 0;

        rc=osenv_irq_alloc(irq, intr_handler, (void *)irq, fdev_flags);
        current = cur;	/* restore current after possibly blocking */
        if (rc) {
            temp = handlers[irq];
            handlers[irq] = handlers[irq]->next;
            osenv_mem_free(temp, 0, sizeof(struct int_handler));

            return (-EBUSY);
        }
    }

    /* update the shared flag */
    if ((flags & SA_SHIRQ) == 0)
        shared[irq] = 0;

    DEBUG_MSG();
    return (0);
}