示例#1
0
文件: sub.c 项目: npe9/harvey
void
devream(Device *d, int top)
{
	Device *l;

loop:
	print("\tdevream: %Z %d\n", d, top);
	switch(d->type) {
	default:
		print("ream: unknown dev type %Z\n", d);
		return;

	case Devcw:
		devream(d->cw.w, 0);
		devream(d->cw.c, 0);
		if(top) {
			wlock(&mainlock);
			cwream(d);
			wunlock(&mainlock);
		}
		devinit(d);
		return;

	case Devfworm:
		devream(d->fw.fw, 0);
		fwormream(d);
		break;

	case Devpart:
		devream(d->part.d, 0);
		break;

	case Devmlev:
	case Devmcat:
	case Devmirr:
		for(l=d->cat.first; l; l=l->link)
			devream(l, 0);
		break;

	case Devjuke:
	case Devworm:
	case Devlworm:
	case Devwren:
		break;

	case Devswab:
		d = d->swab.d;
		goto loop;
	}
	devinit(d);
	if(top) {
		wlock(&mainlock);
		rootream(d, ROOT_ADDR);
		superream(d, SUPER_ADDR);
		wunlock(&mainlock);
	}
}
示例#2
0
void
fwormream(Device *d)
{
	Iobuf *p;
	Device *fdev;
	Off a, b;

	if(chatty)
		print("fworm ream\n");
	devinit(d);
	fdev = FDEV(d);
	a = fwormsize(d);
	b = devsize(fdev);
	if(chatty){
		print("\tfwsize = %lld\n", (Wideoff)a);
		print("\tbwsize = %lld\n", (Wideoff)b-a);
	}
	for(; a < b; a++) {
		p = getbuf(fdev, a, Bmod|Bres);
		if(!p)
			panic("fworm: init");
		memset(p->iobuf, 0, RBUFSIZE);
		settag(p, Tvirgo, a);
		putbuf(p);
	}
}
示例#3
0
int main(int argc, char *argv[])
{
	struct pci_dev *pci_dev_find(struct drm_device *dev);

	init(&argc, &argv);
	devinit();
	
	intel_setup_bios(i915);
	if (i915->bios_bin)
		intel_parse_bios(i915);
}
示例#4
0
int main(int argc, char *argv[])
{
	struct drm_i915_private *dp;

	init(&argc, &argv);
	devinit();
	intel_setup_bios(i915);
	if (i915->bios_bin)
		intel_parse_bios(i915);
#if defined(VERSION) && VERSION == 36
	intel_panel_enable_backlight(i915, 0);
#else
	intel_panel_enable_backlight(i915);
#endif
	i915_driver_load(i915, (unsigned long)i915->dev_private->info);

	/* now walk the connector list, dumping connector type 
	 * and EDID
	 */
	dp = i915->dev_private;

	if (dp->int_lvds_connector) {
		if (verbose){
			fprintf(stderr, "We have an lvds: \n");
		}
	}
	
	if (dp->int_edp_connector) {
		if (verbose)
			fprintf(stderr, "We have an edp: \n");
	}

	u32 pwm = intel_panel_get_backlight(i915);
	printf("pwm %d\n", pwm);

	if (argc)
		pwm = strtol(argv[0], 0, 0);
	printf("new pwm %d\n", pwm);
#if defined(VERSION) && VERSION == 36
	intel_panel_enable_backlight(i915, 0);
#else
	intel_panel_enable_backlight(i915);
#endif
	intel_panel_set_backlight(i915, pwm);
	pwm = intel_panel_get_backlight(i915);
	printf("pwm at end is %d\n", pwm);
}
示例#5
0
文件: sol.c 项目: turtle-fly/openipmi
static int
sol_serial_initialize(ipmi_sol_t *sol)
{
    soldata_t *sd = sol->soldata;
    int err;

#ifdef USE_UUCP_LOCKING
    err = uucp_mk_lock(sd->sys, sol->device);
    if (err > 0) {
	fprintf(stderr, "SOL device %s is already owned by process %d\n",
		sol->device, err);
	err = EBUSY;
	goto out;
    }
    if (err < 0) {
	fprintf(stderr, "Error locking SOL device %s\n", sol->device);
	err = -err;
	goto out;
    }
#endif /* USE_UUCP_LOCKING */
    devinit(sol, &sd->termctl);

    sd->fd = open(sol->device, O_NONBLOCK | O_NOCTTY | O_RDWR);
    if (sd->fd == -1) {
	err = errno;
	fprintf(stderr, "Error opening SOL device %s\n", sol->device);
	goto out;
    }

    err = tcsetattr(sd->fd, TCSANOW, &sd->termctl);
    if (err == -1) {
	err = errno;
	fprintf(stderr, "Error configuring SOL device %s\n", sol->device);
	goto out;
    }

    /* Turn off BREAK. */
    ioctl(sd->fd, TIOCCBRK);

 out:
    return err;
}
示例#6
0
int main(int argc, char *argv[])
{
	struct drm_i915_private *dp;
	bool dpd_is_edp = false;

	init(&argc, &argv);
	devinit();
	intel_setup_bios(i915);
	if (i915->bios_bin)
		intel_parse_bios(i915);
#if defined(VERSION) && VERSION == 36
	intel_panel_enable_backlight(i915, 0);
#else
	intel_panel_enable_backlight(i915);
#endif
	i915_driver_load(i915, (unsigned long)i915->dev_private->info);

	dp = i915->dev_private;

	dpd_is_edp = intel_dpd_is_edp(i915);
	
	if (has_edp_a(i915))
		printf("DP_A,");
	
	if (dp->int_lvds_connector)
		printf("LVDS,");

	if (I915_READ(HDMIC) & PORT_DETECTED)
		printf("HDMIC,");

	if (I915_READ(HDMID) & PORT_DETECTED)
		printf("HDMID,");

	if (I915_READ(PCH_DP_C) & DP_DETECTED)
		printf("DPC,");

	if (!dpd_is_edp && (I915_READ(PCH_DP_D) & DP_DETECTED))
		printf("DPD,");
	printf("\n");

}
示例#7
0
int main(int argc, char *argv[])
{
	u32 c;
	u32 max;
	init(&argc, &argv);
	devinit();

	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0x0
#if 0
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0x0
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0x0
#endif
	I915_WRITE(PCH_PP_CONTROL /*0xc7204*/, 0xabcd0008);
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
#if 0
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
#endif
	max = I915_READ(BLC_PWM_CPU_CTL /*0x48254*/);// returns 0x10ce
#if 0
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	I915_WRITE(PCH_PP_CONTROL /*0xc7204*/, 0xabcd0008);
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	I915_WRITE(PCH_PP_CONTROL /*0xc7204*/, 0xabcd0008);
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0008
#endif
	I915_WRITE(PCH_PP_CONTROL /*0xc7204*/, 0xabcd000b);
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd000b
#if 0
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd000b
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd000b
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd000b
#endif
	I915_WRITE(PCH_PP_CONTROL /*0xc7204*/, 0xabcd0003);
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0003
#if 0
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0003
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0003
#endif
	I915_WRITE(PCH_PP_CONTROL /*0xc7204*/, 0xabcd0007);
	c = I915_READ(PCH_PP_CONTROL /*0xc7204*/);// returns 0xabcd0007
	c = I915_READ(BLC_PWM_CPU_CTL /*0x48254*/);// returns 0x10ce
	I915_WRITE(BLC_PWM_CPU_CTL /*0x48254*/, 0x10ce);
	c = I915_READ(BLC_PWM_CPU_CTL /*0x48254*/);// returns 0x10ce
	I915_WRITE(BLC_PWM_CPU_CTL /*0x48254*/, max);
}
示例#8
0
/* copy device from src to dest */
static int
dodevcopy(void)
{
	Device *from, *to;
	Iobuf *p;
	Off a;
	Devsize lim, tosize;

	/*
	 * convert config strings into Devices.
	 */
	from = iconfig(src);
	if(f.error || from == nil) {
		print("bad src device %s\n", src);
		return -1;
	}
	to = iconfig(dest);
	if(f.error || to == nil) {
		print("bad dest device %s\n", dest);
		return -1;
	}

	/*
	 * initialise devices, size them, more sanity checking.
	 */

	devinit(from);
	lim = devsize(from);
	if(lim == 0)
		panic("no blocks to copy on %Z", from);
	devinit(to);
	tosize = devsize(to);
	if(tosize == 0)
		panic("no blocks to copy on %Z", to);

	/* use smaller of the device sizes */
	if (tosize < lim)
		lim = tosize;

	print("copy %Z to %Z in 8 seconds\n", from, to);
	delay(8000);
	if (userabort("preparing to copy"))
		return -1;
	print("copying dev: %lld blocks from %Z to %Z\n", (Wideoff)lim,
		from, to);

	/*
	 * Copy all blocks, a block at a time.
	 */

	for (a = 0; a < lim; a++) {
		if (userabort("copy"))
			break;
		p = getbuf(from, a, Brd);
		/*
		 * if from is a real WORM device, we'll get errors trying to
		 * read unwritten blocks, but the unwritten blocks need not
		 * be contiguous.
		 */
		if (p == 0) {
			print("%lld not written yet; can't read\n", (Wideoff)a);
			continue;
		}
		if (to != 0 && devwrite(to, p->addr, p->iobuf) != 0) {
			print("out block %lld: write error; bailing",
				(Wideoff)a);
			break;
		}
		putbuf(p);
		if(a % 20000 == 0)
			print("block %lld %T\n", (Wideoff)a, time(nil));
	}

	/*
	 * wrap up: sync target
	 */
	print("copied %lld blocks from %Z to %Z\n", (Wideoff)a, from, to);
	sync("devcopy");
	return 0;
}
示例#9
0
/* copy worm fs from "main"'s inner worm to "output" */
static void
dowormcopy(void)
{
	Filsys *f1, *f2;
	Device *fdev, *from, *to = nil;
	Iobuf *p;
	Off a;
	Devsize lim;

	/*
	 * convert file system names into Filsyss and Devices.
	 */

	f1 = fsstr("main");
	if(f1 == nil)
		panic("main file system missing");
	fdev = f1->dev;
	from = wormof(fdev);			/* fake worm special */
	if (from->type != Devfworm && from->type != Devcw) {
		print("main file system is not a worm; copyworm may not do what you want!\n");
		print("waiting for 20 seconds...\n");
		delay(20000);
	}

	f2 = fsstr("output");
	if(f2 == nil) {
		print("no output file system - check only\n\n");
		print("reading worm from %Z (worm %Z)\n", fdev, from);
	} else {
		to = f2->dev;
		print("\ncopying worm from %Z (worm %Z) to %Z, starting in 8 seconds\n",
			fdev, from, to);
		delay(8000);
	}
	if (userabort("preparing to copy"))
		return;

	/*
	 * initialise devices, size them, more sanity checking.
	 */

	devinit(from);
	if (0 && fdev != from) {
		devinit(fdev);
		print("debugging, sizing %Z first\n", fdev);
		writtensize(fdev);
	}
	lim = writtensize(from);
	if(lim == 0)
		panic("no blocks to copy on %Z", from);
	if (to) {
		print("reaming %Z in 8 seconds\n", to);
		delay(8000);
		if (userabort("preparing to ream & copy"))
			return;
		devream(to, 0);
		devinit(to);
		print("copying worm: %lld blocks from %Z to %Z\n",
			(Wideoff)lim, from, to);
	}
	/* can't read to's blocks in case to is a real WORM device */

	/*
	 * Copy written fs blocks, a block at a time (or just read
	 * if no "output" fs).
	 */

	for (a = 0; a < lim; a++) {
		if (userabort("copy"))
			break;
		p = getbuf(from, a, Brd);
		/*
		 * if from is a real WORM device, we'll get errors trying to
		 * read unwritten blocks, but the unwritten blocks need not
		 * be contiguous.
		 */
		if (p == 0) {
			print("%lld not written yet; can't read\n", (Wideoff)a);
			continue;
		}
		if (to != 0 && devwrite(to, p->addr, p->iobuf) != 0) {
			print("out block %lld: write error; bailing",
				(Wideoff)a);
			break;
		}
		putbuf(p);
		if(a % 20000 == 0)
			print("block %lld %T\n", (Wideoff)a, time(nil));
	}

	/*
	 * wrap up: sync target, loop
	 */
	print("copied %lld blocks from %Z to %Z\n", (Wideoff)a, from, to);
	sync("wormcopy");
	delay(2000);
	print("looping; reset the machine at any time.\n");
	for (; ; )
		continue;		/* await reset */
}
示例#10
0
void
sysinit(void)
{
	int error;
	char *cp, *ep;
	Device *d;
	Filsys *fs;
	Fspar *fsp;
	Iobuf *p;

	cons.chan = fs_chaninit(Devcon, 1, 0);

start:
	/*
	 * part 1 -- read the config file
	 */
	devnone = iconfig("n");

	cp = nvrgetconfig();
	print("config %s\n", cp);

	confdev = d = iconfig(cp);
	devinit(d);
	if(f.newconf) {
		p = getbuf(d, 0, Bmod);
		memset(p->iobuf, 0, RBUFSIZE);
		settag(p, Tconfig, 0);
	} else
		p = getbuf(d, 0, Brd|Bmod);
	if(!p || checktag(p, Tconfig, 0))
		panic("config io");

	mergeconf(p);

	if (resetparams) {
		for (fsp = fspar; fsp->name != nil; fsp++)
			fsp->declared = 0;
		resetparams = 0;
	}

	for (fsp = fspar; fsp->name != nil; fsp++) {
		/* supply defaults from this cwfs instance */
		if (fsp->declared == 0) {
			fsp->declared = fsp->actual;
			f.modconf = 1;
		}
		/* warn if declared value is not our compiled-in value */
		if (fsp->declared != fsp->actual)
			print("warning: config %s %ld != compiled-in %ld\n",
				fsp->name, fsp->declared, fsp->actual);
	}

	if(f.modconf) {
		memset(p->iobuf, 0, BUFSIZE);
		p->flags |= Bmod|Bimm;
		cp = p->iobuf;
		ep = p->iobuf + RBUFSIZE - 1;
		if(service[0])
			cp = seprint(cp, ep, "service %s\n", service);
		for(fs=filsys; fs->name; fs++)
			if(fs->conf && fs->conf[0] != '\0')
				cp = seprint(cp, ep, "filsys %s %s\n", fs->name,
					fs->conf);

		for (fsp = fspar; fsp->name != nil; fsp++)
			cp = seprint(cp, ep, "%s %ld\n",
				fsp->name, fsp->declared);

		putbuf(p);
		f.modconf = f.newconf = 0;
		print("config block written\n");
		goto start;
	}
	putbuf(p);

	print("service    %s\n", service);

loop:
	/*
	 * part 2 -- squeeze out the deleted filesystems
	 */
	for(fs=filsys; fs->name; fs++)
		if(fs->conf == nil || fs->conf[0] == '\0') {
			for(; fs->name; fs++)
				*fs = *(fs+1);
			goto loop;
		}
	if(filsys[0].name == nil)
		panic("no filsys");

	/*
	 * part 3 -- compile the device expression
	 */
	error = 0;
	for(fs=filsys; fs->name; fs++) {
		print("filsys %s %s\n", fs->name, fs->conf);
		fs->dev = iconfig(fs->conf);
		if(f.error) {
			error = 1;
			continue;
		}
	}
	if(error)
		panic("fs config");

	/*
	 * part 4 -- initialize the devices
	 */
	for(fs=filsys; fs->name; fs++) {
		delay(3000);
		print("sysinit: %s\n", fs->name);
		if(fs->flags & FREAM)
			devream(fs->dev, 1);
		if(fs->flags & FRECOVER)
			devrecover(fs->dev);
		devinit(fs->dev);
	}

	/*
	 * part 5 -- optionally copy devices or worms
	 */
	if (copyworm) {
		dowormcopy();		/* can return if user quits early */
		panic("copyworm bailed out!");
	}
	if (copydev)
		if (dodevcopy() < 0)
			panic("copydev failed!");
		else
			panic("copydev done.");
}
示例#11
0
文件: run.c 项目: jwy8612/DRVLESS
i32 main(i32 argc, u8 ** argv)
{
	i32 ret = 0;
	i32 framenum = 0;
	i32 fd;
	fd_set fds;
	struct timeval time;
	VIDEO_BUFF vBuff;
	FILE *file=NULL;
	FILE *filein = NULL;
	FILE *fileout=NULL;
	COMMAND_INFO cmdInfo;
	u8 srcBuff[srcSize];
	u8 dstBuff[dstSize];
	u8 UBuff[dstSize];
	u8 VBuff[dstSize];
	u8 processBuff[dstSize];
	i32 pTh,pR;
	i32 direc, pos;
	u8 threshold;
	u8 testName[20];
	i32 testValue;
	i32 testValue1;
		
	function_in();
	memset(&cmdInfo,0,sizeof(COMMAND_INFO));
	
	ret = devinit();
	if(ret < 0)
	{
		run_err("dev init failed,ret = %d\n",ret);
	}

/*************¹¦ÄܲâÊÔ*******************************/
	if(argc > 1)
	{
		strcpy(testName,argv[1]);
		if(argc>2)
			testValue = atoi(argv[2]);
		if(argc > 3)
			testValue1= atoi(argv[3]);

		/*************µç»ú²âÊÔ********/
		if(!strcmp(testName,"motortest"))
		{
			cmdInfo.motorCmd.bMoterCmd=1;
			cmdInfo.motorCmd.cmdtype=1;
			cmdInfo.motorCmd.motorV=testValue;

			getCmd(comInst, &cmdInfo);
		}

		/*************¶æ»ú²âÊÔ********/
		if(!strcmp(testName,"servotest"))
		{
			cmdInfo.servoCmd.bservoCmd = 1;
			cmdInfo.servoCmd.cmdtype = 1;
			cmdInfo.servoCmd.servoA = testValue;
			cmdInfo.servoCmd.servoV = testValue1;
		
			getCmd(comInst, &cmdInfo);
		}
		
		/*************ͼÏñ²âÊÔ********/
		if(!strcmp(testName,"videotest"))
		{
			filein = fopen("/mnt/sdcard/bishe.yuv","rb+");
			if(file < 0)
			{
				run_err("open 400.yuv failed!!!\n");
			}
			
			fileout = fopen("/mnt/sdcard/out.yuv","wb+");
			if(file < 0)
			{
				run_err("open out.yuv failed!!!\n");
			}
			while(framenum < 350)
			{
			
				fread(srcBuff, 1, srcSize, filein);
				picFmtTrans(picWd, picHt, srcBuff, dstBuff, YUV_Y);
				picFilterAverage(dstWd, dstHt, dstBuff);
				threshold = picGetThreshold(dstBuff,dstWd,dstHt,100,50);
				picBinary(dstBuff, dstWd, dstHt, threshold);
				picLinePre(dstBuff,dstWd,dstHt);
				
				pic_Hough(dstBuff,dstWd,dstWd,&pR,&pTh);
				
				fwrite(dstBuff, 1,dstSize, fileout);
				framenum ++;
			}
			
			if(filein)
				fclose(filein);
			if(fileout)
				fclose(fileout);
		}
		
	}
	
/******************************************/
/*************Õý³£ÔËÐÐ*******************************/
	if(argc == 1)
	{
		if(videoInst==NULL)
		{
			run_err("videoinst is null!!!!\n");
			goto exit;
		}
		Video_StartCapture(videoInst);
		fd = Video_GetFd(videoInst);
		while(1)
		{
			FD_ZERO(&fds);	
			FD_SET(fd, &fds); 
			time.tv_sec = 3;
			time.tv_usec = 0;
		
			ret = select(fd + 1, &fds, NULL, NULL, &time);
			if(ret < 0)
			{
				run_err("select failed!!!\n");
			}
			if(ret == 0)
			{
				run_err("select time out!!!\n");
			}
			if(ret > 0)
			{
				Video_GetFrame(videoInst, &vBuff);
				picFmtTrans(picWd, picHt, (u8*)vBuff.start, dstBuff, YUV_Y);
		
		
				fwrite(srcBuff, 1, srcSize, file);
				framenum ++;
				if(framenum == FRAMENUM)
				{
					goto exit;
				}
			}
		}
	}
/******************************************/

//	cmdInfo->comInst = comInst;
//	comGetInit(comInst);

exit:
	
	ret = devRelease();
	if(ret < 0)
	{
		run_err("dev release failed,ret = %d\n",ret);
	}



	function_out();

	
	return ret;
}	
示例#12
0
文件: fworm.c 项目: 99years/plan9
void
fworminit(Device *d)
{
	print("fworm init\n");
	devinit(FDEV(d));
}
/**
 * The initialization function for the allocation table AT.
 * It contains two major parts:
 * 1. Calculate the actual physical memory of the machine, and sets the number of physical pages (NUM_PAGES).
 * 2. Initializes the physical allocation table (AT) implemented in MATIntro layer, based on the
 *    information available in the physical memory map table.
 *    Review import.h in the current directory for the list of avaiable getter and setter functions.
 */
