Disable delayed connect
This commit is contained in:
		
							parent
							
								
									354f2f50eb
								
							
						
					
					
						commit
						d45041e00c
					
				| @ -49,16 +49,6 @@ process_ev(struct emu *emu) | |||||||
| int | int | ||||||
| model_kernel_event(struct emu *emu) | model_kernel_event(struct emu *emu) | ||||||
| { | { | ||||||
| 	static int enabled = 0; |  | ||||||
| 
 |  | ||||||
| 	if (!enabled) { |  | ||||||
| 		if (model_kernel_connect(emu) != 0) { |  | ||||||
| 			err("kernel_connect failed"); |  | ||||||
| 			return -1; |  | ||||||
| 		} |  | ||||||
| 		enabled = 1; |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	dbg("in kernel_event"); | 	dbg("in kernel_event"); | ||||||
| 	if (emu->ev->m != 'K') { | 	if (emu->ev->m != 'K') { | ||||||
| 		err("unexpected event model %c", emu->ev->m); | 		err("unexpected event model %c", emu->ev->m); | ||||||
|  | |||||||
| @ -24,7 +24,7 @@ struct model_spec model_kernel = { | |||||||
| 	.version = "1.0.0", | 	.version = "1.0.0", | ||||||
| 	.model   = model_id, | 	.model   = model_id, | ||||||
| 	.create  = model_kernel_create, | 	.create  = model_kernel_create, | ||||||
| //	.connect = model_kernel_connect,
 | 	.connect = model_kernel_connect, | ||||||
| 	.event   = model_kernel_event, | 	.event   = model_kernel_event, | ||||||
| 	.probe   = model_kernel_probe, | 	.probe   = model_kernel_probe, | ||||||
| }; | }; | ||||||
|  | |||||||
| @ -44,6 +44,7 @@ model_register(struct model *model, struct model_spec *spec) | |||||||
| int | int | ||||||
| model_probe(struct model *model, struct emu *emu) | model_probe(struct model *model, struct emu *emu) | ||||||
| { | { | ||||||
|  | 	int nenabled = 0; | ||||||
| 	for (int i = 0; i < MAX_MODELS; i++) { | 	for (int i = 0; i < MAX_MODELS; i++) { | ||||||
| 		if (!model->registered[i]) | 		if (!model->registered[i]) | ||||||
| 			continue; | 			continue; | ||||||
| @ -62,9 +63,15 @@ model_probe(struct model *model, struct emu *emu) | |||||||
| 			dbg("model %c disabled", (char) i); | 			dbg("model %c disabled", (char) i); | ||||||
| 		} else { | 		} else { | ||||||
| 			model->enabled[i] = 1; | 			model->enabled[i] = 1; | ||||||
| 			dbg("model %c enabled", (char) i); | 			info("model %s %s [%c] enabled", | ||||||
|  | 					spec->name, spec->version, (char) i); | ||||||
|  | 			nenabled++; | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  | 
 | ||||||
|  | 	if (nenabled == 0) | ||||||
|  | 		warn("no models enabled"); | ||||||
|  | 
 | ||||||
| 	return 0; | 	return 0; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -175,16 +175,6 @@ process_ev(struct emu *emu) | |||||||
| int | int | ||||||
| model_mpi_event(struct emu *emu) | model_mpi_event(struct emu *emu) | ||||||
| { | { | ||||||
| 	static int enabled = 0; |  | ||||||
| 
 |  | ||||||
| 	if (!enabled) { |  | ||||||
| 		if (model_mpi_connect(emu) != 0) { |  | ||||||
| 			err("mpi_connect failed"); |  | ||||||
| 			return -1; |  | ||||||
| 		} |  | ||||||
| 		enabled = 1; |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	dbg("in mpi_event"); | 	dbg("in mpi_event"); | ||||||
| 	if (emu->ev->m != 'M') { | 	if (emu->ev->m != 'M') { | ||||||
| 		err("unexpected event model %c", emu->ev->m); | 		err("unexpected event model %c", emu->ev->m); | ||||||
|  | |||||||
| @ -29,7 +29,7 @@ struct model_spec model_mpi = { | |||||||
| 	.version = "1.0.0", | 	.version = "1.0.0", | ||||||
| 	.model   = model_id, | 	.model   = model_id, | ||||||
| 	.create  = model_mpi_create, | 	.create  = model_mpi_create, | ||||||
| //	.connect = model_mpi_connect,
 | 	.connect = model_mpi_connect, | ||||||
| 	.event   = model_mpi_event, | 	.event   = model_mpi_event, | ||||||
| 	.probe   = model_mpi_probe, | 	.probe   = model_mpi_probe, | ||||||
| 	.finish  = model_mpi_finish, | 	.finish  = model_mpi_finish, | ||||||
|  | |||||||
| @ -194,14 +194,6 @@ mux_init(struct mux *mux, | |||||||
| 		return -1; | 		return -1; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	/* FIXME: Mark the select channel as dirty, so it runs the select
 |  | ||||||
| 	 * callback even if it doesn't have a new value. This hack must be |  | ||||||
| 	 * removed when we get rid of the delayed connect. */ |  | ||||||
| 	if (chan_dirty(select) != 0) { |  | ||||||
| 		err("chan_dirty failed"); |  | ||||||
| 		return -1; |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	return 0; | 	return 0; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -567,19 +567,6 @@ process_ev(struct emu *emu) | |||||||
| int | int | ||||||
| model_nanos6_event(struct emu *emu) | model_nanos6_event(struct emu *emu) | ||||||
| { | { | ||||||
| 	static int enabled = 0; |  | ||||||
| 
 |  | ||||||
| 	if (!enabled) { |  | ||||||
| 		struct nanos6_emu *memu = EXT(emu, '6'); |  | ||||||
| 		memu->event = 1; |  | ||||||
| 
 |  | ||||||
| 		if (model_nanos6_connect(emu) != 0) { |  | ||||||
| 			err("nanos6_connect failed"); |  | ||||||
| 			return -1; |  | ||||||
| 		} |  | ||||||
| 		enabled = 1; |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	if (emu->ev->m != '6') { | 	if (emu->ev->m != '6') { | ||||||
| 		err("unexpected event model %c", emu->ev->m); | 		err("unexpected event model %c", emu->ev->m); | ||||||
| 		return -1; | 		return -1; | ||||||
|  | |||||||
| @ -89,8 +89,6 @@ struct nanos6_proc { | |||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| struct nanos6_emu { | struct nanos6_emu { | ||||||
| 	int connected; |  | ||||||
| 	int event; |  | ||||||
| 	struct breakdown_emu breakdown; | 	struct breakdown_emu breakdown; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -281,16 +281,6 @@ model_nanos6_create(struct emu *emu) | |||||||
| int | int | ||||||
| model_nanos6_connect(struct emu *emu) | model_nanos6_connect(struct emu *emu) | ||||||
| { | { | ||||||
| 	struct nanos6_emu *memu = EXT(emu, model_id); |  | ||||||
| 
 |  | ||||||
| 	if (memu->connected) |  | ||||||
| 		return 0; |  | ||||||
| 
 |  | ||||||
| 	/* Only skip connection if event not reached and
 |  | ||||||
| 	 * breakdown not enabled */ |  | ||||||
| 	if (!memu->event && !emu->args.breakdown) |  | ||||||
| 		return 0; |  | ||||||
| 
 |  | ||||||
| 	if (model_thread_connect(emu, &th_spec) != 0) { | 	if (model_thread_connect(emu, &th_spec) != 0) { | ||||||
| 		err("model_thread_connect failed"); | 		err("model_thread_connect failed"); | ||||||
| 		return -1; | 		return -1; | ||||||
| @ -323,8 +313,6 @@ model_nanos6_connect(struct emu *emu) | |||||||
| 		mux_set_default(mux, value_int64(ST_RESTING)); | 		mux_set_default(mux, value_int64(ST_RESTING)); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	memu->connected = 1; |  | ||||||
| 
 |  | ||||||
| 	return 0; | 	return 0; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -105,16 +105,6 @@ process_ev(struct emu *emu) | |||||||
| int | int | ||||||
| model_nodes_event(struct emu *emu) | model_nodes_event(struct emu *emu) | ||||||
| { | { | ||||||
| 	static int enabled = 0; |  | ||||||
| 
 |  | ||||||
| 	if (!enabled) { |  | ||||||
| 		if (model_nodes_connect(emu) != 0) { |  | ||||||
| 			err("nodes_connect failed"); |  | ||||||
| 			return -1; |  | ||||||
| 		} |  | ||||||
| 		enabled = 1; |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	dbg("in nodes_event"); | 	dbg("in nodes_event"); | ||||||
| 	if (emu->ev->m != 'D') { | 	if (emu->ev->m != 'D') { | ||||||
| 		err("unexpected event model %c", emu->ev->m); | 		err("unexpected event model %c", emu->ev->m); | ||||||
|  | |||||||
| @ -29,7 +29,7 @@ struct model_spec model_nodes = { | |||||||
| 	.version = "1.0.0", | 	.version = "1.0.0", | ||||||
| 	.model   = model_id, | 	.model   = model_id, | ||||||
| 	.create  = model_nodes_create, | 	.create  = model_nodes_create, | ||||||
| //	.connect = model_nodes_connect,
 | 	.connect = model_nodes_connect, | ||||||
| 	.event   = model_nodes_event, | 	.event   = model_nodes_event, | ||||||
| 	.probe   = model_nodes_probe, | 	.probe   = model_nodes_probe, | ||||||
| 	.finish  = model_nodes_finish, | 	.finish  = model_nodes_finish, | ||||||
|  | |||||||
| @ -532,16 +532,6 @@ process_ev(struct emu *emu) | |||||||
| int | int | ||||||
| model_nosv_event(struct emu *emu) | model_nosv_event(struct emu *emu) | ||||||
| { | { | ||||||
| 	static int enabled = 0; |  | ||||||
| 
 |  | ||||||
| 	if (!enabled) { |  | ||||||
| 		if (model_nosv_connect(emu) != 0) { |  | ||||||
| 			err("nosv_connect failed"); |  | ||||||
| 			return -1; |  | ||||||
| 		} |  | ||||||
| 		enabled = 1; |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	dbg("in nosv_event"); | 	dbg("in nosv_event"); | ||||||
| 	if (emu->ev->m != 'V') { | 	if (emu->ev->m != 'V') { | ||||||
| 		err("unexpected event model %c", emu->ev->m); | 		err("unexpected event model %c", emu->ev->m); | ||||||
|  | |||||||
| @ -34,7 +34,7 @@ struct model_spec model_nosv = { | |||||||
| 	.version = "1.0.0", | 	.version = "1.0.0", | ||||||
| 	.model   = model_id, | 	.model   = model_id, | ||||||
| 	.create  = model_nosv_create, | 	.create  = model_nosv_create, | ||||||
| //	.connect = model_nosv_connect,
 | 	.connect = model_nosv_connect, | ||||||
| 	.event   = model_nosv_event, | 	.event   = model_nosv_event, | ||||||
| 	.probe   = model_nosv_probe, | 	.probe   = model_nosv_probe, | ||||||
| 	.finish  = model_nosv_finish, | 	.finish  = model_nosv_finish, | ||||||
|  | |||||||
| @ -85,16 +85,6 @@ process_ev(struct emu *emu) | |||||||
| int | int | ||||||
| model_tampi_event(struct emu *emu) | model_tampi_event(struct emu *emu) | ||||||
| { | { | ||||||
| 	static int enabled = 0; |  | ||||||
| 
 |  | ||||||
| 	if (!enabled) { |  | ||||||
| 		if (model_tampi_connect(emu) != 0) { |  | ||||||
| 			err("tampi_connect failed"); |  | ||||||
| 			return -1; |  | ||||||
| 		} |  | ||||||
| 		enabled = 1; |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	dbg("in tampi_event"); | 	dbg("in tampi_event"); | ||||||
| 	if (emu->ev->m != 'T') { | 	if (emu->ev->m != 'T') { | ||||||
| 		err("unexpected event model %c", emu->ev->m); | 		err("unexpected event model %c", emu->ev->m); | ||||||
|  | |||||||
| @ -29,7 +29,7 @@ struct model_spec model_tampi = { | |||||||
| 	.version = "1.0.0", | 	.version = "1.0.0", | ||||||
| 	.model   = model_id, | 	.model   = model_id, | ||||||
| 	.create  = model_tampi_create, | 	.create  = model_tampi_create, | ||||||
| //	.connect = model_tampi_connect,
 | 	.connect = model_tampi_connect, | ||||||
| 	.event   = model_tampi_event, | 	.event   = model_tampi_event, | ||||||
| 	.probe   = model_tampi_probe, | 	.probe   = model_tampi_probe, | ||||||
| 	.finish  = model_tampi_finish, | 	.finish  = model_tampi_finish, | ||||||
|  | |||||||
| @ -144,49 +144,6 @@ test_duplicate_output(struct mux *mux, int key1, int key2) | |||||||
| 	err("OK"); | 	err("OK"); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /* Ensure that the output of a mux is correct while the mux is connected
 |  | ||||||
|  * to the bay with a clean select channel but that already contains a |  | ||||||
|  * valid value of a input of the mux. The select must be marked as dirty |  | ||||||
|  * */ |  | ||||||
| static void |  | ||||||
| test_delayed_connect(void) |  | ||||||
| { |  | ||||||
| 	struct bay bay; |  | ||||||
| 	bay_init(&bay); |  | ||||||
| 
 |  | ||||||
| 	struct chan input, output, select; |  | ||||||
| 	chan_init(&output, CHAN_SINGLE, "output"); |  | ||||||
| 	chan_init(&select, CHAN_SINGLE, "select"); |  | ||||||
| 	chan_init(&input, CHAN_SINGLE, "input.0"); |  | ||||||
| 
 |  | ||||||
| 	/* Register all channels in the bay */ |  | ||||||
| 	OK(bay_register(&bay, &select)); |  | ||||||
| 	OK(bay_register(&bay, &output)); |  | ||||||
| 	OK(bay_register(&bay, &input)); |  | ||||||
| 
 |  | ||||||
| 	/* Setup channel values */ |  | ||||||
| 	OK(chan_set(&select, value_int64(0))); |  | ||||||
| 	OK(chan_set(&input, value_int64(1000))); |  | ||||||
| 
 |  | ||||||
| 	/* Propagate now so they are clean */ |  | ||||||
| 	OK(bay_propagate(&bay)); |  | ||||||
| 
 |  | ||||||
| 	/* ----- delayed connect ----- */ |  | ||||||
| 
 |  | ||||||
| 	struct mux mux; |  | ||||||
| 	OK(mux_init(&mux, &bay, &select, &output, NULL, 1)); |  | ||||||
| 	OK(mux_set_input(&mux, 0, &input)); |  | ||||||
| 
 |  | ||||||
| 	/* Don't modify the input of the select until propagation, the
 |  | ||||||
| 	 * mux_init must have marked the select as dirty. */ |  | ||||||
| 
 |  | ||||||
| 	OK(bay_propagate(&bay)); |  | ||||||
| 
 |  | ||||||
| 	/* The mux must have selected the first input */ |  | ||||||
| 	check_output(&mux, value_int64(1000)); |  | ||||||
| 	err("OK"); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| int | int | ||||||
| main(void) | main(void) | ||||||
| { | { | ||||||
| @ -234,7 +191,6 @@ main(void) | |||||||
| 	test_input_and_select(&mux, 4); | 	test_input_and_select(&mux, 4); | ||||||
| 	test_mid_propagate(&mux, 5); | 	test_mid_propagate(&mux, 5); | ||||||
| 	test_duplicate_output(&mux, 6, 7); | 	test_duplicate_output(&mux, 6, 7); | ||||||
| 	test_delayed_connect(); |  | ||||||
| 
 | 
 | ||||||
| 	err("OK"); | 	err("OK"); | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user