예제 #1
0
파일: metadata.c 프로젝트: 2asoft/freebsd
vm_offset_t
md_copymodules(vm_offset_t addr, int kern64)
{
    struct preloaded_file	*fp;
    struct file_metadata	*md;
    uint64_t			scratch64;
    int				c;

    c = addr != 0;
    /* start with the first module on the list, should be the kernel */
    for (fp = file_findfile(NULL, NULL); fp != NULL; fp = fp->f_next) {

	MOD_NAME(addr, fp->f_name, c);	/* this field must come first */
	MOD_TYPE(addr, fp->f_type, c);
	if (fp->f_args)
	    MOD_ARGS(addr, fp->f_args, c);
	if (kern64) {
		scratch64 = fp->f_addr;
		MOD_ADDR(addr, scratch64, c);
		scratch64 = fp->f_size;
		MOD_SIZE(addr, scratch64, c);
	} else {
		MOD_ADDR(addr, fp->f_addr, c);
		MOD_SIZE(addr, fp->f_size, c);
	}
	for (md = fp->f_metadata; md != NULL; md = md->md_next) {
	    if (!(md->md_type & MODINFOMD_NOCOPY)) {
		MOD_METADATA(addr, md, c);
	    }
	}
    }
    MOD_END(addr, c);
    return(addr);
}
예제 #2
0
파일: mbx.c 프로젝트: Enextuse/RTAI
static int mbxovrwrput(MBX *mbx, char **msg, int msg_size, int space)
{
	unsigned long flags;
	int tocpy,n;

	if ((n = msg_size - mbx->size) > 0)
	{
		*msg += n;
		msg_size -= n;
	}
	while (msg_size > 0)
	{
		if (mbx->frbs)
		{
			if ((tocpy = mbx->size - mbx->lbyte) > msg_size)
			{
				tocpy = msg_size;
			}
			if (tocpy > mbx->frbs)
			{
				tocpy = mbx->frbs;
			}
			if (space)
			{
				memcpy(mbx->bufadr + mbx->lbyte, *msg, tocpy);
			}
			else
			{
				rt_copy_from_user(mbx->bufadr + mbx->lbyte, *msg, tocpy);
			}
			flags = rt_spin_lock_irqsave(&(mbx->lock));
			mbx->frbs -= tocpy;
			mbx->avbs += tocpy;
			rt_spin_unlock_irqrestore(flags, &(mbx->lock));
			msg_size -= tocpy;
			*msg     += tocpy;
			mbx->lbyte = MOD_SIZE(mbx->lbyte + tocpy);
		}
		if (msg_size)
		{
			while ((n = msg_size - mbx->frbs) > 0)
			{
				if ((tocpy = mbx->size - mbx->fbyte) > n)
				{
					tocpy = n;
				}
				if (tocpy > mbx->avbs)
				{
					tocpy = mbx->avbs;
				}
				flags = rt_spin_lock_irqsave(&(mbx->lock));
				mbx->frbs  += tocpy;
				mbx->avbs  -= tocpy;
				rt_spin_unlock_irqrestore(flags, &(mbx->lock));
				mbx->fbyte = MOD_SIZE(mbx->fbyte + tocpy);
			}
		}
	}
	return 0;
}
예제 #3
0
static vm_offset_t
bi_copymodules64(vm_offset_t addr)
{
    struct preloaded_file	*fp;
    struct file_metadata	*md;
    int				c;
    u_int64_t			v;

    c = addr != 0;
    /* start with the first module on the list, should be the kernel */
    for (fp = file_findfile(NULL, NULL); fp != NULL; fp = fp->f_next) {

	MOD_NAME(addr, fp->f_name, c);	/* this field must come first */
	MOD_TYPE(addr, fp->f_type, c);
	if (fp->f_args)
	    MOD_ARGS(addr, fp->f_args, c);
	v = fp->f_addr;
	MOD_ADDR(addr, v, c);
	v = fp->f_size;
	MOD_SIZE(addr, v, c);
	for (md = fp->f_metadata; md != NULL; md = md->md_next)
	    if (!(md->md_type & MODINFOMD_NOCOPY))
		MOD_METADATA(addr, md, c);
    }
    MOD_END(addr, c);
    return(addr);
}
예제 #4
0
파일: mbx.c 프로젝트: ArcEye/RTAI
static int mbxevdrp(MBX *mbx, char **msg, int msg_size, int space)
{
	int tocpy, fbyte, avbs;

	fbyte = mbx->fbyte;
	avbs  = mbx->avbs;
	while (msg_size > 0 && avbs) {
		if ((tocpy = mbx->size - fbyte) > msg_size) {
			tocpy = msg_size;
		}
		if (tocpy > avbs) {
			tocpy = avbs;
		}
		if (space) {
			memcpy(*msg, mbx->bufadr + fbyte, tocpy);
		} else {
			rt_copy_to_user(*msg, mbx->bufadr + mbx->fbyte, tocpy);
		}
		avbs     -= tocpy;
		msg_size -= tocpy;
		*msg     += tocpy;
		fbyte = MOD_SIZE(fbyte + tocpy);
	}
	return msg_size;
}
예제 #5
0
파일: mbx.c 프로젝트: ArcEye/RTAI
static int mbxget(MBX *mbx, char **msg, int msg_size, int space)
{
	unsigned long flags;
	int tocpy;

	while (msg_size > 0 && mbx->avbs) {
		if ((tocpy = mbx->size - mbx->fbyte) > msg_size) {
			tocpy = msg_size;
		}
		if (tocpy > mbx->avbs) {
			tocpy = mbx->avbs;
		}
		if (space) {
			memcpy(*msg, mbx->bufadr + mbx->fbyte, tocpy);
		} else {
			rt_copy_to_user(*msg, mbx->bufadr + mbx->fbyte, tocpy);
		}
		flags = rt_spin_lock_irqsave(&(mbx->lock));
		mbx->frbs  += tocpy;
		mbx->avbs  -= tocpy;
		rt_spin_unlock_irqrestore(flags, &(mbx->lock));
		msg_size -= tocpy;
		*msg     += tocpy;
		mbx->fbyte = MOD_SIZE(mbx->fbyte + tocpy);
	}
	return msg_size;
}
예제 #6
0
vm_offset_t
bi_copymodules(vm_offset_t addr)
{
	struct preloaded_file *fp;
	struct file_metadata *md;

	/* Start with the first module on the list, should be the kernel. */
	for (fp = file_findfile(NULL, NULL); fp != NULL; fp = fp->f_next) {
		/* The name field must come first. */
		MOD_NAME(addr, fp->f_name);
		MOD_TYPE(addr, fp->f_type);
		if (fp->f_args)
			MOD_ARGS(addr, fp->f_args);
		MOD_ADDR(addr, fp->f_addr);
		MOD_SIZE(addr, fp->f_size);
		for (md = fp->f_metadata; md != NULL; md = md->md_next) {
			if (!(md->md_type & MODINFOMD_NOCOPY))
				MOD_METADATA(addr, md);
		}
	}
	MOD_END(addr);
	return(addr);
}