예제 #1
0
static int
coram_mpeg_intr(struct coram_softc *sc)
{
	struct dtv_payload payload;
	uint32_t s, m, v;
	int i;

	s = bus_space_read_4(sc->sc_memt, sc->sc_memh, VID_C_INT_STAT);
	m = bus_space_read_4(sc->sc_memt, sc->sc_memh, VID_C_INT_MSK);

	if ((s & m) == 0)
		return 0;

	if ( (s & ~CXDTV_TS_RISCI) != 0 ) {
		printf("%s: unexpected TS IS %08x\n",
		    device_xname(sc->sc_dev), s);

		printf("cmds:\n");
		for(i = 0; i < 20; i++)
		{
			v = bus_space_read_4(sc->sc_memt, sc->sc_memh, 0x10140 +(i*4));
			printf("%06x %08x\n", 0x10140+(i*4), v);
		}
	}

	if (sc->sc_dtvsubmitcb == NULL)
		goto done;

	if ((s & CXDTV_TS_RISCI1) == CXDTV_TS_RISCI1) {
		bus_dmamap_sync(sc->sc_dmat, sc->sc_dma->map,
		    0, CORAM_TS_PKTSIZE,
		    BUS_DMASYNC_POSTREAD);
		payload.data = KERNADDR(sc->sc_dma);
		payload.size = CORAM_TS_PKTSIZE;
		sc->sc_dtvsubmitcb(sc->sc_dtvsubmitarg, &payload);
	}

	if ((s & CXDTV_TS_RISCI2) == CXDTV_TS_RISCI2) {
		bus_dmamap_sync(sc->sc_dmat, sc->sc_dma->map,
		    CORAM_TS_PKTSIZE, CORAM_TS_PKTSIZE,
		    BUS_DMASYNC_POSTREAD);
		payload.data = (char *)(KERNADDR(sc->sc_dma)) + (uintptr_t)CORAM_TS_PKTSIZE;
		payload.size = CORAM_TS_PKTSIZE;
		sc->sc_dtvsubmitcb(sc->sc_dtvsubmitarg, &payload);
	}

done:
	bus_space_write_4(sc->sc_memt, sc->sc_memh, VID_C_INT_STAT, s);

	return 1;
}
예제 #2
0
static void *
auacer_allocm(void *v, int direction, size_t size,
    struct malloc_type *pool, int flags)
{
	struct auacer_softc *sc;
	struct auacer_dma *p;
	int error;

	if (size > (ALI_DMALIST_MAX * ALI_DMASEG_MAX))
		return NULL;

	p = malloc(sizeof(*p), pool, flags | M_ZERO);
	if (p == NULL)
		return NULL;
	sc = v;
	error = auacer_allocmem(sc, size, 0, p);
	if (error) {
		free(p, pool);
		return NULL;
	}

	p->next = sc->sc_dmas;
	sc->sc_dmas = p;

	return KERNADDR(p);
}
예제 #3
0
/*  *********************************************************************
    *  flashdrv_allocbuf(dev)
    *  
    *  Allocate sector buffer for flash programming.  Use a global
    *  buffer for all devices.
    *  
    *  Input parameters: 
    *  	   dev - our device
    *  	   
    *  Return value:
    *  	   nothing
    ********************************************************************* */
