Example #1
0
void amiga_chip_free (void *ptr)
{
	struct chip_desc *sdp = DP(ptr) - 1, *dp2;
	struct chip_desc *edp = DP((unsigned long)ptr + sdp->length);

    chipavail += sdp->length + (2* sizeof(sdp)); /*MILAN*/
#ifdef DEBUG
   printk("chip_free: free %ld bytes at %p\n",sdp->length,ptr);
#endif
	/* deallocate the chunk */
	sdp->alloced = edp->alloced = 0;
	release_mem_region(ZTWO_PADDR(ptr), sdp->length);

	/* check if we should merge with the previous chunk */
	if (!sdp->first && !sdp[-1].alloced) {
		dp2 = DP((unsigned long)sdp - sdp[-1].length) - 2;
		dp2->length += sdp->length + 2*sizeof(*sdp);
		edp->length = dp2->length;
		sdp = dp2;
	}

	/* check if we should merge with the following chunk */
	if (!edp->last && !edp[1].alloced) {
		dp2 = DP((unsigned long)edp + edp[1].length) + 2;
		dp2->length += edp->length + 2*sizeof(*sdp);
		sdp->length = dp2->length;
		edp = dp2;
	}
}
Example #2
0
static void __devexit hydra_remove_one(struct zorro_dev *z)
{
    struct net_device *dev = zorro_get_drvdata(z);

    unregister_netdev(dev);
    free_irq(IRQ_AMIGA_PORTS, dev);
    release_mem_region(ZTWO_PADDR(dev->base_addr)-HYDRA_NIC_BASE, 0x10000);
    free_netdev(dev);
}
Example #3
0
static void zorro8390_remove_one(struct zorro_dev *z)
{
	struct net_device *dev = zorro_get_drvdata(z);

	unregister_netdev(dev);
	free_irq(IRQ_AMIGA_PORTS, dev);
	release_mem_region(ZTWO_PADDR(dev->base_addr), NE_IO_EXTENT * 2);
	free_netdev(dev);
}
Example #4
0
static int a2091_release(struct Scsi_Host *instance)
{
#ifdef MODULE
	DMA(instance)->CNTR = 0;
	release_mem_region(ZTWO_PADDR(instance->base), 256);
	free_irq(IRQ_AMIGA_PORTS, instance);
	wd33c93_release();
#endif
	return 1;
}
static void __exit parport_mfc3_exit(void)
{
	int i;

	for (i = 0; i < MAX_MFC; i++) {
		if (!this_port[i])
			continue;
		parport_remove_port(this_port[i]);
		if (this_port[i]->irq != PARPORT_IRQ_NONE) {
			if (--use_cnt == 0) 
				free_irq(IRQ_AMIGA_PORTS, &pp_mfc3_ops);
		}
		release_mem_region(ZTWO_PADDR(this_port[i]->private_data), sizeof(struct pia));
		parport_put_port(this_port[i]);
	}
}
Example #6
0
static void __exit hydra_cleanup(void)
{
#ifdef MODULE
    struct net_device *dev, *next;

    while ((dev = root_hydra_dev)) {
	next = (struct net_device *)(ei_status.priv);
	unregister_netdev(dev);
	free_irq(IRQ_AMIGA_PORTS, dev);
	release_mem_region(ZTWO_PADDR(dev->base_addr)-HYDRA_NIC_BASE, 0x10000);
	kfree(dev);
	root_hydra_dev = next;
    }
    unload_8390_module();
#endif
}
Example #7
0
void amiga_chip_free(void *ptr)
{
	unsigned long start = ZTWO_PADDR(ptr);
	struct resource *res;
	unsigned long size;

	res = lookup_resource(&chipram_res, start);
	if (!res) {
		pr_err("amiga_chip_free: trying to free nonexistent region at "
		       "%p\n", ptr);
		return;
	}

	size = resource_size(res);
	pr_debug("amiga_chip_free: free %lu bytes at %p\n", size, ptr);
	atomic_add(size, &chipavail);
	release_resource(res);
	kfree(res);
}
void amiga_chip_free(void *ptr)
{
    unsigned long start = ZTWO_PADDR(ptr);
    struct resource **p, *res;
    unsigned long size;

    for (p = &chipram_res.child; (res = *p); p = &res->sibling) {
	if (res->start != start)
	    continue;
	*p = res->sibling;
	size = res->end-start;
#ifdef DEBUG
	printk("amiga_chip_free: free %ld bytes at %p\n", size, ptr);
#endif
	chipavail += size;
	kfree(res);
	return;
    }
    printk("amiga_chip_free: trying to free nonexistent region at %p\n", ptr);
}
Example #9
0
void *amiga_chip_alloc(long size, const char *name)
{
	/* last chunk */
	struct chip_desc *dp;
	void *ptr;

	/* round off */
	size = (size + 7) & ~7;

#ifdef DEBUG
   printk("amiga_chip_alloc: allocate %ld bytes\n", size);
#endif

	/*
	 * get pointer to descriptor for last chunk by 
	 * going backwards from end chunk
	 */
	dp = DP(chipaddr + amiga_chip_size) - 1;
	dp = DP((unsigned long)dp - dp->length) - 1;
	
	while ((dp->alloced || dp->length < size)
	       && !dp->first)
		dp = DP ((unsigned long)dp - dp[-1].length) - 2;

	if (dp->alloced || dp->length < size) {
		printk ("no chipmem available for %ld allocation\n", size);
		return NULL;
	}

	if (dp->length < (size + 2*sizeof(*dp))) {
		/* length too small to split; allocate the whole thing */
		dp->alloced = 1;
		ptr = (void *)(dp+1);
		dp = DP((unsigned long)ptr + dp->length);
		dp->alloced = 1;
#ifdef DEBUG
		printk ("amiga_chip_alloc: no split\n");
#endif
	} else {
		/* split the extent; use the end part */
		long newsize = dp->length - (2*sizeof(*dp) + size);

#ifdef DEBUG
		printk ("amiga_chip_alloc: splitting %d to %ld\n", dp->length,
			newsize);
#endif
		dp->length = newsize;
		dp = DP((unsigned long)(dp+1) + newsize);
		dp->first = dp->last = 0;
		dp->alloced = 0;
		dp->length = newsize;
		dp++;
		dp->first = dp->last = 0;
		dp->alloced = 1;
		dp->length = size;
		ptr = (void *)(dp+1);
		dp = DP((unsigned long)ptr + size);
		dp->alloced = 1;
		dp->length = size;
	}

#ifdef DEBUG
	printk ("amiga_chip_alloc: returning %p\n", ptr);
#endif

	if ((unsigned long)ptr & 7)
		panic("amiga_chip_alloc: alignment violation\n");

    chipavail -= size + (2*sizeof(*dp)); /*MILAN*/

    if (!request_mem_region(ZTWO_PADDR(ptr), size, name))
	printk(KERN_WARNING "amiga_chip_alloc: region of size %ld at 0x%08lx "
	       "is busy\n", size, ZTWO_PADDR(ptr));

    return ptr;
}
Example #10
0
int __init hydra_init(unsigned long board)
{
    struct net_device *dev;
    unsigned long ioaddr = board+HYDRA_NIC_BASE;
    const char *name = NULL;
    int start_page, stop_page;
    int j;

    static u32 hydra_offsets[16] = {
	0x00, 0x02, 0x04, 0x06, 0x08, 0x0a, 0x0c, 0x0e,
	0x10, 0x12, 0x14, 0x16, 0x18, 0x1a, 0x1c, 0x1e,
    };

    dev = init_etherdev(0, 0);
    if (!dev)
	return -ENOMEM;

    for(j = 0; j < ETHER_ADDR_LEN; j++)
	dev->dev_addr[j] = *((u8 *)(board + HYDRA_ADDRPROM + 2*j));

    /* We must set the 8390 for word mode. */
    writeb(0x4b, ioaddr + NE_EN0_DCFG);
    start_page = NESM_START_PG;
    stop_page = NESM_STOP_PG;

    dev->base_addr = ioaddr;
    dev->irq = IRQ_AMIGA_PORTS;

    /* Install the Interrupt handler */
    if (request_irq(IRQ_AMIGA_PORTS, ei_interrupt, SA_SHIRQ, "Hydra Ethernet",
		    dev))
	return -EAGAIN;

    /* Allocate dev->priv and fill in 8390 specific dev fields. */
    if (ethdev_init(dev)) {
	printk("Unable to get memory for dev->priv.\n");
	return -ENOMEM;
    }

    name = "NE2000";

    printk("%s: hydra at 0x%08lx, address %02x:%02x:%02x:%02x:%02x:%02x (hydra.c " HYDRA_VERSION ")\n", dev->name, ZTWO_PADDR(board),
	dev->dev_addr[0], dev->dev_addr[1], dev->dev_addr[2],
	dev->dev_addr[3], dev->dev_addr[4], dev->dev_addr[5]);

    ei_status.name = name;
    ei_status.tx_start_page = start_page;
    ei_status.stop_page = stop_page;
    ei_status.word16 = 1;
    ei_status.bigendian = 1;

    ei_status.rx_start_page = start_page + TX_PAGES;

    ei_status.reset_8390 = &hydra_reset_8390;
    ei_status.block_input = &hydra_block_input;
    ei_status.block_output = &hydra_block_output;
    ei_status.get_8390_hdr = &hydra_get_8390_hdr;
    ei_status.reg_offset = hydra_offsets;
    dev->open = &hydra_open;
    dev->stop = &hydra_close;
#ifdef MODULE
    ei_status.priv = (unsigned long)root_hydra_dev;
    root_hydra_dev = dev;
#endif
    NS8390_init(dev, 0);
    return 0;
}