コード例 #1
0
ファイル: wavelan.c プロジェクト: Nurb432/plan9front
static void
w_rxdone(Ether* ether)
{
	Ctlr* ctlr = (Ctlr*) ether->ctlr;
	int len, sp;
	WFrame f;
	Block* bp=0;
	Etherpkt* ep;

	sp = csr_ins(ctlr, WR_RXId);
	len = w_read(ctlr, sp, 0, &f, sizeof(f));
	if(len == 0){
		DEBUG("wavelan: read frame error\n");
		goto rxerror;
	}
	if(f.sts&WF_Err){
		goto rxerror;
	}
	switch(f.sts){
	case WF_1042:
	case WF_Tunnel:
	case WF_WMP:
		len = f.dlen + WSnapHdrLen;
		bp = iallocb(ETHERHDRSIZE + len + 2);
		if(!bp)
			goto rxerror;
		ep = (Etherpkt*) bp->wp;
		memmove(ep->d, f.addr1, Eaddrlen);
		memmove(ep->s, f.addr2, Eaddrlen);
		memmove(ep->type,&f.type,2);
		bp->wp += ETHERHDRSIZE;
		if(w_read(ctlr, sp, WF_802_11_Off, bp->wp, len+2) == 0){
			DEBUG("wavelan: read 802.11 error\n");
			goto rxerror;
		}
		bp->wp = bp->rp+(ETHERHDRSIZE+f.dlen);
		break;
	default:
		len = ETHERHDRSIZE + f.dlen + 2;
		bp = iallocb(len);
		if(!bp)
			goto rxerror;
		if(w_read(ctlr, sp, WF_802_3_Off, bp->wp, len) == 0){
			DEBUG("wavelan: read 800.3 error\n");
			goto rxerror;
		}
		bp->wp += len;
	}

	ctlr->nrx++;
	etheriq(ether,bp,1);
	ctlr->signal = ((ctlr->signal*15)+((f.qinfo>>8) & 0xFF))/16;
	ctlr->noise = ((ctlr->noise*15)+(f.qinfo & 0xFF))/16;
	return;

rxerror:
	freeb(bp);
	ctlr->nrxerr++;
}
コード例 #2
0
ファイル: pdp-load.c プロジェクト: Avi2011class/Test
void mem_dump(adr start, word n)
{
    word i;
    for (i = 0; i < n; i += 2)
    {
        word w = w_read(start + i);
        printf("%06o : %06o\n", start + i, w);
    }
}
コード例 #3
0
ファイル: wavelan.c プロジェクト: Nurb432/plan9front
static int
w_info(Ether *ether, Ctlr* ctlr)
{
	int sp;
	Wltv ltv;

	sp = csr_ins(ctlr, WR_InfoId);
	ltv.len = ltv.type = 0;
	w_read(ctlr, sp, 0, &ltv, 4);
	ltv.len--;
	switch(ltv.type){
	case WTyp_Stats:
		w_stats(ctlr, ltv.len);
		return 0;
	case WTyp_Scan:
		w_scaninfo(ether, ctlr, ltv.len);
		return 0;
	}
	return -1;
}
コード例 #4
0
int main(int argc, char *argv[])
{
	e_platform_t platform;
	e_epiphany_t device;

	w_mapper_t mapper;
	w_sa_config_t sa_config;
	w_list_t task1;
	w_core_id_t first_id, last_id;

	Mailbox mailbox;
	memset(&mailbox, 0, sizeof(mailbox));

	w_init_list(&task1, 0);

	printf("=== Initializing system\n");
	e_set_host_verbosity(H_D0);

	e_init(NULL);
	e_reset_system();
	e_get_platform_info(&platform);

	printf("=== Creating workgroup\n");
	e_open(&device, 0, 0, platform.rows, platform.cols);

	printf("=== Mapping device program\n");
	e_reset_group(&device);

	// Initialize the mapping system: we will use this to automatically map our
	// application, to assign a device program to each core.
	mapper = w_create_mapper(platform.rows, platform.cols);

	// Tell the mapper about our application. It needs to know about allocated
	// tasks, constraints and faults are optional. By default the mapper assumes
	// no faults and no constraints.
	w_set_allocation_matrix(&mapper, allocation_matrix);
	w_set_constraint_matrix(&mapper, constraint_matrix);
	w_set_fault_matrix(&mapper, fault_matrix);

	// Find the ID of all cores allocated for task 1, and create a link between
	// each core. Links are used to indicate which tasks that communicate with
	// each other, and to minimize the distance between communicating tasks.
	w_find_in_matrix(&mapper.allocation_matrix, &task1, 1);
	connect_task1(&mapper, &task1);

	// Map the application using simulated annealing. This is will optimize our
	// poor allocation.
	sa_config = w_create_sa_config();
	if (w_assign_sa(&mapper, &sa_config) != E_OK) {
		printf("ERROR: Assignment failed.\n");
		return 1;
	}

	w_print_matrix(&mapper.assignment_matrix, "Assignment");
	w_print_matrix(&mapper.mapping_matrix, "Mapping");

	// Find the ID of all cores assigned to task 1.
	w_find_in_matrix(&mapper.assignment_matrix, &task1, 1);
	first_id = task1.elements[0];
	last_id = task1.elements[task1.size - 1];

	printf("=== Setting initial conditions\n");
	init_task1(&device, &task1);

	printf("=== Loading device program\n");
	// Load the device program onto all cores assigned to task 1.
	if (w_load(&device, &task1, "e_main.srec") != E_OK) {
		printf("ERROR: Unable to load device program.\n");
		return 1;
	}

	printf("=== Starting device\n");
	e_start_group(&device);

	printf("=== Starting counter\n");
	mailbox.go = 1;
	w_write(&device, first_id, _MAILBOX_ADDRESS, &mailbox, sizeof(mailbox));

	printf("=== Waiting for last core\n");
	do {
		msleep(100);
		w_read(&device, last_id, _MAILBOX_ADDRESS, &mailbox, sizeof(mailbox));
	} while (mailbox.done == 0);

	printf("Counted to %i (expected %i)\n", mailbox.counter, task1.size - 1);

	printf("=== Finalizing\n");
	w_free_mapper(&mapper);
	w_free_list(&task1);

	e_close(&device);
	e_finalize();

	printf("=== Done\n");
	return 0;
}