gctINT
gckDebugFileSystemCreateNode (
                               IN gctINT SizeInKB ,
                               IN gctCONST_STRING ParentName ,
                               IN gctCONST_STRING NodeName ,
                               OUT gcsDebugFileSystemNode **Node
                               )
{
    gcsDebugFileSystemNode*node ;
    /* allocate space for our metadata and initialize it */
    if ( ( node = kmalloc ( sizeof (gcsDebugFileSystemNode ) , GFP_KERNEL ) ) == NULL )
        goto struct_malloc_failed ;

    /*Zero it out*/
    memset ( node , 0 , sizeof (gcsDebugFileSystemNode ) ) ;

    /*Init the sync primitives*/
#if defined(DECLARE_WAIT_QUEUE_HEAD)
    init_waitqueue_head ( gcmkNODE_READQ ( node ) ) ;
#else
    init_waitqueue ( gcmkNODE_READQ ( node ) ) ;
#endif

#if defined(DECLARE_WAIT_QUEUE_HEAD)
    init_waitqueue_head ( gcmkNODE_WRITEQ ( node ) ) ;
#else
    init_waitqueue ( gcmkNODE_WRITEQ ( node ) ) ;
#endif
    sema_init ( gcmkNODE_SEM ( node ) , 1 ) ;
    /*End the sync primitives*/


    /* figure out how much of a buffer this should be and allocate the buffer */
    node->size = 1024 * SizeInKB ;
    if ( ( node->data = ( char * ) vmalloc ( sizeof (char ) * node->size ) ) == NULL )
        goto data_malloc_failed ;

    /*creating the debug file system*/
    node->parent = debugfs_create_dir ( ParentName , NULL ) ;

    /*creating the file*/
    node->filen = debugfs_create_file ( NodeName , S_IRUGO | S_IWUSR , node->parent , NULL ,
                                        &debugfs_operations ) ;

    /* add it to our linked list */
    node->next = gc_dbgfs.linkedlist ;
    gc_dbgfs.linkedlist = node ;

    /* pass the struct back */
    *Node = node ;
    return 0 ;

    vfree ( node->data ) ;
data_malloc_failed:
    kfree ( node ) ;
struct_malloc_failed:
    return - ENOMEM ;
}
Beispiel #2
0
/*
 * These are initializations that only need to be done
 * once, because the fields are idempotent across use
 * of the inode..
 */
static inline void init_once(struct inode * inode)
{
	memset(inode, 0, sizeof(*inode));
	init_waitqueue(&inode->i_wait);
	INIT_LIST_HEAD(&inode->i_hash);
	INIT_LIST_HEAD(&inode->i_dentry);
	sema_init(&inode->i_sem, 1);
	sema_init(&inode->i_atomic_write, 1);
}
Beispiel #3
0
static void
afs_addevent(char *event)
{
    int hashcode;
    afs_event_t *newp;

    AFS_ASSERT_GLOCK();
    hashcode = afs_evhash(event);
    newp = osi_linux_alloc(sizeof(afs_event_t), 0);
    afs_evhashcnt++;
    newp->next = afs_evhasht[hashcode];
    afs_evhasht[hashcode] = newp;
#if defined(AFS_LINUX24_ENV)
    init_waitqueue_head(&newp->cond);
#else
    init_waitqueue(&newp->cond);
#endif
    newp->seq = 0;
    newp->event = &dummyV;	/* Dummy address for new events */
    newp->refcount = 0;
}
Beispiel #4
0
/*
 * Open a Linux block device given its Linux device number.
 * The gendisk parameter need only be non-NULL if opening a partition;
 * it can be NULL when opening the entire disk ("partition 0").
 */
