Esempio n. 1
0
File: usbtest.c Progetto: DSKIM3/lk
static void usbtest_entry(const struct app_descriptor *app, void *args)
{
    LTRACE_ENTRY;

    TRACEF("starting usb stack\n");
    usb_start();

    // XXX get callback from stack
    thread_sleep(2000);

    TRACEF("queuing transfers\n");
    queue_rx_transfer();
    queue_tx_transfer();

    while (event_wait(&testevent) == NO_ERROR) {
        if (!rxqueued) {
            /* dump the state of the transfer */
            LTRACEF("rx transfer completed\n");
            usbc_dump_transfer(&rx);
            hexdump8(rx.buf, MIN(128, rx.bufpos));

            queue_rx_transfer();
        }
        if (!txqueued) {
            /* dump the state of the transfer */
            LTRACEF("tx transfer completed\n");
            usbc_dump_transfer(&tx);

            queue_tx_transfer();
        }
    }

    LTRACE_EXIT;
}
Esempio n. 2
0
/*
 * @brief: set buffer data
 */
int buffer_setdata(buffer_t *b, unsigned char *data, size_t size)
{
	if (b->data) {
		platform_free(b->data);
	}

	b->data = (unsigned char *)platform_calloc(size);
	if (!b->data) {
		return -1;
	}
	memcpy(b->data, data, size);
#if LOCAL_TRACE
	hexdump8(b->data, MIN(size, 64));
#endif
	b->pos = 0;
	b->len = size;
	return 0;
}
Esempio n. 3
0
void PciConfig::DumpConfig(uint16_t len) const {
    printf("%u bytes of raw config (base %s:%#" PRIxPTR ")\n",
           len, (addr_space_ == PciAddrSpace::MMIO) ? "MMIO" : "PIO", base_);
    if (addr_space_ == PciAddrSpace::MMIO) {
        hexdump8(reinterpret_cast<const void*>(base_), len);
    } else {
        // PIO space can't be dumped directly so we read a row at a time
        constexpr uint8_t row_len = 16;
        uint32_t pos = 0;
        uint8_t buf[row_len];

        do {
            for (uint16_t i = 0; i < row_len; i++) {
                buf[i] = Read(PciReg8(static_cast<uint8_t>(pos + i)));
            }

            hexdump8_ex(buf, row_len, base_ + pos);
            pos += row_len;
        } while (pos < PCIE_BASE_CONFIG_SIZE);
    }
}