static void flashdrv_allocbuf(flashdev_t *softc)
{
    if (!flash_sector_buffer) {
#if CFG_FLASH_ALLOC_SECTOR_BUFFER
	flash_sector_buffer = KMALLOC(CFG_FLASH_SECTOR_BUFFER_SIZE,0);
	if (!flash_sector_buffer) {
	    printf("FLASH: Could not allocate sector buffer, using default\n");
	    flash_sector_buffer = (uint8_t *) KERNADDR(CFG_FLASH_SECTOR_BUFFER_SIZE);
	    }
#else
	flash_sector_buffer = (uint8_t *) KERNADDR(CFG_FLASH_SECTOR_BUFFER_ADDR);
#endif
	}

    softc->fd_sectorbuffer = flash_sector_buffer;
}
예제 #4
0
static int
auich_trigger_input(void *v, void *start, void *end, int blksize,
    void (*intr)(void *), void *arg, const audio_params_t *param)
{
	struct auich_softc *sc;
	struct auich_dma *p;
	size_t size;

	DPRINTF(ICH_DEBUG_DMA,
	    ("auich_trigger_input(%p, %p, %d, %p, %p, %p)\n",
	    start, end, blksize, intr, arg, param));
	sc = v;

	for (p = sc->sc_dmas; p && KERNADDR(p) != start; p = p->next)
		continue;
	if (!p) {
		printf("auich_trigger_input: bad addr %p\n", start);
		return EINVAL;
	}

	size = (size_t)((char *)end - (char *)start);

	sc->pcmi.intr = intr;
	sc->pcmi.arg = arg;
	sc->pcmi.start = DMAADDR(p);
	sc->pcmi.p = sc->pcmi.start;
	sc->pcmi.end = sc->pcmi.start + size;
	sc->pcmi.blksize = blksize;

	bus_space_write_4(sc->iot, sc->aud_ioh, ICH_PCMI + ICH_BDBAR,
	    sc->sc_cddma + ICH_PCMI_OFF(0));
	auich_trigger_pipe(sc, ICH_PCMI, &sc->pcmi);

	return 0;
}
예제 #5
0
static void *
auich_allocm(void *v, int direction, size_t size)
{
	struct auich_softc *sc;
	struct auich_dma *p;
	int error;

	if (size > (ICH_DMALIST_MAX * ICH_DMASEG_MAX))
		return NULL;

	p = kmem_alloc(sizeof(*p), KM_SLEEP);
	if (p == NULL)
		return NULL;

	sc = v;
	error = auich_allocmem(sc, size, 0, p);
	if (error) {
		kmem_free(p, sizeof(*p));
		return NULL;
	}

	p->next = sc->sc_dmas;
	sc->sc_dmas = p;

	return KERNADDR(p);
}
예제 #6
0
static int
auacer_trigger_output(void *v, void *start, void *end, int blksize,
    void (*intr)(void *), void *arg, const audio_params_t *param)
{
	struct auacer_softc *sc;
	struct auacer_dma *p;
	uint32_t size;

	DPRINTF(ALI_DEBUG_DMA,
		("auacer_trigger_output(%p, %p, %d, %p, %p, %p)\n",
		 start, end, blksize, intr, arg, param));
	sc = v;
	for (p = sc->sc_dmas; p && KERNADDR(p) != start; p = p->next)
		continue;
	if (!p) {
		printf("auacer_trigger_output: bad addr %p\n", start);
		return (EINVAL);
	}

	size = (char *)end - (char *)start;
	auacer_setup_chan(sc, &sc->sc_pcmo, DMAADDR(p), size, blksize,
			  intr, arg);

	return 0;
}
예제 #7
0
파일: yds.c 프로젝트: ryoon/netbsd-xhci
static struct yds_dma *
yds_find_dma(struct yds_softc *sc, void *addr)
{
	struct yds_dma *p;

	for (p = sc->sc_dmas; p && KERNADDR(p) != addr; p = p->next)
		continue;

	return p;
}
예제 #8
0
static void
auacer_freem(void *v, void *ptr, struct malloc_type *pool)
{
	struct auacer_softc *sc;
	struct auacer_dma *p, **pp;

	sc = v;
	for (pp = &sc->sc_dmas; (p = *pp) != NULL; pp = &p->next) {
		if (KERNADDR(p) == ptr) {
			auacer_freemem(sc, p);
			*pp = p->next;
			free(p, pool);
			return;
		}
	}
}
예제 #9
0
static paddr_t
auacer_mappage(void *v, void *mem, off_t off, int prot)
{
	struct auacer_softc *sc;
	struct auacer_dma *p;

	if (off < 0)
		return -1;
	sc = v;
	for (p = sc->sc_dmas; p && KERNADDR(p) != mem; p = p->next)
		continue;
	if (p == NULL)
		return -1;
	return bus_dmamem_mmap(sc->dmat, p->segs, p->nsegs,
	    off, prot, BUS_DMA_WAITOK);
}
예제 #10
0
static void
auich_freem(void *v, void *ptr, size_t size)
{
	struct auich_softc *sc;
	struct auich_dma *p, **pp;

	sc = v;
	for (pp = &sc->sc_dmas; (p = *pp) != NULL; pp = &p->next) {
		if (KERNADDR(p) == ptr) {
			auich_freemem(sc, p);
			*pp = p->next;
			kmem_free(p, sizeof(*p));
			return;
		}
	}
}
예제 #11
0
파일: yds.c 프로젝트: ryoon/netbsd-xhci
static void
yds_free(void *addr, void *ptr, size_t size)
{
	struct yds_softc *sc;
	struct yds_dma **pp, *p;

	sc = addr;
	for (pp = &sc->sc_dmas; (p = *pp) != NULL; pp = &p->next) {
		if (KERNADDR(p) == ptr) {
			yds_freemem(sc, p);
			*pp = p->next;
			kmem_free(p, sizeof(*p));
			return;
		}
	}
}
예제 #12
0
static void
coram_mpeg_free(struct coram_softc *sc, void *addr)
{
	struct coram_dma *p;
	struct coram_dma **pp;

	for (pp = &sc->sc_dma; (p = *pp) != NULL; pp = &p->next)
		if (KERNADDR(p) == addr) {
			coram_freemem(sc, p);
			*pp = p->next;
			kmem_free(p, sizeof(struct coram_dma));
			return;
		}

	printf("%s: %p is already free\n", device_xname(sc->sc_dev), addr);
	return;
}
예제 #13
0
void
usb_freemem(usbd_bus_handle bus, usb_dma_t *p)
{
	struct usb_frag_dma *f;
	int s;

	if (p->block->fullblock) {
		DPRINTFN(1, ("usb_freemem: large free\n"));
		usb_block_freemem(p->block);
		return;
	}
	f = KERNADDR(p, 0);
	f->block = p->block;
	f->offs = p->offs;
	s = splusb();
	LIST_INSERT_HEAD(&usb_frag_freelist, f, next);
	splx(s);
	DPRINTFN(5, ("usb_freemem: frag=%p\n", f));
}
예제 #14
0
void
usb_freemem(usbd_bus_handle bus, usb_dma_t *p)
{
	struct usb_frag_dma *f;

	if (p->block->fullblock) {
		DPRINTFN(1, ("usb_freemem: large free\n"));
		usb_block_freemem(p->block);
		logmemory(free_full, p, bus, (size_t)0, (size_t)0);
		return;
	}
	logmemory(free_frag, p, bus, (size_t)0, (size_t)0);
	f = KERNADDR(p, 0);
	f->block = p->block;
	f->offs = p->offs;
	crit_enter();
	LIST_INSERT_HEAD(&usb_frag_freelist, f, next);
	crit_exit();
	DPRINTFN(5, ("usb_freemem: frag=%p\n", f));
}
예제 #15
0
static void *
coram_mpeg_malloc(struct coram_softc *sc, size_t size)
{
	struct coram_dma *p;
	int err;

	p = kmem_alloc(sizeof(struct coram_dma), KM_SLEEP);
	if ( p == NULL )
		return NULL;
	err = coram_allocmem(sc, size, 16, p);
	if (err) {
		kmem_free(p, sizeof(struct coram_dma));
		return NULL;
	}

	p->next = sc->sc_dma;
	sc->sc_dma = p;

	return KERNADDR(p);
}
예제 #16
0
파일: yds.c 프로젝트: ryoon/netbsd-xhci
static void *
yds_malloc(void *addr, int direction, size_t size)
{
	struct yds_softc *sc;
	struct yds_dma *p;
	int error;

	p = kmem_alloc(sizeof(*p), KM_SLEEP);
	if (p == NULL)
		return NULL;
	sc = addr;
	error = yds_allocmem(sc, size, 16, p);
	if (error) {
		kmem_free(p, sizeof(*p));
		return NULL;
	}
	p->next = sc->sc_dmas;
	sc->sc_dmas = p;
	return KERNADDR(p);
}
예제 #17
0
파일: uhidev.c 프로젝트: ajinkya93/OpenBSD
void
uhidev_get_report_async_cb(struct usbd_xfer *xfer, void *priv, usbd_status err)
{
	struct uhidev_async_info *info = priv;
	char *buf;
	int len = -1;

	if (err == USBD_NORMAL_COMPLETION || err == USBD_SHORT_XFER) {
		len = xfer->actlen;
		buf = KERNADDR(&xfer->dmabuf, 0);
		if (info->id > 0) {
			len--;
			memcpy(info->data, buf + 1, len);
		} else {
			memcpy(info->data, buf, len);
		}
	}
	info->callback(info->priv, info->id, info->data, len);
	free(info, M_TEMP, sizeof(*info));
	usbd_free_xfer(xfer);
}
예제 #18
0
static int
coram_risc_field(struct coram_softc *sc, uint32_t *rm, uint32_t bpl)
{
	struct coram_dma *p;

	for (p = sc->sc_dma; p && KERNADDR(p) != sc->sc_tsbuf; p = p->next)
		continue;
	if (p == NULL) {
		printf("%s: coram_risc_field: bad addr %p\n",
		    device_xname(sc->sc_dev), sc->sc_tsbuf);
		return ENOENT;
	}

	memset(sc->sc_riscbuf, 0, sc->sc_riscbufsz);

	rm = sc->sc_riscbuf;

	/* htole32 will be done when program is copied to chip sram */

	/* XXX */
	*(rm++) = (CX_RISC_SYNC|0);

	*(rm++) = (CX_RISC_WRITE|CX_RISC_SOL|CX_RISC_EOL|CX_RISC_IRQ1|bpl);
	*(rm++) = (DMAADDR(p) + 0 * bpl);
	*(rm++) = 0; /* high dword */

	*(rm++) = (CX_RISC_WRITE|CX_RISC_SOL|CX_RISC_EOL|CX_RISC_IRQ2|bpl);
	*(rm++) = (DMAADDR(p) + 1 * bpl);
	*(rm++) = 0;

	*(rm++) = (CX_RISC_JUMP|1);
	*(rm++) = (coram_sram_chs[CORAM_SRAM_CH6].csc_risc + 4);
	*(rm++) = 0;

	return 0;
}
예제 #19
0
static int
yds_allocate_slots(struct yds_softc *sc, int resuming)
{
	size_t pcs, rcs, ecs, ws, memsize;
	void *mp;
	u_int32_t da;		/* DMA address */
	char *va;		/* KVA */
	off_t cb;
	int i;
	struct yds_dma *p;

	/* Alloc DSP Control Data */
	pcs = YREAD4(sc, YDS_PLAY_CTRLSIZE) * sizeof(u_int32_t);
	rcs = YREAD4(sc, YDS_REC_CTRLSIZE) * sizeof(u_int32_t);
	ecs = YREAD4(sc, YDS_EFFECT_CTRLSIZE) * sizeof(u_int32_t);
	ws = WORK_SIZE;
	YWRITE4(sc, YDS_WORK_SIZE, ws / sizeof(u_int32_t));

	DPRINTF(("play control size : %d\n", (unsigned int)pcs));
	DPRINTF(("rec control size : %d\n", (unsigned int)rcs));
	DPRINTF(("eff control size : %d\n", (unsigned int)ecs));
	DPRINTF(("work size : %d\n", (unsigned int)ws));
#ifdef DIAGNOSTIC
	if (pcs != sizeof(struct play_slot_ctrl_bank)) {
		printf("%s: invalid play slot ctrldata %d != %d\n",
		       sc->sc_dev.dv_xname, (unsigned int)pcs,
		       (unsigned int)sizeof(struct play_slot_ctrl_bank));
	}
	if (rcs != sizeof(struct rec_slot_ctrl_bank)) {
		printf("%s: invalid rec slot ctrldata %d != %d\n",
		       sc->sc_dev.dv_xname, (unsigned int)rcs,
		       (unsigned int)sizeof(struct rec_slot_ctrl_bank));
        }
#endif

	memsize = N_PLAY_SLOTS*N_PLAY_SLOT_CTRL_BANK*pcs +
		  N_REC_SLOT_CTRL*N_REC_SLOT_CTRL_BANK*rcs + ws;
	memsize += (N_PLAY_SLOTS+1)*sizeof(u_int32_t);

	p = &sc->sc_ctrldata;
	if (!resuming) {
		i = yds_allocmem(sc, memsize, 16, p);
		if (i) {
			printf("%s: couldn't alloc/map DSP DMA buffer, reason %d\n",
			       sc->sc_dev.dv_xname, i);
			free(p, M_DEVBUF);
			return 1;
		}
	}
	mp = KERNADDR(p);
	da = DMAADDR(p);

	DPRINTF(("mp:%p, DMA addr:%p\n",
		 mp, (void *) sc->sc_ctrldata.map->dm_segs[0].ds_addr));

	bzero(mp, memsize);

	/* Work space */
        cb = 0;
	va = (u_int8_t*)mp;
	YWRITE4(sc, YDS_WORK_BASE, da + cb);
        cb += ws;

	/* Play control data table */
        sc->ptbl = (u_int32_t *)(va + cb);
	sc->ptbloff = cb;
        YWRITE4(sc, YDS_PLAY_CTRLBASE, da + cb);
        cb += (N_PLAY_SLOT_CTRL + 1) * sizeof(u_int32_t);

	/* Record slot control data */
        sc->rbank = (struct rec_slot_ctrl_bank *)(va + cb);
        YWRITE4(sc, YDS_REC_CTRLBASE, da + cb);
	sc->rbankoff = cb;
        cb += N_REC_SLOT_CTRL * N_REC_SLOT_CTRL_BANK * rcs;

#if 0
	/* Effect slot control data -- unused */
        YWRITE4(sc, YDS_EFFECT_CTRLBASE, da + cb);
        cb += N_EFFECT_SLOT_CTRL * N_EFFECT_SLOT_CTRL_BANK * ecs;
#endif

	/* Play slot control data */
        sc->pbankoff = da + cb;
        for (i=0; i<N_PLAY_SLOT_CTRL; i++) {
		sc->pbankp[i*2] = (struct play_slot_ctrl_bank *)(va + cb);
		*(sc->ptbl + i+1) = da + cb;
                cb += pcs;

                sc->pbankp[i*2+1] = (struct play_slot_ctrl_bank *)(va + cb);
                cb += pcs;
        }
	/* Sync play control data table */
	bus_dmamap_sync(sc->sc_dmatag, p->map,
			sc->ptbloff, (N_PLAY_SLOT_CTRL+1) * sizeof(u_int32_t),
			BUS_DMASYNC_PREWRITE);

	return 0;
}
예제 #20
0
/*
 * Calibrate card (some boards are overclocked and need scaling)
 */