oskit_error_t
oskit_linux_block_open_kdev(int kdev, struct gendisk *gd,
		     unsigned flags, oskit_blkio_t **out_io)
{
	int err, i, mode;
	struct file file;
	struct peropen *po;
	struct task_struct ts;

	OSKIT_LINUX_CREATE_CURRENT(ts);

	if (flags & ~OSKIT_DEV_OPEN_ALL) {
		err = OSKIT_E_DEV_BADPARAM;
		goto finish;
	}

	switch (flags & (OSKIT_DEV_OPEN_READ|OSKIT_DEV_OPEN_WRITE)) {

	case OSKIT_DEV_OPEN_READ:
		mode = O_RDONLY;
		break;

	case OSKIT_DEV_OPEN_WRITE:
		mode = O_WRONLY;
		break;

	case OSKIT_DEV_OPEN_READ|OSKIT_DEV_OPEN_WRITE:
		mode = O_RDWR;
		break;

	default:
		err = OSKIT_E_DEV_BADPARAM;
		goto finish;
	}

	/*
	 * Linux uses 1k blocks by default.
	 * We WANT sector-sized blocks in all cases.
	 */
	if (!hardsect_size[MAJOR(kdev)]) {
		osenv_log(OSENV_LOG_DEBUG,
			"default sector size = 512b on %d,%d\n",
			MAJOR(kdev), MINOR(kdev));
		blksize_size[MAJOR(kdev)][MINOR(kdev)] = 512;

	} else if (blksize_size[MAJOR(kdev)][MINOR(kdev)]!=
	    hardsect_size[MAJOR(kdev)][MINOR(kdev)]) {
		osenv_log(OSENV_LOG_DEBUG,
			"setting block size to sector size on %d,%d\n",
			MAJOR(kdev), MINOR(kdev));
		blksize_size[MAJOR(kdev)][MINOR(kdev)] =
		    hardsect_size[MAJOR(kdev)][MINOR(kdev)];

		/* this is a Linux limitation: */
		if (hardsect_size[MAJOR(kdev)][MINOR(kdev)] < 512) {
			err = OSKIT_E_DEV_BADOP;	/* XXX */
			goto finish;
		}
	}

	/*
	 * Search the open list.
	 */
	while (1) {
		for (po = open_list; po; po = po->next)
			if (po->inode.i_rdev == kdev && po->mode == mode)
				break;
		if (po) {
			if (po->busy) {
				po->want = 1;
				sleep_on(&po->waitq);
				continue;
			}
			po->count++;
			*out_io = &po->ioi;
			err = 0;
			goto finish;
		}
		break;
	}

	/*
	 * Allocate and initialize a device structure.
	 */
	po = oskit_linux_mem_alloc(sizeof(struct peropen),
				  OSENV_PHYS_WIRED, 0);
	if (!po) {
		err = OSKIT_E_OUTOFMEMORY;
		goto finish;
	}
	po->ioi.ops = &block_io_ops;
	po->fops = blkdevs[MAJOR(kdev)].fops;
	po->count = 1;
	po->busy = 1;
	po->want = 0;
	po->mode = mode;
	init_waitqueue(&po->waitq);

	po->inode.i_rdev = kdev;

	po->inode.i_emul_data = po;

	po->next = open_list;
	open_list = po->next;

	if (!po->fops->open)
		err = 0;
	else {
		struct dentry dentry;
		file.f_mode = mode;
		file.f_flags = 0;
		file.f_dentry = &dentry;
		dentry.d_inode = &po->inode;

		err = (*po->fops->open)(&po->inode, &file);
	}

	if (err) {
		open_list_remove(po);
		if (po->want) {
			po->want = 0;
			wake_up(&po->waitq);
		}
		err = linux_to_oskit_error(err);
		oskit_linux_mem_free(po, OSENV_PHYS_WIRED,
				    sizeof(struct peropen));
	} else {
		/*
		 * Now that the device has been opened,
		 * we can extract its size.  This might
		 * not have been set properly in blk_size
		 * before the open call, e.g. for the floppy driver.
		 */
		if (gd)
			po->size = gd->part[MINOR(kdev)].nr_sects;
		else {
			osenv_assert(blk_size[MAJOR(kdev)] &&
				     blk_size[MAJOR(kdev)][MINOR(kdev)]);
			po->size = (blk_size[MAJOR(kdev)][MINOR(kdev)]
				    << (BLOCK_SIZE_BITS - DISK_BLOCK_BITS));
		}

		if (blksize_size[MAJOR(kdev)]
		    && blksize_size[MAJOR(kdev)][MINOR(kdev)]) {
			int bshift = DISK_BLOCK_BITS;
			po->bsize = blksize_size[MAJOR(kdev)][MINOR(kdev)];
			for (i = po->bsize >> DISK_BLOCK_BITS; i != 1; i >>= 1)
				bshift++;
			po->bshift = bshift;
		}
		else {
Beispiel #5
0
void
flash_probe()
{
	int i;

	/* start adresses for the Flash chips - these should really
	 * be settable in some other way.
	 */
#ifdef FLASH_VERBOSE
	safe_printk("Probing flash...\n");
#endif

#ifdef CONFIG_COLDFIRE
	chips[0].start = (unsigned char *)(0xf0200000);
#elif   CONFIG_SED_SIOS
    chips[0].start = (unsigned char *)(0x01400000);
    chips[1].start = (unsigned char *)(0x01600000);
#elif	CONFIG_ARCH_NETARM
	chips[0].start = (unsigned char *)(0x10000000);
#elif	CONFIG_MWI
	chips[0].start = (unsigned char *)(0x000000);
#else
	chips[0].start = (unsigned char *)(MEM_CSE0_START | MEM_NON_CACHEABLE);
	chips[1].start = (unsigned char *)(MEM_CSE1_START | MEM_NON_CACHEABLE);
#endif

	for(i = 0; i < MAX_CHIPS; i++) {
		struct flashchip *chip = chips + i;
		flashptr flashStart = (flashptr)chip->start;
#ifdef FLASH_8BITX4
        unsigned long manu_long;
#endif
		unsigned short manu;

#ifdef FLASH_VERBOSE
		safe_printk("Probing flash #%d at 0x%p\n", i, flashStart);
#endif

#ifdef CONFIG_SVINTO_SIM
		/* in the simulator, dont trash the flash ram by writing unlocks */
		chip->isValid = 1;
		chip->device_id = AM29LV160BT;
#else
		/* reset */

		flashStart[unlockAddress1] = unlockData1;
		flashStart[unlockAddress2] = unlockData2;
		flashStart[unlockAddress1] = resetData;

		/* read manufacturer */

		flashStart[unlockAddress1] = unlockData1;
		flashStart[unlockAddress2] = unlockData2;
		flashStart[unlockAddress1] = manufacturerUnlockData;
#ifdef FLASH_8BITX4
        manu_long = flashStart[manufacturerAddress];
        manu = manu_long & 0x000000ffU;
#else
		manu = flashStart[manufacturerAddress];
#endif
		chip->isValid = (manu == ManufacturerAMD ||
				 manu == ManufacturerToshiba ||
				 manu == ManufacturerST ||
				 manu == ManufacturerSST);
		chip->manufacturer_id = manu;

		if(!chip->isValid) {
#ifdef FLASH_VERBOSE
			safe_printk("Flash: No flash or unsupported "
				    "manufacturer.\n");
#endif
			continue;
		}
		/* reset */

		flashStart[unlockAddress1] = unlockData1;
		flashStart[unlockAddress2] = unlockData2;
		flashStart[unlockAddress1] = resetData;

		/* read device id */

		flashStart[unlockAddress1] = unlockData1;
		flashStart[unlockAddress2] = unlockData2;
		flashStart[unlockAddress1] = manufacturerUnlockData;
#ifdef FLASH_8BITX4
        manu_long = flashStart[deviceIdAddress];
        manu_long &= 0x000000ff;
        switch(chip->manufacturer_id)
        {
            case ManufacturerAMD:
                manu_long |= 0x00002200;
                break;
            case ManufacturerSST:
                manu_long |= 0x00002700;
                break;
            case ManufacturerToshiba:
            case ManufacturerST:
                break;
        }
        chip->device_id = manu_long;
#else
		chip->device_id = flashStart[deviceIdAddress];
#endif /*FLASH_8BITX4*/

		/* reset */

		flashStart[unlockAddress1] = unlockData1;
		flashStart[unlockAddress2] = unlockData2;
		flashStart[unlockAddress1] = resetData;
#endif /*CONFIG_SVINTO_SIM*/

		/* check device type and fill in correct sizes etc */

		switch(chip->device_id) {
		case AM29LV322DT:
		case AM29LV323DT:
#ifdef FLASH_VERBOSE
			safe_printk("Flash: 32Mb TB.\n");
#endif
			chip->size = FL_SIZEOF(0x00400000);
			chip->sectorsize = FL_SIZEOF(0x10000);
			chip->bootsector = chip->start + chip->size
					   - chip->sectorsize;
			chip->bootsectorsize[0] = FL_SIZEOF(0x2000);
			chip->bootsectorsize[1] = FL_SIZEOF(0x2000);
			chip->bootsectorsize[2] = FL_SIZEOF(0x2000);
			chip->bootsectorsize[3] = FL_SIZEOF(0x2000);
			chip->bootsectorsize[4] = FL_SIZEOF(0x2000);
			chip->bootsectorsize[5] = FL_SIZEOF(0x2000);
			chip->bootsectorsize[6] = FL_SIZEOF(0x2000);
			chip->bootsectorsize[7] = FL_SIZEOF(0x2000);
			break;
		case AM29LV322DB:
		case AM29LV323DB:
#ifdef FLASH_VERBOSE
			safe_printk("Flash: 32Mb BB.\n");
#endif
			chip->size = FL_SIZEOF(0x00400000);
			chip->sectorsize = FL_SIZEOF(0x10000);
			chip->bootsector = chip->start;
			chip->bootsectorsize[0] = FL_SIZEOF(0x2000);
			chip->bootsectorsize[1] = FL_SIZEOF(0x2000);
			chip->bootsectorsize[2] = FL_SIZEOF(0x2000);
			chip->bootsectorsize[3] = FL_SIZEOF(0x2000);
			chip->bootsectorsize[4] = FL_SIZEOF(0x2000);
			chip->bootsectorsize[5] = FL_SIZEOF(0x2000);
			chip->bootsectorsize[6] = FL_SIZEOF(0x2000);
			chip->bootsectorsize[7] = FL_SIZEOF(0x2000);
			break;
		case AM29LV160BT:
		case TC58FVT160:
#ifdef FLASH_VERBOSE
			safe_printk("Flash: 16Mb TB.\n");
#endif
			chip->size = FL_SIZEOF(0x00200000);
			chip->sectorsize = FL_SIZEOF(0x10000);
			chip->bootsector = chip->start + chip->size
					   - chip->sectorsize;
			chip->bootsectorsize[0] = FL_SIZEOF(0x8000);
			chip->bootsectorsize[1] = FL_SIZEOF(0x2000);
			chip->bootsectorsize[2] = FL_SIZEOF(0x2000);
			chip->bootsectorsize[3] = FL_SIZEOF(0x4000);
			break;
        case AM29LV400BB:
#ifdef FLASH_VERBOSE
            safe_printk("Flash: AMD AM 29LV400BB - 4Megabit.\n");
#endif
            chip->size= FL_SIZEOF(0x00080000);
			chip->sectorsize = FL_SIZEOF(0x10000);
            chip->bootsector = chip->start;
            chip->bootsectorsize[0] = FL_SIZEOF(0x4000);
            chip->bootsectorsize[1] = FL_SIZEOF(0x2000);
            chip->bootsectorsize[2] = FL_SIZEOF(0x2000);
            chip->bootsectorsize[3] = FL_SIZEOF(0x8000);
            break;
		case AM29LV160BB:
		case TC58FVB160:
#ifdef FLASH_VERBOSE
			safe_printk("Flash: 16Mb BB.\n");
#endif
			chip->size = FL_SIZEOF(0x00200000);
			chip->sectorsize = FL_SIZEOF(0x10000);
			chip->bootsector = chip->start;
			chip->bootsectorsize[0] = FL_SIZEOF(0x4000);
			chip->bootsectorsize[1] = FL_SIZEOF(0x2000);
			chip->bootsectorsize[2] = FL_SIZEOF(0x2000);
			chip->bootsectorsize[3] = FL_SIZEOF(0x8000);
			break;
		case AM29LV800BB:
		case AM29F800BB:
#ifdef FLASH_VERBOSE
			safe_printk("Flash: 8Mb BB.\n");
#endif
			chip->size = FL_SIZEOF(0x00100000);
			chip->sectorsize = FL_SIZEOF(0x10000);
			chip->bootsector = chip->start;
			chip->bootsectorsize[0] = FL_SIZEOF(0x4000);
			chip->bootsectorsize[1] = FL_SIZEOF(0x2000);
			chip->bootsectorsize[2] = FL_SIZEOF(0x2000);
			chip->bootsectorsize[3] = FL_SIZEOF(0x8000);
			break;
		case M29W800T:
		case AM29LV800BT:
		case AM29F800BT:
#ifdef FLASH_VERBOSE
			safe_printk("Flash: 8Mb TB.\n");
#endif
			chip->size = FL_SIZEOF(0x00100000);
			chip->sectorsize = FL_SIZEOF(0x10000);
			chip->bootsector = chip->start + chip->size
					   - chip->sectorsize;
			chip->bootsectorsize[0] = FL_SIZEOF(0x8000);
			chip->bootsectorsize[1] = FL_SIZEOF(0x2000);
			chip->bootsectorsize[2] = FL_SIZEOF(0x2000);
			chip->bootsectorsize[3] = FL_SIZEOF(0x4000);
			break;
			//     case AM29LV800BB:

			/* the following supports smaller sector erases (like 2 Kword)
			 * so they dont use bootblocks. until we've implemented real
			 * support for the smaller erases, we just treat them as if they
			 * dont have bootblocks at all.
			 */

		case SST39LF800:
#ifdef FLASH_VERBOSE
			safe_printk("Flash: 8Mb No B\n");
#endif
			chip->size = FL_SIZEOF(0x00100000);
			chip->sectorsize = FL_SIZEOF(0x10000);

			chip->bootsector = (unsigned char *)MEM_DRAM_START; /* never a flash address (see above) */

			break;

		case SST39LF160:
#ifdef FLASH_VERBOSE
			safe_printk("Flash: 16Mb No B\n");
#endif
			chip->size = FL_SIZEOF(0x00200000);
			chip->sectorsize = FL_SIZEOF(0x10000);

			chip->bootsector = (unsigned char *)MEM_DRAM_START; /* never a flash address */

			break;

		default:
#ifdef FLASH_VERBOSE
			safe_printk("Flash: Unknown device\n");
#endif
			chip->isValid = 0;
			break;
		}

		chip->busy = 0;
		init_waitqueue(&chip->wqueue);
	}
}
Beispiel #6
0
int autofs_wait(struct autofs_sb_info *sbi, struct qstr * name)
{
	struct autofs_wait_queue *wq;
	int status;

	/* In catatonic mode, we don't wait for nobody */
	if ( sbi->catatonic )
		return -ENOENT;

	for ( wq = sbi->queues ; wq ; wq = wq->next ) {
		if ( wq->hash == name->hash &&
		     wq->len == name->len &&
		     wq->name && !memcmp(wq->name,name->name,name->len) )
			break;
	}
	
	if ( !wq ) {
		/* Create a new wait queue */
		wq = kmalloc(sizeof(struct autofs_wait_queue),GFP_KERNEL);
		if ( !wq )
			return -ENOMEM;

		wq->name = kmalloc(name->len,GFP_KERNEL);
		if ( !wq->name ) {
			kfree(wq);
			return -ENOMEM;
		}
		wq->wait_queue_token = autofs_next_wait_queue++;
		init_waitqueue(&wq->queue);
		wq->hash = name->hash;
		wq->len = name->len;
		wq->status = -EINTR; /* Status return if interrupted */
		memcpy(wq->name, name->name, name->len);
		wq->next = sbi->queues;
		sbi->queues = wq;

		/* autofs_notify_daemon() may block */
		wq->wait_ctr = 2;
		autofs_notify_daemon(sbi,wq);
	} else
		wq->wait_ctr++;

	/* wq->name is NULL if and only if the lock is already released */

	if ( sbi->catatonic ) {
		/* We might have slept, so check again for catatonic mode */
		wq->status = -ENOENT;
		if ( wq->name ) {
			kfree(wq->name);
			wq->name = NULL;
		}
	}

	if ( wq->name ) {
		/* Block all but "shutdown" signals while waiting */
		sigset_t oldset;
		unsigned long irqflags;

		spin_lock_irqsave(&current->sigmask_lock, irqflags);
		oldset = current->blocked;
		siginitsetinv(&current->blocked, SHUTDOWN_SIGS & ~oldset.sig[0]);
		recalc_sigpending(current);
		spin_unlock_irqrestore(&current->sigmask_lock, irqflags);

		interruptible_sleep_on(&wq->queue);

		spin_lock_irqsave(&current->sigmask_lock, irqflags);
		current->blocked = oldset;
		recalc_sigpending(current);
		spin_unlock_irqrestore(&current->sigmask_lock, irqflags);
	} else {
		DPRINTK(("autofs_wait: skipped sleeping\n"));
	}

	status = wq->status;

	if ( ! --wq->wait_ctr )	/* Are we the last process to need status? */
		kfree(wq);

	return status;
}