示例#1
0
static int __init vr41xx_cmu_init(void)
{
	unsigned long start, size;

	switch (current_cpu_type()) {
        case CPU_VR4111:
        case CPU_VR4121:
		start = CMU_TYPE1_BASE;
		size = CMU_TYPE1_SIZE;
                break;
        case CPU_VR4122:
        case CPU_VR4131:
		start = CMU_TYPE2_BASE;
		size = CMU_TYPE2_SIZE;
		break;
        case CPU_VR4133:
		start = CMU_TYPE3_BASE;
		size = CMU_TYPE3_SIZE;
                break;
	default:
		panic("Unexpected CPU of NEC VR4100 series");
		break;
        }

	if (request_mem_region(start, size, "CMU") == NULL)
		return -EBUSY;

	cmu_base = ioremap(start, size);
	if (cmu_base == NULL) {
		release_mem_region(start, size);
		return -EBUSY;
	}

	cmuclkmsk = cmu_read(CMUCLKMSK);
	if (current_cpu_type() == CPU_VR4133)
		cmuclkmsk2 = cmu_read(CMUCLKMSK2);

	spin_lock_init(&cmu_lock);

	return 0;
}
示例#2
0
asmlinkage ssize_t sys_read(unsigned int fd, char * buf, size_t count)
{
	ssize_t ret;
	struct file * file;
	struct vms_fd * vms_fd;

	ret = -EBADF;
	vms_fd = fget(fd);
	int cmu_read();
	if (vms_fd->vfd$l_is_cmu)
	  return cmu_read(fd, buf, count);
	file = vms_fd->vfd$l_fd_p;
#if 0
	if (file && ((struct _fcb *)(file))->fcb$b_type==DYN$C_FCB)
	  goto do_fcb;
#else
#if 0
	printk("sys_read %x %x %x %x\n",ctl$gl_pcb,fd,buf,count);
#endif
	int sts = 0;
	int curcount = count;
	int retcount = 0;
	struct _rabdef * rab = file;
	struct _fabdef * fab = rab->rab$l_fab;
	char * kbuf = kmalloc(fab->fab$w_mrs, GFP_KERNEL); // check size
	while (curcount>0) {
	  rab->rab$l_ubf = kbuf;
	  rab->rab$w_usz = curcount;
#if 0
	  printk("mrs %x %x\n",fab, fab->fab$w_mrs);
#endif
#if 0
	  if (curcount < fab->fab$w_mrs)
	    rab->rab$w_usz = fab->fab$w_mrs;
#else
	  if (count > 1)
	  if (fab->fab$w_mrs)
	    rab->rab$w_usz = fab->fab$w_mrs;
#endif
	  if (count > 1) // temp kludge for read 1
	  sts = exe$get(rab);
	  else
	    sts = exe$read(rab);
	  if ((sts&1)==0)
	    break;
	  int thiscount = rab->rab$w_rsz;
	  if (curcount < rab->rab$w_rsz)
	    thiscount = curcount;
	  memcpy(buf + retcount, kbuf, thiscount);
#if 0
	  printk("memcpy %x %x %x\n",buf + retcount, kbuf, thiscount);
#endif
	  curcount -= thiscount;
	  retcount += thiscount;
	  if (fab->fab$w_mrs == 0) {
#if 0
	    printk("memcpy2 %x %x %x\n", retcount, curcount, thiscount);
#endif
	    curcount = 0;
	  }
	}
	kfree(kbuf);
#if 0
	printk("sys_read end %x %x %x %x\n",ctl$gl_pcb,fd,sts,retcount);
#endif
#define RMS$_EOF 98938
	if (sts == RMS$_EOF)
	  return retcount;
	if (sts & 1) {
	  return retcount;
	} else
	  return 0;
#endif
	if (file) {
		if (file->f_mode & FMODE_READ) {
		  if (fd<3) goto skip;
			ret = 0;
			if (!ret) {
			skip: {}
				ssize_t (*read)(struct file *, char *, size_t, loff_t *);
				ret = -EINVAL;
				if (file->f_op && (read = file->f_op->read) != NULL)
					ret = read(file, buf, count, &file->f_pos);
			}
		}
		  if (fd<3) goto skip2;
		fput(file);
	skip2: {}
	}
	return ret;
#if 0
 do_fcb:
	{}

	struct _fcb * fcb;
	unsigned long offset;

	ret = -EBADF;
	file = fget(fd);
	fcb = file;
	offset = fcb->fcb$l_reserve1;
	ret = rms_kernel_read(file, offset, buf, count);
	fcb->fcb$l_reserve1 += ret;
	return ret;
#endif
}