void
pmem_init(unsigned int mbi_addr)
{
  unsigned int nps;

  // TODO: Define your local variables here.
  // number of rows
  unsigned int rows;
  unsigned int h_addr;
  unsigned int i;
  unsigned int first_row, tmp_row;
  //Calls the lower layer initializatin primitives.
  //The parameter mbi_addr shell not be used in the further code.
	devinit(mbi_addr);

  /**
   * Calculate the number of actual number of avaiable physical pages and store it into the local varaible nps.
   * Hint: Think of it as the highest address possible in the ranges of the memory map table,
   *       divided by the page size.
   */
  // TODO
  rows = get_size();
  h_addr = get_mms(rows - 1) + get_mml(rows - 1);
  dprintf("h_addr: %u\n", h_addr);
  nps = h_addr / PAGESIZE;
	set_nps(nps); // Setting the value computed above to NUM_PAGES.

  /**
   * Initialization of the physical allocation table (AT).
   *
   * In CertiKOS, the entire addresses < VM_USERLO or >= VM_USERHI are reserved by the kernel.
   * That corresponds to the physical pages from 0 to VM_USERLO_PI-1, and from VM_USERHI_PI to NUM_PAGES-1.
   * The rest of pages that correspond to addresses [VM_USERLO, VM_USERHI), can be used freely ONLY IF
   * the entire page falls into one of the ranges in the memory map table with the permission marked as usable.
   *
   * Hint:
   * 1. You have to initialize AT for all the page indices from 0 to NPS - 1.
   * 2. For the pages that are reserved by the kernel, simply set its permission to 1.
   *    Recall that the setter at_set_perm also marks the page as unallocated. 
   *    Thus, you don't have to call another function to set the allocation flag.
   * 3. For the rest of the pages, explore the memory map table to set its permission accordingly.
   *    The permission should be set to 2 only if there is a range containing the entire page that
   *    is marked as available in the memory map table. O.w., it should be set to 0.
   *    Note that the ranges in the memory map are not aligned by pages.
   *    So it may be possible that for some pages, only part of the addresses are in the ranges.
   *    Currently, we do not utilize partial pages, so in that case, you should consider those pages as unavailble.
   * 4. Every page in the allocation table shold be initialized.
   *    But the ranges in the momory map table may not cover the entire available address space.
   *    That means there may be some gaps between the ranges.
   *    You should still set the permission of those pages in allocation table to 0.
   */
  // TODO
  for (i = 0; i < VM_USERLO_PI; i++) {
      // check if one page occupies two rows
     at_set_perm(i, 1);
  }
  for (first_row = 0; first_row < rows - 1; first_row++) {
     if (get_mms(first_row) + get_mml(first_row) < i * PAGESIZE && get_mms(first_row + 1) < (i + 1) * PAGESIZE) {
        first_row ++;
        break;
     }
  }
  for (i = VM_USERLO_PI; i < VM_USERHI_PI; i++) {
     if (i * PAGESIZE <= get_mms(first_row) + get_mml(first_row) && (i + 1) * PAGESIZE > get_mms(first_row) + get_mml(first_row)) {
        first_row ++ ;
        at_set_perm(i, 0);
     } else if (is_usable(i)) {
        at_set_perm(i, 2);
     } else {
        at_set_perm(i, 0);
     }
  }
  for (i = VM_USERHI; i < nps; i++) {
     at_set_perm(i, 1);
  }
  
}