void target_init(void) { paddr_t buf_vaddr; void *hdr_addr; /* TODO: Move into zynq_common once the init order is sorted out with gem_init needing * pktbufs, and app init running after target_init */ if (vmm_alloc_contiguous(vmm_get_kernel_aspace(), "pktbuf_headers", ZYNQ_PKTBUF_CNT * sizeof(pktbuf_buf_t), (void **)&hdr_addr, 0, 0, ARCH_MMU_FLAG_CACHED) < 0) { printf("Failed to initialize pktbuf hdr slab\n"); return; } for (size_t i = 0; i < ZYNQ_PKTBUF_CNT; i++) { pktbuf_create((void *)hdr_addr, sizeof(pktbuf_t)); hdr_addr += sizeof(pktbuf_t); } if (vmm_alloc_contiguous(vmm_get_kernel_aspace(), "pktbuf_buffers", ZYNQ_PKTBUF_CNT * sizeof(pktbuf_buf_t), (void **)&buf_vaddr, 0, 0, ARCH_MMU_FLAG_UNCACHED) < 0) { printf("Failed to initialize pktbuf vm slab\n"); return; } pktbuf_create_bufs((void *)buf_vaddr, ZYNQ_PKTBUF_CNT * sizeof(pktbuf_buf_t)); gem_init(GEM0_BASE); register_gpio_int_handler(ZYBO_BTN5, toggle_ledy, NULL); zynq_unmask_gpio_interrupt(ZYBO_BTN5); }
int main() { static rtp_packet *pp; static pktbuf_t *pb; int32_t i, j, n,ts; if (pktbuf_create(&pb, PKTBUF_SIZE) == 0) { printf("Failed to create buffer\n"); exit(-1); } xmemchk(); for(i = 0; i < 100000; i++) { n = lrand48() % 16; for(j = 0; j <= n; j++) { pp = (rtp_packet*)xmalloc(sizeof(rtp_packet)); pp->ts = ts ++; add_thing(pb, pp); } n = lrand48() % 16; for(j = 0; j < n; j++) { remove_thing(pb); } } pktbuf_destroy(&pb); xmemdmp(); printf("Okay\n"); return 0; }