static void
auich_calibrate(struct auich_softc *sc)
{
	struct timeval t1, t2;
	uint8_t ociv, nciv;
	uint64_t wait_us;
	uint32_t actual_48k_rate, bytes, ac97rate;
	void *temp_buffer;
	struct auich_dma *p;
	u_int rate;

	/*
	 * Grab audio from input for fixed interval and compare how
	 * much we actually get with what we expect.  Interval needs
	 * to be sufficiently short that no interrupts are
	 * generated.
	 */

	/* Force the codec to a known state first. */
	sc->codec_if->vtbl->set_clock(sc->codec_if, 48000);
	rate = sc->sc_ac97_clock = 48000;
	sc->codec_if->vtbl->set_rate(sc->codec_if, AC97_REG_PCM_LR_ADC_RATE,
	    &rate);

	/* Setup a buffer */
	bytes = 64000;
	temp_buffer = auich_allocm(sc, AUMODE_RECORD, bytes);

	for (p = sc->sc_dmas; p && KERNADDR(p) != temp_buffer; p = p->next)
		continue;
	if (p == NULL) {
		printf("auich_calibrate: bad address %p\n", temp_buffer);
		return;
	}
	sc->pcmi.dmalist[0].base = DMAADDR(p);
	sc->pcmi.dmalist[0].len = (bytes >> sc->sc_sample_shift);

	/*
	 * our data format is stereo, 16 bit so each sample is 4 bytes.
	 * assuming we get 48000 samples per second, we get 192000 bytes/sec.
	 * we're going to start recording with interrupts disabled and measure
	 * the time taken for one block to complete.  we know the block size,
	 * we know the time in microseconds, we calculate the sample rate:
	 *
	 * actual_rate [bps] = bytes / (time [s] * 4)
	 * actual_rate [bps] = (bytes * 1000000) / (time [us] * 4)
	 * actual_rate [Hz] = (bytes * 250000) / time [us]
	 */

	/* prepare */
	ociv = bus_space_read_1(sc->iot, sc->aud_ioh, ICH_PCMI + ICH_CIV);
	bus_space_write_4(sc->iot, sc->aud_ioh, ICH_PCMI + ICH_BDBAR,
			  sc->sc_cddma + ICH_PCMI_OFF(0));
	bus_space_write_1(sc->iot, sc->aud_ioh, ICH_PCMI + ICH_LVI,
			  (0 - 1) & ICH_LVI_MASK);

	/* start */
	kpreempt_disable();
	microtime(&t1);
	bus_space_write_1(sc->iot, sc->aud_ioh, ICH_PCMI + ICH_CTRL, ICH_RPBM);

	/* wait */
	nciv = ociv;
	do {
		microtime(&t2);
		if (t2.tv_sec - t1.tv_sec > 1)
			break;
		nciv = bus_space_read_1(sc->iot, sc->aud_ioh,
					ICH_PCMI + ICH_CIV);
	} while (nciv == ociv);
	microtime(&t2);

	/* stop */
	bus_space_write_1(sc->iot, sc->aud_ioh, ICH_PCMI + ICH_CTRL, 0);
	kpreempt_enable();

	/* reset */
	DELAY(100);
	bus_space_write_1(sc->iot, sc->aud_ioh, ICH_PCMI + ICH_CTRL, ICH_RR);

	/* turn time delta into us */
	wait_us = ((t2.tv_sec - t1.tv_sec) * 1000000) + t2.tv_usec - t1.tv_usec;

	auich_freem(sc, temp_buffer, bytes);

	if (nciv == ociv) {
		printf("%s: ac97 link rate calibration timed out after %"
		       PRIu64 " us\n", device_xname(sc->sc_dev), wait_us);
		return;
	}

	actual_48k_rate = (bytes * UINT64_C(250000)) / wait_us;

	if (actual_48k_rate < 50000)
		ac97rate = 48000;
	else
		ac97rate = ((actual_48k_rate + 500) / 1000) * 1000;

	aprint_verbose_dev(sc->sc_dev, "measured ac97 link rate at %d Hz",
	       actual_48k_rate);
	if (ac97rate != actual_48k_rate)
		aprint_verbose(", will use %d Hz", ac97rate);
	aprint_verbose("\n");

	sc->sc_ac97_clock = ac97rate;
}
예제 #21
0
int ui_init_examcmds(void)
{
    cmd_addcmd("u",
	       ui_cmd_disasm,
	       NULL,
	       "Disassemble instructions.",
	       "u [addr [length]]\n\n"
	       "This command disassembles instructions at the specified address.\n"
	       "CFE will display standard register names and symbolic names for\n"
	       "certain CP0 registers.  The 'u' command remembers the last address\n"
	       "that was disassembled so you can enter 'u' again with no parameters\n"
	       "to continue a previous request.\n",
               "-p;Address is an uncached physical address|"
	       "-v;Address is a kernel virtual address");


    cmd_addcmd("d",
	       ui_cmd_memdump,
	       NULL,
	       "Dump memory.",
	       "d [-b|-h|-w|-q] [addr [length]]\n\n"
	       "This command displays data from memory as bytes, halfwords, words,\n"
	       "or quadwords.  ASCII text, if present, will appear to the right of\n"
	       "the hex data.  The dump command remembers the previous word size,\n"
	       "dump length and last displayed address, so you can enter 'd' again\n"
	       "to continue a previous dump request.",
	       "-b;Dump memory as bytes|"
	       "-h;Dump memory as halfwords (16-bits)|"
               "-w;Dump memory as words (32-bits)|"
               "-q;Dump memory as quadwords (64-bits)|"
               "-p;Address is an uncached physical address|"
	       "-v;Address is a kernel virtual address");


    cmd_addcmd("e",
	       ui_cmd_memedit,
	       NULL,
	       "Modify contents of memory.",
	       "e [-b|-h|-w|-q] [addr [data...]]\n\n"
	       "This command modifies the contents of memory.  If you do not specify\n"
	       "data on the command line, CFE will prompt for it.  When prompting for\n"
	       "data you may enter '-' to back up, '=' to dump memory at the current\n"
	       "location, or '.' to exit edit mode.",
	       "-b;Edit memory as bytes|"
	       "-h;Edit memory as halfwords (16-bits)|"
               "-w;Edit memory as words (32-bits)|"
               "-q;Edit memory as quadwords (64-bits)|"
	       "-p;Address is an uncached physical address|"
	       "-v;Address is a kernel virtual address");

    cmd_addcmd("f",
	       ui_cmd_memfill,
	       NULL,
	       "Fill contents of memory.",
	       "f [-b|-h|-w|-q] addr length pattern\n\n"
	       "This command modifies the contents of memory.  You can specify the\n"
	       "starting address, length, and pattern of data to fill (in hex)\n",
	       "-b;Edit memory as bytes|"
	       "-h;Edit memory as halfwords (16-bits)|"
               "-w;Edit memory as words (32-bits)|"
               "-q;Edit memory as quadwords (64-bits)|"
	       "-p;Address is an uncached physical address|"
	       "-v;Address is a kernel virtual address");

    cmd_addcmd("memtest",
	       ui_cmd_memtest,
	       NULL,
	       "Test memory.",
	       "memtest [options] addr length\n\n"
	       "This command tests memory.  It is a very crude test, so don't\n"
	       "rely on it for anything really important.  Addr and length are in hex\n",
	       "-p;Address is an uncached physical address|"
	       "-v;Address is a kernel virtual address|"
	       "-loop;Loop till keypress");


    prev_addr = KERNADDR(0);

    return 0;
}
예제 #22
0
static int
coram_mpeg_trigger(struct coram_softc *sc, void *buf)
{
	struct coram_dma *p;
	struct coram_sram_ch *ch;
	uint32_t v;

	ch = &coram_sram_chs[CORAM_SRAM_CH6];

	for (p = sc->sc_dma; p && KERNADDR(p) != buf; p = p->next)
		continue;
	if (p == NULL) {
		printf("%s: coram_mpeg_trigger: bad addr %p\n",
		    device_xname(sc->sc_dev), buf);
		return ENOENT;
	}

	/* disable fifo + risc */
	bus_space_write_4(sc->sc_memt, sc->sc_memh, VID_C_DMA_CTL, 0);

	coram_risc_buffer(sc, CORAM_TS_PKTSIZE, 1);
	coram_sram_ch_setup(sc, ch, CORAM_TS_PKTSIZE);

	/* let me hope this bit is the same as on the 2388[0-3] */
	/* software reset */
	bus_space_write_4(sc->sc_memt, sc->sc_memh, VID_C_GEN_CTL, 0x0040);
	delay (100*1000);

	bus_space_write_4(sc->sc_memt, sc->sc_memh, VID_C_LNGTH, CORAM_TS_PKTSIZE);
	bus_space_write_4(sc->sc_memt, sc->sc_memh, VID_C_HW_SOP_CTL, 0x47 << 16 | 188 << 4);
	bus_space_write_4(sc->sc_memt, sc->sc_memh, VID_C_TS_CLK_EN, 1);
	bus_space_write_4(sc->sc_memt, sc->sc_memh, VID_C_VLD_MISC, 0);
	bus_space_write_4(sc->sc_memt, sc->sc_memh, VID_C_GEN_CTL, 12);
	delay (100*1000);

	v = bus_space_read_4(sc->sc_memt, sc->sc_memh, PAD_CTRL);
	v &= ~0x4; /* Clear TS2_SOP_OE */
	bus_space_write_4(sc->sc_memt, sc->sc_memh, PAD_CTRL, v);

	v = bus_space_read_4(sc->sc_memt, sc->sc_memh, VID_C_INT_MSK);
	v |= 0x111111;
	bus_space_write_4(sc->sc_memt, sc->sc_memh, VID_C_INT_MSK, v);

	v = bus_space_read_4(sc->sc_memt, sc->sc_memh, VID_C_DMA_CTL);
	v |= 0x11; /* Enable RISC controller and FIFO */
	bus_space_write_4(sc->sc_memt, sc->sc_memh, VID_C_DMA_CTL, v);

	v = bus_space_read_4(sc->sc_memt, sc->sc_memh, DEV_CNTRL2);
	v |= __BIT(5); /* Enable RISC controller */
	bus_space_write_4(sc->sc_memt, sc->sc_memh, DEV_CNTRL2, v);

	v = bus_space_read_4(sc->sc_memt, sc->sc_memh, PCI_INT_MSK);
	v |= 0x001f00;
	v |= 0x04;
	bus_space_write_4(sc->sc_memt, sc->sc_memh, PCI_INT_MSK, v);

	v = bus_space_read_4(sc->sc_memt, sc->sc_memh, VID_C_GEN_CTL);
#ifdef CORAM_DEBUG
	printf("%s, %06x %08x\n", __func__, VID_C_GEN_CTL, v);
#endif
	v = bus_space_read_4(sc->sc_memt, sc->sc_memh, VID_C_SOP_STATUS);
#ifdef CORAM_DEBUG
	printf("%s, %06x %08x\n", __func__, VID_C_SOP_STATUS, v);
#endif
	delay(100*1000);
	v = bus_space_read_4(sc->sc_memt, sc->sc_memh, VID_C_GEN_CTL);
#ifdef CORAM_DEBUG
	printf("%s, %06x %08x\n", __func__, VID_C_GEN_CTL, v);
#endif
	v = bus_space_read_4(sc->sc_memt, sc->sc_memh, VID_C_SOP_STATUS);
#ifdef CORAM_DEBUG
	printf("%s, %06x %08x\n", __func__, VID_C_SOP_STATUS, v);
#endif

	return 0;
}
예제 #23
0
static int ui_cmd_config1250(ui_cmdline_t *cmd,int argc,char *argv[])
{
    char *tok;
    int fh;
    uint8_t *base;
    int len;
    int res;

    tok = cmd_getarg(cmd, 0);
    if (!tok) {
	return ui_showusage(cmd);
	}

    if (argc > 1) {
	char *fname;
	cfe_loadargs_t *la = &cfe_loadargs;
	int res;
    
	fname = cmd_getarg(cmd, 1);
	if (!fname) {
	    return ui_showusage(cmd);
	    }

	/* Get the file using tftp and read it into a known location. */

	/* (From ui_flash.c):
         * We can't allocate the space from the heap to store the 
	 * file to download, because the heap may not be big enough.
	 * So, grab some unallocated memory at the 1MB line (we could
	 * also calculate something, but this will do for now).
	 * We assume the downloadable file will be no bigger than 4MB.
	 */

	/* Fill out the loadargs */

	la->la_flags = LOADFLG_NOISY;

	la->la_device = (char *) net_getparam(NET_DEVNAME);
	la->la_filesys = "tftp";
	la->la_filename = fname;

	/* Temporary: use a fixed memory buffer. */
	la->la_address = KERNADDR(FILE_STAGING_BUFFER);
	la->la_maxsize = FILE_STAGING_BUFFER_SIZE;;
	la->la_flags |= LOADFLG_SPECADDR;

	la->la_options = NULL;

	xprintf("Loader:raw Filesys:%s Dev:%s File:%s Options:%s\n",
		la->la_filesys, la->la_device, la->la_filename, la->la_options);

	res = cfe_load_program("raw", la);
	if (res < 0) {
	    xprintf("Could not load %s\n", fname);
	    return res;
	    }

	base = (uint8_t *)(la->la_address);
	len = res;
	}
    else {
	/* This code casts a function pointer to a byte pointer, which is
	   suspect in ANSI C but appears to work with the gnu MIPS tool
	   chain.  Changing the externs to, e.g., uint8_t * does not work
	   with PIC code (generates relocation errors). */

	base = (uint8_t *)download_start;
	len  = (uint8_t *)download_end - (uint8_t *)download_start;
	}
    xprintf("PCI download: base %p len %d\n", base, len);

    fh = cfe_open(tok);
    if (fh < 0) {
	xprintf("Could not open device: %s\n", cfe_errortext(fh));
	return fh;
	}

    res = cfe_write(fh, base, len);
    if (res != 0) {
	xprintf("Could not download device: %s\n", cfe_errortext(res));
	}

    cfe_close(fh);

    return res;
}